Test and build performance improvements (#552)
* Small build perf improvements. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Remove dead code. Stabilize test. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Further optimizations Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Upgrade mariadb driver. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Raise timeouts for more robustness on slower build environments. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Move webappcontext into rest tests. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Raised timeout. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Remove test dependency on target to groups distribution order. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Code reuse. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Context available to tests. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Typos fixed. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Fix PollEvent send. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Fix typos. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Test log readability and removed unused method from CM. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Remove empty payload. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Stabilize tests. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Raised timeout. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Fixed fire directory change during one test class run. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>
This commit is contained in:
@@ -126,17 +126,6 @@ public class JpaControllerManagement implements ControllerManagement {
|
||||
.getConfigurationValue(TenantConfigurationKey.POLLING_TIME_INTERVAL, String.class).getValue());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public Target updateLastTargetQuery(final String controllerId, final URI address) {
|
||||
final JpaTarget target = (JpaTarget) targetRepository.findByControllerId(controllerId)
|
||||
.orElseThrow(() -> new EntityNotFoundException(Target.class, controllerId));
|
||||
|
||||
return updateTargetStatus(target, null, System.currentTimeMillis(), address);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Action> getActionForDownloadByTargetAndSoftwareModule(final String controllerId,
|
||||
final Long moduleId) {
|
||||
@@ -221,27 +210,20 @@ public class JpaControllerManagement implements ControllerManagement {
|
||||
return result;
|
||||
}
|
||||
|
||||
return updateTargetStatus(target, null, System.currentTimeMillis(), address);
|
||||
return updateTargetStatus(target, address);
|
||||
}
|
||||
|
||||
private Target updateTargetStatus(final JpaTarget toUpdate, final TargetUpdateStatus status,
|
||||
final Long lastTargetQuery, final URI address) {
|
||||
if (status != null) {
|
||||
toUpdate.setUpdateStatus(status);
|
||||
}
|
||||
if (lastTargetQuery != null) {
|
||||
toUpdate.setLastTargetQuery(lastTargetQuery);
|
||||
}
|
||||
private Target updateTargetStatus(final JpaTarget toUpdate, final URI address) {
|
||||
|
||||
if (TargetUpdateStatus.UNKNOWN.equals(toUpdate.getUpdateStatus())) {
|
||||
toUpdate.setUpdateStatus(TargetUpdateStatus.REGISTERED);
|
||||
}
|
||||
|
||||
if (address != null) {
|
||||
toUpdate.setAddress(address.toString());
|
||||
afterCommit.afterCommit(
|
||||
() -> eventPublisher.publishEvent(new TargetPollEvent(toUpdate, applicationContext.getId())));
|
||||
}
|
||||
toUpdate.setAddress(address.toString());
|
||||
toUpdate.setLastTargetQuery(System.currentTimeMillis());
|
||||
|
||||
afterCommit.afterCommit(
|
||||
() -> eventPublisher.publishEvent(new TargetPollEvent(toUpdate, applicationContext.getId())));
|
||||
|
||||
return targetRepository.save(toUpdate);
|
||||
}
|
||||
|
||||
@@ -14,7 +14,6 @@ import static org.eclipse.hawkbit.im.authentication.SpPermission.SpringEvalExpre
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -61,7 +60,7 @@ import ru.yandex.qatools.allure.annotations.Stories;
|
||||
@Features("Component Tests - Repository")
|
||||
@Stories("Controller Management")
|
||||
public class ControllerManagementTest extends AbstractJpaIntegrationTest {
|
||||
private static final URI LOCALHOST = URI.create("http://127.0.0.1");
|
||||
|
||||
@Autowired
|
||||
private RepositoryProperties repositoryProperties;
|
||||
|
||||
@@ -121,9 +120,6 @@ public class ControllerManagementTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
verifyThrownExceptionBy(() -> controllerManagement.updateControllerAttributes(NOT_EXIST_ID, Maps.newHashMap()),
|
||||
"Target");
|
||||
|
||||
verifyThrownExceptionBy(
|
||||
() -> controllerManagement.updateLastTargetQuery(NOT_EXIST_ID, new URI("http://test.com")), "Target");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -424,17 +420,15 @@ public class ControllerManagementTest extends AbstractJpaIntegrationTest {
|
||||
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1),
|
||||
@Expect(type = TargetPollEvent.class, count = 2) })
|
||||
public void findOrRegisterTargetIfItDoesNotexist() {
|
||||
final Target target = controllerManagement.findOrRegisterTargetIfItDoesNotexist("AA",
|
||||
LOCALHOST);
|
||||
final Target target = controllerManagement.findOrRegisterTargetIfItDoesNotexist("AA", LOCALHOST);
|
||||
assertThat(target).as("target should not be null").isNotNull();
|
||||
|
||||
final Target sameTarget = controllerManagement.findOrRegisterTargetIfItDoesNotexist("AA",
|
||||
LOCALHOST);
|
||||
final Target sameTarget = controllerManagement.findOrRegisterTargetIfItDoesNotexist("AA", LOCALHOST);
|
||||
assertThat(target.getId()).as("Target should be the equals").isEqualTo(sameTarget.getId());
|
||||
assertThat(targetRepository.count()).as("Only 1 target should be registred").isEqualTo(1L);
|
||||
|
||||
assertThatExceptionOfType(ConstraintViolationException.class).isThrownBy(
|
||||
() -> controllerManagement.findOrRegisterTargetIfItDoesNotexist("", LOCALHOST))
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.isThrownBy(() -> controllerManagement.findOrRegisterTargetIfItDoesNotexist("", LOCALHOST))
|
||||
.as("register target with empty controllerId should fail");
|
||||
}
|
||||
|
||||
|
||||
@@ -869,17 +869,16 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
ds.getId(), ActionType.SOFT,
|
||||
org.eclipse.hawkbit.repository.model.RepositoryModelConstants.NO_FORCE_TIME,
|
||||
Arrays.asList(target.getControllerId()));
|
||||
final Action action = deploymentManagement.findActionWithDetails(assignDistributionSet.getActions().get(0))
|
||||
.get();
|
||||
final Long actionId = assignDistributionSet.getActions().get(0);
|
||||
// verify preparation
|
||||
Action findAction = deploymentManagement.findAction(action.getId()).get();
|
||||
Action findAction = deploymentManagement.findAction(actionId).get();
|
||||
assertThat(findAction.getActionType()).as("action type is wrong").isEqualTo(ActionType.SOFT);
|
||||
|
||||
// test
|
||||
deploymentManagement.forceTargetAction(action.getId());
|
||||
deploymentManagement.forceTargetAction(actionId);
|
||||
|
||||
// verify test
|
||||
findAction = deploymentManagement.findAction(action.getId()).get();
|
||||
findAction = deploymentManagement.findAction(actionId).get();
|
||||
assertThat(findAction.getActionType()).as("action type is wrong").isEqualTo(ActionType.FORCED);
|
||||
}
|
||||
|
||||
@@ -894,18 +893,17 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
ds.getId(), ActionType.FORCED,
|
||||
org.eclipse.hawkbit.repository.model.RepositoryModelConstants.NO_FORCE_TIME,
|
||||
Arrays.asList(target.getControllerId()));
|
||||
final Action action = deploymentManagement.findActionWithDetails(assignDistributionSet.getActions().get(0))
|
||||
.get();
|
||||
final Long actionId = assignDistributionSet.getActions().get(0);
|
||||
// verify perparation
|
||||
Action findAction = deploymentManagement.findAction(action.getId()).get();
|
||||
Action findAction = deploymentManagement.findAction(actionId).get();
|
||||
assertThat(findAction.getActionType()).as("action type is wrong").isEqualTo(ActionType.FORCED);
|
||||
|
||||
// test
|
||||
final Action forceTargetAction = deploymentManagement.forceTargetAction(action.getId());
|
||||
final Action forceTargetAction = deploymentManagement.forceTargetAction(actionId);
|
||||
|
||||
// verify test
|
||||
assertThat(forceTargetAction.getActionType()).as("action type is wrong").isEqualTo(ActionType.FORCED);
|
||||
findAction = deploymentManagement.findAction(action.getId()).get();
|
||||
findAction = deploymentManagement.findAction(actionId).get();
|
||||
assertThat(findAction.getActionType()).as("action type is wrong").isEqualTo(ActionType.FORCED);
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,6 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
@@ -448,8 +447,8 @@ public class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
.createDistributionSetTag(entityFactory.tag().create().name("DistributionSetTag-C"));
|
||||
tagManagement.createDistributionSetTag(entityFactory.tag().create().name("DistributionSetTag-D"));
|
||||
|
||||
Collection<DistributionSet> ds100Group1 = testdataFactory.createDistributionSets("", 100);
|
||||
Collection<DistributionSet> ds100Group2 = testdataFactory.createDistributionSets("test2", 100);
|
||||
List<DistributionSet> ds5Group1 = testdataFactory.createDistributionSets("", 5);
|
||||
List<DistributionSet> dsGroup2 = testdataFactory.createDistributionSets("test2", 5);
|
||||
DistributionSet dsDeleted = testdataFactory.createDistributionSet("deleted");
|
||||
final DistributionSet dsInComplete = distributionSetManagement.createDistributionSet(entityFactory
|
||||
.distributionSet().create().name("notcomplete").version("1").type(standardDsType.getKey()));
|
||||
@@ -470,27 +469,27 @@ public class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
distributionSetManagement.deleteDistributionSet(dsDeleted.getId());
|
||||
dsDeleted = distributionSetManagement.findDistributionSetById(dsDeleted.getId()).get();
|
||||
|
||||
ds100Group1 = toggleTagAssignment(ds100Group1, dsTagA).getAssignedEntity();
|
||||
ds5Group1 = toggleTagAssignment(ds5Group1, dsTagA).getAssignedEntity();
|
||||
dsTagA = distributionSetTagRepository.findByNameEquals(dsTagA.getName()).get();
|
||||
ds100Group1 = toggleTagAssignment(ds100Group1, dsTagB).getAssignedEntity();
|
||||
ds5Group1 = toggleTagAssignment(ds5Group1, dsTagB).getAssignedEntity();
|
||||
dsTagA = distributionSetTagRepository.findByNameEquals(dsTagA.getName()).get();
|
||||
ds100Group2 = toggleTagAssignment(ds100Group2, dsTagA).getAssignedEntity();
|
||||
dsGroup2 = toggleTagAssignment(dsGroup2, dsTagA).getAssignedEntity();
|
||||
dsTagA = distributionSetTagRepository.findByNameEquals(dsTagA.getName()).get();
|
||||
|
||||
// check setup
|
||||
assertThat(distributionSetRepository.findAll()).hasSize(203);
|
||||
assertThat(distributionSetRepository.findAll()).hasSize(13);
|
||||
|
||||
// Find all
|
||||
List<DistributionSet> expected = Lists.newArrayListWithExpectedSize(203);
|
||||
expected.addAll(ds100Group1);
|
||||
expected.addAll(ds100Group2);
|
||||
List<DistributionSet> expected = Lists.newArrayListWithExpectedSize(13);
|
||||
expected.addAll(ds5Group1);
|
||||
expected.addAll(dsGroup2);
|
||||
expected.add(dsDeleted);
|
||||
expected.add(dsInComplete);
|
||||
expected.add(dsNewType);
|
||||
|
||||
assertThat(distributionSetManagement
|
||||
.findDistributionSetsByFilters(PAGE, getDistributionSetFilterBuilder().build()).getContent())
|
||||
.hasSize(203).containsOnly(expected.toArray(new DistributionSet[0]));
|
||||
.hasSize(13).containsOnly(expected.toArray(new DistributionSet[0]));
|
||||
|
||||
DistributionSetFilterBuilder distributionSetFilterBuilder;
|
||||
|
||||
@@ -501,18 +500,18 @@ public class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsDeleted(false);
|
||||
assertThat(distributionSetManagement.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build())
|
||||
.getContent()).hasSize(202);
|
||||
.getContent()).hasSize(12);
|
||||
|
||||
// search for completed
|
||||
expected = new ArrayList<>();
|
||||
expected.addAll(ds100Group1);
|
||||
expected.addAll(ds100Group2);
|
||||
expected.addAll(ds5Group1);
|
||||
expected.addAll(dsGroup2);
|
||||
expected.add(dsDeleted);
|
||||
expected.add(dsNewType);
|
||||
|
||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(true);
|
||||
assertThat(distributionSetManagement.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build())
|
||||
.getContent()).hasSize(202).containsOnly(expected.toArray(new DistributionSet[0]));
|
||||
.getContent()).hasSize(12).containsOnly(expected.toArray(new DistributionSet[0]));
|
||||
|
||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(Boolean.FALSE);
|
||||
expected = new ArrayList<>();
|
||||
@@ -527,31 +526,31 @@ public class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setType(standardDsType);
|
||||
assertThat(distributionSetManagement.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build())
|
||||
.getContent()).hasSize(202);
|
||||
.getContent()).hasSize(12);
|
||||
|
||||
// search for text
|
||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setSearchText("%test2");
|
||||
assertThat(distributionSetManagement.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build())
|
||||
.getContent()).hasSize(100);
|
||||
.getContent()).hasSize(5);
|
||||
|
||||
// search for tags
|
||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setTagNames(Arrays.asList(dsTagA.getName()));
|
||||
assertThat(distributionSetManagement.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build())
|
||||
.getContent()).hasSize(200);
|
||||
.getContent()).hasSize(10);
|
||||
|
||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setTagNames(Arrays.asList(dsTagB.getName()));
|
||||
assertThat(distributionSetManagement.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build())
|
||||
.getContent()).hasSize(100);
|
||||
.getContent()).hasSize(5);
|
||||
|
||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder()
|
||||
.setTagNames(Arrays.asList(dsTagA.getName(), dsTagB.getName()));
|
||||
assertThat(distributionSetManagement.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build())
|
||||
.getContent()).hasSize(200);
|
||||
.getContent()).hasSize(10);
|
||||
|
||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder()
|
||||
.setTagNames(Arrays.asList(dsTagC.getName(), dsTagB.getName()));
|
||||
assertThat(distributionSetManagement.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build())
|
||||
.getContent()).hasSize(100);
|
||||
.getContent()).hasSize(5);
|
||||
|
||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setTagNames(Arrays.asList(dsTagC.getName()));
|
||||
assertThat(distributionSetManagement.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build())
|
||||
@@ -559,23 +558,21 @@ public class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
// combine deleted and complete
|
||||
expected = new ArrayList<>();
|
||||
expected.addAll(ds100Group1);
|
||||
expected.addAll(ds100Group2);
|
||||
expected.addAll(ds5Group1);
|
||||
expected.addAll(dsGroup2);
|
||||
expected.add(dsNewType);
|
||||
|
||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(Boolean.TRUE)
|
||||
.setIsDeleted(Boolean.FALSE);
|
||||
assertThat(distributionSetManagement.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build())
|
||||
.getContent()).hasSize(201).containsOnly(expected.toArray(new DistributionSet[0]));
|
||||
.getContent()).hasSize(11).containsOnly(expected.toArray(new DistributionSet[0]));
|
||||
|
||||
expected = new ArrayList<>();
|
||||
expected.add(dsInComplete);
|
||||
expected = Arrays.asList(dsInComplete);
|
||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(Boolean.FALSE);
|
||||
assertThat(distributionSetManagement.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build())
|
||||
.getContent()).hasSize(1).containsOnly(expected.toArray(new DistributionSet[0]));
|
||||
|
||||
expected = new ArrayList<>();
|
||||
expected.add(dsDeleted);
|
||||
expected = Arrays.asList(dsDeleted);
|
||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(Boolean.TRUE)
|
||||
.setIsDeleted(Boolean.TRUE);
|
||||
assertThat(distributionSetManagement.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build())
|
||||
@@ -588,15 +585,14 @@ public class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
// combine deleted and complete and type
|
||||
expected = new ArrayList<>();
|
||||
expected.addAll(ds100Group1);
|
||||
expected.addAll(ds100Group2);
|
||||
expected.addAll(ds5Group1);
|
||||
expected.addAll(dsGroup2);
|
||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsDeleted(Boolean.FALSE)
|
||||
.setIsComplete(Boolean.TRUE).setType(standardDsType);
|
||||
assertThat(distributionSetManagement.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build())
|
||||
.getContent()).hasSize(200).containsOnly(expected.toArray(new DistributionSet[0]));
|
||||
.getContent()).hasSize(10).containsOnly(expected.toArray(new DistributionSet[0]));
|
||||
|
||||
expected = new ArrayList<>();
|
||||
expected.add(dsDeleted);
|
||||
expected = Arrays.asList(dsDeleted);
|
||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(Boolean.TRUE)
|
||||
.setType(standardDsType).setIsDeleted(Boolean.TRUE);
|
||||
assertThat(distributionSetManagement.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build())
|
||||
@@ -607,19 +603,17 @@ public class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
assertThat(distributionSetManagement.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build())
|
||||
.getContent()).hasSize(0);
|
||||
|
||||
expected = new ArrayList<>();
|
||||
expected.add(dsNewType);
|
||||
expected = Arrays.asList(dsNewType);
|
||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(Boolean.TRUE).setType(newType);
|
||||
assertThat(distributionSetManagement.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build())
|
||||
.getContent()).hasSize(1).containsOnly(expected.toArray(new DistributionSet[0]));
|
||||
|
||||
// combine deleted and complete and type and text
|
||||
expected = new ArrayList<>();
|
||||
expected.addAll(ds100Group2);
|
||||
expected = dsGroup2;
|
||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(Boolean.TRUE)
|
||||
.setType(standardDsType).setSearchText("%test2");
|
||||
assertThat(distributionSetManagement.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build())
|
||||
.getContent()).hasSize(100).containsOnly(expected.toArray(new DistributionSet[0]));
|
||||
.getContent()).hasSize(5).containsOnly(expected.toArray(new DistributionSet[0]));
|
||||
|
||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(Boolean.TRUE)
|
||||
.setIsDeleted(Boolean.TRUE).setType(standardDsType).setSearchText("%test2");
|
||||
@@ -637,12 +631,11 @@ public class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
.getContent()).hasSize(0);
|
||||
|
||||
// combine deleted and complete and type and text and tag
|
||||
expected = new ArrayList<>();
|
||||
expected.addAll(ds100Group2);
|
||||
expected = dsGroup2;
|
||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(true).setType(standardDsType)
|
||||
.setSearchText("%test2").setTagNames(Arrays.asList(dsTagA.getName()));
|
||||
assertThat(distributionSetManagement.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build())
|
||||
.getContent()).hasSize(100).containsOnly(expected.toArray(new DistributionSet[0]));
|
||||
.getContent()).hasSize(5).containsOnly(expected.toArray(new DistributionSet[0]));
|
||||
|
||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setType(standardDsType).setSearchText("%test2")
|
||||
.setTagNames(Arrays.asList(dsTagA.getName())).setIsComplete(Boolean.FALSE).setIsDeleted(Boolean.FALSE);
|
||||
|
||||
@@ -1171,7 +1171,7 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
@Description("Verify the creation and the start of a rollout.")
|
||||
public void createAndStartRollout() throws Exception {
|
||||
|
||||
final int amountTargetsForRollout = 500;
|
||||
final int amountTargetsForRollout = 50;
|
||||
final int amountGroups = 5;
|
||||
final String successCondition = "50";
|
||||
final String errorCondition = "80";
|
||||
@@ -1203,8 +1203,8 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
myRollout = rolloutManagement.findRolloutById(myRollout.getId()).get();
|
||||
assertThat(myRollout.getStatus()).isEqualTo(RolloutStatus.RUNNING);
|
||||
final Map<TotalTargetCountStatus.Status, Long> expectedTargetCountStatus = createInitStatusMap();
|
||||
expectedTargetCountStatus.put(TotalTargetCountStatus.Status.RUNNING, 100L);
|
||||
expectedTargetCountStatus.put(TotalTargetCountStatus.Status.SCHEDULED, 400L);
|
||||
expectedTargetCountStatus.put(TotalTargetCountStatus.Status.RUNNING, 10L);
|
||||
expectedTargetCountStatus.put(TotalTargetCountStatus.Status.SCHEDULED, 40L);
|
||||
validateRolloutActionStatus(myRollout.getId(), expectedTargetCountStatus);
|
||||
}
|
||||
|
||||
@@ -1212,7 +1212,7 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
@Description("Verify the creation and the automatic start of a rollout.")
|
||||
public void createAndAutoStartRollout() throws Exception {
|
||||
|
||||
final int amountTargetsForRollout = 500;
|
||||
final int amountTargetsForRollout = 50;
|
||||
final int amountGroups = 5;
|
||||
final String successCondition = "50";
|
||||
final String errorCondition = "80";
|
||||
@@ -1254,8 +1254,8 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
myRollout = rolloutManagement.findRolloutById(myRollout.getId()).get();
|
||||
assertThat(myRollout.getStatus()).isEqualTo(RolloutStatus.RUNNING);
|
||||
final Map<TotalTargetCountStatus.Status, Long> expectedTargetCountStatus = createInitStatusMap();
|
||||
expectedTargetCountStatus.put(TotalTargetCountStatus.Status.RUNNING, 100L);
|
||||
expectedTargetCountStatus.put(TotalTargetCountStatus.Status.SCHEDULED, 400L);
|
||||
expectedTargetCountStatus.put(TotalTargetCountStatus.Status.RUNNING, 10L);
|
||||
expectedTargetCountStatus.put(TotalTargetCountStatus.Status.SCHEDULED, 40L);
|
||||
validateRolloutActionStatus(myRollout.getId(), expectedTargetCountStatus);
|
||||
}
|
||||
|
||||
|
||||
@@ -397,7 +397,8 @@ public class TargetManagementTest extends AbstractJpaIntegrationTest {
|
||||
@Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetUpdatedEvent.class, count = 5),
|
||||
@Expect(type = ActionCreatedEvent.class, count = 2), @Expect(type = ActionUpdatedEvent.class, count = 1),
|
||||
@Expect(type = TargetAssignDistributionSetEvent.class, count = 2),
|
||||
@Expect(type = SoftwareModuleCreatedEvent.class, count = 6) })
|
||||
@Expect(type = SoftwareModuleCreatedEvent.class, count = 6),
|
||||
@Expect(type = TargetPollEvent.class, count = 1) })
|
||||
public void findTargetByControllerIDWithDetails() {
|
||||
final DistributionSet set = testdataFactory.createDistributionSet("test");
|
||||
final DistributionSet set2 = testdataFactory.createDistributionSet("test2");
|
||||
@@ -414,7 +415,7 @@ public class TargetManagementTest extends AbstractJpaIntegrationTest {
|
||||
Target target = createTargetWithAttributes("4711");
|
||||
|
||||
final long current = System.currentTimeMillis();
|
||||
controllerManagement.updateLastTargetQuery("4711", null);
|
||||
controllerManagement.findOrRegisterTargetIfItDoesNotexist("4711", LOCALHOST);
|
||||
|
||||
final DistributionSetAssignmentResult result = assignDistributionSet(set.getId(), "4711");
|
||||
|
||||
|
||||
@@ -23,6 +23,8 @@ import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationProperties.T
|
||||
import org.eclipse.hawkbit.tenancy.configuration.validator.TenantConfigurationValidatorException;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.springframework.context.EnvironmentAware;
|
||||
import org.springframework.core.env.Environment;
|
||||
|
||||
import ru.yandex.qatools.allure.annotations.Description;
|
||||
import ru.yandex.qatools.allure.annotations.Features;
|
||||
@@ -30,7 +32,14 @@ import ru.yandex.qatools.allure.annotations.Stories;
|
||||
|
||||
@Features("Component Tests - Repository")
|
||||
@Stories("Tenant Configuration Management")
|
||||
public class TenantConfigurationManagementTest extends AbstractJpaIntegrationTest {
|
||||
public class TenantConfigurationManagementTest extends AbstractJpaIntegrationTest implements EnvironmentAware {
|
||||
|
||||
private Environment environment = null;
|
||||
|
||||
@Override
|
||||
public void setEnvironment(final Environment environment) {
|
||||
this.environment = environment;
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Tests that tenant specific configuration can be persisted and in case the tenant does not have specific configuration the default from environment is used instead.")
|
||||
|
||||
@@ -60,8 +60,7 @@ public class RepositoryEntityEventTest extends AbstractJpaIntegrationTest {
|
||||
public void targetCreatedEventIsPublished() throws InterruptedException {
|
||||
final Target createdTarget = testdataFactory.createTarget("12345");
|
||||
|
||||
final TargetCreatedEvent targetCreatedEvent = eventListener.waitForEvent(TargetCreatedEvent.class, 1,
|
||||
TimeUnit.SECONDS);
|
||||
final TargetCreatedEvent targetCreatedEvent = eventListener.waitForEvent(TargetCreatedEvent.class);
|
||||
assertThat(targetCreatedEvent).isNotNull();
|
||||
assertThat(targetCreatedEvent.getEntity().getId()).isEqualTo(createdTarget.getId());
|
||||
}
|
||||
@@ -73,8 +72,7 @@ public class RepositoryEntityEventTest extends AbstractJpaIntegrationTest {
|
||||
targetManagement
|
||||
.updateTarget(entityFactory.target().update(createdTarget.getControllerId()).name("updateName"));
|
||||
|
||||
final TargetUpdatedEvent targetUpdatedEvent = eventListener.waitForEvent(TargetUpdatedEvent.class, 1,
|
||||
TimeUnit.SECONDS);
|
||||
final TargetUpdatedEvent targetUpdatedEvent = eventListener.waitForEvent(TargetUpdatedEvent.class);
|
||||
assertThat(targetUpdatedEvent).isNotNull();
|
||||
assertThat(targetUpdatedEvent.getEntity().getId()).isEqualTo(createdTarget.getId());
|
||||
}
|
||||
@@ -86,8 +84,7 @@ public class RepositoryEntityEventTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
targetManagement.deleteTarget("12345");
|
||||
|
||||
final TargetDeletedEvent targetDeletedEvent = eventListener.waitForEvent(TargetDeletedEvent.class, 1,
|
||||
TimeUnit.SECONDS);
|
||||
final TargetDeletedEvent targetDeletedEvent = eventListener.waitForEvent(TargetDeletedEvent.class);
|
||||
assertThat(targetDeletedEvent).isNotNull();
|
||||
assertThat(targetDeletedEvent.getEntityId()).isEqualTo(createdTarget.getId());
|
||||
}
|
||||
@@ -110,8 +107,7 @@ public class RepositoryEntityEventTest extends AbstractJpaIntegrationTest {
|
||||
rolloutManagement.deleteRollout(createdRollout.getId());
|
||||
rolloutManagement.handleRollouts();
|
||||
|
||||
final RolloutDeletedEvent rolloutDeletedEvent = eventListener.waitForEvent(RolloutDeletedEvent.class, 1,
|
||||
TimeUnit.SECONDS);
|
||||
final RolloutDeletedEvent rolloutDeletedEvent = eventListener.waitForEvent(RolloutDeletedEvent.class);
|
||||
assertThat(rolloutDeletedEvent).isNotNull();
|
||||
assertThat(rolloutDeletedEvent.getEntityId()).isEqualTo(createdRollout.getId());
|
||||
}
|
||||
@@ -121,8 +117,8 @@ public class RepositoryEntityEventTest extends AbstractJpaIntegrationTest {
|
||||
public void distributionSetCreatedEventIsPublished() throws InterruptedException {
|
||||
final DistributionSet createDistributionSet = testdataFactory.createDistributionSet();
|
||||
|
||||
final DistributionSetCreatedEvent dsCreatedEvent = eventListener.waitForEvent(DistributionSetCreatedEvent.class,
|
||||
1, TimeUnit.SECONDS);
|
||||
final DistributionSetCreatedEvent dsCreatedEvent = eventListener
|
||||
.waitForEvent(DistributionSetCreatedEvent.class);
|
||||
assertThat(dsCreatedEvent).isNotNull();
|
||||
assertThat(dsCreatedEvent.getEntity().getId()).isEqualTo(createDistributionSet.getId());
|
||||
}
|
||||
@@ -134,8 +130,8 @@ public class RepositoryEntityEventTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
distributionSetManagement.deleteDistributionSet(createDistributionSet.getId());
|
||||
|
||||
final DistributionSetDeletedEvent dsDeletedEvent = eventListener.waitForEvent(DistributionSetDeletedEvent.class,
|
||||
1, TimeUnit.SECONDS);
|
||||
final DistributionSetDeletedEvent dsDeletedEvent = eventListener
|
||||
.waitForEvent(DistributionSetDeletedEvent.class);
|
||||
assertThat(dsDeletedEvent).isNotNull();
|
||||
assertThat(dsDeletedEvent.getEntityId()).isEqualTo(createDistributionSet.getId());
|
||||
}
|
||||
@@ -146,7 +142,7 @@ public class RepositoryEntityEventTest extends AbstractJpaIntegrationTest {
|
||||
final SoftwareModule softwareModule = testdataFactory.createSoftwareModuleApp();
|
||||
|
||||
final SoftwareModuleCreatedEvent softwareModuleCreatedEvent = eventListener
|
||||
.waitForEvent(SoftwareModuleCreatedEvent.class, 1, TimeUnit.SECONDS);
|
||||
.waitForEvent(SoftwareModuleCreatedEvent.class);
|
||||
assertThat(softwareModuleCreatedEvent).isNotNull();
|
||||
assertThat(softwareModuleCreatedEvent.getEntity().getId()).isEqualTo(softwareModule.getId());
|
||||
}
|
||||
@@ -159,7 +155,7 @@ public class RepositoryEntityEventTest extends AbstractJpaIntegrationTest {
|
||||
.updateSoftwareModule(entityFactory.softwareModule().update(softwareModule.getId()).description("New"));
|
||||
|
||||
final SoftwareModuleUpdatedEvent softwareModuleUpdatedEvent = eventListener
|
||||
.waitForEvent(SoftwareModuleUpdatedEvent.class, 1, TimeUnit.SECONDS);
|
||||
.waitForEvent(SoftwareModuleUpdatedEvent.class);
|
||||
assertThat(softwareModuleUpdatedEvent).isNotNull();
|
||||
assertThat(softwareModuleUpdatedEvent.getEntity().getId()).isEqualTo(softwareModule.getId());
|
||||
}
|
||||
@@ -171,7 +167,7 @@ public class RepositoryEntityEventTest extends AbstractJpaIntegrationTest {
|
||||
softwareModuleManagement.deleteSoftwareModule(softwareModule.getId());
|
||||
|
||||
final SoftwareModuleDeletedEvent softwareModuleDeletedEvent = eventListener
|
||||
.waitForEvent(SoftwareModuleDeletedEvent.class, 1, TimeUnit.SECONDS);
|
||||
.waitForEvent(SoftwareModuleDeletedEvent.class);
|
||||
assertThat(softwareModuleDeletedEvent).isNotNull();
|
||||
assertThat(softwareModuleDeletedEvent.getEntityId()).isEqualTo(softwareModule.getId());
|
||||
}
|
||||
@@ -194,15 +190,14 @@ public class RepositoryEntityEventTest extends AbstractJpaIntegrationTest {
|
||||
queue.offer(event);
|
||||
}
|
||||
|
||||
public <T> T waitForEvent(final Class<T> eventType, final long timeout, final TimeUnit timeUnit)
|
||||
throws InterruptedException {
|
||||
public <T> T waitForEvent(final Class<T> eventType) throws InterruptedException {
|
||||
TenantAwareEvent event = null;
|
||||
while ((event = queue.poll(timeout, timeUnit)) != null) {
|
||||
while ((event = queue.poll(5, TimeUnit.SECONDS)) != null) {
|
||||
if (event.getClass().isAssignableFrom(eventType)) {
|
||||
return (T) event;
|
||||
}
|
||||
}
|
||||
Assertions.fail("Missing event " + eventType + " within timeout " + timeout + " " + timeUnit);
|
||||
Assertions.fail("Missing event " + eventType + " within timeout.");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ public class RSQLTargetFieldTest extends AbstractJpaIntegrationTest {
|
||||
private Target target2;
|
||||
|
||||
@Before
|
||||
public void seuptBeforeTest() throws InterruptedException {
|
||||
public void setupBeforeTest() throws InterruptedException {
|
||||
|
||||
final DistributionSet ds = testdataFactory.createDistributionSet("AssignedDs");
|
||||
|
||||
@@ -48,14 +48,14 @@ public class RSQLTargetFieldTest extends AbstractJpaIntegrationTest {
|
||||
.name("targetName123").description("targetDesc123"));
|
||||
attributes.put("revision", "1.1");
|
||||
target = controllerManagement.updateControllerAttributes(target.getControllerId(), attributes);
|
||||
target = controllerManagement.updateLastTargetQuery(target.getControllerId(), null);
|
||||
target = controllerManagement.findOrRegisterTargetIfItDoesNotexist(target.getControllerId(), LOCALHOST);
|
||||
|
||||
target2 = targetManagement
|
||||
.createTarget(entityFactory.target().create().controllerId("targetId1234").description("targetId1234"));
|
||||
attributes.put("revision", "1.2");
|
||||
Thread.sleep(1);
|
||||
target2 = controllerManagement.updateControllerAttributes(target2.getControllerId(), attributes);
|
||||
target2 = controllerManagement.updateLastTargetQuery(target2.getControllerId(), null);
|
||||
target2 = controllerManagement.findOrRegisterTargetIfItDoesNotexist(target2.getControllerId(), LOCALHOST);
|
||||
|
||||
testdataFactory.createTarget("targetId1235");
|
||||
testdataFactory.createTarget("targetId1236");
|
||||
|
||||
Reference in New Issue
Block a user