Test and build performance improvements (#552)
* Small build perf improvements. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Remove dead code. Stabilize test. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Further optimizations Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Upgrade mariadb driver. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Raise timeouts for more robustness on slower build environments. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Move webappcontext into rest tests. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Raised timeout. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Remove test dependency on target to groups distribution order. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Code reuse. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Context available to tests. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Typos fixed. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Fix PollEvent send. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Fix typos. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Test log readability and removed unused method from CM. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Remove empty payload. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Stabilize tests. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Raised timeout. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Fixed fire directory change during one test class run. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>
This commit is contained in:
@@ -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<Target> 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
|
||||
|
||||
@@ -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<Target> toAssign = new ArrayList<>();
|
||||
toAssign.add(target);
|
||||
final List<Target> 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<Target> 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();
|
||||
|
||||
@@ -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"))
|
||||
|
||||
1
hawkbit-dmf/hawkbit-dmf-amqp/.gitignore
vendored
Normal file
1
hawkbit-dmf/hawkbit-dmf-amqp/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
/artifactrepo/
|
||||
@@ -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<Target> findTargetByControllerID = targetManagement
|
||||
.findTargetByControllerID(REGISTER_TARGET);
|
||||
final Optional<Target> 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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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<org.eclipse.hawkbit.repository.model.ActionStatus> actionStatusList = deploymentManagement
|
||||
final List<ActionStatus> 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> status = actionStatusList.stream().map(actionStatus -> actionStatus.getStatus())
|
||||
final List<Status> status = actionStatusList.stream().map(ActionStatus::getStatus)
|
||||
.collect(Collectors.toList());
|
||||
assertThat(status).containsOnly(expectedActionStates);
|
||||
|
||||
|
||||
@@ -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<SoftwareModule> expectedSoftwareModulesInMessage) {
|
||||
registerAndAssertTargetWithExistingTenant(REGISTER_TARGET, 1, expectedStatus, CREATED_BY);
|
||||
final TargetUpdateStatus expectedStatus, final Set<SoftwareModule> 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<SoftwareModule> dsModules) {
|
||||
final Message replyMessage = assertReplyMessageHeader(EventTopic.DOWNLOAD_AND_INSTALL);
|
||||
protected void assertDownloadAndInstallMessage(final Set<SoftwareModule> 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<String, Object> 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<Target> findTargetBasedOnNewPolltime(final String controllerId, final Long pollingTimeTargetOld) {
|
||||
private Optional<Target> findTargetBasedOnNewVersion(final String controllerId, final int version) {
|
||||
final Optional<Target> 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) {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
|
||||
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
|
||||
|
||||
-->
|
||||
<configuration>
|
||||
<include resource="org/springframework/boot/logging/logback/base.xml" />
|
||||
|
||||
<logger name="org.eclipse.hawkbit.eventbus.DeadEventListener" level="WARN" />
|
||||
<Logger name="org.springframework.boot.actuate.audit.listener.AuditListener" level="WARN" />
|
||||
|
||||
<Logger name="org.hibernate.validator.internal.util.Version" level="WARN" />
|
||||
|
||||
<Logger name="org.apache.coyote.http11.Http11NioProtocol" level="WARN" />
|
||||
<Logger name="org.apache.tomcat.util.net.NioSelectorPool" level="WARN" />
|
||||
<Logger name="org.apache.tomcat.jdbc.pool.ConnectionPool" level="DEBUG" />
|
||||
<Logger name="org.apache.catalina.startup.DigesterFactory" level="ERROR" />
|
||||
|
||||
|
||||
<!-- <Logger name="org.eclipse.hawkbit.rest.util.MockMvcResultPrinter" level="DEBUG" /> -->
|
||||
|
||||
<!-- Security Log with hints on potential attacks -->
|
||||
<logger name="server-security" level="INFO" />
|
||||
|
||||
<Root level="INFO">
|
||||
<appender-ref ref="CONSOLE" />
|
||||
</Root>
|
||||
|
||||
</configuration>
|
||||
1
hawkbit-mgmt-resource/.gitignore
vendored
Normal file
1
hawkbit-mgmt-resource/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
/artifactrepo/
|
||||
@@ -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<Target> 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)));
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -159,7 +159,11 @@ public interface ControllerManagement {
|
||||
Page<ActionStatus> 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<String, String> 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
|
||||
|
||||
@@ -126,17 +126,6 @@ public class JpaControllerManagement implements ControllerManagement {
|
||||
.getConfigurationValue(TenantConfigurationKey.POLLING_TIME_INTERVAL, String.class).getValue());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public Target updateLastTargetQuery(final String controllerId, final URI address) {
|
||||
final JpaTarget target = (JpaTarget) targetRepository.findByControllerId(controllerId)
|
||||
.orElseThrow(() -> new EntityNotFoundException(Target.class, controllerId));
|
||||
|
||||
return updateTargetStatus(target, null, System.currentTimeMillis(), address);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Action> getActionForDownloadByTargetAndSoftwareModule(final String controllerId,
|
||||
final Long moduleId) {
|
||||
@@ -221,27 +210,20 @@ public class JpaControllerManagement implements ControllerManagement {
|
||||
return result;
|
||||
}
|
||||
|
||||
return updateTargetStatus(target, null, System.currentTimeMillis(), address);
|
||||
return updateTargetStatus(target, address);
|
||||
}
|
||||
|
||||
private Target updateTargetStatus(final JpaTarget toUpdate, final TargetUpdateStatus status,
|
||||
final Long lastTargetQuery, final URI address) {
|
||||
if (status != null) {
|
||||
toUpdate.setUpdateStatus(status);
|
||||
}
|
||||
if (lastTargetQuery != null) {
|
||||
toUpdate.setLastTargetQuery(lastTargetQuery);
|
||||
}
|
||||
private Target updateTargetStatus(final JpaTarget toUpdate, final URI address) {
|
||||
|
||||
if (TargetUpdateStatus.UNKNOWN.equals(toUpdate.getUpdateStatus())) {
|
||||
toUpdate.setUpdateStatus(TargetUpdateStatus.REGISTERED);
|
||||
}
|
||||
|
||||
if (address != null) {
|
||||
toUpdate.setAddress(address.toString());
|
||||
afterCommit.afterCommit(
|
||||
() -> eventPublisher.publishEvent(new TargetPollEvent(toUpdate, applicationContext.getId())));
|
||||
}
|
||||
toUpdate.setAddress(address.toString());
|
||||
toUpdate.setLastTargetQuery(System.currentTimeMillis());
|
||||
|
||||
afterCommit.afterCommit(
|
||||
() -> eventPublisher.publishEvent(new TargetPollEvent(toUpdate, applicationContext.getId())));
|
||||
|
||||
return targetRepository.save(toUpdate);
|
||||
}
|
||||
|
||||
@@ -14,7 +14,6 @@ import static org.eclipse.hawkbit.im.authentication.SpPermission.SpringEvalExpre
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -61,7 +60,7 @@ import ru.yandex.qatools.allure.annotations.Stories;
|
||||
@Features("Component Tests - Repository")
|
||||
@Stories("Controller Management")
|
||||
public class ControllerManagementTest extends AbstractJpaIntegrationTest {
|
||||
private static final URI LOCALHOST = URI.create("http://127.0.0.1");
|
||||
|
||||
@Autowired
|
||||
private RepositoryProperties repositoryProperties;
|
||||
|
||||
@@ -121,9 +120,6 @@ public class ControllerManagementTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
verifyThrownExceptionBy(() -> controllerManagement.updateControllerAttributes(NOT_EXIST_ID, Maps.newHashMap()),
|
||||
"Target");
|
||||
|
||||
verifyThrownExceptionBy(
|
||||
() -> controllerManagement.updateLastTargetQuery(NOT_EXIST_ID, new URI("http://test.com")), "Target");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -424,17 +420,15 @@ public class ControllerManagementTest extends AbstractJpaIntegrationTest {
|
||||
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1),
|
||||
@Expect(type = TargetPollEvent.class, count = 2) })
|
||||
public void findOrRegisterTargetIfItDoesNotexist() {
|
||||
final Target target = controllerManagement.findOrRegisterTargetIfItDoesNotexist("AA",
|
||||
LOCALHOST);
|
||||
final Target target = controllerManagement.findOrRegisterTargetIfItDoesNotexist("AA", LOCALHOST);
|
||||
assertThat(target).as("target should not be null").isNotNull();
|
||||
|
||||
final Target sameTarget = controllerManagement.findOrRegisterTargetIfItDoesNotexist("AA",
|
||||
LOCALHOST);
|
||||
final Target sameTarget = controllerManagement.findOrRegisterTargetIfItDoesNotexist("AA", LOCALHOST);
|
||||
assertThat(target.getId()).as("Target should be the equals").isEqualTo(sameTarget.getId());
|
||||
assertThat(targetRepository.count()).as("Only 1 target should be registred").isEqualTo(1L);
|
||||
|
||||
assertThatExceptionOfType(ConstraintViolationException.class).isThrownBy(
|
||||
() -> controllerManagement.findOrRegisterTargetIfItDoesNotexist("", LOCALHOST))
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.isThrownBy(() -> controllerManagement.findOrRegisterTargetIfItDoesNotexist("", LOCALHOST))
|
||||
.as("register target with empty controllerId should fail");
|
||||
}
|
||||
|
||||
|
||||
@@ -869,17 +869,16 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
ds.getId(), ActionType.SOFT,
|
||||
org.eclipse.hawkbit.repository.model.RepositoryModelConstants.NO_FORCE_TIME,
|
||||
Arrays.asList(target.getControllerId()));
|
||||
final Action action = deploymentManagement.findActionWithDetails(assignDistributionSet.getActions().get(0))
|
||||
.get();
|
||||
final Long actionId = assignDistributionSet.getActions().get(0);
|
||||
// verify preparation
|
||||
Action findAction = deploymentManagement.findAction(action.getId()).get();
|
||||
Action findAction = deploymentManagement.findAction(actionId).get();
|
||||
assertThat(findAction.getActionType()).as("action type is wrong").isEqualTo(ActionType.SOFT);
|
||||
|
||||
// test
|
||||
deploymentManagement.forceTargetAction(action.getId());
|
||||
deploymentManagement.forceTargetAction(actionId);
|
||||
|
||||
// verify test
|
||||
findAction = deploymentManagement.findAction(action.getId()).get();
|
||||
findAction = deploymentManagement.findAction(actionId).get();
|
||||
assertThat(findAction.getActionType()).as("action type is wrong").isEqualTo(ActionType.FORCED);
|
||||
}
|
||||
|
||||
@@ -894,18 +893,17 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
ds.getId(), ActionType.FORCED,
|
||||
org.eclipse.hawkbit.repository.model.RepositoryModelConstants.NO_FORCE_TIME,
|
||||
Arrays.asList(target.getControllerId()));
|
||||
final Action action = deploymentManagement.findActionWithDetails(assignDistributionSet.getActions().get(0))
|
||||
.get();
|
||||
final Long actionId = assignDistributionSet.getActions().get(0);
|
||||
// verify perparation
|
||||
Action findAction = deploymentManagement.findAction(action.getId()).get();
|
||||
Action findAction = deploymentManagement.findAction(actionId).get();
|
||||
assertThat(findAction.getActionType()).as("action type is wrong").isEqualTo(ActionType.FORCED);
|
||||
|
||||
// test
|
||||
final Action forceTargetAction = deploymentManagement.forceTargetAction(action.getId());
|
||||
final Action forceTargetAction = deploymentManagement.forceTargetAction(actionId);
|
||||
|
||||
// verify test
|
||||
assertThat(forceTargetAction.getActionType()).as("action type is wrong").isEqualTo(ActionType.FORCED);
|
||||
findAction = deploymentManagement.findAction(action.getId()).get();
|
||||
findAction = deploymentManagement.findAction(actionId).get();
|
||||
assertThat(findAction.getActionType()).as("action type is wrong").isEqualTo(ActionType.FORCED);
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,6 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
@@ -448,8 +447,8 @@ public class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
.createDistributionSetTag(entityFactory.tag().create().name("DistributionSetTag-C"));
|
||||
tagManagement.createDistributionSetTag(entityFactory.tag().create().name("DistributionSetTag-D"));
|
||||
|
||||
Collection<DistributionSet> ds100Group1 = testdataFactory.createDistributionSets("", 100);
|
||||
Collection<DistributionSet> ds100Group2 = testdataFactory.createDistributionSets("test2", 100);
|
||||
List<DistributionSet> ds5Group1 = testdataFactory.createDistributionSets("", 5);
|
||||
List<DistributionSet> dsGroup2 = testdataFactory.createDistributionSets("test2", 5);
|
||||
DistributionSet dsDeleted = testdataFactory.createDistributionSet("deleted");
|
||||
final DistributionSet dsInComplete = distributionSetManagement.createDistributionSet(entityFactory
|
||||
.distributionSet().create().name("notcomplete").version("1").type(standardDsType.getKey()));
|
||||
@@ -470,27 +469,27 @@ public class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
distributionSetManagement.deleteDistributionSet(dsDeleted.getId());
|
||||
dsDeleted = distributionSetManagement.findDistributionSetById(dsDeleted.getId()).get();
|
||||
|
||||
ds100Group1 = toggleTagAssignment(ds100Group1, dsTagA).getAssignedEntity();
|
||||
ds5Group1 = toggleTagAssignment(ds5Group1, dsTagA).getAssignedEntity();
|
||||
dsTagA = distributionSetTagRepository.findByNameEquals(dsTagA.getName()).get();
|
||||
ds100Group1 = toggleTagAssignment(ds100Group1, dsTagB).getAssignedEntity();
|
||||
ds5Group1 = toggleTagAssignment(ds5Group1, dsTagB).getAssignedEntity();
|
||||
dsTagA = distributionSetTagRepository.findByNameEquals(dsTagA.getName()).get();
|
||||
ds100Group2 = toggleTagAssignment(ds100Group2, dsTagA).getAssignedEntity();
|
||||
dsGroup2 = toggleTagAssignment(dsGroup2, dsTagA).getAssignedEntity();
|
||||
dsTagA = distributionSetTagRepository.findByNameEquals(dsTagA.getName()).get();
|
||||
|
||||
// check setup
|
||||
assertThat(distributionSetRepository.findAll()).hasSize(203);
|
||||
assertThat(distributionSetRepository.findAll()).hasSize(13);
|
||||
|
||||
// Find all
|
||||
List<DistributionSet> expected = Lists.newArrayListWithExpectedSize(203);
|
||||
expected.addAll(ds100Group1);
|
||||
expected.addAll(ds100Group2);
|
||||
List<DistributionSet> expected = Lists.newArrayListWithExpectedSize(13);
|
||||
expected.addAll(ds5Group1);
|
||||
expected.addAll(dsGroup2);
|
||||
expected.add(dsDeleted);
|
||||
expected.add(dsInComplete);
|
||||
expected.add(dsNewType);
|
||||
|
||||
assertThat(distributionSetManagement
|
||||
.findDistributionSetsByFilters(PAGE, getDistributionSetFilterBuilder().build()).getContent())
|
||||
.hasSize(203).containsOnly(expected.toArray(new DistributionSet[0]));
|
||||
.hasSize(13).containsOnly(expected.toArray(new DistributionSet[0]));
|
||||
|
||||
DistributionSetFilterBuilder distributionSetFilterBuilder;
|
||||
|
||||
@@ -501,18 +500,18 @@ public class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsDeleted(false);
|
||||
assertThat(distributionSetManagement.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build())
|
||||
.getContent()).hasSize(202);
|
||||
.getContent()).hasSize(12);
|
||||
|
||||
// search for completed
|
||||
expected = new ArrayList<>();
|
||||
expected.addAll(ds100Group1);
|
||||
expected.addAll(ds100Group2);
|
||||
expected.addAll(ds5Group1);
|
||||
expected.addAll(dsGroup2);
|
||||
expected.add(dsDeleted);
|
||||
expected.add(dsNewType);
|
||||
|
||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(true);
|
||||
assertThat(distributionSetManagement.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build())
|
||||
.getContent()).hasSize(202).containsOnly(expected.toArray(new DistributionSet[0]));
|
||||
.getContent()).hasSize(12).containsOnly(expected.toArray(new DistributionSet[0]));
|
||||
|
||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(Boolean.FALSE);
|
||||
expected = new ArrayList<>();
|
||||
@@ -527,31 +526,31 @@ public class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setType(standardDsType);
|
||||
assertThat(distributionSetManagement.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build())
|
||||
.getContent()).hasSize(202);
|
||||
.getContent()).hasSize(12);
|
||||
|
||||
// search for text
|
||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setSearchText("%test2");
|
||||
assertThat(distributionSetManagement.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build())
|
||||
.getContent()).hasSize(100);
|
||||
.getContent()).hasSize(5);
|
||||
|
||||
// search for tags
|
||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setTagNames(Arrays.asList(dsTagA.getName()));
|
||||
assertThat(distributionSetManagement.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build())
|
||||
.getContent()).hasSize(200);
|
||||
.getContent()).hasSize(10);
|
||||
|
||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setTagNames(Arrays.asList(dsTagB.getName()));
|
||||
assertThat(distributionSetManagement.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build())
|
||||
.getContent()).hasSize(100);
|
||||
.getContent()).hasSize(5);
|
||||
|
||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder()
|
||||
.setTagNames(Arrays.asList(dsTagA.getName(), dsTagB.getName()));
|
||||
assertThat(distributionSetManagement.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build())
|
||||
.getContent()).hasSize(200);
|
||||
.getContent()).hasSize(10);
|
||||
|
||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder()
|
||||
.setTagNames(Arrays.asList(dsTagC.getName(), dsTagB.getName()));
|
||||
assertThat(distributionSetManagement.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build())
|
||||
.getContent()).hasSize(100);
|
||||
.getContent()).hasSize(5);
|
||||
|
||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setTagNames(Arrays.asList(dsTagC.getName()));
|
||||
assertThat(distributionSetManagement.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build())
|
||||
@@ -559,23 +558,21 @@ public class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
// combine deleted and complete
|
||||
expected = new ArrayList<>();
|
||||
expected.addAll(ds100Group1);
|
||||
expected.addAll(ds100Group2);
|
||||
expected.addAll(ds5Group1);
|
||||
expected.addAll(dsGroup2);
|
||||
expected.add(dsNewType);
|
||||
|
||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(Boolean.TRUE)
|
||||
.setIsDeleted(Boolean.FALSE);
|
||||
assertThat(distributionSetManagement.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build())
|
||||
.getContent()).hasSize(201).containsOnly(expected.toArray(new DistributionSet[0]));
|
||||
.getContent()).hasSize(11).containsOnly(expected.toArray(new DistributionSet[0]));
|
||||
|
||||
expected = new ArrayList<>();
|
||||
expected.add(dsInComplete);
|
||||
expected = Arrays.asList(dsInComplete);
|
||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(Boolean.FALSE);
|
||||
assertThat(distributionSetManagement.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build())
|
||||
.getContent()).hasSize(1).containsOnly(expected.toArray(new DistributionSet[0]));
|
||||
|
||||
expected = new ArrayList<>();
|
||||
expected.add(dsDeleted);
|
||||
expected = Arrays.asList(dsDeleted);
|
||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(Boolean.TRUE)
|
||||
.setIsDeleted(Boolean.TRUE);
|
||||
assertThat(distributionSetManagement.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build())
|
||||
@@ -588,15 +585,14 @@ public class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
// combine deleted and complete and type
|
||||
expected = new ArrayList<>();
|
||||
expected.addAll(ds100Group1);
|
||||
expected.addAll(ds100Group2);
|
||||
expected.addAll(ds5Group1);
|
||||
expected.addAll(dsGroup2);
|
||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsDeleted(Boolean.FALSE)
|
||||
.setIsComplete(Boolean.TRUE).setType(standardDsType);
|
||||
assertThat(distributionSetManagement.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build())
|
||||
.getContent()).hasSize(200).containsOnly(expected.toArray(new DistributionSet[0]));
|
||||
.getContent()).hasSize(10).containsOnly(expected.toArray(new DistributionSet[0]));
|
||||
|
||||
expected = new ArrayList<>();
|
||||
expected.add(dsDeleted);
|
||||
expected = Arrays.asList(dsDeleted);
|
||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(Boolean.TRUE)
|
||||
.setType(standardDsType).setIsDeleted(Boolean.TRUE);
|
||||
assertThat(distributionSetManagement.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build())
|
||||
@@ -607,19 +603,17 @@ public class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
assertThat(distributionSetManagement.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build())
|
||||
.getContent()).hasSize(0);
|
||||
|
||||
expected = new ArrayList<>();
|
||||
expected.add(dsNewType);
|
||||
expected = Arrays.asList(dsNewType);
|
||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(Boolean.TRUE).setType(newType);
|
||||
assertThat(distributionSetManagement.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build())
|
||||
.getContent()).hasSize(1).containsOnly(expected.toArray(new DistributionSet[0]));
|
||||
|
||||
// combine deleted and complete and type and text
|
||||
expected = new ArrayList<>();
|
||||
expected.addAll(ds100Group2);
|
||||
expected = dsGroup2;
|
||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(Boolean.TRUE)
|
||||
.setType(standardDsType).setSearchText("%test2");
|
||||
assertThat(distributionSetManagement.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build())
|
||||
.getContent()).hasSize(100).containsOnly(expected.toArray(new DistributionSet[0]));
|
||||
.getContent()).hasSize(5).containsOnly(expected.toArray(new DistributionSet[0]));
|
||||
|
||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(Boolean.TRUE)
|
||||
.setIsDeleted(Boolean.TRUE).setType(standardDsType).setSearchText("%test2");
|
||||
@@ -637,12 +631,11 @@ public class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
.getContent()).hasSize(0);
|
||||
|
||||
// combine deleted and complete and type and text and tag
|
||||
expected = new ArrayList<>();
|
||||
expected.addAll(ds100Group2);
|
||||
expected = dsGroup2;
|
||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(true).setType(standardDsType)
|
||||
.setSearchText("%test2").setTagNames(Arrays.asList(dsTagA.getName()));
|
||||
assertThat(distributionSetManagement.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build())
|
||||
.getContent()).hasSize(100).containsOnly(expected.toArray(new DistributionSet[0]));
|
||||
.getContent()).hasSize(5).containsOnly(expected.toArray(new DistributionSet[0]));
|
||||
|
||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setType(standardDsType).setSearchText("%test2")
|
||||
.setTagNames(Arrays.asList(dsTagA.getName())).setIsComplete(Boolean.FALSE).setIsDeleted(Boolean.FALSE);
|
||||
|
||||
@@ -1171,7 +1171,7 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
@Description("Verify the creation and the start of a rollout.")
|
||||
public void createAndStartRollout() throws Exception {
|
||||
|
||||
final int amountTargetsForRollout = 500;
|
||||
final int amountTargetsForRollout = 50;
|
||||
final int amountGroups = 5;
|
||||
final String successCondition = "50";
|
||||
final String errorCondition = "80";
|
||||
@@ -1203,8 +1203,8 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
myRollout = rolloutManagement.findRolloutById(myRollout.getId()).get();
|
||||
assertThat(myRollout.getStatus()).isEqualTo(RolloutStatus.RUNNING);
|
||||
final Map<TotalTargetCountStatus.Status, Long> expectedTargetCountStatus = createInitStatusMap();
|
||||
expectedTargetCountStatus.put(TotalTargetCountStatus.Status.RUNNING, 100L);
|
||||
expectedTargetCountStatus.put(TotalTargetCountStatus.Status.SCHEDULED, 400L);
|
||||
expectedTargetCountStatus.put(TotalTargetCountStatus.Status.RUNNING, 10L);
|
||||
expectedTargetCountStatus.put(TotalTargetCountStatus.Status.SCHEDULED, 40L);
|
||||
validateRolloutActionStatus(myRollout.getId(), expectedTargetCountStatus);
|
||||
}
|
||||
|
||||
@@ -1212,7 +1212,7 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
@Description("Verify the creation and the automatic start of a rollout.")
|
||||
public void createAndAutoStartRollout() throws Exception {
|
||||
|
||||
final int amountTargetsForRollout = 500;
|
||||
final int amountTargetsForRollout = 50;
|
||||
final int amountGroups = 5;
|
||||
final String successCondition = "50";
|
||||
final String errorCondition = "80";
|
||||
@@ -1254,8 +1254,8 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
myRollout = rolloutManagement.findRolloutById(myRollout.getId()).get();
|
||||
assertThat(myRollout.getStatus()).isEqualTo(RolloutStatus.RUNNING);
|
||||
final Map<TotalTargetCountStatus.Status, Long> expectedTargetCountStatus = createInitStatusMap();
|
||||
expectedTargetCountStatus.put(TotalTargetCountStatus.Status.RUNNING, 100L);
|
||||
expectedTargetCountStatus.put(TotalTargetCountStatus.Status.SCHEDULED, 400L);
|
||||
expectedTargetCountStatus.put(TotalTargetCountStatus.Status.RUNNING, 10L);
|
||||
expectedTargetCountStatus.put(TotalTargetCountStatus.Status.SCHEDULED, 40L);
|
||||
validateRolloutActionStatus(myRollout.getId(), expectedTargetCountStatus);
|
||||
}
|
||||
|
||||
|
||||
@@ -397,7 +397,8 @@ public class TargetManagementTest extends AbstractJpaIntegrationTest {
|
||||
@Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetUpdatedEvent.class, count = 5),
|
||||
@Expect(type = ActionCreatedEvent.class, count = 2), @Expect(type = ActionUpdatedEvent.class, count = 1),
|
||||
@Expect(type = TargetAssignDistributionSetEvent.class, count = 2),
|
||||
@Expect(type = SoftwareModuleCreatedEvent.class, count = 6) })
|
||||
@Expect(type = SoftwareModuleCreatedEvent.class, count = 6),
|
||||
@Expect(type = TargetPollEvent.class, count = 1) })
|
||||
public void findTargetByControllerIDWithDetails() {
|
||||
final DistributionSet set = testdataFactory.createDistributionSet("test");
|
||||
final DistributionSet set2 = testdataFactory.createDistributionSet("test2");
|
||||
@@ -414,7 +415,7 @@ public class TargetManagementTest extends AbstractJpaIntegrationTest {
|
||||
Target target = createTargetWithAttributes("4711");
|
||||
|
||||
final long current = System.currentTimeMillis();
|
||||
controllerManagement.updateLastTargetQuery("4711", null);
|
||||
controllerManagement.findOrRegisterTargetIfItDoesNotexist("4711", LOCALHOST);
|
||||
|
||||
final DistributionSetAssignmentResult result = assignDistributionSet(set.getId(), "4711");
|
||||
|
||||
|
||||
@@ -23,6 +23,8 @@ import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationProperties.T
|
||||
import org.eclipse.hawkbit.tenancy.configuration.validator.TenantConfigurationValidatorException;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.springframework.context.EnvironmentAware;
|
||||
import org.springframework.core.env.Environment;
|
||||
|
||||
import ru.yandex.qatools.allure.annotations.Description;
|
||||
import ru.yandex.qatools.allure.annotations.Features;
|
||||
@@ -30,7 +32,14 @@ import ru.yandex.qatools.allure.annotations.Stories;
|
||||
|
||||
@Features("Component Tests - Repository")
|
||||
@Stories("Tenant Configuration Management")
|
||||
public class TenantConfigurationManagementTest extends AbstractJpaIntegrationTest {
|
||||
public class TenantConfigurationManagementTest extends AbstractJpaIntegrationTest implements EnvironmentAware {
|
||||
|
||||
private Environment environment = null;
|
||||
|
||||
@Override
|
||||
public void setEnvironment(final Environment environment) {
|
||||
this.environment = environment;
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Tests that tenant specific configuration can be persisted and in case the tenant does not have specific configuration the default from environment is used instead.")
|
||||
|
||||
@@ -60,8 +60,7 @@ public class RepositoryEntityEventTest extends AbstractJpaIntegrationTest {
|
||||
public void targetCreatedEventIsPublished() throws InterruptedException {
|
||||
final Target createdTarget = testdataFactory.createTarget("12345");
|
||||
|
||||
final TargetCreatedEvent targetCreatedEvent = eventListener.waitForEvent(TargetCreatedEvent.class, 1,
|
||||
TimeUnit.SECONDS);
|
||||
final TargetCreatedEvent targetCreatedEvent = eventListener.waitForEvent(TargetCreatedEvent.class);
|
||||
assertThat(targetCreatedEvent).isNotNull();
|
||||
assertThat(targetCreatedEvent.getEntity().getId()).isEqualTo(createdTarget.getId());
|
||||
}
|
||||
@@ -73,8 +72,7 @@ public class RepositoryEntityEventTest extends AbstractJpaIntegrationTest {
|
||||
targetManagement
|
||||
.updateTarget(entityFactory.target().update(createdTarget.getControllerId()).name("updateName"));
|
||||
|
||||
final TargetUpdatedEvent targetUpdatedEvent = eventListener.waitForEvent(TargetUpdatedEvent.class, 1,
|
||||
TimeUnit.SECONDS);
|
||||
final TargetUpdatedEvent targetUpdatedEvent = eventListener.waitForEvent(TargetUpdatedEvent.class);
|
||||
assertThat(targetUpdatedEvent).isNotNull();
|
||||
assertThat(targetUpdatedEvent.getEntity().getId()).isEqualTo(createdTarget.getId());
|
||||
}
|
||||
@@ -86,8 +84,7 @@ public class RepositoryEntityEventTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
targetManagement.deleteTarget("12345");
|
||||
|
||||
final TargetDeletedEvent targetDeletedEvent = eventListener.waitForEvent(TargetDeletedEvent.class, 1,
|
||||
TimeUnit.SECONDS);
|
||||
final TargetDeletedEvent targetDeletedEvent = eventListener.waitForEvent(TargetDeletedEvent.class);
|
||||
assertThat(targetDeletedEvent).isNotNull();
|
||||
assertThat(targetDeletedEvent.getEntityId()).isEqualTo(createdTarget.getId());
|
||||
}
|
||||
@@ -110,8 +107,7 @@ public class RepositoryEntityEventTest extends AbstractJpaIntegrationTest {
|
||||
rolloutManagement.deleteRollout(createdRollout.getId());
|
||||
rolloutManagement.handleRollouts();
|
||||
|
||||
final RolloutDeletedEvent rolloutDeletedEvent = eventListener.waitForEvent(RolloutDeletedEvent.class, 1,
|
||||
TimeUnit.SECONDS);
|
||||
final RolloutDeletedEvent rolloutDeletedEvent = eventListener.waitForEvent(RolloutDeletedEvent.class);
|
||||
assertThat(rolloutDeletedEvent).isNotNull();
|
||||
assertThat(rolloutDeletedEvent.getEntityId()).isEqualTo(createdRollout.getId());
|
||||
}
|
||||
@@ -121,8 +117,8 @@ public class RepositoryEntityEventTest extends AbstractJpaIntegrationTest {
|
||||
public void distributionSetCreatedEventIsPublished() throws InterruptedException {
|
||||
final DistributionSet createDistributionSet = testdataFactory.createDistributionSet();
|
||||
|
||||
final DistributionSetCreatedEvent dsCreatedEvent = eventListener.waitForEvent(DistributionSetCreatedEvent.class,
|
||||
1, TimeUnit.SECONDS);
|
||||
final DistributionSetCreatedEvent dsCreatedEvent = eventListener
|
||||
.waitForEvent(DistributionSetCreatedEvent.class);
|
||||
assertThat(dsCreatedEvent).isNotNull();
|
||||
assertThat(dsCreatedEvent.getEntity().getId()).isEqualTo(createDistributionSet.getId());
|
||||
}
|
||||
@@ -134,8 +130,8 @@ public class RepositoryEntityEventTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
distributionSetManagement.deleteDistributionSet(createDistributionSet.getId());
|
||||
|
||||
final DistributionSetDeletedEvent dsDeletedEvent = eventListener.waitForEvent(DistributionSetDeletedEvent.class,
|
||||
1, TimeUnit.SECONDS);
|
||||
final DistributionSetDeletedEvent dsDeletedEvent = eventListener
|
||||
.waitForEvent(DistributionSetDeletedEvent.class);
|
||||
assertThat(dsDeletedEvent).isNotNull();
|
||||
assertThat(dsDeletedEvent.getEntityId()).isEqualTo(createDistributionSet.getId());
|
||||
}
|
||||
@@ -146,7 +142,7 @@ public class RepositoryEntityEventTest extends AbstractJpaIntegrationTest {
|
||||
final SoftwareModule softwareModule = testdataFactory.createSoftwareModuleApp();
|
||||
|
||||
final SoftwareModuleCreatedEvent softwareModuleCreatedEvent = eventListener
|
||||
.waitForEvent(SoftwareModuleCreatedEvent.class, 1, TimeUnit.SECONDS);
|
||||
.waitForEvent(SoftwareModuleCreatedEvent.class);
|
||||
assertThat(softwareModuleCreatedEvent).isNotNull();
|
||||
assertThat(softwareModuleCreatedEvent.getEntity().getId()).isEqualTo(softwareModule.getId());
|
||||
}
|
||||
@@ -159,7 +155,7 @@ public class RepositoryEntityEventTest extends AbstractJpaIntegrationTest {
|
||||
.updateSoftwareModule(entityFactory.softwareModule().update(softwareModule.getId()).description("New"));
|
||||
|
||||
final SoftwareModuleUpdatedEvent softwareModuleUpdatedEvent = eventListener
|
||||
.waitForEvent(SoftwareModuleUpdatedEvent.class, 1, TimeUnit.SECONDS);
|
||||
.waitForEvent(SoftwareModuleUpdatedEvent.class);
|
||||
assertThat(softwareModuleUpdatedEvent).isNotNull();
|
||||
assertThat(softwareModuleUpdatedEvent.getEntity().getId()).isEqualTo(softwareModule.getId());
|
||||
}
|
||||
@@ -171,7 +167,7 @@ public class RepositoryEntityEventTest extends AbstractJpaIntegrationTest {
|
||||
softwareModuleManagement.deleteSoftwareModule(softwareModule.getId());
|
||||
|
||||
final SoftwareModuleDeletedEvent softwareModuleDeletedEvent = eventListener
|
||||
.waitForEvent(SoftwareModuleDeletedEvent.class, 1, TimeUnit.SECONDS);
|
||||
.waitForEvent(SoftwareModuleDeletedEvent.class);
|
||||
assertThat(softwareModuleDeletedEvent).isNotNull();
|
||||
assertThat(softwareModuleDeletedEvent.getEntityId()).isEqualTo(softwareModule.getId());
|
||||
}
|
||||
@@ -194,15 +190,14 @@ public class RepositoryEntityEventTest extends AbstractJpaIntegrationTest {
|
||||
queue.offer(event);
|
||||
}
|
||||
|
||||
public <T> T waitForEvent(final Class<T> eventType, final long timeout, final TimeUnit timeUnit)
|
||||
throws InterruptedException {
|
||||
public <T> T waitForEvent(final Class<T> eventType) throws InterruptedException {
|
||||
TenantAwareEvent event = null;
|
||||
while ((event = queue.poll(timeout, timeUnit)) != null) {
|
||||
while ((event = queue.poll(5, TimeUnit.SECONDS)) != null) {
|
||||
if (event.getClass().isAssignableFrom(eventType)) {
|
||||
return (T) event;
|
||||
}
|
||||
}
|
||||
Assertions.fail("Missing event " + eventType + " within timeout " + timeout + " " + timeUnit);
|
||||
Assertions.fail("Missing event " + eventType + " within timeout.");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ public class RSQLTargetFieldTest extends AbstractJpaIntegrationTest {
|
||||
private Target target2;
|
||||
|
||||
@Before
|
||||
public void seuptBeforeTest() throws InterruptedException {
|
||||
public void setupBeforeTest() throws InterruptedException {
|
||||
|
||||
final DistributionSet ds = testdataFactory.createDistributionSet("AssignedDs");
|
||||
|
||||
@@ -48,14 +48,14 @@ public class RSQLTargetFieldTest extends AbstractJpaIntegrationTest {
|
||||
.name("targetName123").description("targetDesc123"));
|
||||
attributes.put("revision", "1.1");
|
||||
target = controllerManagement.updateControllerAttributes(target.getControllerId(), attributes);
|
||||
target = controllerManagement.updateLastTargetQuery(target.getControllerId(), null);
|
||||
target = controllerManagement.findOrRegisterTargetIfItDoesNotexist(target.getControllerId(), LOCALHOST);
|
||||
|
||||
target2 = targetManagement
|
||||
.createTarget(entityFactory.target().create().controllerId("targetId1234").description("targetId1234"));
|
||||
attributes.put("revision", "1.2");
|
||||
Thread.sleep(1);
|
||||
target2 = controllerManagement.updateControllerAttributes(target2.getControllerId(), attributes);
|
||||
target2 = controllerManagement.updateLastTargetQuery(target2.getControllerId(), null);
|
||||
target2 = controllerManagement.findOrRegisterTargetIfItDoesNotexist(target2.getControllerId(), LOCALHOST);
|
||||
|
||||
testdataFactory.createTarget("targetId1235");
|
||||
testdataFactory.createTarget("targetId1236");
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<Target> createTargets(final int number) {
|
||||
final List<Target> targets = Lists.newArrayListWithExpectedSize(number);
|
||||
|
||||
final List<TargetCreate> 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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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<HttpServletResponse> httpResponseFactoryBean() {
|
||||
FactoryBean<HttpServletResponse> 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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<Class<?>, RefreshableContainer> getSupportedPushEvents() {
|
||||
final Map<Class<?>, 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());
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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<org.eclipse.hawkbit.repository.event.TenantAwareEvent> events,
|
||||
final WrappedSession wrappedSession) {
|
||||
private void doDispatch(final List<TenantAwareEvent> events, final WrappedSession wrappedSession) {
|
||||
final SecurityContext userContext = (SecurityContext) wrappedSession
|
||||
.getAttribute(HttpSessionSecurityContextRepository.SPRING_SECURITY_CONTEXT_KEY);
|
||||
final SecurityContext oldContext = SecurityContextHolder.getContext();
|
||||
|
||||
@@ -16,11 +16,11 @@ import org.eclipse.hawkbit.repository.event.remote.entity.DistributionSetCreated
|
||||
* EventHolder for {@link DistributionSetCreatedEvent}s.
|
||||
*
|
||||
*/
|
||||
public class DistributionCreatedEventContainer implements EventContainer<DistributionSetCreatedEvent> {
|
||||
public class DistributionSetCreatedEventContainer implements EventContainer<DistributionSetCreatedEvent> {
|
||||
private static final String I18N_UNREAD_NOTIFICATION_UNREAD_MESSAGE = "distribution.created.event.container.notifcation.message";
|
||||
private final List<DistributionSetCreatedEvent> events;
|
||||
|
||||
DistributionCreatedEventContainer(final List<DistributionSetCreatedEvent> events) {
|
||||
DistributionSetCreatedEventContainer(final List<DistributionSetCreatedEvent> events) {
|
||||
this.events = events;
|
||||
}
|
||||
|
||||
@@ -16,11 +16,11 @@ import org.eclipse.hawkbit.repository.event.remote.DistributionSetDeletedEvent;
|
||||
* EventHolder for {@link DistributionSetDeletedEvent}s.
|
||||
*
|
||||
*/
|
||||
public class DistributionDeletedEventContainer implements EventContainer<DistributionSetDeletedEvent> {
|
||||
public class DistributionSetDeletedEventContainer implements EventContainer<DistributionSetDeletedEvent> {
|
||||
private static final String I18N_UNREAD_NOTIFICATION_UNREAD_MESSAGE = "distribution.deleted.event.container.notifcation.message";
|
||||
private final List<DistributionSetDeletedEvent> events;
|
||||
|
||||
DistributionDeletedEventContainer(final List<DistributionSetDeletedEvent> events) {
|
||||
DistributionSetDeletedEventContainer(final List<DistributionSetDeletedEvent> events) {
|
||||
this.events = events;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
9
pom.xml
9
pom.xml
@@ -162,7 +162,7 @@
|
||||
<gwtmockito.version>1.1.6</gwtmockito.version>
|
||||
<pl.pragmatists.version>1.0.2</pl.pragmatists.version>
|
||||
<guava.version>19.0</guava.version>
|
||||
<mariadb-java-client.version>1.5.7</mariadb-java-client.version>
|
||||
<mariadb-java-client.version>2.0.2</mariadb-java-client.version>
|
||||
<embedded-mongo.version>1.50.5</embedded-mongo.version>
|
||||
<javax.el-api.version>2.2.4</javax.el-api.version>
|
||||
<corn-cps.version>1.1.7</corn-cps.version>
|
||||
@@ -194,6 +194,11 @@
|
||||
<jacoco.itReportPath>${jacoco.outputDir}/jacoco-it.exec</jacoco.itReportPath>
|
||||
<sonar.jacoco.reportPaths>${jacoco.reportPath},${jacoco.itReportPath}</sonar.jacoco.reportPaths>
|
||||
<!-- Sonar - END -->
|
||||
|
||||
<!-- ************************ -->
|
||||
<!-- Maven Surefire settings -->
|
||||
<!-- ************************ -->
|
||||
<surefire.forkcount>1</surefire.forkcount>
|
||||
</properties>
|
||||
|
||||
<build>
|
||||
@@ -364,7 +369,7 @@
|
||||
<version>${maven.surefire.plugin.version}</version>
|
||||
<configuration>
|
||||
<reuseForks>true</reuseForks>
|
||||
<forkCount>1</forkCount>
|
||||
<forkCount>${surefire.forkcount}</forkCount>
|
||||
<argLine>
|
||||
${jacoco.agent.ut.arg}
|
||||
</argLine>
|
||||
|
||||
Reference in New Issue
Block a user