From f142cb414217c494f2ce3d6ecca27c40eced451a Mon Sep 17 00:00:00 2001 From: Kai Zimmermann Date: Mon, 10 Jul 2017 09:32:53 +0200 Subject: [PATCH] Test and build performance improvements (#552) * Small build perf improvements. Signed-off-by: kaizimmerm * Remove dead code. Stabilize test. Signed-off-by: kaizimmerm * Further optimizations Signed-off-by: kaizimmerm * Upgrade mariadb driver. Signed-off-by: kaizimmerm * Raise timeouts for more robustness on slower build environments. Signed-off-by: kaizimmerm * Move webappcontext into rest tests. Signed-off-by: kaizimmerm * Raised timeout. Signed-off-by: kaizimmerm * Remove test dependency on target to groups distribution order. Signed-off-by: kaizimmerm * Code reuse. Signed-off-by: kaizimmerm * Context available to tests. Signed-off-by: kaizimmerm * Typos fixed. Signed-off-by: kaizimmerm * Fix PollEvent send. Signed-off-by: kaizimmerm * Fix typos. Signed-off-by: kaizimmerm * Test log readability and removed unused method from CM. Signed-off-by: kaizimmerm * Remove empty payload. Signed-off-by: kaizimmerm * Stabilize tests. Signed-off-by: kaizimmerm * Raised timeout. Signed-off-by: kaizimmerm * Fixed fire directory change during one test class run. Signed-off-by: kaizimmerm --- .../rest/resource/DdiCancelActionTest.java | 87 ++++++-------- .../rest/resource/DdiDeploymentBaseTest.java | 48 +++----- .../ddi/rest/resource/DosFilterTest.java | 3 +- hawkbit-dmf/hawkbit-dmf-amqp/.gitignore | 1 + ...ssageDispatcherServiceIntegrationTest.java | 51 +++++---- ...pMessageHandlerServiceIntegrationTest.java | 108 +++++++++++------- .../AmqpServiceIntegrationTest.java | 59 +++++----- .../resources/application-test.properties | 42 ------- .../src/test/resources/logback-spring.xml | 35 ------ hawkbit-mgmt-resource/.gitignore | 1 + .../resource/MgmtRolloutResourceTest.java | 9 +- .../MgmtSoftwareModuleResourceTest.java | 76 ++++++------ .../rest/resource/MgmtTargetResourceTest.java | 6 +- .../repository/ControllerManagement.java | 23 +--- .../jpa/JpaControllerManagement.java | 32 ++---- .../jpa/ControllerManagementTest.java | 16 +-- .../jpa/DeploymentManagementTest.java | 18 ++- .../jpa/DistributionSetManagementTest.java | 75 ++++++------ .../repository/jpa/RolloutManagementTest.java | 12 +- .../repository/jpa/TargetManagementTest.java | 5 +- .../TenantConfigurationManagementTest.java | 11 +- .../jpa/event/RepositoryEntityEventTest.java | 33 +++--- .../jpa/rsql/RSQLTargetFieldTest.java | 6 +- .../test/util/AbstractIntegrationTest.java | 62 +++++----- .../repository/test/util/TestdataFactory.java | 8 +- .../hawkbit-test-defaults.properties | 2 +- .../hawkbit/rest/RestConfiguration.java | 20 +++- .../rest/AbstractRestIntegrationTest.java | 31 ++++- .../ui/distributions/DistributionsView.java | 8 +- .../hawkbit/ui/management/DeploymentView.java | 8 +- .../ui/push/DelayedEventBusPushStrategy.java | 8 +- ...DistributionSetCreatedEventContainer.java} | 4 +- ...DistributionSetDeletedEventContainer.java} | 4 +- .../hawkbit/ui/push/HawkbitEventProvider.java | 4 +- pom.xml | 9 +- 35 files changed, 423 insertions(+), 502 deletions(-) create mode 100644 hawkbit-dmf/hawkbit-dmf-amqp/.gitignore delete mode 100644 hawkbit-dmf/hawkbit-dmf-amqp/src/test/resources/application-test.properties delete mode 100644 hawkbit-dmf/hawkbit-dmf-amqp/src/test/resources/logback-spring.xml create mode 100644 hawkbit-mgmt-resource/.gitignore rename hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/push/{DistributionCreatedEventContainer.java => DistributionSetCreatedEventContainer.java} (83%) rename hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/push/{DistributionDeletedEventContainer.java => DistributionSetDeletedEventContainer.java} (83%) diff --git a/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiCancelActionTest.java b/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiCancelActionTest.java index c5d8e1bbd..fee39c205 100644 --- a/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiCancelActionTest.java +++ b/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiCancelActionTest.java @@ -51,10 +51,9 @@ public class DdiCancelActionTest extends AbstractDDiApiIntegrationTest { final DistributionSet ds = testdataFactory.createDistributionSet(""); final Target savedTarget = testdataFactory.createTarget(); - final Action updateAction = deploymentManagement.findActionWithDetails( - assignDistributionSet(ds.getId(), savedTarget.getControllerId()).getActions().get(0)).get(); + final Long actionId = assignDistributionSet(ds.getId(), savedTarget.getControllerId()).getActions().get(0); - final Action cancelAction = deploymentManagement.cancelAction(updateAction.getId()); + final Action cancelAction = deploymentManagement.cancelAction(actionId); // controller rejects cancelation mvc.perform(post("/{tenant}/controller/v1/" + TestdataFactory.DEFAULT_CONTROLLER_ID + "/cancelAction/" @@ -66,11 +65,12 @@ public class DdiCancelActionTest extends AbstractDDiApiIntegrationTest { final long current = System.currentTimeMillis(); // get update action anyway - mvc.perform(get("/{tenant}/controller/v1/" + TestdataFactory.DEFAULT_CONTROLLER_ID + "/deploymentBase/" - + updateAction.getId(), tenantAware.getCurrentTenant()).accept(MediaType.APPLICATION_JSON)) + mvc.perform( + get("/{tenant}/controller/v1/" + TestdataFactory.DEFAULT_CONTROLLER_ID + "/deploymentBase/" + actionId, + tenantAware.getCurrentTenant()).accept(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)) - .andExpect(jsonPath("$.id", equalTo(String.valueOf(updateAction.getId())))) + .andExpect(jsonPath("$.id", equalTo(String.valueOf(actionId)))) .andExpect(jsonPath("$.deployment.download", equalTo("forced"))) .andExpect(jsonPath("$.deployment.update", equalTo("forced"))) .andExpect(jsonPath("$.deployment.chunks[?(@.part==jvm)].version", @@ -82,8 +82,8 @@ public class DdiCancelActionTest extends AbstractDDiApiIntegrationTest { // and finish it mvc.perform(post("/{tenant}/controller/v1/" + TestdataFactory.DEFAULT_CONTROLLER_ID + "/deploymentBase/" - + updateAction.getId() + "/feedback", tenantAware.getCurrentTenant()).content( - JsonBuilder.deploymentActionFeedback(updateAction.getId().toString(), "closed", "success")) + + actionId + "/feedback", tenantAware.getCurrentTenant()) + .content(JsonBuilder.deploymentActionFeedback(actionId.toString(), "closed", "success")) .contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()); @@ -103,8 +103,7 @@ public class DdiCancelActionTest extends AbstractDDiApiIntegrationTest { final DistributionSet ds = testdataFactory.createDistributionSet(""); final Target savedTarget = testdataFactory.createTarget(); - final Action updateAction = deploymentManagement.findActionWithDetails( - assignDistributionSet(ds.getId(), savedTarget.getControllerId()).getActions().get(0)).get(); + final Long actionId = assignDistributionSet(ds.getId(), savedTarget.getControllerId()).getActions().get(0); long current = System.currentTimeMillis(); mvc.perform(get("/{tenant}/controller/v1/{controller}", tenantAware.getCurrentTenant(), @@ -114,7 +113,7 @@ public class DdiCancelActionTest extends AbstractDDiApiIntegrationTest { .andExpect(jsonPath("$.config.polling.sleep", equalTo("00:01:00"))) .andExpect(jsonPath("$._links.deploymentBase.href", startsWith("http://localhost/" + tenantAware.getCurrentTenant() + "/controller/v1/" - + TestdataFactory.DEFAULT_CONTROLLER_ID + "/deploymentBase/" + updateAction.getId()))); + + TestdataFactory.DEFAULT_CONTROLLER_ID + "/deploymentBase/" + actionId))); Thread.sleep(1); // is required: otherwise processing the next line is // often too fast and // the following assert will fail @@ -130,7 +129,7 @@ public class DdiCancelActionTest extends AbstractDDiApiIntegrationTest { assertThat(activeActionsByTarget).hasSize(1); assertThat(activeActionsByTarget.get(0).getStatus()).isEqualTo(Status.RUNNING); - final Action cancelAction = deploymentManagement.cancelAction(updateAction.getId()); + final Action cancelAction = deploymentManagement.cancelAction(actionId); activeActionsByTarget = deploymentManagement.findActiveActionsByTarget(PAGE, savedTarget.getControllerId()) .getContent(); @@ -164,14 +163,14 @@ public class DdiCancelActionTest extends AbstractDDiApiIntegrationTest { .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)) .andExpect(jsonPath("$.id", equalTo(String.valueOf(cancelAction.getId())))) - .andExpect(jsonPath("$.cancelAction.stopId", equalTo(String.valueOf(updateAction.getId())))); + .andExpect(jsonPath("$.cancelAction.stopId", equalTo(String.valueOf(actionId)))); assertThat(targetManagement.findTargetByControllerID(TestdataFactory.DEFAULT_CONTROLLER_ID).get() .getLastTargetQuery()).isLessThanOrEqualTo(System.currentTimeMillis()); // controller confirmed cancelled action, should not be active anymore mvc.perform(post("/{tenant}/controller/v1/" + TestdataFactory.DEFAULT_CONTROLLER_ID + "/cancelAction/" + cancelAction.getId() + "/feedback", tenantAware.getCurrentTenant()).accept(MediaType.APPLICATION_JSON) - .content(JsonBuilder.cancelActionFeedback(updateAction.getId().toString(), "closed")) + .content(JsonBuilder.cancelActionFeedback(actionId.toString(), "closed")) .contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()); @@ -220,10 +219,9 @@ public class DdiCancelActionTest extends AbstractDDiApiIntegrationTest { final Target savedTarget = testdataFactory.createTarget(targetid); final List toAssign = new ArrayList<>(); toAssign.add(savedTarget); - final Action updateAction = deploymentManagement - .findActionWithDetails(assignDistributionSet(ds, toAssign).getActions().get(0)).get(); + final Long actionId = assignDistributionSet(ds, toAssign).getActions().get(0); - return deploymentManagement.cancelAction(updateAction.getId()); + return deploymentManagement.cancelAction(actionId); } @Test @@ -234,13 +232,11 @@ public class DdiCancelActionTest extends AbstractDDiApiIntegrationTest { final Target savedTarget = testdataFactory.createTarget(); - final Action updateAction = deploymentManagement - .findActionWithDetails( - assignDistributionSet(ds.getId(), TestdataFactory.DEFAULT_CONTROLLER_ID).getActions().get(0)) - .get(); + final Long actionId = assignDistributionSet(ds.getId(), TestdataFactory.DEFAULT_CONTROLLER_ID).getActions() + .get(0); // cancel action manually - final Action cancelAction = deploymentManagement.cancelAction(updateAction.getId()); + final Action cancelAction = deploymentManagement.cancelAction(actionId); assertThat(deploymentManagement.countActionStatusAll()).isEqualTo(2); assertThat(deploymentManagement.findActiveActionsByTarget(PAGE, savedTarget.getControllerId())).hasSize(1); @@ -311,26 +307,20 @@ public class DdiCancelActionTest extends AbstractDDiApiIntegrationTest { final Target savedTarget = testdataFactory.createTarget(); - final Action updateAction = deploymentManagement - .findActionWithDetails( - assignDistributionSet(ds.getId(), TestdataFactory.DEFAULT_CONTROLLER_ID).getActions().get(0)) - .get(); - final Action updateAction2 = deploymentManagement - .findActionWithDetails( - assignDistributionSet(ds2.getId(), TestdataFactory.DEFAULT_CONTROLLER_ID).getActions().get(0)) - .get(); - final Action updateAction3 = deploymentManagement - .findActionWithDetails( - assignDistributionSet(ds3.getId(), TestdataFactory.DEFAULT_CONTROLLER_ID).getActions().get(0)) - .get(); + final Long actionId = assignDistributionSet(ds.getId(), TestdataFactory.DEFAULT_CONTROLLER_ID).getActions() + .get(0); + final Long actionId2 = assignDistributionSet(ds2.getId(), TestdataFactory.DEFAULT_CONTROLLER_ID).getActions() + .get(0); + final Long actionId3 = assignDistributionSet(ds3.getId(), TestdataFactory.DEFAULT_CONTROLLER_ID).getActions() + .get(0); assertThat(deploymentManagement.countActionStatusAll()).isEqualTo(3); // 3 update actions, 0 cancel actions assertThat(deploymentManagement.findActiveActionsByTarget(PAGE, savedTarget.getControllerId())).hasSize(3); assertThat(deploymentManagement.findActiveActionsByTarget(PAGE, savedTarget.getControllerId())).hasSize(3); - final Action cancelAction = deploymentManagement.cancelAction(updateAction.getId()); - final Action cancelAction2 = deploymentManagement.cancelAction(updateAction2.getId()); + final Action cancelAction = deploymentManagement.cancelAction(actionId); + final Action cancelAction2 = deploymentManagement.cancelAction(actionId2); assertThat(deploymentManagement.findActiveActionsByTarget(PAGE, savedTarget.getControllerId())).hasSize(3); assertThat(deploymentManagement.countActionsByTarget(savedTarget.getControllerId())).isEqualTo(3); @@ -339,7 +329,7 @@ public class DdiCancelActionTest extends AbstractDDiApiIntegrationTest { .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) .andExpect(jsonPath("$.id", equalTo(String.valueOf(cancelAction.getId())))) - .andExpect(jsonPath("$.cancelAction.stopId", equalTo(String.valueOf(updateAction.getId())))); + .andExpect(jsonPath("$.cancelAction.stopId", equalTo(String.valueOf(actionId)))); assertThat(deploymentManagement.countActionStatusAll()).isEqualTo(6); mvc.perform(get("/{tenant}/controller/v1/{controllerId}", tenantAware.getCurrentTenant(), @@ -366,7 +356,7 @@ public class DdiCancelActionTest extends AbstractDDiApiIntegrationTest { .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)) .andExpect(jsonPath("$.id", equalTo(String.valueOf(cancelAction2.getId())))) - .andExpect(jsonPath("$.cancelAction.stopId", equalTo(String.valueOf(updateAction2.getId())))); + .andExpect(jsonPath("$.cancelAction.stopId", equalTo(String.valueOf(actionId2)))); assertThat(deploymentManagement.countActionStatusAll()).isEqualTo(8); mvc.perform(get("/{tenant}/controller/v1/{controller}", tenantAware.getCurrentTenant(), @@ -387,15 +377,16 @@ public class DdiCancelActionTest extends AbstractDDiApiIntegrationTest { assertThat(deploymentManagement.getAssignedDistributionSet(TestdataFactory.DEFAULT_CONTROLLER_ID).get()) .isEqualTo(ds3); - mvc.perform(get("/{tenant}/controller/v1/" + TestdataFactory.DEFAULT_CONTROLLER_ID + "/deploymentBase/" - + updateAction3.getId(), tenantAware.getCurrentTenant())).andDo(MockMvcResultPrinter.print()) - .andExpect(status().isOk()); + mvc.perform( + get("/{tenant}/controller/v1/" + TestdataFactory.DEFAULT_CONTROLLER_ID + "/deploymentBase/" + actionId3, + tenantAware.getCurrentTenant())) + .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()); assertThat(deploymentManagement.countActionStatusAll()).isEqualTo(10); // 1 update actions, 0 cancel actions assertThat(deploymentManagement.findActiveActionsByTarget(PAGE, savedTarget.getControllerId())).hasSize(1); - final Action cancelAction3 = deploymentManagement.cancelAction(updateAction3.getId()); + final Action cancelAction3 = deploymentManagement.cancelAction(actionId3); // action is in cancelling state assertThat(deploymentManagement.findActiveActionsByTarget(PAGE, savedTarget.getControllerId())).hasSize(1); @@ -408,7 +399,7 @@ public class DdiCancelActionTest extends AbstractDDiApiIntegrationTest { .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)) .andExpect(jsonPath("$.id", equalTo(String.valueOf(cancelAction3.getId())))) - .andExpect(jsonPath("$.cancelAction.stopId", equalTo(String.valueOf(updateAction3.getId())))); + .andExpect(jsonPath("$.cancelAction.stopId", equalTo(String.valueOf(actionId3)))); assertThat(deploymentManagement.countActionStatusAll()).isEqualTo(12); // now lets return feedback for the third cancelation @@ -427,15 +418,13 @@ public class DdiCancelActionTest extends AbstractDDiApiIntegrationTest { @Test @Description("Tests the feeback channel closing for too many feedbacks, i.e. denial of service prevention.") public void tooMuchCancelActionFeedback() throws Exception { - final Target target = testdataFactory.createTarget(); + testdataFactory.createTarget(); final DistributionSet ds = testdataFactory.createDistributionSet(""); - final Action action = deploymentManagement - .findActionWithDetails( - assignDistributionSet(ds.getId(), TestdataFactory.DEFAULT_CONTROLLER_ID).getActions().get(0)) - .get(); + final Long actionId = assignDistributionSet(ds.getId(), TestdataFactory.DEFAULT_CONTROLLER_ID).getActions() + .get(0); - final Action cancelAction = deploymentManagement.cancelAction(action.getId()); + final Action cancelAction = deploymentManagement.cancelAction(actionId); final String feedback = JsonBuilder.cancelActionFeedback(cancelAction.getId().toString(), "proceeding"); // assignDistributionSet creates an ActionStatus and cancel action diff --git a/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiDeploymentBaseTest.java b/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiDeploymentBaseTest.java index 238da4f53..bc6d2ef73 100644 --- a/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiDeploymentBaseTest.java +++ b/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiDeploymentBaseTest.java @@ -41,7 +41,6 @@ import org.eclipse.hawkbit.repository.model.Action.Status; import org.eclipse.hawkbit.repository.model.ActionStatus; import org.eclipse.hawkbit.repository.model.Artifact; import org.eclipse.hawkbit.repository.model.DistributionSet; -import org.eclipse.hawkbit.repository.model.DistributionSetAssignmentResult; import org.eclipse.hawkbit.repository.model.RepositoryModelConstants; import org.eclipse.hawkbit.repository.model.Target; import org.eclipse.hawkbit.repository.model.TargetUpdateStatus; @@ -231,12 +230,8 @@ public class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest { final Target target = testdataFactory.createTarget("4712"); final DistributionSet ds = testdataFactory.createDistributionSet("", true); - final DistributionSetAssignmentResult result = deploymentManagement.assignDistributionSet(ds.getId(), - ActionType.TIMEFORCED, System.currentTimeMillis() + 2_000, Arrays.asList(target.getControllerId())); - - final Action action = deploymentManagement - .findActiveActionsByTarget(PAGE, result.getAssignedEntity().get(0).getControllerId()).getContent() - .get(0); + final Long actionId = deploymentManagement.assignDistributionSet(ds.getId(), ActionType.TIMEFORCED, + System.currentTimeMillis() + 2_000, Arrays.asList(target.getControllerId())).getActions().get(0); MvcResult mvcResult = mvc.perform(get("/{tenant}/controller/v1/4712", tenantAware.getCurrentTenant())) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) @@ -252,7 +247,7 @@ public class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest { assertThat(JsonPath.compile("_links.deploymentBase.href").read(mvcResult.getResponse().getContentAsString()) .toString()).isEqualTo(urlBeforeSwitch) .startsWith("http://localhost/" + tenantAware.getCurrentTenant() - + "/controller/v1/4712/deploymentBase/" + action.getId()); + + "/controller/v1/4712/deploymentBase/" + actionId); // After the time is over we should see a new etag TimeUnit.MILLISECONDS.sleep(2_000); @@ -521,19 +516,15 @@ public class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest { .andDo(MockMvcResultPrinter.print()).andExpect(status().isNotFound()); // wrong media type - final List toAssign = new ArrayList<>(); - toAssign.add(target); + final List toAssign = Arrays.asList(target); final DistributionSet savedSet = testdataFactory.createDistributionSet(""); - final Action action1 = deploymentManagement - .findActionWithDetails(assignDistributionSet(savedSet, toAssign).getActions().get(0)).get(); - mvc.perform( - get("/{tenant}/controller/v1/4712/deploymentBase/" + action1.getId(), tenantAware.getCurrentTenant())) + final Long actionId = assignDistributionSet(savedSet, toAssign).getActions().get(0); + mvc.perform(get("/{tenant}/controller/v1/4712/deploymentBase/" + actionId, tenantAware.getCurrentTenant())) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()); - mvc.perform( - get("/{tenant}/controller/v1/4712/deploymentBase/" + action1.getId(), tenantAware.getCurrentTenant()) - .accept(MediaType.APPLICATION_ATOM_XML)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isNotAcceptable()); + mvc.perform(get("/{tenant}/controller/v1/4712/deploymentBase/" + actionId, tenantAware.getCurrentTenant()) + .accept(MediaType.APPLICATION_ATOM_XML)).andDo(MockMvcResultPrinter.print()) + .andExpect(status().isNotAcceptable()); } @Test @@ -601,12 +592,9 @@ public class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest { final List toAssign = new ArrayList<>(); toAssign.add(savedTarget1); - final Action action1 = deploymentManagement - .findActionWithDetails(assignDistributionSet(ds1.getId(), "4712").getActions().get(0)).get(); - final Action action2 = deploymentManagement - .findActionWithDetails(assignDistributionSet(ds2.getId(), "4712").getActions().get(0)).get(); - final Action action3 = deploymentManagement - .findActionWithDetails(assignDistributionSet(ds3.getId(), "4712").getActions().get(0)).get(); + final Long actionId1 = assignDistributionSet(ds1.getId(), "4712").getActions().get(0); + final Long actionId2 = assignDistributionSet(ds2.getId(), "4712").getActions().get(0); + final Long actionId3 = assignDistributionSet(ds3.getId(), "4712").getActions().get(0); Target myT = targetManagement.findTargetByControllerID("4712").get(); assertThat(myT.getUpdateStatus()).isEqualTo(TargetUpdateStatus.PENDING); @@ -618,9 +606,9 @@ public class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest { // action1 done - mvc.perform(post("/{tenant}/controller/v1/4712/deploymentBase/" + action1.getId() + "/feedback", + mvc.perform(post("/{tenant}/controller/v1/4712/deploymentBase/" + actionId1 + "/feedback", tenantAware.getCurrentTenant()) - .content(JsonBuilder.deploymentActionFeedback(action1.getId().toString(), "closed")) + .content(JsonBuilder.deploymentActionFeedback(actionId1.toString(), "closed")) .contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()); myT = targetManagement.findTargetByControllerID("4712").get(); @@ -635,9 +623,9 @@ public class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest { assertThat(actionStatusMessages.iterator().next().getStatus()).isEqualTo(Status.FINISHED); // action2 done - mvc.perform(post("/{tenant}/controller/v1/4712/deploymentBase/" + action2.getId() + "/feedback", + mvc.perform(post("/{tenant}/controller/v1/4712/deploymentBase/" + actionId2 + "/feedback", tenantAware.getCurrentTenant()) - .content(JsonBuilder.deploymentActionFeedback(action2.getId().toString(), "closed")) + .content(JsonBuilder.deploymentActionFeedback(actionId2.toString(), "closed")) .contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()); myT = targetManagement.findTargetByControllerID("4712").get(); @@ -652,9 +640,9 @@ public class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest { assertThat(actionStatusMessages).haveAtLeast(1, new ActionStatusCondition(Status.FINISHED)); // action3 done - mvc.perform(post("/{tenant}/controller/v1/4712/deploymentBase/" + action3.getId() + "/feedback", + mvc.perform(post("/{tenant}/controller/v1/4712/deploymentBase/" + actionId3 + "/feedback", tenantAware.getCurrentTenant()) - .content(JsonBuilder.deploymentActionFeedback(action3.getId().toString(), "closed")) + .content(JsonBuilder.deploymentActionFeedback(actionId3.toString(), "closed")) .contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()); myT = targetManagement.findTargetByControllerID("4712").get(); diff --git a/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DosFilterTest.java b/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DosFilterTest.java index ff663f14e..b7db01219 100644 --- a/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DosFilterTest.java +++ b/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DosFilterTest.java @@ -29,6 +29,7 @@ import org.springframework.test.context.ActiveProfiles; import org.springframework.test.web.servlet.MvcResult; import org.springframework.test.web.servlet.setup.DefaultMockMvcBuilder; import org.springframework.test.web.servlet.setup.MockMvcBuilders; +import org.springframework.web.context.WebApplicationContext; import com.google.common.net.HttpHeaders; @@ -46,7 +47,7 @@ import ru.yandex.qatools.allure.annotations.Stories; public class DosFilterTest extends AbstractDDiApiIntegrationTest { @Override - protected DefaultMockMvcBuilder createMvcWebAppContext() { + protected DefaultMockMvcBuilder createMvcWebAppContext(final WebApplicationContext context) { return MockMvcBuilders.webAppContextSetup(context) .addFilter(new DosFilter(null, 10, 10, "127\\.0\\.0\\.1|\\[0:0:0:0:0:0:0:1\\]", "(^192\\.168\\.)", "X-Forwarded-For")) diff --git a/hawkbit-dmf/hawkbit-dmf-amqp/.gitignore b/hawkbit-dmf/hawkbit-dmf-amqp/.gitignore new file mode 100644 index 000000000..5ea5939a3 --- /dev/null +++ b/hawkbit-dmf/hawkbit-dmf-amqp/.gitignore @@ -0,0 +1 @@ +/artifactrepo/ diff --git a/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/integration/AmqpMessageDispatcherServiceIntegrationTest.java b/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/integration/AmqpMessageDispatcherServiceIntegrationTest.java index 147339500..cb115dfea 100644 --- a/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/integration/AmqpMessageDispatcherServiceIntegrationTest.java +++ b/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/integration/AmqpMessageDispatcherServiceIntegrationTest.java @@ -37,6 +37,7 @@ import ru.yandex.qatools.allure.annotations.Stories; @Features("Component Tests - Device Management Federation API") @Stories("Amqp Message Dispatcher Service") public class AmqpMessageDispatcherServiceIntegrationTest extends AmqpServiceIntegrationTest { + private static final String TARGET_PREFIX = "Dmf_disp_"; @Test @Description("Verify that a distribution assignment send a download and install message.") @@ -47,11 +48,12 @@ public class AmqpMessageDispatcherServiceIntegrationTest extends AmqpServiceInte @Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = TargetUpdatedEvent.class, count = 1), @Expect(type = TargetPollEvent.class, count = 2) }) public void sendDownloadAndInstallStatus() { - registerTargetAndAssignDistributionSet(); + final String controllerId = TARGET_PREFIX + "sendDownloadAndInstallStatus"; + registerTargetAndAssignDistributionSet(controllerId); - createAndSendTarget(TENANT_EXIST); - waitUntilTargetStatusIsPending(); - assertDownloadAndInstallMessage(getDistributionSet().getModules()); + createAndSendTarget(controllerId, TENANT_EXIST); + waitUntilTargetStatusIsPending(controllerId); + assertDownloadAndInstallMessage(getDistributionSet().getModules(), controllerId); } @Test @@ -64,16 +66,18 @@ public class AmqpMessageDispatcherServiceIntegrationTest extends AmqpServiceInte @Expect(type = DistributionSetCreatedEvent.class, count = 2), @Expect(type = TargetUpdatedEvent.class, count = 2), @Expect(type = TargetPollEvent.class, count = 3) }) public void assignDistributionSetMultipleTimes() { - final DistributionSetAssignmentResult assignmentResult = registerTargetAndAssignDistributionSet(); + final String controllerId = TARGET_PREFIX + "assignDistributionSetMultipleTimes"; + + final DistributionSetAssignmentResult assignmentResult = registerTargetAndAssignDistributionSet(controllerId); final DistributionSet distributionSet2 = testdataFactory.createDistributionSet(UUID.randomUUID().toString()); registerTargetAndAssignDistributionSet(distributionSet2.getId(), TargetUpdateStatus.PENDING, - getDistributionSet().getModules()); - assertCancelActionMessage(assignmentResult.getActions().get(0)); + getDistributionSet().getModules(), controllerId); + assertCancelActionMessage(assignmentResult.getActions().get(0), controllerId); - createAndSendTarget(TENANT_EXIST); - waitUntilTargetStatusIsPending(); - assertCancelActionMessage(assignmentResult.getActions().get(0)); + createAndSendTarget(controllerId, TENANT_EXIST); + waitUntilTargetStatusIsPending(controllerId); + assertCancelActionMessage(assignmentResult.getActions().get(0), controllerId); } @@ -87,11 +91,13 @@ public class AmqpMessageDispatcherServiceIntegrationTest extends AmqpServiceInte @Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = TargetUpdatedEvent.class, count = 1), @Expect(type = TargetPollEvent.class, count = 2) }) public void sendCancelStatus() { - final Long actionId = registerTargetAndCancelActionId(); + final String controllerId = TARGET_PREFIX + "sendCancelStatus"; - createAndSendTarget(TENANT_EXIST); - waitUntilTargetStatusIsPending(); - assertCancelActionMessage(actionId); + final Long actionId = registerTargetAndCancelActionId(controllerId); + + createAndSendTarget(controllerId, TENANT_EXIST); + waitUntilTargetStatusIsPending(controllerId); + assertCancelActionMessage(actionId, controllerId); } @Test @@ -99,16 +105,16 @@ public class AmqpMessageDispatcherServiceIntegrationTest extends AmqpServiceInte @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetPollEvent.class, count = 1), @Expect(type = TargetDeletedEvent.class, count = 1) }) public void sendDeleteMessage() { + final String controllerId = TARGET_PREFIX + "sendDeleteMessage"; - registerAndAssertTargetWithExistingTenant(REGISTER_TARGET, 1); - targetManagement.deleteTarget(REGISTER_TARGET); - assertDeleteMessage(REGISTER_TARGET); + registerAndAssertTargetWithExistingTenant(controllerId, 1); + targetManagement.deleteTarget(controllerId); + assertDeleteMessage(controllerId); } - private void waitUntilTargetStatusIsPending() { + private void waitUntilTargetStatusIsPending(final String controllerId) { waitUntil(() -> { - final Optional findTargetByControllerID = targetManagement - .findTargetByControllerID(REGISTER_TARGET); + final Optional findTargetByControllerID = targetManagement.findTargetByControllerID(controllerId); return findTargetByControllerID.isPresent() && TargetUpdateStatus.PENDING.equals(findTargetByControllerID.get().getUpdateStatus()); }); @@ -119,9 +125,4 @@ public class AmqpMessageDispatcherServiceIntegrationTest extends AmqpServiceInte return securityRule.runAsPrivileged(callable); }); } - - private void createAndSendTarget(final String tenant) { - createAndSendTarget(REGISTER_TARGET, tenant); - } - } diff --git a/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/integration/AmqpMessageHandlerServiceIntegrationTest.java b/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/integration/AmqpMessageHandlerServiceIntegrationTest.java index 5bf8ad31a..9a655ff69 100644 --- a/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/integration/AmqpMessageHandlerServiceIntegrationTest.java +++ b/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/integration/AmqpMessageHandlerServiceIntegrationTest.java @@ -33,9 +33,9 @@ import org.eclipse.hawkbit.repository.event.remote.entity.SoftwareModuleCreatedE import org.eclipse.hawkbit.repository.event.remote.entity.TargetCreatedEvent; import org.eclipse.hawkbit.repository.event.remote.entity.TargetUpdatedEvent; import org.eclipse.hawkbit.repository.model.Action.Status; +import org.eclipse.hawkbit.repository.model.ActionStatus; import org.eclipse.hawkbit.repository.model.DistributionSet; import org.eclipse.hawkbit.repository.model.DistributionSetAssignmentResult; -import org.eclipse.hawkbit.repository.model.Target; import org.eclipse.hawkbit.repository.model.TargetUpdateStatus; import org.eclipse.hawkbit.repository.test.matcher.Expect; import org.eclipse.hawkbit.repository.test.matcher.ExpectEvents; @@ -54,6 +54,7 @@ import ru.yandex.qatools.allure.annotations.Stories; @Stories("Amqp Message Handler Service") public class AmqpMessageHandlerServiceIntegrationTest extends AmqpServiceIntegrationTest { private static final String CORRELATION_ID = UUID.randomUUID().toString(); + private static final String TARGET_PREFIX = "Dmf_hand_"; @Autowired private AmqpProperties amqpProperties; @@ -63,12 +64,13 @@ public class AmqpMessageHandlerServiceIntegrationTest extends AmqpServiceIntegra @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 2), @Expect(type = TargetPollEvent.class, count = 3) }) public void registerTargets() { - registerAndAssertTargetWithExistingTenant(REGISTER_TARGET, 1); + final String controllerId = TARGET_PREFIX + "registerTargets"; + registerAndAssertTargetWithExistingTenant(controllerId, 1); final String target2 = "Target2"; registerAndAssertTargetWithExistingTenant(target2, 2); - final Long pollingTimeTarget2 = controllerManagement.findByControllerId(target2).get().getLastTargetQuery(); - registerSameTargetAndAssertBasedOnLastPolling(target2, 2, TargetUpdateStatus.REGISTERED, pollingTimeTarget2); + + registerSameTargetAndAssertBasedOnVersion(target2, 2, TargetUpdateStatus.REGISTERED); Mockito.verifyZeroInteractions(getDeadletterListener()); } @@ -106,7 +108,8 @@ public class AmqpMessageHandlerServiceIntegrationTest extends AmqpServiceIntegra @Description("Tests not allowed content-type in message. This message should forwarded to the deadletter queue") @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 0) }) public void wrongContentType() { - final Message createTargetMessage = createTargetMessage(REGISTER_TARGET, TENANT_EXIST); + final String controllerId = TARGET_PREFIX + "wrongContentType"; + final Message createTargetMessage = createTargetMessage(controllerId, TENANT_EXIST); createTargetMessage.getMessageProperties().setContentType("WrongContentType"); getDmfClient().send(createTargetMessage); @@ -118,7 +121,8 @@ public class AmqpMessageHandlerServiceIntegrationTest extends AmqpServiceIntegra @Description("Tests null reply to property in message header. This message should forwarded to the deadletter queue") @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 0) }) public void missingReplyToProperty() { - final Message createTargetMessage = createTargetMessage(REGISTER_TARGET, TENANT_EXIST); + final String controllerId = TARGET_PREFIX + "missingReplyToProperty"; + final Message createTargetMessage = createTargetMessage(controllerId, TENANT_EXIST); createTargetMessage.getMessageProperties().setReplyTo(null); getDmfClient().send(createTargetMessage); @@ -130,7 +134,8 @@ public class AmqpMessageHandlerServiceIntegrationTest extends AmqpServiceIntegra @Description("Tests missing reply to property in message header. This message should forwarded to the deadletter queue") @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 0) }) public void emptyReplyToProperty() { - final Message createTargetMessage = createTargetMessage(REGISTER_TARGET, TENANT_EXIST); + final String controllerId = TARGET_PREFIX + "emptyReplyToProperty"; + final Message createTargetMessage = createTargetMessage(controllerId, TENANT_EXIST); createTargetMessage.getMessageProperties().setReplyTo(""); getDmfClient().send(createTargetMessage); @@ -165,7 +170,8 @@ public class AmqpMessageHandlerServiceIntegrationTest extends AmqpServiceIntegra @Description("Tests missing tenant message header. This message should forwarded to the deadletter queue") @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 0) }) public void missingTenantHeader() { - final Message createTargetMessage = createTargetMessage(REGISTER_TARGET, TENANT_EXIST); + final String controllerId = TARGET_PREFIX + "missingTenantHeader"; + final Message createTargetMessage = createTargetMessage(controllerId, TENANT_EXIST); createTargetMessage.getMessageProperties().getHeaders().remove(MessageHeaderKey.TENANT); getDmfClient().send(createTargetMessage); @@ -177,7 +183,8 @@ public class AmqpMessageHandlerServiceIntegrationTest extends AmqpServiceIntegra @Description("Tests null tenant message header. This message should forwarded to the deadletter queue") @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 0) }) public void nullTenantHeader() { - final Message createTargetMessage = createTargetMessage(REGISTER_TARGET, null); + final String controllerId = TARGET_PREFIX + "nullTenantHeader"; + final Message createTargetMessage = createTargetMessage(controllerId, null); getDmfClient().send(createTargetMessage); verifyOneDeadLetterMessage(); @@ -188,7 +195,8 @@ public class AmqpMessageHandlerServiceIntegrationTest extends AmqpServiceIntegra @Description("Tests empty tenant message header. This message should forwarded to the deadletter queue") @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 0) }) public void emptyTenantHeader() { - final Message createTargetMessage = createTargetMessage(REGISTER_TARGET, ""); + final String controllerId = TARGET_PREFIX + "emptyTenantHeader"; + final Message createTargetMessage = createTargetMessage(controllerId, ""); getDmfClient().send(createTargetMessage); verifyOneDeadLetterMessage(); @@ -199,7 +207,8 @@ public class AmqpMessageHandlerServiceIntegrationTest extends AmqpServiceIntegra @Description("Tests tenant not exist. This message should forwarded to the deadletter queue") @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 0) }) public void tenantNotExist() { - final Message createTargetMessage = createTargetMessage(REGISTER_TARGET, "TenantNotExist"); + final String controllerId = TARGET_PREFIX + "tenantNotExist"; + final Message createTargetMessage = createTargetMessage(controllerId, "TenantNotExist"); getDmfClient().send(createTargetMessage); verifyOneDeadLetterMessage(); @@ -346,7 +355,8 @@ public class AmqpMessageHandlerServiceIntegrationTest extends AmqpServiceIntegra @Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = TargetUpdatedEvent.class, count = 2), @Expect(type = TargetPollEvent.class, count = 1) }) public void finishActionStatus() { - registerTargetAndSendAndAssertUpdateActionStatus(DmfActionStatus.FINISHED, Status.FINISHED); + final String controllerId = TARGET_PREFIX + "finishActionStatus"; + registerTargetAndSendAndAssertUpdateActionStatus(DmfActionStatus.FINISHED, Status.FINISHED, controllerId); } @Test @@ -358,7 +368,8 @@ public class AmqpMessageHandlerServiceIntegrationTest extends AmqpServiceIntegra @Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = TargetUpdatedEvent.class, count = 1), @Expect(type = TargetPollEvent.class, count = 1) }) public void runningActionStatus() { - registerTargetAndSendAndAssertUpdateActionStatus(DmfActionStatus.RUNNING, Status.RUNNING); + final String controllerId = TARGET_PREFIX + "runningActionStatus"; + registerTargetAndSendAndAssertUpdateActionStatus(DmfActionStatus.RUNNING, Status.RUNNING, controllerId); } @Test @@ -370,7 +381,8 @@ public class AmqpMessageHandlerServiceIntegrationTest extends AmqpServiceIntegra @Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = TargetUpdatedEvent.class, count = 1), @Expect(type = TargetPollEvent.class, count = 1) }) public void downloadActionStatus() { - registerTargetAndSendAndAssertUpdateActionStatus(DmfActionStatus.DOWNLOAD, Status.DOWNLOAD); + final String controllerId = TARGET_PREFIX + "downloadActionStatus"; + registerTargetAndSendAndAssertUpdateActionStatus(DmfActionStatus.DOWNLOAD, Status.DOWNLOAD, controllerId); } @Test @@ -382,7 +394,8 @@ public class AmqpMessageHandlerServiceIntegrationTest extends AmqpServiceIntegra @Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = TargetUpdatedEvent.class, count = 2), @Expect(type = TargetPollEvent.class, count = 1) }) public void errorActionStatus() { - registerTargetAndSendAndAssertUpdateActionStatus(DmfActionStatus.ERROR, Status.ERROR); + final String controllerId = TARGET_PREFIX + "errorActionStatus"; + registerTargetAndSendAndAssertUpdateActionStatus(DmfActionStatus.ERROR, Status.ERROR, controllerId); } @Test @@ -394,7 +407,8 @@ public class AmqpMessageHandlerServiceIntegrationTest extends AmqpServiceIntegra @Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = TargetUpdatedEvent.class, count = 1), @Expect(type = TargetPollEvent.class, count = 1) }) public void warningActionStatus() { - registerTargetAndSendAndAssertUpdateActionStatus(DmfActionStatus.WARNING, Status.WARNING); + final String controllerId = TARGET_PREFIX + "warningActionStatus"; + registerTargetAndSendAndAssertUpdateActionStatus(DmfActionStatus.WARNING, Status.WARNING, controllerId); } @Test @@ -406,7 +420,8 @@ public class AmqpMessageHandlerServiceIntegrationTest extends AmqpServiceIntegra @Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = TargetUpdatedEvent.class, count = 1), @Expect(type = TargetPollEvent.class, count = 1) }) public void retrievedActionStatus() { - registerTargetAndSendAndAssertUpdateActionStatus(DmfActionStatus.RETRIEVED, Status.RETRIEVED); + final String controllerId = TARGET_PREFIX + "retrievedActionStatus"; + registerTargetAndSendAndAssertUpdateActionStatus(DmfActionStatus.RETRIEVED, Status.RETRIEVED, controllerId); } @Test @@ -418,7 +433,8 @@ public class AmqpMessageHandlerServiceIntegrationTest extends AmqpServiceIntegra @Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = TargetUpdatedEvent.class, count = 1), @Expect(type = TargetPollEvent.class, count = 1) }) public void cancelNotAllowActionStatus() { - registerTargetAndSendActionStatus(DmfActionStatus.CANCELED); + final String controllerId = TARGET_PREFIX + "cancelNotAllowActionStatus"; + registerTargetAndSendActionStatus(DmfActionStatus.CANCELED, controllerId); verifyOneDeadLetterMessage(); } @@ -431,17 +447,18 @@ public class AmqpMessageHandlerServiceIntegrationTest extends AmqpServiceIntegra @Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = TargetUpdatedEvent.class, count = 1), @Expect(type = TargetPollEvent.class, count = 2) }) public void receiveDownLoadAndInstallMessageAfterAssignment() { + final String controllerId = TARGET_PREFIX + "receiveDownLoadAndInstallMessageAfterAssignment"; // setup - controllerManagement.findOrRegisterTargetIfItDoesNotexist(REGISTER_TARGET, TEST_URI); + controllerManagement.findOrRegisterTargetIfItDoesNotexist(controllerId, TEST_URI); final DistributionSet distributionSet = testdataFactory.createDistributionSet(UUID.randomUUID().toString()); - assignDistributionSet(distributionSet.getId(), REGISTER_TARGET); + assignDistributionSet(distributionSet.getId(), controllerId); // test - registerAndAssertTargetWithExistingTenant(REGISTER_TARGET, 1, TargetUpdateStatus.PENDING, "bumlux"); + registerSameTargetAndAssertBasedOnVersion(controllerId, 1, TargetUpdateStatus.PENDING); // verify - assertDownloadAndInstallMessage(distributionSet.getModules()); + assertDownloadAndInstallMessage(distributionSet.getModules(), controllerId); Mockito.verifyZeroInteractions(getDeadletterListener()); } @@ -456,20 +473,20 @@ public class AmqpMessageHandlerServiceIntegrationTest extends AmqpServiceIntegra @Expect(type = ActionUpdatedEvent.class, count = 1), @Expect(type = TargetUpdatedEvent.class, count = 1), @Expect(type = TargetPollEvent.class, count = 2) }) public void receiveCancelUpdateMessageAfterAssignmentWasCanceled() { + final String controllerId = TARGET_PREFIX + "receiveCancelUpdateMessageAfterAssignmentWasCanceled"; // Setup - final Target target = controllerManagement.findOrRegisterTargetIfItDoesNotexist(REGISTER_TARGET, TEST_URI); + controllerManagement.findOrRegisterTargetIfItDoesNotexist(controllerId, TEST_URI); final DistributionSet distributionSet = testdataFactory.createDistributionSet(UUID.randomUUID().toString()); final DistributionSetAssignmentResult distributionSetAssignmentResult = assignDistributionSet( - distributionSet.getId(), REGISTER_TARGET); + distributionSet.getId(), controllerId); deploymentManagement.cancelAction(distributionSetAssignmentResult.getActions().get(0)); // test - registerSameTargetAndAssertBasedOnLastPolling(REGISTER_TARGET, 1, TargetUpdateStatus.PENDING, - target.getLastTargetQuery()); + registerSameTargetAndAssertBasedOnVersion(controllerId, 1, TargetUpdateStatus.PENDING); // verify - assertCancelActionMessage(distributionSetAssignmentResult.getActions().get(0)); + assertCancelActionMessage(distributionSetAssignmentResult.getActions().get(0), controllerId); Mockito.verifyZeroInteractions(getDeadletterListener()); } @@ -483,7 +500,9 @@ public class AmqpMessageHandlerServiceIntegrationTest extends AmqpServiceIntegra @Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = TargetUpdatedEvent.class, count = 1), @Expect(type = TargetPollEvent.class, count = 1) }) public void actionNotExists() { - final Long actionId = registerTargetAndCancelActionId(); + final String controllerId = TARGET_PREFIX + "actionNotExists"; + + final Long actionId = registerTargetAndCancelActionId(controllerId); final Long actionNotExist = actionId + 1; sendActionUpdateStatus(new DmfActionUpdateStatus(actionNotExist, DmfActionStatus.CANCELED)); @@ -499,7 +518,8 @@ public class AmqpMessageHandlerServiceIntegrationTest extends AmqpServiceIntegra @Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = TargetUpdatedEvent.class, count = 1), @Expect(type = TargetPollEvent.class, count = 1) }) public void canceledRejectedNotAllowActionStatus() { - registerTargetAndSendActionStatus(DmfActionStatus.CANCEL_REJECTED); + final String controllerId = TARGET_PREFIX + "canceledRejectedNotAllowActionStatus"; + registerTargetAndSendActionStatus(DmfActionStatus.CANCEL_REJECTED, controllerId); verifyOneDeadLetterMessage(); } @@ -513,7 +533,9 @@ public class AmqpMessageHandlerServiceIntegrationTest extends AmqpServiceIntegra @Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = TargetUpdatedEvent.class, count = 1), @Expect(type = TargetPollEvent.class, count = 1) }) public void canceledRejectedActionStatus() { - final Long actionId = registerTargetAndCancelActionId(); + final String controllerId = TARGET_PREFIX + "canceledRejectedActionStatus"; + + final Long actionId = registerTargetAndCancelActionId(controllerId); sendActionUpdateStatus(new DmfActionUpdateStatus(actionId, DmfActionStatus.CANCEL_REJECTED)); assertAction(actionId, 1, Status.RUNNING, Status.CANCELING, Status.CANCEL_REJECTED); @@ -524,19 +546,19 @@ public class AmqpMessageHandlerServiceIntegrationTest extends AmqpServiceIntegra @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetUpdatedEvent.class, count = 1), @Expect(type = TargetPollEvent.class, count = 1) }) public void updateAttributes() { + final String controllerId = TARGET_PREFIX + "updateAttributes"; // setup - final String target = "ControllerAttributeTestTarget"; - registerAndAssertTargetWithExistingTenant(target, 1); + registerAndAssertTargetWithExistingTenant(controllerId, 1); final DmfAttributeUpdate controllerAttribute = new DmfAttributeUpdate(); controllerAttribute.getAttributes().put("test1", "testA"); controllerAttribute.getAttributes().put("test2", "testB"); // test - sendUpdateAttributeMessage(target, TENANT_EXIST, controllerAttribute); + sendUpdateAttributeMessage(controllerId, TENANT_EXIST, controllerAttribute); // validate - assertUpdateAttributes(target, controllerAttribute.getAttributes()); + assertUpdateAttributes(controllerId, controllerAttribute.getAttributes()); } @Test @@ -544,10 +566,10 @@ public class AmqpMessageHandlerServiceIntegrationTest extends AmqpServiceIntegra @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetUpdatedEvent.class, count = 0), @Expect(type = TargetPollEvent.class, count = 1) }) public void updateAttributesWithNoThingId() { + final String controllerId = TARGET_PREFIX + "updateAttributesWithNoThingId"; // setup - final String target = "ControllerAttributeTestTarget"; - registerAndAssertTargetWithExistingTenant(target, 1); + registerAndAssertTargetWithExistingTenant(controllerId, 1); final DmfAttributeUpdate controllerAttribute = new DmfAttributeUpdate(); controllerAttribute.getAttributes().put("test1", "testA"); controllerAttribute.getAttributes().put("test2", "testB"); @@ -561,7 +583,7 @@ public class AmqpMessageHandlerServiceIntegrationTest extends AmqpServiceIntegra // verify verifyOneDeadLetterMessage(); final DmfAttributeUpdate controllerAttributeEmpty = new DmfAttributeUpdate(); - assertUpdateAttributes(target, controllerAttributeEmpty.getAttributes()); + assertUpdateAttributes(controllerId, controllerAttributeEmpty.getAttributes()); } @Test @@ -586,8 +608,8 @@ public class AmqpMessageHandlerServiceIntegrationTest extends AmqpServiceIntegra verifyOneDeadLetterMessage(); } - private Long registerTargetAndSendActionStatus(final DmfActionStatus sendActionStatus) { - final DistributionSetAssignmentResult assignmentResult = registerTargetAndAssignDistributionSet(); + private Long registerTargetAndSendActionStatus(final DmfActionStatus sendActionStatus, final String controllerId) { + final DistributionSetAssignmentResult assignmentResult = registerTargetAndAssignDistributionSet(controllerId); final Long actionId = assignmentResult.getActions().get(0); sendActionUpdateStatus(new DmfActionUpdateStatus(actionId, sendActionStatus)); return actionId; @@ -599,8 +621,8 @@ public class AmqpMessageHandlerServiceIntegrationTest extends AmqpServiceIntegra } private void registerTargetAndSendAndAssertUpdateActionStatus(final DmfActionStatus sendActionStatus, - final Status expectedActionStatus) { - final Long actionId = registerTargetAndSendActionStatus(sendActionStatus); + final Status expectedActionStatus, final String controllerId) { + final Long actionId = registerTargetAndSendActionStatus(sendActionStatus, controllerId); assertAction(actionId, 1, Status.RUNNING, expectedActionStatus); } @@ -608,7 +630,7 @@ public class AmqpMessageHandlerServiceIntegrationTest extends AmqpServiceIntegra createConditionFactory().await().until(() -> { try { securityRule.runAsPrivileged(() -> { - final List actionStatusList = deploymentManagement + final List actionStatusList = deploymentManagement .findActionStatusByAction(PAGE, actionId).getContent(); // Check correlation ID @@ -623,7 +645,7 @@ public class AmqpMessageHandlerServiceIntegrationTest extends AmqpServiceIntegra assertThat(messagesFromServer).hasSize(messages) .allMatch(message -> message.endsWith(CORRELATION_ID)); - final List status = actionStatusList.stream().map(actionStatus -> actionStatus.getStatus()) + final List status = actionStatusList.stream().map(ActionStatus::getStatus) .collect(Collectors.toList()); assertThat(status).containsOnly(expectedActionStates); diff --git a/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/integration/AmqpServiceIntegrationTest.java b/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/integration/AmqpServiceIntegrationTest.java index 4fc969c26..96c6207d2 100644 --- a/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/integration/AmqpServiceIntegrationTest.java +++ b/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/integration/AmqpServiceIntegrationTest.java @@ -55,7 +55,6 @@ import org.springframework.boot.test.SpringApplicationConfiguration; public abstract class AmqpServiceIntegrationTest extends AbstractAmqpIntegrationTest { protected static final String TENANT_EXIST = "DEFAULT"; - protected static final String REGISTER_TARGET = "NewDmfTarget"; protected static final String CREATED_BY = "CONTROLLER_PLUG_AND_PLAY"; private DeadletterListener deadletterListener; @@ -105,23 +104,24 @@ public abstract class AmqpServiceIntegrationTest extends AbstractAmqpIntegration return distributionSet; } - protected DistributionSetAssignmentResult registerTargetAndAssignDistributionSet() { + protected DistributionSetAssignmentResult registerTargetAndAssignDistributionSet(final String controllerId) { distributionSet = testdataFactory.createDistributionSet(UUID.randomUUID().toString()); return registerTargetAndAssignDistributionSet(distributionSet.getId(), TargetUpdateStatus.REGISTERED, - distributionSet.getModules()); + distributionSet.getModules(), controllerId); } protected DistributionSetAssignmentResult registerTargetAndAssignDistributionSet(final Long assignDs, - final TargetUpdateStatus expectedStatus, final Set expectedSoftwareModulesInMessage) { - registerAndAssertTargetWithExistingTenant(REGISTER_TARGET, 1, expectedStatus, CREATED_BY); + final TargetUpdateStatus expectedStatus, final Set expectedSoftwareModulesInMessage, + final String controllerId) { + registerAndAssertTargetWithExistingTenant(controllerId, 1, expectedStatus, CREATED_BY); - final DistributionSetAssignmentResult assignmentResult = assignDistributionSet(assignDs, REGISTER_TARGET); - assertDownloadAndInstallMessage(expectedSoftwareModulesInMessage); + final DistributionSetAssignmentResult assignmentResult = assignDistributionSet(assignDs, controllerId); + assertDownloadAndInstallMessage(expectedSoftwareModulesInMessage, controllerId); return assignmentResult; } - protected void assertCancelActionMessage(final Long actionId) { - final Message replyMessage = assertReplyMessageHeader(EventTopic.CANCEL_DOWNLOAD); + protected void assertCancelActionMessage(final Long actionId, final String controllerId) { + final Message replyMessage = assertReplyMessageHeader(EventTopic.CANCEL_DOWNLOAD, controllerId); final Long actionUpdateStatus = (Long) getDmfClient().getMessageConverter().fromMessage(replyMessage); assertThat(actionUpdateStatus).isEqualTo(actionId); @@ -138,8 +138,8 @@ public abstract class AmqpServiceIntegrationTest extends AbstractAmqpIntegration assertThat(headers.get(MessageHeaderKey.TYPE)).isEqualTo(MessageType.THING_DELETED.toString()); } - protected void assertDownloadAndInstallMessage(final Set dsModules) { - final Message replyMessage = assertReplyMessageHeader(EventTopic.DOWNLOAD_AND_INSTALL); + protected void assertDownloadAndInstallMessage(final Set dsModules, final String controllerId) { + final Message replyMessage = assertReplyMessageHeader(EventTopic.DOWNLOAD_AND_INSTALL, controllerId); assertAllTargetsCount(1); final DmfDownloadAndUpdateRequest downloadAndUpdateRequest = (DmfDownloadAndUpdateRequest) getDmfClient() @@ -148,8 +148,7 @@ public abstract class AmqpServiceIntegrationTest extends AbstractAmqpIntegration Assert.assertThat(dsModules, SoftwareModuleJsonMatcher.containsExactly(downloadAndUpdateRequest.getSoftwareModules())); - final Target updatedTarget = waitUntilIsPresent( - () -> targetManagement.findTargetByControllerID(REGISTER_TARGET)); + final Target updatedTarget = waitUntilIsPresent(() -> targetManagement.findTargetByControllerID(controllerId)); assertThat(updatedTarget.getSecurityToken()).isEqualTo(downloadAndUpdateRequest.getTargetSecurityToken()); } @@ -165,28 +164,28 @@ public abstract class AmqpServiceIntegrationTest extends AbstractAmqpIntegration }); } - protected Long cancelAction(final Long actionId) { + protected Long cancelAction(final Long actionId, final String controllerId) { deploymentManagement.cancelAction(actionId); - assertCancelActionMessage(actionId); + assertCancelActionMessage(actionId, controllerId); return actionId; } - protected Long registerTargetAndCancelActionId() { - final DistributionSetAssignmentResult assignmentResult = registerTargetAndAssignDistributionSet(); - return cancelAction(assignmentResult.getActions().get(0)); + protected Long registerTargetAndCancelActionId(final String controllerId) { + final DistributionSetAssignmentResult assignmentResult = registerTargetAndAssignDistributionSet(controllerId); + return cancelAction(assignmentResult.getActions().get(0), controllerId); } protected void assertAllTargetsCount(final long expectedTargetsCount) { assertThat(targetManagement.countTargetsAll()).isEqualTo(expectedTargetsCount); } - private Message assertReplyMessageHeader(final EventTopic eventTopic) { + private Message assertReplyMessageHeader(final EventTopic eventTopic, final String controllerId) { verifyReplyToListener(); final Message replyMessage = replyToListener.getEventTopicMessages().get(eventTopic); assertAllTargetsCount(1); final Map headers = replyMessage.getMessageProperties().getHeaders(); assertThat(headers.get(MessageHeaderKey.TOPIC)).isEqualTo(eventTopic.toString()); - assertThat(headers.get(MessageHeaderKey.THING_ID)).isEqualTo(REGISTER_TARGET); + assertThat(headers.get(MessageHeaderKey.THING_ID)).isEqualTo(controllerId); assertThat(headers.get(MessageHeaderKey.TENANT)).isEqualTo(TENANT_EXIST); assertThat(headers.get(MessageHeaderKey.TYPE)).isEqualTo(MessageType.EVENT.toString()); return replyMessage; @@ -209,20 +208,18 @@ public abstract class AmqpServiceIntegrationTest extends AbstractAmqpIntegration assertTarget(registerdTarget, expectedTargetStatus, createdBy); } - protected void registerSameTargetAndAssertBasedOnLastPolling(final String target, - final int existingTargetsAfterCreation, final TargetUpdateStatus expectedTargetStatus, - final Long pollingTimeTargetOld) { - createAndSendTarget(target, TENANT_EXIST); - final Target registerdTarget = waitUntilIsPresent( - () -> findTargetBasedOnNewPolltime(target, pollingTimeTargetOld)); + protected void registerSameTargetAndAssertBasedOnVersion(final String controllerId, + final int existingTargetsAfterCreation, final TargetUpdateStatus expectedTargetStatus) { + final int version = controllerManagement.findByControllerId(controllerId).get().getOptLockRevision(); + createAndSendTarget(controllerId, TENANT_EXIST); + final Target registeredTarget = waitUntilIsPresent(() -> findTargetBasedOnNewVersion(controllerId, version)); assertAllTargetsCount(existingTargetsAfterCreation); - assertThat(registerdTarget.getUpdateStatus()).isEqualTo(expectedTargetStatus); + assertThat(registeredTarget.getUpdateStatus()).isEqualTo(expectedTargetStatus); } - private Optional findTargetBasedOnNewPolltime(final String controllerId, final Long pollingTimeTargetOld) { + private Optional findTargetBasedOnNewVersion(final String controllerId, final int version) { final Optional target2 = controllerManagement.findByControllerId(controllerId); - final Long pollingTimeTargetNew = target2.get().getLastTargetQuery(); - if (pollingTimeTargetOld < pollingTimeTargetNew) { + if (version < target2.get().getOptLockRevision()) { return target2; } return Optional.empty(); @@ -244,7 +241,7 @@ public abstract class AmqpServiceIntegrationTest extends AbstractAmqpIntegration messageProperties.getHeaders().put(MessageHeaderKey.TYPE, MessageType.THING_CREATED.toString()); messageProperties.setReplyTo(DmfTestConfiguration.REPLY_TO_EXCHANGE); - return createMessage("", messageProperties); + return createMessage(null, messageProperties); } protected MessageProperties createMessagePropertiesWithTenant(final String tenant) { diff --git a/hawkbit-dmf/hawkbit-dmf-amqp/src/test/resources/application-test.properties b/hawkbit-dmf/hawkbit-dmf-amqp/src/test/resources/application-test.properties deleted file mode 100644 index ee14154fa..000000000 --- a/hawkbit-dmf/hawkbit-dmf-amqp/src/test/resources/application-test.properties +++ /dev/null @@ -1,42 +0,0 @@ -# -# Copyright (c) 2015 Bosch Software Innovations GmbH and others. -# -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v1.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/epl-v10.html -# - -# RabbitMQ -spring.rabbitmq.host=localhost - -spring.jpa.database=H2 -flyway.sqlMigrationSuffix=${spring.jpa.database}.sql - -# Default tenant configuration properties -hawkbit.server.tenant.configuration.authentication-header-enabled.keyName=authentication.header.enabled -hawkbit.server.tenant.configuration.authentication-header-enabled.defaultValue=false -hawkbit.server.tenant.configuration.authentication-header-enabled.dataType=java.lang.Boolean -hawkbit.server.tenant.configuration.authentication-header-enabled.validator=org.eclipse.hawkbit.tenancy.configuration.validator.TenantConfigurationBooleanValidator - -hawkbit.server.tenant.configuration.authentication-header-authority.keyName=authentication.header.authority -hawkbit.server.tenant.configuration.authentication-header-authority.defaultValue=false - -hawkbit.server.tenant.configuration.authentication-targettoken-enabled.keyName=authentication.targettoken.enabled -hawkbit.server.tenant.configuration.authentication-targettoken-enabled.defaultValue=false -hawkbit.server.tenant.configuration.authentication-targettoken-enabled.dataType=java.lang.Boolean -hawkbit.server.tenant.configuration.authentication-targettoken-enabled.validator=org.eclipse.hawkbit.tenancy.configuration.validator.TenantConfigurationBooleanValidator - -hawkbit.server.tenant.configuration.authentication-gatewaytoken-enabled.keyName=authentication.gatewaytoken.enabled -hawkbit.server.tenant.configuration.authentication-gatewaytoken-enabled.defaultValue=false -hawkbit.server.tenant.configuration.authentication-gatewaytoken-enabled.dataType=java.lang.Boolean -hawkbit.server.tenant.configuration.authentication-gatewaytoken-enabled.validator=org.eclipse.hawkbit.tenancy.configuration.validator.TenantConfigurationBooleanValidator - -hawkbit.server.tenant.configuration.authentication-gatewaytoken-key.keyName=authentication.gatewaytoken.key -hawkbit.server.tenant.configuration.authentication-gatewaytoken-key.defaultValue=false - -hawkbit.server.tenant.configuration.anonymous-download-enabled.keyName=anonymous.download.enabled -hawkbit.server.tenant.configuration.anonymous-download-enabled.defaultValue=false -hawkbit.server.tenant.configuration.anonymous-download-enabled.dataType=java.lang.Boolean -hawkbit.server.tenant.configuration.anonymous-download-enabled.validator=org.eclipse.hawkbit.tenancy.configuration.validator.TenantConfigurationBooleanValidator - diff --git a/hawkbit-dmf/hawkbit-dmf-amqp/src/test/resources/logback-spring.xml b/hawkbit-dmf/hawkbit-dmf-amqp/src/test/resources/logback-spring.xml deleted file mode 100644 index 6dd6c94e0..000000000 --- a/hawkbit-dmf/hawkbit-dmf-amqp/src/test/resources/logback-spring.xml +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/hawkbit-mgmt-resource/.gitignore b/hawkbit-mgmt-resource/.gitignore new file mode 100644 index 000000000..5ea5939a3 --- /dev/null +++ b/hawkbit-mgmt-resource/.gitignore @@ -0,0 +1 @@ +/artifactrepo/ diff --git a/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtRolloutResourceTest.java b/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtRolloutResourceTest.java index 9c837feed..2096a43c8 100644 --- a/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtRolloutResourceTest.java +++ b/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtRolloutResourceTest.java @@ -37,7 +37,6 @@ import org.eclipse.hawkbit.repository.model.RolloutGroup; import org.eclipse.hawkbit.repository.model.RolloutGroup.RolloutGroupSuccessCondition; import org.eclipse.hawkbit.repository.model.RolloutGroupConditionBuilder; import org.eclipse.hawkbit.repository.model.RolloutGroupConditions; -import org.eclipse.hawkbit.repository.model.Target; import org.eclipse.hawkbit.repository.test.util.WithUser; import org.eclipse.hawkbit.rest.util.JsonBuilder; import org.eclipse.hawkbit.rest.util.MockMvcResultPrinter; @@ -714,7 +713,7 @@ public class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTes public void retrieveTargetsFromRolloutGroupWithQuery() throws Exception { // setup final int amountTargets = 10; - final List targets = testdataFactory.createTargets(amountTargets, "rollout", "rollout"); + testdataFactory.createTargets(amountTargets, "rollout", "rollout"); final DistributionSet dsA = testdataFactory.createDistributionSet(""); // create rollout including the created targets with prefix 'rollout' @@ -724,11 +723,13 @@ public class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTes .findRolloutGroupsByRolloutId(rollout.getId(), new PageRequest(0, 1, Direction.ASC, "id")).getContent() .get(0); + final String targetInGroup = rolloutGroupManagement.findRolloutGroupTargets(firstGroup.getId(), PAGE) + .getContent().get(0).getControllerId(); + // retrieve targets from the first rollout group with known ID mvc.perform( get("/rest/v1/rollouts/{rolloutId}/deploygroups/{groupId}/targets", rollout.getId(), firstGroup.getId()) - .accept(MediaType.APPLICATION_JSON).param("q", - "controllerId==" + targets.get(0).getControllerId())) + .accept(MediaType.APPLICATION_JSON).param("q", "controllerId==" + targetInGroup)) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) .andExpect(jsonPath("$.content", hasSize(1))).andExpect(jsonPath("$.total", equalTo(1))); diff --git a/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleResourceTest.java b/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleResourceTest.java index 8e3e367bd..828d05796 100644 --- a/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleResourceTest.java +++ b/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleResourceTest.java @@ -86,8 +86,9 @@ public class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegra final String updateVendor = "newVendor1"; final String updateDescription = "newDescription1"; - SoftwareModule sm = softwareModuleManagement.createSoftwareModule(entityFactory.softwareModule().create().type(osType) - .name(knownSWName).version(knownSWVersion).description(knownSWDescription).vendor(knownSWVendor)); + SoftwareModule sm = softwareModuleManagement + .createSoftwareModule(entityFactory.softwareModule().create().type(osType).name(knownSWName) + .version(knownSWVersion).description(knownSWDescription).vendor(knownSWVendor)); assertThat(sm.getName()).as("Wrong name of the software module").isEqualTo(knownSWName); @@ -140,7 +141,8 @@ public class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegra // check rest of response compared to DB final MgmtArtifact artResult = ResourceUtility .convertArtifactResponse(mvcResult.getResponse().getContentAsString()); - final Long artId = softwareModuleManagement.findSoftwareModuleById(sm.getId()).get().getArtifacts().get(0).getId(); + final Long artId = softwareModuleManagement.findSoftwareModuleById(sm.getId()).get().getArtifacts().get(0) + .getId(); assertThat(artResult.getArtifactId()).as("Wrong artifact id").isEqualTo(artId); assertThat(JsonPath.compile("$._links.self.href").read(mvcResult.getResponse().getContentAsString()).toString()) .as("Link contains no self url") @@ -158,9 +160,8 @@ public class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegra assertThat(artifactManagement.countArtifactsAll()).as("Wrong artifact size").isEqualTo(1); // binary - try (InputStream fileInputStream = artifactManagement - .loadArtifactBinary( - softwareModuleManagement.findSoftwareModuleById(sm.getId()).get().getArtifacts().get(0).getSha1Hash()) + try (InputStream fileInputStream = artifactManagement.loadArtifactBinary( + softwareModuleManagement.findSoftwareModuleById(sm.getId()).get().getArtifacts().get(0).getSha1Hash()) .get().getFileInputStream()) { assertTrue("Wrong artifact content", IOUtils.contentEquals(new ByteArrayInputStream(random), fileInputStream)); @@ -174,8 +175,9 @@ public class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegra .isEqualTo(HashGeneratorUtils.generateMD5(random)); // metadata - assertThat(softwareModuleManagement.findSoftwareModuleById(sm.getId()).get().getArtifacts().get(0).getFilename()) - .as("wrong metadata of the filename").isEqualTo("origFilename"); + assertThat( + softwareModuleManagement.findSoftwareModuleById(sm.getId()).get().getArtifacts().get(0).getFilename()) + .as("wrong metadata of the filename").isEqualTo("origFilename"); } @Test @@ -295,27 +297,24 @@ public class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegra final Artifact artifact2 = artifactManagement.createArtifact(new ByteArrayInputStream(random), sm.getId(), "file2", false); - final MvcResult result = mvc - .perform( - get("/rest/v1/softwaremodules/{smId}/artifacts/{artId}/download", sm.getId(), artifact.getId())) - .andExpect(header().string("ETag", artifact.getSha1Hash())) - .andExpect(content().contentType(MediaType.APPLICATION_OCTET_STREAM)).andReturn(); - - assertTrue("Wrong response content", Arrays.equals(result.getResponse().getContentAsByteArray(), random)); - - final MvcResult result2 = mvc - .perform(get("/rest/v1/softwaremodules/{smId}/artifacts/{artId}/download", sm.getId(), - artifact2.getId())) - .andExpect(header().string("ETag", artifact2.getSha1Hash())) - .andExpect(content().contentType(MediaType.APPLICATION_OCTET_STREAM)).andReturn(); - - assertTrue("Response has wrong response content", - Arrays.equals(result2.getResponse().getContentAsByteArray(), random)); + downloadAndVerify(sm, random, artifact); + downloadAndVerify(sm, random, artifact2); assertThat(softwareModuleManagement.findSoftwareModulesAll(PAGE)).as("Softwaremodule size is wrong").hasSize(1); assertThat(artifactManagement.countArtifactsAll()).isEqualTo(2); } + private void downloadAndVerify(final SoftwareModule sm, final byte[] random, final Artifact artifact) + throws Exception { + final MvcResult result = mvc + .perform( + get("/rest/v1/softwaremodules/{smId}/artifacts/{artId}/download", sm.getId(), artifact.getId())) + .andExpect(status().isOk()).andExpect(content().contentType(MediaType.APPLICATION_OCTET_STREAM)) + .andExpect(header().string("ETag", artifact.getSha1Hash())).andReturn(); + + assertTrue("Wrong response content", Arrays.equals(result.getResponse().getContentAsByteArray(), random)); + } + @Test @Description("Verifies the listing of one defined artifact assigned to a given software module. That includes the artifact metadata and download links.") public void getArtifact() throws Exception { @@ -444,10 +443,9 @@ public class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegra final SoftwareModule toLongName = entityFactory.softwareModule().create().type(osType) .name(RandomStringUtils.randomAscii(80)).build(); - mvc.perform( - post("/rest/v1/softwaremodules").content(JsonBuilder.softwareModules(Arrays.asList(toLongName))) - .contentType(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isBadRequest()); + mvc.perform(post("/rest/v1/softwaremodules").content(JsonBuilder.softwareModules(Arrays.asList(toLongName))) + .contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()) + .andExpect(status().isBadRequest()); // unsupported media type mvc.perform(post("/rest/v1/softwaremodules").content(JsonBuilder.softwareModules(modules)) @@ -707,14 +705,16 @@ public class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegra .isEqualTo("http://localhost/rest/v1/softwaremodules/" + appCreated.getId() + "/artifacts"); assertThat(softwareModuleManagement.findSoftwareModulesAll(PAGE)).as("Wrong softwaremodule size").hasSize(2); - assertThat(softwareModuleManagement.findSoftwareModulesByType(PAGE, osType.getId()).getContent().get(0).getName()) - .as("Softwaremoudle name is wrong").isEqualTo(os.getName()); + assertThat( + softwareModuleManagement.findSoftwareModulesByType(PAGE, osType.getId()).getContent().get(0).getName()) + .as("Softwaremoudle name is wrong").isEqualTo(os.getName()); assertThat(softwareModuleManagement.findSoftwareModulesByType(PAGE, osType.getId()).getContent().get(0) .getCreatedBy()).as("Softwaremoudle created by is wrong").isEqualTo("uploadTester"); assertThat(softwareModuleManagement.findSoftwareModulesByType(PAGE, osType.getId()).getContent().get(0) .getCreatedAt()).as("Softwaremoudle created at is wrong").isGreaterThanOrEqualTo(current); - assertThat(softwareModuleManagement.findSoftwareModulesByType(PAGE, appType.getId()).getContent().get(0).getName()) - .as("Softwaremoudle name is wrong").isEqualTo(ah.getName()); + assertThat( + softwareModuleManagement.findSoftwareModulesByType(PAGE, appType.getId()).getContent().get(0).getName()) + .as("Softwaremoudle name is wrong").isEqualTo(ah.getName()); } @Test @@ -819,10 +819,10 @@ public class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegra .andExpect(jsonPath("[1]key", equalTo(knownKey2))) .andExpect(jsonPath("[1]value", equalTo(knownValue2))); - final SoftwareModuleMetadata metaKey1 = softwareModuleManagement.findSoftwareModuleMetadata(sm.getId(), knownKey1) - .get(); - final SoftwareModuleMetadata metaKey2 = softwareModuleManagement.findSoftwareModuleMetadata(sm.getId(), knownKey2) - .get(); + final SoftwareModuleMetadata metaKey1 = softwareModuleManagement + .findSoftwareModuleMetadata(sm.getId(), knownKey1).get(); + final SoftwareModuleMetadata metaKey2 = softwareModuleManagement + .findSoftwareModuleMetadata(sm.getId(), knownKey2).get(); assertThat(metaKey1.getValue()).as("Metadata key is wrong").isEqualTo(knownValue1); assertThat(metaKey2.getValue()).as("Metadata key is wrong").isEqualTo(knownValue2); @@ -848,8 +848,8 @@ public class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegra .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) .andExpect(jsonPath("key", equalTo(knownKey))).andExpect(jsonPath("value", equalTo(updateValue))); - final SoftwareModuleMetadata assertDS = softwareModuleManagement.findSoftwareModuleMetadata(sm.getId(), knownKey) - .get(); + final SoftwareModuleMetadata assertDS = softwareModuleManagement + .findSoftwareModuleMetadata(sm.getId(), knownKey).get(); assertThat(assertDS.getValue()).as("Metadata is wrong").isEqualTo(updateValue); } diff --git a/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetResourceTest.java b/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetResourceTest.java index 9bb3d4c6d..960bb1af1 100644 --- a/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetResourceTest.java +++ b/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetResourceTest.java @@ -24,6 +24,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers. import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; +import java.net.URISyntaxException; import java.util.Arrays; import java.util.HashMap; import java.util.Iterator; @@ -1322,7 +1323,7 @@ public class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest private Target createSingleTarget(final String controllerId, final String name) { targetManagement.createTarget(entityFactory.target().create().controllerId(controllerId).name(name) .description(TARGET_DESCRIPTION_TEST)); - return controllerManagement.updateLastTargetQuery(controllerId, null); + return controllerManagement.findOrRegisterTargetIfItDoesNotexist(controllerId, LOCALHOST); } /** @@ -1331,13 +1332,14 @@ public class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest * * @param amount * The number of targets to create + * @throws URISyntaxException */ private void createTargetsAlphabetical(final int amount) { char character = 'a'; for (int index = 0; index < amount; index++) { final String str = String.valueOf(character); targetManagement.createTarget(entityFactory.target().create().controllerId(str).name(str).description(str)); - controllerManagement.updateLastTargetQuery(str, null); + controllerManagement.findOrRegisterTargetIfItDoesNotexist(str, LOCALHOST); character++; } } diff --git a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/ControllerManagement.java b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/ControllerManagement.java index 03a251ce1..8eadd1cc6 100644 --- a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/ControllerManagement.java +++ b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/ControllerManagement.java @@ -159,7 +159,11 @@ public interface ControllerManagement { Page findActionStatusByAction(@NotNull Pageable pageReq, @NotNull Long actionId); /** - * register new target in the repository (plug-and-play). + * Register new target in the repository (plug-and-play) and in case it + * already exists updates {@link Target#getAddress()} and + * {@link Target#getLastTargetQuery()} and switches if + * {@link TargetUpdateStatus#UNKNOWN} to + * {@link TargetUpdateStatus#REGISTERED}. * * @param controllerId * reference @@ -274,23 +278,6 @@ public interface ControllerManagement { @PreAuthorize(SpringEvalExpressions.IS_CONTROLLER) Target updateControllerAttributes(@NotEmpty String controllerId, @NotNull Map attributes); - /** - * Refreshes the time of the last time the controller has been connected to - * the server. Switches {@link TargetUpdateStatus#UNKNOWN} to - * {@link TargetUpdateStatus#REGISTERED} if necessary. - * - * @param controllerId - * of the target to to update - * @param address - * the client address of the target, might be {@code null} - * @return the updated target - * - * @throws EntityNotFoundException - * if target with given ID could not be found - */ - @PreAuthorize(SpringEvalExpressions.IS_CONTROLLER) - Target updateLastTargetQuery(@NotEmpty String controllerId, URI address); - /** * Finds {@link Target} based on given controller ID returns found Target * without details, i.e. NO {@link Target#getTags()} and diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaControllerManagement.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaControllerManagement.java index 7be41cbda..e4ce85e09 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaControllerManagement.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaControllerManagement.java @@ -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 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); } diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/ControllerManagementTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/ControllerManagementTest.java index 3b95c594c..0ace0f03d 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/ControllerManagementTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/ControllerManagementTest.java @@ -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"); } diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/DeploymentManagementTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/DeploymentManagementTest.java index d6d5b83b8..2b69d87ed 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/DeploymentManagementTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/DeploymentManagementTest.java @@ -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); } diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/DistributionSetManagementTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/DistributionSetManagementTest.java index b79a89f20..1c264cc86 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/DistributionSetManagementTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/DistributionSetManagementTest.java @@ -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 ds100Group1 = testdataFactory.createDistributionSets("", 100); - Collection ds100Group2 = testdataFactory.createDistributionSets("test2", 100); + List ds5Group1 = testdataFactory.createDistributionSets("", 5); + List 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 expected = Lists.newArrayListWithExpectedSize(203); - expected.addAll(ds100Group1); - expected.addAll(ds100Group2); + List 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); diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/RolloutManagementTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/RolloutManagementTest.java index 4cf194845..5a3758195 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/RolloutManagementTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/RolloutManagementTest.java @@ -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 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 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); } diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/TargetManagementTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/TargetManagementTest.java index 47fff1a2c..6a281a466 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/TargetManagementTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/TargetManagementTest.java @@ -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"); diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/TenantConfigurationManagementTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/TenantConfigurationManagementTest.java index b124ec51a..741d2bfdf 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/TenantConfigurationManagementTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/TenantConfigurationManagementTest.java @@ -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.") diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/event/RepositoryEntityEventTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/event/RepositoryEntityEventTest.java index 6aa9c6d8f..a90f05ef0 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/event/RepositoryEntityEventTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/event/RepositoryEntityEventTest.java @@ -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 waitForEvent(final Class eventType, final long timeout, final TimeUnit timeUnit) - throws InterruptedException { + public T waitForEvent(final Class 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; } } diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/rsql/RSQLTargetFieldTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/rsql/RSQLTargetFieldTest.java index f86588ee3..dbde2bd09 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/rsql/RSQLTargetFieldTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/rsql/RSQLTargetFieldTest.java @@ -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"); diff --git a/hawkbit-repository/hawkbit-repository-test/src/main/java/org/eclipse/hawkbit/repository/test/util/AbstractIntegrationTest.java b/hawkbit-repository/hawkbit-repository-test/src/main/java/org/eclipse/hawkbit/repository/test/util/AbstractIntegrationTest.java index 51354226b..321e22511 100644 --- a/hawkbit-repository/hawkbit-repository-test/src/main/java/org/eclipse/hawkbit/repository/test/util/AbstractIntegrationTest.java +++ b/hawkbit-repository/hawkbit-repository-test/src/main/java/org/eclipse/hawkbit/repository/test/util/AbstractIntegrationTest.java @@ -13,12 +13,14 @@ import static org.eclipse.hawkbit.im.authentication.SpPermission.SpringEvalExpre import java.io.File; import java.io.IOException; +import java.net.URI; import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.stream.Collectors; import org.apache.commons.io.FileUtils; +import org.apache.commons.lang3.RandomStringUtils; import org.eclipse.hawkbit.artifact.repository.ArtifactFilesystemProperties; import org.eclipse.hawkbit.artifact.repository.ArtifactRepository; import org.eclipse.hawkbit.cache.TenantAwareCacheManager; @@ -52,11 +54,12 @@ import org.eclipse.hawkbit.repository.model.Target; import org.eclipse.hawkbit.repository.model.TargetWithActionType; import org.eclipse.hawkbit.repository.test.TestConfiguration; import org.eclipse.hawkbit.repository.test.matcher.EventVerifier; -import org.eclipse.hawkbit.security.ExcludePathAwareShallowETagFilter; import org.eclipse.hawkbit.security.SystemSecurityContext; import org.eclipse.hawkbit.tenancy.TenantAware; import org.junit.After; +import org.junit.AfterClass; import org.junit.Before; +import org.junit.BeforeClass; import org.junit.Rule; import org.junit.rules.TestWatcher; import org.junit.runner.Description; @@ -67,8 +70,6 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.SpringApplicationConfiguration; import org.springframework.cloud.bus.ServiceMatcher; import org.springframework.cloud.stream.test.binder.TestSupportBinderAutoConfiguration; -import org.springframework.context.EnvironmentAware; -import org.springframework.core.env.Environment; import org.springframework.data.auditing.AuditingHandler; import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Pageable; @@ -81,14 +82,8 @@ import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.TestExecutionListeners.MergeMode; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import org.springframework.test.context.web.WebAppConfiguration; -import org.springframework.test.web.servlet.MockMvc; -import org.springframework.test.web.servlet.setup.DefaultMockMvcBuilder; -import org.springframework.test.web.servlet.setup.MockMvcBuilders; -import org.springframework.web.context.WebApplicationContext; @RunWith(SpringJUnit4ClassRunner.class) -@WebAppConfiguration @ActiveProfiles({ "test" }) @WithUser(principal = "bumlux", allSpPermissions = true, authorities = { CONTROLLER_ROLE, SYSTEM_ROLE }) @SpringApplicationConfiguration(classes = { TestConfiguration.class, TestSupportBinderAutoConfiguration.class }) @@ -102,11 +97,13 @@ import org.springframework.web.context.WebApplicationContext; // important! @TestExecutionListeners(inheritListeners = true, listeners = { EventVerifier.class, CleanupTestExecutionListener.class, MySqlTestDatabase.class }, mergeMode = MergeMode.MERGE_WITH_DEFAULTS) -public abstract class AbstractIntegrationTest implements EnvironmentAware { +public abstract class AbstractIntegrationTest { private static final Logger LOG = LoggerFactory.getLogger(AbstractIntegrationTest.class); protected static final Pageable PAGE = new PageRequest(0, 400, new Sort(Direction.ASC, "id")); + protected static final URI LOCALHOST = URI.create("http://127.0.0.1"); + /** * Constant for MediaType HAL with encoding UTF-8. Necessary since Spring * version 4.3.2 @see https://jira.spring.io/browse/SPR-14577 @@ -154,9 +151,6 @@ public abstract class AbstractIntegrationTest implements EnvironmentAware { @Autowired protected ArtifactManagement artifactManagement; - @Autowired - protected WebApplicationContext context; - @Autowired protected AuditingHandler auditingHandler; @@ -190,8 +184,6 @@ public abstract class AbstractIntegrationTest implements EnvironmentAware { @Autowired protected QuotaManagement quotaManagement; - protected MockMvc mvc; - protected SoftwareModuleType osType; protected SoftwareModuleType appType; protected SoftwareModuleType runtimeType; @@ -226,13 +218,6 @@ public abstract class AbstractIntegrationTest implements EnvironmentAware { } }; - protected Environment environment = null; - - @Override - public void setEnvironment(final Environment environment) { - this.environment = environment; - } - protected DistributionSetAssignmentResult assignDistributionSet(final Long dsID, final String controllerId) { return deploymentManagement.assignDistributionSet(dsID, Arrays.asList( new TargetWithActionType(controllerId, ActionType.FORCED, RepositoryModelConstants.NO_FORCE_TIME))); @@ -278,7 +263,6 @@ public abstract class AbstractIntegrationTest implements EnvironmentAware { @Before public void before() throws Exception { - mvc = createMvcWebAppContext().build(); final String description = "Updated description."; osType = securityRule @@ -299,20 +283,32 @@ public abstract class AbstractIntegrationTest implements EnvironmentAware { standardDsType = securityRule.runAsPrivileged(() -> testdataFactory.findOrCreateDefaultTestDsType()); } + private static String artifactDirectory = "./artifactrepo/" + RandomStringUtils.randomAlphanumeric(20); + @After public void cleanUp() { - try { - FileUtils.deleteDirectory(new File(artifactFilesystemProperties.getPath())); - } catch (final IOException | IllegalArgumentException e) { - LOG.warn("Cannot cleanup file-directory", e); + if (new File(artifactDirectory).exists()) { + try { + FileUtils.cleanDirectory(new File(artifactDirectory)); + } catch (final IOException | IllegalArgumentException e) { + LOG.warn("Cannot cleanup file-directory", e); + } } } - protected DefaultMockMvcBuilder createMvcWebAppContext() { - return MockMvcBuilders.webAppContextSetup(context) - .addFilter(new ExcludePathAwareShallowETagFilter( - "/rest/v1/softwaremodules/{smId}/artifacts/{artId}/download", - "/{tenant}/controller/v1/{controllerId}/softwaremodules/{softwareModuleId}/artifacts/**", - "/api/v1/downloadserver/**")); + @BeforeClass + public static void beforeClass() { + System.setProperty("org.eclipse.hawkbit.repository.file.path", artifactDirectory); + } + + @AfterClass + public static void afterClass() { + if (new File(artifactDirectory).exists()) { + try { + FileUtils.deleteDirectory(new File(artifactDirectory)); + } catch (final IOException | IllegalArgumentException e) { + LOG.warn("Cannot delete file-directory", e); + } + } } } diff --git a/hawkbit-repository/hawkbit-repository-test/src/main/java/org/eclipse/hawkbit/repository/test/util/TestdataFactory.java b/hawkbit-repository/hawkbit-repository-test/src/main/java/org/eclipse/hawkbit/repository/test/util/TestdataFactory.java index a7bc20504..f114aa539 100644 --- a/hawkbit-repository/hawkbit-repository-test/src/main/java/org/eclipse/hawkbit/repository/test/util/TestdataFactory.java +++ b/hawkbit-repository/hawkbit-repository-test/src/main/java/org/eclipse/hawkbit/repository/test/util/TestdataFactory.java @@ -35,6 +35,7 @@ import org.eclipse.hawkbit.repository.SoftwareModuleTypeManagement; import org.eclipse.hawkbit.repository.TagManagement; import org.eclipse.hawkbit.repository.TargetManagement; import org.eclipse.hawkbit.repository.builder.TagCreate; +import org.eclipse.hawkbit.repository.builder.TargetCreate; import org.eclipse.hawkbit.repository.model.Action; import org.eclipse.hawkbit.repository.model.Action.Status; import org.eclipse.hawkbit.repository.model.ActionStatus; @@ -752,12 +753,13 @@ public class TestdataFactory { * @return {@link List} of {@link Target} entities */ public List createTargets(final int number) { - final List targets = Lists.newArrayListWithExpectedSize(number); + + final List targets = Lists.newArrayListWithExpectedSize(number); for (int i = 0; i < number; i++) { - targets.add(createTarget(DEFAULT_CONTROLLER_ID + i)); + targets.add(entityFactory.target().create().controllerId(DEFAULT_CONTROLLER_ID + i)); } - return targets; + return targetManagement.createTargets(targets); } /** diff --git a/hawkbit-repository/hawkbit-repository-test/src/main/resources/hawkbit-test-defaults.properties b/hawkbit-repository/hawkbit-repository-test/src/main/resources/hawkbit-test-defaults.properties index 0306a4dfe..849f8213e 100644 --- a/hawkbit-repository/hawkbit-repository-test/src/main/resources/hawkbit-test-defaults.properties +++ b/hawkbit-repository/hawkbit-repository-test/src/main/resources/hawkbit-test-defaults.properties @@ -9,7 +9,7 @@ # Test utility properties for easier fault investigation - START ## Logging - START -logging.level.=INFO +logging.level.root=ERROR logging.level.org.eclipse.hawkbit.repository.test.matcher.EventVerifier=ERROR logging.level.org.eclipse.persistence=ERROR spring.datasource.eclipselink.logging.logger=JavaLogger diff --git a/hawkbit-rest-core/src/main/java/org/eclipse/hawkbit/rest/RestConfiguration.java b/hawkbit-rest-core/src/main/java/org/eclipse/hawkbit/rest/RestConfiguration.java index b78325440..896a4e09f 100644 --- a/hawkbit-rest-core/src/main/java/org/eclipse/hawkbit/rest/RestConfiguration.java +++ b/hawkbit-rest-core/src/main/java/org/eclipse/hawkbit/rest/RestConfiguration.java @@ -10,23 +10,24 @@ package org.eclipse.hawkbit.rest; import javax.servlet.http.HttpServletResponse; +import org.eclipse.hawkbit.rest.exception.ResponseExceptionHandler; import org.eclipse.hawkbit.rest.util.FilterHttpResponse; import org.eclipse.hawkbit.rest.util.HttpResponseFactoryBean; import org.eclipse.hawkbit.rest.util.RequestResponseContextHolder; import org.springframework.beans.factory.FactoryBean; import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Scope; import org.springframework.hateoas.config.EnableHypermediaSupport; import org.springframework.hateoas.config.EnableHypermediaSupport.HypermediaType; +import org.springframework.http.HttpStatus; +import org.springframework.web.bind.annotation.ControllerAdvice; import org.springframework.web.context.WebApplicationContext; /** * Configuration for Rest api. */ @Configuration -@ComponentScan @EnableHypermediaSupport(type = { HypermediaType.HAL }) public class RestConfiguration { @@ -34,7 +35,7 @@ public class RestConfiguration { * Create filter for {@link HttpServletResponse}. */ @Bean - public FilterHttpResponse filterHttpResponse() { + FilterHttpResponse filterHttpResponse() { return new FilterHttpResponse(); } @@ -42,7 +43,7 @@ public class RestConfiguration { * Create factory bean for {@link HttpServletResponse}. */ @Bean - public FactoryBean httpResponseFactoryBean() { + FactoryBean httpResponseFactoryBean() { return new HttpResponseFactoryBean(); } @@ -51,7 +52,16 @@ public class RestConfiguration { */ @Bean @Scope(value = WebApplicationContext.SCOPE_REQUEST) - public RequestResponseContextHolder requestResponseContextHolder() { + RequestResponseContextHolder requestResponseContextHolder() { return new RequestResponseContextHolder(); } + + /** + * {@link ControllerAdvice} for mapping {@link RuntimeException}s from the + * repository to {@link HttpStatus} codes. + */ + @Bean + ResponseExceptionHandler responseExceptionHandler() { + return new ResponseExceptionHandler(); + } } diff --git a/hawkbit-rest-core/src/test/java/org/eclipse/hawkbit/rest/AbstractRestIntegrationTest.java b/hawkbit-rest-core/src/test/java/org/eclipse/hawkbit/rest/AbstractRestIntegrationTest.java index 4f0c9e760..050d9c183 100644 --- a/hawkbit-rest-core/src/test/java/org/eclipse/hawkbit/rest/AbstractRestIntegrationTest.java +++ b/hawkbit-rest-core/src/test/java/org/eclipse/hawkbit/rest/AbstractRestIntegrationTest.java @@ -11,22 +11,47 @@ package org.eclipse.hawkbit.rest; import org.eclipse.hawkbit.repository.jpa.RepositoryApplicationConfiguration; import org.eclipse.hawkbit.repository.test.util.AbstractIntegrationTest; import org.eclipse.hawkbit.rest.util.FilterHttpResponse; +import org.eclipse.hawkbit.security.ExcludePathAwareShallowETagFilter; +import org.junit.Before; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.SpringApplicationConfiguration; +import org.springframework.test.context.web.WebAppConfiguration; +import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.setup.DefaultMockMvcBuilder; +import org.springframework.test.web.servlet.setup.MockMvcBuilders; +import org.springframework.web.context.WebApplicationContext; /** * Abstract Test for Rest tests. */ +@WebAppConfiguration @SpringApplicationConfiguration(classes = { RestConfiguration.class, RepositoryApplicationConfiguration.class }) public abstract class AbstractRestIntegrationTest extends AbstractIntegrationTest { + protected MockMvc mvc; + @Autowired private FilterHttpResponse filterHttpResponse; + @Autowired + protected WebApplicationContext webApplicationContext; + @Override - protected DefaultMockMvcBuilder createMvcWebAppContext() { - final DefaultMockMvcBuilder createMvcWebAppContext = super.createMvcWebAppContext(); - return createMvcWebAppContext.addFilter(filterHttpResponse); + @Before + public void before() throws Exception { + super.before(); + mvc = createMvcWebAppContext(webApplicationContext).build(); + } + + protected DefaultMockMvcBuilder createMvcWebAppContext(final WebApplicationContext context) { + final DefaultMockMvcBuilder createMvcWebAppContext = MockMvcBuilders.webAppContextSetup(context); + + createMvcWebAppContext.addFilter( + new ExcludePathAwareShallowETagFilter("/rest/v1/softwaremodules/{smId}/artifacts/{artId}/download", + "/{tenant}/controller/v1/{controllerId}/softwaremodules/{softwareModuleId}/artifacts/**", + "/api/v1/downloadserver/**")); + createMvcWebAppContext.addFilter(filterHttpResponse); + + return createMvcWebAppContext; } } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/DistributionsView.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/DistributionsView.java index e60f4a79d..758793dac 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/DistributionsView.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/DistributionsView.java @@ -38,8 +38,8 @@ import org.eclipse.hawkbit.ui.distributions.smtype.DistSMTypeFilterLayout; import org.eclipse.hawkbit.ui.distributions.state.ManageDistUIState; import org.eclipse.hawkbit.ui.management.event.DistributionTableEvent; import org.eclipse.hawkbit.ui.menu.DashboardMenuItem; -import org.eclipse.hawkbit.ui.push.DistributionCreatedEventContainer; -import org.eclipse.hawkbit.ui.push.DistributionDeletedEventContainer; +import org.eclipse.hawkbit.ui.push.DistributionSetCreatedEventContainer; +import org.eclipse.hawkbit.ui.push.DistributionSetDeletedEventContainer; import org.eclipse.hawkbit.ui.push.SoftwareModuleCreatedEventContainer; import org.eclipse.hawkbit.ui.push.SoftwareModuleDeletedEventContainer; import org.eclipse.hawkbit.ui.utils.SPUIDefinitions; @@ -278,8 +278,8 @@ public class DistributionsView extends AbstractNotificationView implements Brows protected Map, RefreshableContainer> getSupportedPushEvents() { final Map, RefreshableContainer> supportedEvents = Maps.newHashMapWithExpectedSize(2); - supportedEvents.put(DistributionCreatedEventContainer.class, distributionTableLayout.getTable()); - supportedEvents.put(DistributionDeletedEventContainer.class, distributionTableLayout.getTable()); + supportedEvents.put(DistributionSetCreatedEventContainer.class, distributionTableLayout.getTable()); + supportedEvents.put(DistributionSetDeletedEventContainer.class, distributionTableLayout.getTable()); supportedEvents.put(SoftwareModuleCreatedEventContainer.class, softwareModuleTableLayout.getTable()); supportedEvents.put(SoftwareModuleDeletedEventContainer.class, softwareModuleTableLayout.getTable()); diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/DeploymentView.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/DeploymentView.java index 513a461b2..8ffabb288 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/DeploymentView.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/DeploymentView.java @@ -47,8 +47,8 @@ import org.eclipse.hawkbit.ui.management.targettable.TargetTableLayout; import org.eclipse.hawkbit.ui.management.targettag.CreateUpdateTargetTagLayoutWindow; import org.eclipse.hawkbit.ui.management.targettag.TargetTagFilterLayout; import org.eclipse.hawkbit.ui.menu.DashboardMenuItem; -import org.eclipse.hawkbit.ui.push.DistributionCreatedEventContainer; -import org.eclipse.hawkbit.ui.push.DistributionDeletedEventContainer; +import org.eclipse.hawkbit.ui.push.DistributionSetCreatedEventContainer; +import org.eclipse.hawkbit.ui.push.DistributionSetDeletedEventContainer; import org.eclipse.hawkbit.ui.push.DistributionSetTagCreatedEventContainer; import org.eclipse.hawkbit.ui.push.DistributionSetTagDeletedEventContainer; import org.eclipse.hawkbit.ui.push.DistributionSetTagUpdatedEventContainer; @@ -402,8 +402,8 @@ public class DeploymentView extends AbstractNotificationView implements BrowserW supportedEvents.put(TargetCreatedEventContainer.class, targetTableLayout.getTable()); supportedEvents.put(TargetDeletedEventContainer.class, targetTableLayout.getTable()); - supportedEvents.put(DistributionCreatedEventContainer.class, distributionTableLayout.getTable()); - supportedEvents.put(DistributionDeletedEventContainer.class, distributionTableLayout.getTable()); + supportedEvents.put(DistributionSetCreatedEventContainer.class, distributionTableLayout.getTable()); + supportedEvents.put(DistributionSetDeletedEventContainer.class, distributionTableLayout.getTable()); supportedEvents.put(TargetTagCreatedEventContainer.class, targetTagFilterLayout); supportedEvents.put(TargetTagDeletedEventContainer.class, targetTagFilterLayout); diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/push/DelayedEventBusPushStrategy.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/push/DelayedEventBusPushStrategy.java index 5f590bf8e..3cd952001 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/push/DelayedEventBusPushStrategy.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/push/DelayedEventBusPushStrategy.java @@ -96,7 +96,7 @@ public class DelayedEventBusPushStrategy implements EventPushStrategy, Applicati this.delay = delay; } - private boolean isEventProvided(final org.eclipse.hawkbit.repository.event.TenantAwareEvent event) { + private boolean isEventProvided(final TenantAwareEvent event) { return eventProvider.getEvents().containsKey(event.getClass()); } @@ -174,8 +174,7 @@ public class DelayedEventBusPushStrategy implements EventPushStrategy, Applicati * @return {@code true} if the event can be dispatched to the UI * otherwise {@code false} */ - private boolean eventSecurityCheck(final SecurityContext userContext, - final org.eclipse.hawkbit.repository.event.TenantAwareEvent event) { + private boolean eventSecurityCheck(final SecurityContext userContext, final TenantAwareEvent event) { if (userContext == null || userContext.getAuthentication() == null) { return false; } @@ -187,8 +186,7 @@ public class DelayedEventBusPushStrategy implements EventPushStrategy, Applicati return false; } - private void doDispatch(final List events, - final WrappedSession wrappedSession) { + private void doDispatch(final List events, final WrappedSession wrappedSession) { final SecurityContext userContext = (SecurityContext) wrappedSession .getAttribute(HttpSessionSecurityContextRepository.SPRING_SECURITY_CONTEXT_KEY); final SecurityContext oldContext = SecurityContextHolder.getContext(); diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/push/DistributionCreatedEventContainer.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/push/DistributionSetCreatedEventContainer.java similarity index 83% rename from hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/push/DistributionCreatedEventContainer.java rename to hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/push/DistributionSetCreatedEventContainer.java index 1c1ace1b7..1ab77f7d2 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/push/DistributionCreatedEventContainer.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/push/DistributionSetCreatedEventContainer.java @@ -16,11 +16,11 @@ import org.eclipse.hawkbit.repository.event.remote.entity.DistributionSetCreated * EventHolder for {@link DistributionSetCreatedEvent}s. * */ -public class DistributionCreatedEventContainer implements EventContainer { +public class DistributionSetCreatedEventContainer implements EventContainer { private static final String I18N_UNREAD_NOTIFICATION_UNREAD_MESSAGE = "distribution.created.event.container.notifcation.message"; private final List events; - DistributionCreatedEventContainer(final List events) { + DistributionSetCreatedEventContainer(final List events) { this.events = events; } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/push/DistributionDeletedEventContainer.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/push/DistributionSetDeletedEventContainer.java similarity index 83% rename from hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/push/DistributionDeletedEventContainer.java rename to hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/push/DistributionSetDeletedEventContainer.java index 917c6462d..1dce0235f 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/push/DistributionDeletedEventContainer.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/push/DistributionSetDeletedEventContainer.java @@ -16,11 +16,11 @@ import org.eclipse.hawkbit.repository.event.remote.DistributionSetDeletedEvent; * EventHolder for {@link DistributionSetDeletedEvent}s. * */ -public class DistributionDeletedEventContainer implements EventContainer { +public class DistributionSetDeletedEventContainer implements EventContainer { private static final String I18N_UNREAD_NOTIFICATION_UNREAD_MESSAGE = "distribution.deleted.event.container.notifcation.message"; private final List events; - DistributionDeletedEventContainer(final List events) { + DistributionSetDeletedEventContainer(final List events) { this.events = events; } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/push/HawkbitEventProvider.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/push/HawkbitEventProvider.java index ebd60a18e..0409003ad 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/push/HawkbitEventProvider.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/push/HawkbitEventProvider.java @@ -56,8 +56,8 @@ public class HawkbitEventProvider implements UIEventProvider { EVENTS.put(CancelTargetAssignmentEvent.class, CancelTargetAssignmentEventContainer.class); EVENTS.put(DistributionSetUpdatedEvent.class, DistributionSetUpdatedEventContainer.class); - EVENTS.put(DistributionSetDeletedEvent.class, DistributionDeletedEventContainer.class); - EVENTS.put(DistributionSetCreatedEvent.class, DistributionCreatedEventContainer.class); + EVENTS.put(DistributionSetDeletedEvent.class, DistributionSetDeletedEventContainer.class); + EVENTS.put(DistributionSetCreatedEvent.class, DistributionSetCreatedEventContainer.class); EVENTS.put(RolloutGroupChangedEvent.class, RolloutGroupChangedEventContainer.class); EVENTS.put(RolloutChangedEvent.class, RolloutChangeEventContainer.class); diff --git a/pom.xml b/pom.xml index 744f28cbc..9d21f0f20 100644 --- a/pom.xml +++ b/pom.xml @@ -162,7 +162,7 @@ 1.1.6 1.0.2 19.0 - 1.5.7 + 2.0.2 1.50.5 2.2.4 1.1.7 @@ -194,6 +194,11 @@ ${jacoco.outputDir}/jacoco-it.exec ${jacoco.reportPath},${jacoco.itReportPath} + + + + + 1 @@ -364,7 +369,7 @@ ${maven.surefire.plugin.version} true - 1 + ${surefire.forkcount} ${jacoco.agent.ut.arg}