Feature/speedup quota tests (#1125)
* reduce the number of created entities in tests Signed-off-by: Ahmed Sayed <ahmed.sayed@bosch.io> * fixed tests Signed-off-by: Ahmed Sayed <ahmed.sayed@bosch.io> * fixed review findings Signed-off-by: Ahmed Sayed <ahmed.sayed@bosch.io> * merged master Signed-off-by: Ahmed Sayed <ahmed.sayed@bosch.io> * adapted target count Signed-off-by: Ahmed Sayed <ahmed.sayed@bosch.io> * fixed review findings Signed-off-by: Ahmed Sayed <ahmed.sayed@bosch.io> * fixed RolloutManagementTest Signed-off-by: Ahmed Sayed <ahmed.sayed@bosch.io> * fixed flaky test ConcurrentDistributionSetInvalidationTest Signed-off-by: Ahmed Sayed <ahmed.sayed@bosch.io>
This commit is contained in:
@@ -45,7 +45,7 @@ public class RolloutEventTest extends AbstractRemoteEntityEventTest<Rollout> {
|
|||||||
|
|
||||||
return rolloutManagement.create(
|
return rolloutManagement.create(
|
||||||
entityFactory.rollout().create().name("exampleRollout").targetFilterQuery("controllerId==*").set(ds),
|
entityFactory.rollout().create().name("exampleRollout").targetFilterQuery("controllerId==*").set(ds),
|
||||||
10, new RolloutGroupConditionBuilder().withDefaults()
|
5, new RolloutGroupConditionBuilder().withDefaults()
|
||||||
.successCondition(RolloutGroupSuccessCondition.THRESHOLD, "10").build());
|
.successCondition(RolloutGroupSuccessCondition.THRESHOLD, "10").build());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ public class RolloutGroupEventTest extends AbstractRemoteEntityEventTest<Rollout
|
|||||||
|
|
||||||
final Rollout entity = rolloutManagement.create(
|
final Rollout entity = rolloutManagement.create(
|
||||||
entityFactory.rollout().create().name("exampleRollout").targetFilterQuery("controllerId==*").set(ds),
|
entityFactory.rollout().create().name("exampleRollout").targetFilterQuery("controllerId==*").set(ds),
|
||||||
10, new RolloutGroupConditionBuilder().withDefaults()
|
5, new RolloutGroupConditionBuilder().withDefaults()
|
||||||
.successCondition(RolloutGroupSuccessCondition.THRESHOLD, "10").build());
|
.successCondition(RolloutGroupSuccessCondition.THRESHOLD, "10").build());
|
||||||
|
|
||||||
return rolloutGroupManagement.findByRollout(PAGE, entity.getId()).getContent().get(0);
|
return rolloutGroupManagement.findByRollout(PAGE, entity.getId()).getContent().get(0);
|
||||||
|
|||||||
@@ -8,12 +8,13 @@
|
|||||||
*/
|
*/
|
||||||
package org.eclipse.hawkbit.repository.jpa;
|
package org.eclipse.hawkbit.repository.jpa;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
import io.qameta.allure.Description;
|
||||||
|
import io.qameta.allure.Feature;
|
||||||
import java.util.Collections;
|
import io.qameta.allure.Story;
|
||||||
|
|
||||||
import org.awaitility.Awaitility;
|
import org.awaitility.Awaitility;
|
||||||
|
import org.awaitility.Duration;
|
||||||
import org.eclipse.hawkbit.repository.exception.StopRolloutException;
|
import org.eclipse.hawkbit.repository.exception.StopRolloutException;
|
||||||
|
import org.eclipse.hawkbit.repository.jpa.model.JpaRolloutGroup;
|
||||||
import org.eclipse.hawkbit.repository.model.Action.ActionType;
|
import org.eclipse.hawkbit.repository.model.Action.ActionType;
|
||||||
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||||
import org.eclipse.hawkbit.repository.model.DistributionSetInvalidation;
|
import org.eclipse.hawkbit.repository.model.DistributionSetInvalidation;
|
||||||
@@ -25,11 +26,20 @@ import org.eclipse.hawkbit.repository.model.RolloutGroup.RolloutGroupSuccessCond
|
|||||||
import org.eclipse.hawkbit.repository.model.RolloutGroupConditionBuilder;
|
import org.eclipse.hawkbit.repository.model.RolloutGroupConditionBuilder;
|
||||||
import org.eclipse.hawkbit.repository.model.RolloutGroupConditions;
|
import org.eclipse.hawkbit.repository.model.RolloutGroupConditions;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.context.annotation.Primary;
|
||||||
|
import org.springframework.test.context.ContextConfiguration;
|
||||||
import org.springframework.test.context.TestPropertySource;
|
import org.springframework.test.context.TestPropertySource;
|
||||||
|
|
||||||
import io.qameta.allure.Description;
|
import java.util.Collections;
|
||||||
import io.qameta.allure.Feature;
|
import java.util.concurrent.TimeUnit;
|
||||||
import io.qameta.allure.Story;
|
|
||||||
|
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||||
|
import static org.mockito.AdditionalAnswers.delegatesTo;
|
||||||
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
|
import static org.mockito.Mockito.doAnswer;
|
||||||
|
import static org.mockito.Mockito.mock;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test class testing the invalidation of a {@link DistributionSet} while the
|
* Test class testing the invalidation of a {@link DistributionSet} while the
|
||||||
@@ -38,35 +48,54 @@ import io.qameta.allure.Story;
|
|||||||
*/
|
*/
|
||||||
@Feature("Component Tests - Repository")
|
@Feature("Component Tests - Repository")
|
||||||
@Story("Concurrent Distribution Set invalidation")
|
@Story("Concurrent Distribution Set invalidation")
|
||||||
@TestPropertySource(properties = "hawkbit.server.repository.dsInvalidationLockTimeout=1")
|
@ContextConfiguration(classes = ConcurrentDistributionSetInvalidationTest.Config.class)
|
||||||
|
@TestPropertySource(properties = { "hawkbit.server.repository.dsInvalidationLockTimeout=1" })
|
||||||
public class ConcurrentDistributionSetInvalidationTest extends AbstractJpaIntegrationTest {
|
public class ConcurrentDistributionSetInvalidationTest extends AbstractJpaIntegrationTest {
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
static class Config {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a {@link RolloutGroupRepository} bean that is slow during saving already created Groups.
|
||||||
|
* This gives this test more time to succeed
|
||||||
|
*/
|
||||||
|
@Bean
|
||||||
|
@Primary
|
||||||
|
RolloutGroupRepository slowRolloutGroupRepository(final RolloutGroupRepository groupRepo) {
|
||||||
|
final RolloutGroupRepository slowGroupRepo = mock(RolloutGroupRepository.class, delegatesTo(groupRepo));
|
||||||
|
|
||||||
|
doAnswer(invocation -> {
|
||||||
|
final JpaRolloutGroup group = invocation.getArgument(0);
|
||||||
|
if (group.getId() == null) {
|
||||||
|
return groupRepo.save(group);
|
||||||
|
}
|
||||||
|
TimeUnit.SECONDS.sleep(2);
|
||||||
|
return groupRepo.save(group);
|
||||||
|
}).when(slowGroupRepo).save(any());
|
||||||
|
|
||||||
|
return slowGroupRepo;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Description("Verify that a large rollout causes a timeout when trying to invalidate a distribution set")
|
@Description("Verify that a large rollout causes a timeout when trying to invalidate a distribution set")
|
||||||
public void verifyInvalidateDistributionSetWithLargeRolloutThrowsException() throws Exception {
|
public void verifyInvalidateDistributionSetWithLargeRolloutThrowsException() throws Exception {
|
||||||
final DistributionSet distributionSet = testdataFactory.createDistributionSet();
|
final DistributionSet distributionSet = testdataFactory.createDistributionSet();
|
||||||
testdataFactory.createTargets(10000, "verifyInvalidateDistributionSetWithLargeRolloutThrowsException");
|
final Rollout rollout = createRollout(distributionSet);
|
||||||
final RolloutGroupConditions conditions = new RolloutGroupConditionBuilder().withDefaults()
|
|
||||||
.successCondition(RolloutGroupSuccessCondition.THRESHOLD, "50")
|
|
||||||
.errorCondition(RolloutGroupErrorCondition.THRESHOLD, "80")
|
|
||||||
.errorAction(RolloutGroupErrorAction.PAUSE, null).build();
|
|
||||||
final Rollout rollout = rolloutManagement.create(entityFactory.rollout().create()
|
|
||||||
.name("verifyInvalidateDistributionSetWithLargeRolloutThrowsException").description("desc")
|
|
||||||
.targetFilterQuery("name==*").set(distributionSet).actionType(ActionType.FORCED), 20, conditions);
|
|
||||||
final String tenant = tenantAware.getCurrentTenant();
|
final String tenant = tenantAware.getCurrentTenant();
|
||||||
|
|
||||||
// run in new Thread so that the invalidation can be executed in
|
// run in new Thread so that the invalidation can be executed in
|
||||||
// parallel
|
// parallel
|
||||||
final Thread handleRolloutsThread = new Thread(() -> {
|
new Thread(() -> systemSecurityContext.runAsSystemAsTenant(() -> {
|
||||||
tenantAware.runAsTenant(tenant, () -> systemSecurityContext.runAsSystem(() -> {
|
|
||||||
rolloutManagement.handleRollouts();
|
rolloutManagement.handleRollouts();
|
||||||
return 0;
|
return 0;
|
||||||
}));
|
}, tenant)).start();
|
||||||
});
|
|
||||||
handleRolloutsThread.start();
|
|
||||||
// wait until at least one RolloutGroup is created, as this means that
|
// wait until at least one RolloutGroup is created, as this means that
|
||||||
// the thread has started and has acquired the lock
|
// the thread has started and has acquired the lock
|
||||||
Awaitility.await().until(() -> tenantAware.runAsTenant(tenant, () -> systemSecurityContext
|
Awaitility.await().atMost(Duration.FIVE_SECONDS)
|
||||||
|
.pollInterval(Duration.ONE_HUNDRED_MILLISECONDS)
|
||||||
|
.until(() -> tenantAware.runAsTenant(tenant, () -> systemSecurityContext
|
||||||
.runAsSystem(() -> rolloutGroupManagement.findByRollout(PAGE, rollout.getId()).getSize() > 0)));
|
.runAsSystem(() -> rolloutGroupManagement.findByRollout(PAGE, rollout.getId()).getSize() > 0)));
|
||||||
|
|
||||||
assertThatExceptionOfType(StopRolloutException.class)
|
assertThatExceptionOfType(StopRolloutException.class)
|
||||||
@@ -76,4 +105,19 @@ public class ConcurrentDistributionSetInvalidationTest extends AbstractJpaIntegr
|
|||||||
CancelationType.SOFT, true)));
|
CancelationType.SOFT, true)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Rollout createRollout(final DistributionSet distributionSet) {
|
||||||
|
testdataFactory.createTargets(
|
||||||
|
quotaManagement.getMaxTargetsPerRolloutGroup() * quotaManagement.getMaxRolloutGroupsPerRollout(),
|
||||||
|
"verifyInvalidateDistributionSetWithLargeRolloutThrowsException");
|
||||||
|
final RolloutGroupConditions conditions = new RolloutGroupConditionBuilder().withDefaults()
|
||||||
|
.successCondition(RolloutGroupSuccessCondition.THRESHOLD, "50")
|
||||||
|
.errorCondition(RolloutGroupErrorCondition.THRESHOLD, "80")
|
||||||
|
.errorAction(RolloutGroupErrorAction.PAUSE, null).build();
|
||||||
|
|
||||||
|
return rolloutManagement.create(entityFactory.rollout().create()
|
||||||
|
.name("verifyInvalidateDistributionSetWithLargeRolloutThrowsException").description("desc")
|
||||||
|
.targetFilterQuery("name==*").set(distributionSet).actionType(ActionType.FORCED),
|
||||||
|
quotaManagement.getMaxRolloutGroupsPerRollout(), conditions);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -262,12 +262,12 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Description("Test verifies that an assignment with automatic cancelation works correctly even if the update is split into multiple partitions on the database.")
|
@Description("Test verifies that an assignment with automatic cancelation works correctly even if the update is split into multiple partitions on the database.")
|
||||||
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = Constants.MAX_ENTRIES_IN_STATEMENT + 10),
|
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 20),
|
||||||
@Expect(type = TargetUpdatedEvent.class, count = 2 * (Constants.MAX_ENTRIES_IN_STATEMENT + 10)),
|
@Expect(type = TargetUpdatedEvent.class, count = 40),
|
||||||
@Expect(type = TargetAssignDistributionSetEvent.class, count = 2),
|
@Expect(type = TargetAssignDistributionSetEvent.class, count = 2),
|
||||||
@Expect(type = ActionCreatedEvent.class, count = 2 * (Constants.MAX_ENTRIES_IN_STATEMENT + 10)),
|
@Expect(type = ActionCreatedEvent.class, count = 40),
|
||||||
@Expect(type = CancelTargetAssignmentEvent.class, count = Constants.MAX_ENTRIES_IN_STATEMENT + 10),
|
@Expect(type = CancelTargetAssignmentEvent.class, count = 20),
|
||||||
@Expect(type = ActionUpdatedEvent.class, count = Constants.MAX_ENTRIES_IN_STATEMENT + 10),
|
@Expect(type = ActionUpdatedEvent.class, count = 20),
|
||||||
@Expect(type = DistributionSetCreatedEvent.class, count = 2),
|
@Expect(type = DistributionSetCreatedEvent.class, count = 2),
|
||||||
@Expect(type = SoftwareModuleCreatedEvent.class, count = 6) })
|
@Expect(type = SoftwareModuleCreatedEvent.class, count = 6) })
|
||||||
void multiAssigmentHistoryOverMultiplePagesResultsInTwoActiveAction() {
|
void multiAssigmentHistoryOverMultiplePagesResultsInTwoActiveAction() {
|
||||||
@@ -278,14 +278,14 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
final DistributionSet cancelDs2 = testdataFactory.createDistributionSet("Canceled DS", "1.2",
|
final DistributionSet cancelDs2 = testdataFactory.createDistributionSet("Canceled DS", "1.2",
|
||||||
Collections.emptyList());
|
Collections.emptyList());
|
||||||
|
|
||||||
final List<Target> targets = testdataFactory.createTargets(Constants.MAX_ENTRIES_IN_STATEMENT + 10);
|
final List<Target> targets = testdataFactory.createTargets(quotaManagement.getMaxTargetsPerAutoAssignment());
|
||||||
|
|
||||||
assertThat(deploymentManagement.countActionsAll()).isZero();
|
assertThat(deploymentManagement.countActionsAll()).isZero();
|
||||||
|
|
||||||
assignDistributionSet(cancelDs, targets).getAssignedEntity();
|
assignDistributionSet(cancelDs, targets).getAssignedEntity();
|
||||||
assertThat(deploymentManagement.countActionsAll()).isEqualTo(Constants.MAX_ENTRIES_IN_STATEMENT + 10);
|
assertThat(deploymentManagement.countActionsAll()).isEqualTo(quotaManagement.getMaxTargetsPerAutoAssignment());
|
||||||
assignDistributionSet(cancelDs2, targets).getAssignedEntity();
|
assignDistributionSet(cancelDs2, targets).getAssignedEntity();
|
||||||
assertThat(deploymentManagement.countActionsAll()).isEqualTo(2 * (Constants.MAX_ENTRIES_IN_STATEMENT + 10));
|
assertThat(deploymentManagement.countActionsAll()).isEqualTo(2L * quotaManagement.getMaxTargetsPerAutoAssignment());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -1393,7 +1393,7 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
Collections.singletonList(ds.getType()));
|
Collections.singletonList(ds.getType()));
|
||||||
|
|
||||||
final List<DeploymentRequest> deploymentRequests = new ArrayList<>();
|
final List<DeploymentRequest> deploymentRequests = new ArrayList<>();
|
||||||
for (int i = 0; i < 100; i++) {
|
for (int i = 0; i < quotaManagement.getMaxTargetDistributionSetAssignmentsPerManualAssignment(); i++) {
|
||||||
final Target target = testdataFactory.createTarget("test-target-" + i, "test-target-" + i,
|
final Target target = testdataFactory.createTarget("test-target-" + i, "test-target-" + i,
|
||||||
targetType.getId());
|
targetType.getId());
|
||||||
final DeploymentRequest deployment = DeploymentManagement
|
final DeploymentRequest deployment = DeploymentManagement
|
||||||
|
|||||||
@@ -1011,12 +1011,12 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
final DistributionSet ds1 = testdataFactory.createDistributionSet("testDs1");
|
final DistributionSet ds1 = testdataFactory.createDistributionSet("testDs1");
|
||||||
final DistributionSet ds2 = testdataFactory.createDistributionSet("testDs2");
|
final DistributionSet ds2 = testdataFactory.createDistributionSet("testDs2");
|
||||||
|
|
||||||
for (int index = 0; index < 10; index++) {
|
for (int index = 0; index < quotaManagement.getMaxMetaDataEntriesPerDistributionSet(); index++) {
|
||||||
createDistributionSetMetadata(ds1.getId(),
|
createDistributionSetMetadata(ds1.getId(),
|
||||||
new JpaDistributionSetMetadata("key" + index, ds1, "value" + index));
|
new JpaDistributionSetMetadata("key" + index, ds1, "value" + index));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int index = 0; index < 8; index++) {
|
for (int index = 0; index <= quotaManagement.getMaxMetaDataEntriesPerDistributionSet() - 2; index++) {
|
||||||
createDistributionSetMetadata(ds2.getId(),
|
createDistributionSetMetadata(ds2.getId(),
|
||||||
new JpaDistributionSetMetadata("key" + index, ds2, "value" + index));
|
new JpaDistributionSetMetadata("key" + index, ds2, "value" + index));
|
||||||
}
|
}
|
||||||
@@ -1027,11 +1027,11 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
final Page<DistributionSetMetadata> metadataOfDs2 = distributionSetManagement
|
final Page<DistributionSetMetadata> metadataOfDs2 = distributionSetManagement
|
||||||
.findMetaDataByDistributionSetId(PageRequest.of(0, 100), ds2.getId());
|
.findMetaDataByDistributionSetId(PageRequest.of(0, 100), ds2.getId());
|
||||||
|
|
||||||
assertThat(metadataOfDs1.getNumberOfElements()).isEqualTo(10);
|
assertThat(metadataOfDs1.getNumberOfElements()).isEqualTo(quotaManagement.getMaxMetaDataEntriesPerDistributionSet());
|
||||||
assertThat(metadataOfDs1.getTotalElements()).isEqualTo(10);
|
assertThat(metadataOfDs1.getTotalElements()).isEqualTo(quotaManagement.getMaxMetaDataEntriesPerDistributionSet());
|
||||||
|
|
||||||
assertThat(metadataOfDs2.getNumberOfElements()).isEqualTo(8);
|
assertThat(metadataOfDs2.getNumberOfElements()).isEqualTo(quotaManagement.getMaxMetaDataEntriesPerDistributionSet() - 1);
|
||||||
assertThat(metadataOfDs2.getTotalElements()).isEqualTo(8);
|
assertThat(metadataOfDs2.getTotalElements()).isEqualTo(quotaManagement.getMaxMetaDataEntriesPerDistributionSet() - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
@@ -44,12 +44,14 @@ public class RolloutGroupManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
@Description("Verifies that management queries react as specfied on calls for non existing entities "
|
@Description("Verifies that management queries react as specfied on calls for non existing entities "
|
||||||
+ " by means of throwing EntityNotFoundException.")
|
+ " by means of throwing EntityNotFoundException.")
|
||||||
@ExpectEvents({ @Expect(type = RolloutDeletedEvent.class, count = 0),
|
@ExpectEvents({ @Expect(type = RolloutDeletedEvent.class, count = 0),
|
||||||
@Expect(type = RolloutGroupCreatedEvent.class, count = 10),
|
@Expect(type = RolloutGroupCreatedEvent.class, count = 5),
|
||||||
@Expect(type = RolloutGroupUpdatedEvent.class, count = 10),
|
@Expect(type = RolloutGroupUpdatedEvent.class, count = 5),
|
||||||
@Expect(type = DistributionSetCreatedEvent.class, count = 1),
|
@Expect(type = DistributionSetCreatedEvent.class, count = 1),
|
||||||
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3),
|
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3),
|
||||||
@Expect(type = RolloutUpdatedEvent.class, count = 1), @Expect(type = TargetCreatedEvent.class, count = 10),
|
@Expect(type = RolloutUpdatedEvent.class, count = 1),
|
||||||
|
@Expect(type = TargetCreatedEvent.class, count = 125),
|
||||||
@Expect(type = RolloutCreatedEvent.class, count = 1) })
|
@Expect(type = RolloutCreatedEvent.class, count = 1) })
|
||||||
|
|
||||||
public void entityQueriesReferringToNotExistingEntitiesThrowsException() {
|
public void entityQueriesReferringToNotExistingEntitiesThrowsException() {
|
||||||
testdataFactory.createRollout("xxx");
|
testdataFactory.createRollout("xxx");
|
||||||
|
|
||||||
|
|||||||
@@ -192,13 +192,14 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
@Test
|
@Test
|
||||||
@Description("Verifies that management queries react as specified on calls for non existing entities "
|
@Description("Verifies that management queries react as specified on calls for non existing entities "
|
||||||
+ " by means of throwing EntityNotFoundException.")
|
+ " by means of throwing EntityNotFoundException.")
|
||||||
@ExpectEvents({ @Expect(type = RolloutDeletedEvent.class),
|
@ExpectEvents({ @Expect(type = RolloutDeletedEvent.class, count = 0),
|
||||||
@Expect(type = RolloutGroupCreatedEvent.class, count = 10),
|
@Expect(type = RolloutGroupCreatedEvent.class, count = 5),
|
||||||
@Expect(type = RolloutGroupUpdatedEvent.class, count = 10),
|
@Expect(type = RolloutGroupUpdatedEvent.class, count = 5),
|
||||||
@Expect(type = DistributionSetCreatedEvent.class, count = 1),
|
@Expect(type = DistributionSetCreatedEvent.class, count = 1),
|
||||||
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3),
|
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3),
|
||||||
@Expect(type = RolloutUpdatedEvent.class, count = 1), @Expect(type = RolloutCreatedEvent.class, count = 1),
|
@Expect(type = RolloutCreatedEvent.class, count = 1),
|
||||||
@Expect(type = TargetCreatedEvent.class, count = 10) })
|
@Expect(type = RolloutUpdatedEvent.class, count = 1),
|
||||||
|
@Expect(type = TargetCreatedEvent.class, count = 125)})
|
||||||
void entityQueriesReferringToNotExistingEntitiesThrowsException() {
|
void entityQueriesReferringToNotExistingEntitiesThrowsException() {
|
||||||
testdataFactory.createRollout("xxx");
|
testdataFactory.createRollout("xxx");
|
||||||
|
|
||||||
@@ -1495,10 +1496,10 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
void createRolloutWithGroupDefinition() throws Exception {
|
void createRolloutWithGroupDefinition() throws Exception {
|
||||||
final String rolloutName = "rolloutTest3";
|
final String rolloutName = "rolloutTest3";
|
||||||
|
|
||||||
final int amountTargetsInGroup1 = 100;
|
final int amountTargetsInGroup1 = 10;
|
||||||
final int percentTargetsInGroup1 = 100;
|
final int percentTargetsInGroup1 = 100;
|
||||||
|
|
||||||
final int amountTargetsInGroup1and2 = 500;
|
final int amountTargetsInGroup1and2 = 20;
|
||||||
final int percentTargetsInGroup2 = 20;
|
final int percentTargetsInGroup2 = 20;
|
||||||
final int percentTargetsInGroup3 = 100;
|
final int percentTargetsInGroup3 = 100;
|
||||||
|
|
||||||
|
|||||||
@@ -91,17 +91,17 @@ public class SystemManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
@Description("Checks that the system report calculates correctly the actions size of all tenants in the system")
|
@Description("Checks that the system report calculates correctly the actions size of all tenants in the system")
|
||||||
public void systemUsageReportCollectsActionsOfAllTenants() throws Exception {
|
public void systemUsageReportCollectsActionsOfAllTenants() throws Exception {
|
||||||
// Prepare tenants
|
// Prepare tenants
|
||||||
createTestTenantsForSystemStatistics(2, 0, 100, 2);
|
createTestTenantsForSystemStatistics(2, 0, 20, 2);
|
||||||
|
|
||||||
// 2 tenants, 100 targets each, 2 deployments per target => 400
|
// 2 tenants, 100 targets each, 2 deployments per target => 400
|
||||||
assertThat(systemManagement.getSystemUsageStatistics().getOverallActions()).isEqualTo(400);
|
assertThat(systemManagement.getSystemUsageStatistics().getOverallActions()).isEqualTo(80);
|
||||||
|
|
||||||
// per tenant data
|
// per tenant data
|
||||||
final List<TenantUsage> tenants = systemManagement.getSystemUsageStatisticsWithTenants().getTenants();
|
final List<TenantUsage> tenants = systemManagement.getSystemUsageStatisticsWithTenants().getTenants();
|
||||||
assertThat(tenants).hasSize(3);
|
assertThat(tenants).hasSize(3);
|
||||||
assertThat(tenants).containsOnly(new TenantUsage("default"),
|
assertThat(tenants).containsOnly(new TenantUsage("default"),
|
||||||
new TenantUsage("tenant0").setTargets(100).setActions(200),
|
new TenantUsage("tenant0").setTargets(20).setActions(40),
|
||||||
new TenantUsage("tenant1").setTargets(100).setActions(200));
|
new TenantUsage("tenant1").setTargets(20).setActions(40));
|
||||||
}
|
}
|
||||||
|
|
||||||
private byte[] createTestTenantsForSystemStatistics(final int tenants, final int artifactSize, final int targets,
|
private byte[] createTestTenantsForSystemStatistics(final int tenants, final int artifactSize, final int targets,
|
||||||
|
|||||||
@@ -118,7 +118,7 @@ class AutoAssignCheckerTest extends AbstractJpaIntegrationTest {
|
|||||||
.ds(setA.getId()));
|
.ds(setA.getId()));
|
||||||
|
|
||||||
final String targetDsAIdPref = "targ";
|
final String targetDsAIdPref = "targ";
|
||||||
final List<Target> targets = testdataFactory.createTargets(100, targetDsAIdPref,
|
final List<Target> targets = testdataFactory.createTargets(25, targetDsAIdPref,
|
||||||
targetDsAIdPref.concat(" description"));
|
targetDsAIdPref.concat(" description"));
|
||||||
final int targetsCount = targets.size();
|
final int targetsCount = targets.size();
|
||||||
|
|
||||||
@@ -138,12 +138,12 @@ class AutoAssignCheckerTest extends AbstractJpaIntegrationTest {
|
|||||||
|
|
||||||
// Count the number of targets that will be assigned with setA
|
// Count the number of targets that will be assigned with setA
|
||||||
assertThat(targetManagement.countByRsqlAndNonDSAndCompatible(setA.getId(), targetFilterQuery.getQuery()))
|
assertThat(targetManagement.countByRsqlAndNonDSAndCompatible(setA.getId(), targetFilterQuery.getQuery()))
|
||||||
.isEqualTo(90);
|
.isEqualTo(15);
|
||||||
|
|
||||||
// Run the check
|
// Run the check
|
||||||
autoAssignChecker.check();
|
autoAssignChecker.check();
|
||||||
|
|
||||||
verifyThatTargetsHaveDistributionSetAssignment(setA, targets.subList(5, 100), targetsCount);
|
verifyThatTargetsHaveDistributionSetAssignment(setA, targets.subList(5, 25), targetsCount);
|
||||||
|
|
||||||
// first 5 should keep their dsB, because they already had the dsA once
|
// first 5 should keep their dsB, because they already had the dsA once
|
||||||
verifyThatTargetsHaveDistributionSetAssignment(setB, targets.subList(0, 5), targetsCount);
|
verifyThatTargetsHaveDistributionSetAssignment(setB, targets.subList(0, 5), targetsCount);
|
||||||
|
|||||||
@@ -129,7 +129,7 @@ public class RepositoryEntityEventTest extends AbstractJpaIntegrationTest {
|
|||||||
@Test
|
@Test
|
||||||
@Description("Verifies that the rollout deleted event is published when a rollout has been deleted")
|
@Description("Verifies that the rollout deleted event is published when a rollout has been deleted")
|
||||||
public void rolloutDeletedEventIsPublished() throws InterruptedException {
|
public void rolloutDeletedEventIsPublished() throws InterruptedException {
|
||||||
final int amountTargetsForRollout = 500;
|
final int amountTargetsForRollout = 50;
|
||||||
final int amountGroups = 5;
|
final int amountGroups = 5;
|
||||||
final String successCondition = "50";
|
final String successCondition = "50";
|
||||||
final String errorCondition = "80";
|
final String errorCondition = "80";
|
||||||
|
|||||||
@@ -7,21 +7,6 @@
|
|||||||
# http://www.eclipse.org/legal/epl-v10.html
|
# http://www.eclipse.org/legal/epl-v10.html
|
||||||
#
|
#
|
||||||
|
|
||||||
# Quota - START
|
|
||||||
hawkbit.server.security.dos.maxStatusEntriesPerAction=10
|
|
||||||
hawkbit.server.security.dos.maxAttributeEntriesPerTarget=10
|
|
||||||
hawkbit.server.security.dos.maxMetaDataEntriesPerSoftwareModule=10
|
|
||||||
hawkbit.server.security.dos.maxRolloutGroupsPerRollout=20
|
|
||||||
hawkbit.server.security.dos.maxMessagesPerActionStatus=10
|
|
||||||
hawkbit.server.security.dos.maxMetaDataEntriesPerDistributionSet=10
|
|
||||||
hawkbit.server.security.dos.maxSoftwareModuleTypesPerDistributionSetType=10
|
|
||||||
hawkbit.server.security.dos.maxSoftwareModulesPerDistributionSet=10
|
|
||||||
hawkbit.server.security.dos.maxArtifactsPerSoftwareModule=10
|
|
||||||
hawkbit.server.security.dos.maxTargetsPerRolloutGroup=1000
|
|
||||||
hawkbit.server.security.dos.maxArtifactSize=600000
|
|
||||||
hawkbit.server.security.dos.maxArtifactStorage=1000000
|
|
||||||
# Quota - END
|
|
||||||
|
|
||||||
# Debug utility functions - START
|
# Debug utility functions - START
|
||||||
logging.level.org.eclipse.persistence=ERROR
|
logging.level.org.eclipse.persistence=ERROR
|
||||||
spring.jpa.properties.eclipselink.logging.level=FINE
|
spring.jpa.properties.eclipselink.logging.level=FINE
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ import org.eclipse.hawkbit.repository.DistributionSetManagement;
|
|||||||
import org.eclipse.hawkbit.repository.DistributionSetTagManagement;
|
import org.eclipse.hawkbit.repository.DistributionSetTagManagement;
|
||||||
import org.eclipse.hawkbit.repository.DistributionSetTypeManagement;
|
import org.eclipse.hawkbit.repository.DistributionSetTypeManagement;
|
||||||
import org.eclipse.hawkbit.repository.EntityFactory;
|
import org.eclipse.hawkbit.repository.EntityFactory;
|
||||||
|
import org.eclipse.hawkbit.repository.QuotaManagement;
|
||||||
import org.eclipse.hawkbit.repository.RolloutManagement;
|
import org.eclipse.hawkbit.repository.RolloutManagement;
|
||||||
import org.eclipse.hawkbit.repository.SoftwareModuleManagement;
|
import org.eclipse.hawkbit.repository.SoftwareModuleManagement;
|
||||||
import org.eclipse.hawkbit.repository.SoftwareModuleTypeManagement;
|
import org.eclipse.hawkbit.repository.SoftwareModuleTypeManagement;
|
||||||
@@ -173,6 +174,9 @@ public class TestdataFactory {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private RolloutManagement rolloutManagement;
|
private RolloutManagement rolloutManagement;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private QuotaManagement quotaManagement;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates {@link DistributionSet} in repository including three
|
* Creates {@link DistributionSet} in repository including three
|
||||||
* {@link SoftwareModule}s of types {@link #SM_TYPE_OS}, {@link #SM_TYPE_RT} ,
|
* {@link SoftwareModule}s of types {@link #SM_TYPE_OS}, {@link #SM_TYPE_RT} ,
|
||||||
@@ -1180,8 +1184,10 @@ public class TestdataFactory {
|
|||||||
* @return created {@link Rollout}
|
* @return created {@link Rollout}
|
||||||
*/
|
*/
|
||||||
public Rollout createRollout(final String prefix) {
|
public Rollout createRollout(final String prefix) {
|
||||||
createTargets(10, prefix);
|
createTargets(quotaManagement.getMaxTargetsPerRolloutGroup() * quotaManagement.getMaxRolloutGroupsPerRollout(),
|
||||||
return createRolloutByVariables(prefix, prefix + " description", 10, "controllerId==" + prefix + "*",
|
prefix);
|
||||||
|
return createRolloutByVariables(prefix, prefix + " description",
|
||||||
|
quotaManagement.getMaxRolloutGroupsPerRollout(), "controllerId==" + prefix + "*",
|
||||||
createDistributionSet(prefix), "50", "5");
|
createDistributionSet(prefix), "50", "5");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -53,4 +53,22 @@ hawkbit.artifact.url.protocols.md5sum-http.supports=DDI
|
|||||||
hawkbit.artifact.url.protocols.md5sum-http.ref=${hawkbit.artifact.url.protocols.download-http.ref}.MD5SUM
|
hawkbit.artifact.url.protocols.md5sum-http.ref=${hawkbit.artifact.url.protocols.download-http.ref}.MD5SUM
|
||||||
## Download URL Generation - END
|
## Download URL Generation - END
|
||||||
|
|
||||||
|
# Quota - START
|
||||||
|
hawkbit.server.security.dos.maxStatusEntriesPerAction=10
|
||||||
|
hawkbit.server.security.dos.maxAttributeEntriesPerTarget=10
|
||||||
|
hawkbit.server.security.dos.maxMetaDataEntriesPerSoftwareModule=10
|
||||||
|
hawkbit.server.security.dos.maxRolloutGroupsPerRollout=5
|
||||||
|
hawkbit.server.security.dos.maxMessagesPerActionStatus=10
|
||||||
|
hawkbit.server.security.dos.maxMetaDataEntriesPerDistributionSet=10
|
||||||
|
hawkbit.server.security.dos.maxSoftwareModuleTypesPerDistributionSetType=5
|
||||||
|
hawkbit.server.security.dos.maxSoftwareModulesPerDistributionSet=5
|
||||||
|
hawkbit.server.security.dos.maxArtifactsPerSoftwareModule=3
|
||||||
|
hawkbit.server.security.dos.maxTargetsPerRolloutGroup=25
|
||||||
|
hawkbit.server.security.dos.maxArtifactSize=600000
|
||||||
|
hawkbit.server.security.dos.maxArtifactStorage=1000000
|
||||||
|
hawkbit.server.security.dos.maxTargetDistributionSetAssignmentsPerManualAssignment=20
|
||||||
|
hawkbit.server.security.dos.maxTargetsPerAutoAssignment=20
|
||||||
|
hawkbit.server.security.dos.maxActionsPerTarget=20
|
||||||
|
# Quota - END
|
||||||
|
|
||||||
# Properties that are managed by autoconfigure module at runtime and not available during test - END
|
# Properties that are managed by autoconfigure module at runtime and not available during test - END
|
||||||
|
|||||||
@@ -170,7 +170,7 @@ public class DdiArtifactDownloadTest extends AbstractDDiApiIntegrationTest {
|
|||||||
final DistributionSet ds = testdataFactory.createDistributionSet("");
|
final DistributionSet ds = testdataFactory.createDistributionSet("");
|
||||||
|
|
||||||
// create artifact
|
// create artifact
|
||||||
final int artifactSize = 5 * 1024 * 1024;
|
final int artifactSize = (int) quotaManagement.getMaxArtifactSize();
|
||||||
final byte random[] = RandomUtils.nextBytes(artifactSize);
|
final byte random[] = RandomUtils.nextBytes(artifactSize);
|
||||||
final Artifact artifact = artifactManagement.create(new ArtifactUpload(new ByteArrayInputStream(random),
|
final Artifact artifact = artifactManagement.create(new ArtifactUpload(new ByteArrayInputStream(random),
|
||||||
ds.findFirstModuleByType(osType).get().getId(), "file1", false, artifactSize));
|
ds.findFirstModuleByType(osType).get().getId(), "file1", false, artifactSize));
|
||||||
@@ -238,7 +238,7 @@ public class DdiArtifactDownloadTest extends AbstractDDiApiIntegrationTest {
|
|||||||
// create ds
|
// create ds
|
||||||
final DistributionSet ds = testdataFactory.createDistributionSet("");
|
final DistributionSet ds = testdataFactory.createDistributionSet("");
|
||||||
|
|
||||||
final int resultLength = 5 * 1000 * 1024;
|
final int resultLength = (int) quotaManagement.getMaxArtifactSize();
|
||||||
|
|
||||||
// create artifact
|
// create artifact
|
||||||
final byte random[] = RandomUtils.nextBytes(resultLength);
|
final byte random[] = RandomUtils.nextBytes(resultLength);
|
||||||
@@ -250,7 +250,7 @@ public class DdiArtifactDownloadTest extends AbstractDDiApiIntegrationTest {
|
|||||||
// now assign and download successful
|
// now assign and download successful
|
||||||
assignDistributionSet(ds, targets);
|
assignDistributionSet(ds, targets);
|
||||||
|
|
||||||
final int range = 100 * 1024;
|
final int range = resultLength / 50;
|
||||||
|
|
||||||
// full file download with standard range request
|
// full file download with standard range request
|
||||||
final ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
final ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||||
|
|||||||
@@ -493,7 +493,7 @@ public class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest {
|
|||||||
.get(0);
|
.get(0);
|
||||||
|
|
||||||
final List<String> messages = new ArrayList<>();
|
final List<String> messages = new ArrayList<>();
|
||||||
for (int i = 0; i < 51; i++) {
|
for (int i = 0; i < quotaManagement.getMaxMessagesPerActionStatus() + 1; i++) {
|
||||||
messages.add(String.valueOf(i));
|
messages.add(String.valueOf(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -112,7 +112,7 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest {
|
|||||||
void createRolloutWithNotWellFormedFilterReturnsBadRequest() throws Exception {
|
void createRolloutWithNotWellFormedFilterReturnsBadRequest() throws Exception {
|
||||||
final DistributionSet dsA = testdataFactory.createDistributionSet("");
|
final DistributionSet dsA = testdataFactory.createDistributionSet("");
|
||||||
mvc.perform(post("/rest/v1/rollouts").content(
|
mvc.perform(post("/rest/v1/rollouts").content(
|
||||||
JsonBuilder.rollout("name", "desc", 10, dsA.getId(), "name=test", null))
|
JsonBuilder.rollout("name", "desc", 5, dsA.getId(), "name=test", null))
|
||||||
.contentType(MediaType.APPLICATION_JSON)
|
.contentType(MediaType.APPLICATION_JSON)
|
||||||
.accept(MediaType.APPLICATION_JSON))
|
.accept(MediaType.APPLICATION_JSON))
|
||||||
.andDo(MockMvcResultPrinter.print())
|
.andDo(MockMvcResultPrinter.print())
|
||||||
@@ -143,7 +143,7 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest {
|
|||||||
testdataFactory.createTargets(20, "target", "rollout");
|
testdataFactory.createTargets(20, "target", "rollout");
|
||||||
|
|
||||||
final DistributionSet dsA = testdataFactory.createDistributionSet("");
|
final DistributionSet dsA = testdataFactory.createDistributionSet("");
|
||||||
postRollout("rollout1", 10, dsA.getId(), "id==target*", 20, Action.ActionType.FORCED);
|
postRollout("rollout1", 5, dsA.getId(), "id==target*", 20, Action.ActionType.FORCED);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -399,7 +399,7 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest {
|
|||||||
testdataFactory.createTargets(20, "target", "rollout");
|
testdataFactory.createTargets(20, "target", "rollout");
|
||||||
|
|
||||||
// setup - create 2 rollouts
|
// setup - create 2 rollouts
|
||||||
postRollout("rollout1", 10, dsA.getId(), "id==target*", 20, Action.ActionType.FORCED);
|
postRollout("rollout1", 5, dsA.getId(), "id==target*", 20, Action.ActionType.FORCED);
|
||||||
postRollout("rollout2", 5, dsA.getId(), "id==target-0001*", 10, Action.ActionType.FORCED);
|
postRollout("rollout2", 5, dsA.getId(), "id==target-0001*", 10, Action.ActionType.FORCED);
|
||||||
|
|
||||||
// Run here, because Scheduler is disabled during tests
|
// Run here, because Scheduler is disabled during tests
|
||||||
@@ -440,7 +440,7 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest {
|
|||||||
testdataFactory.createTargets(20, "target", "rollout");
|
testdataFactory.createTargets(20, "target", "rollout");
|
||||||
|
|
||||||
// setup - create 2 rollouts
|
// setup - create 2 rollouts
|
||||||
postRollout("rollout1", 10, dsA.getId(), "id==target*", 20, Action.ActionType.FORCED);
|
postRollout("rollout1", 5, dsA.getId(), "id==target*", 20, Action.ActionType.FORCED);
|
||||||
postRollout("rollout2", 5, dsA.getId(), "id==target*", 20, Action.ActionType.FORCED);
|
postRollout("rollout2", 5, dsA.getId(), "id==target*", 20, Action.ActionType.FORCED);
|
||||||
|
|
||||||
// Run here, because Scheduler is disabled during tests
|
// Run here, because Scheduler is disabled during tests
|
||||||
@@ -822,7 +822,7 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest {
|
|||||||
@Description("Start the rollout in async mode")
|
@Description("Start the rollout in async mode")
|
||||||
void startingRolloutSwitchesIntoRunningStateAsync() throws Exception {
|
void startingRolloutSwitchesIntoRunningStateAsync() throws Exception {
|
||||||
|
|
||||||
final int amountTargets = 1000;
|
final int amountTargets = 50;
|
||||||
testdataFactory.createTargets(amountTargets, "rollout", "rollout");
|
testdataFactory.createTargets(amountTargets, "rollout", "rollout");
|
||||||
final DistributionSet dsA = testdataFactory.createDistributionSet("");
|
final DistributionSet dsA = testdataFactory.createDistributionSet("");
|
||||||
|
|
||||||
@@ -965,7 +965,7 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest {
|
|||||||
testdataFactory.createTargets(20, "target", "rollout");
|
testdataFactory.createTargets(20, "target", "rollout");
|
||||||
|
|
||||||
final DistributionSet dsA = testdataFactory.createDistributionSet("");
|
final DistributionSet dsA = testdataFactory.createDistributionSet("");
|
||||||
postRollout("rollout1", 10, dsA.getId(), "id==target*", 20, Action.ActionType.DOWNLOAD_ONLY);
|
postRollout("rollout1", 5, dsA.getId(), "id==target*", 20, Action.ActionType.DOWNLOAD_ONLY);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
@@ -183,7 +183,7 @@ public class RolloutResourceDocumentationTest extends AbstractApiRestDocumentati
|
|||||||
final String name = "exampleRollout";
|
final String name = "exampleRollout";
|
||||||
final String type = "forced";
|
final String type = "forced";
|
||||||
final String description = "Rollout for all named targets";
|
final String description = "Rollout for all named targets";
|
||||||
final int groupSize = 10;
|
final int groupSize = 5;
|
||||||
final Long dsId = testdataFactory.createDistributionSet().getId();
|
final Long dsId = testdataFactory.createDistributionSet().getId();
|
||||||
final String targetFilter = "id==targets-*";
|
final String targetFilter = "id==targets-*";
|
||||||
|
|
||||||
@@ -642,7 +642,7 @@ public class RolloutResourceDocumentationTest extends AbstractApiRestDocumentati
|
|||||||
if (isMultiAssignmentsEnabled()) {
|
if (isMultiAssignmentsEnabled()) {
|
||||||
rolloutCreate.weight(400);
|
rolloutCreate.weight(400);
|
||||||
}
|
}
|
||||||
final Rollout rollout = rolloutManagement.create(rolloutCreate, 10, new RolloutGroupConditionBuilder()
|
final Rollout rollout = rolloutManagement.create(rolloutCreate, 5, new RolloutGroupConditionBuilder()
|
||||||
.withDefaults().successCondition(RolloutGroupSuccessCondition.THRESHOLD, "10").build());
|
.withDefaults().successCondition(RolloutGroupSuccessCondition.THRESHOLD, "10").build());
|
||||||
|
|
||||||
// Run here, because Scheduler is disabled during tests
|
// Run here, because Scheduler is disabled during tests
|
||||||
|
|||||||
Reference in New Issue
Block a user