Support for Multi-Assignments (#833)
* First draft of new assignment logic Signed-off-by: Stefan Behl <stefan.behl@bosch-si.com> * Enhancements of System Configuration view Signed-off-by: Stefan Behl <stefan.behl@bosch-si.com> * Drag&drop enhancements for multiple distribution set assignments Signed-off-by: Stefan Behl <stefan.behl@bosch-si.com> * Misc fixes Signed-off-by: Stefan Behl <stefan.behl@bosch-si.com> * test that previous assignments are not canceled Signed-off-by: Stefan Klotz <stefan.klotz@bosch-si.com> * add description and expected events to test Signed-off-by: Stefan Klotz <stefan.klotz@bosch-si.com> * extend TenantConfigurationManagement by NullPointerException proof getConfigurationValue method Signed-off-by: Stefan Klotz <stefan.klotz@bosch-si.com> * Hide "Required Migration Step" if Multi Assignments is enabled Signed-off-by: Stefan Klotz <stefan.klotz@bosch-si.com> * Make fields transient Signed-off-by: Stefan Klotz <stefan.klotz@bosch-si.com> * Add IDs for Required Migration Step elements Signed-off-by: Stefan Klotz <stefan.klotz@bosch-si.com> * Save work in progress Signed-off-by: Stefan Behl <stefan.behl@bosch-si.com> * Added new DMF message DmfMultiActionRequest Signed-off-by: Stefan Behl <stefan.behl@bosch-si.com> * DMF enhancements to send out MultiActionRequest messages Signed-off-by: Stefan Behl <stefan.behl@bosch-si.com> * Minor changes Signed-off-by: Stefan Behl <stefan.behl@bosch-si.com> * Multi Assignment support for cancellations Signed-off-by: Stefan Behl <stefan.behl@bosch-si.com> * fix permission problems and immutable lists Signed-off-by: Stefan Klotz <stefan.klotz@bosch-si.com> * add message dispatcher tests for outgoing multiassignment messages, fix old tests Signed-off-by: Stefan Klotz <stefan.klotz@bosch-si.com> * Implement Multi-Assignment support for rollout groups Signed-off-by: Stefan Behl <stefan.behl@bosch-si.com> * Minor changes Signed-off-by: Stefan Behl <stefan.behl@bosch-si.com> * Refactoring Signed-off-by: Stefan Behl <stefan.behl@bosch-si.com> * Register new deployment event with protobuff framework Signed-off-by: Stefan Behl <stefan.behl@bosch-si.com> * Allow same DS to be assigned multiple times Signed-off-by: Stefan Behl <stefan.behl@bosch-si.com> * Fix assignment with pending cancellations Signed-off-by: Stefan Behl <stefan.behl@bosch-si.com> * Reduce repository /DB calls Signed-off-by: Stefan Behl <stefan.behl@bosch-si.com> * Revert latest perf fix (causing a regression) Signed-off-by: Stefan Behl <stefan.behl@bosch-si.com> * test if a rollout sends multiaction messages in multiassignment mode Signed-off-by: Stefan Klotz <stefan.klotz@bosch-si.com> * Minor changes Signed-off-by: Stefan Behl <stefan.behl@bosch-si.com> * Do not close new action if DS is already assigned (if multi-assign on) Signed-off-by: Stefan Behl <stefan.behl@bosch-si.com> * add test that starts and finishes multiple rollouts in multiassignt mode Signed-off-by: Stefan Klotz <stefan.klotz@bosch-si.com> * add javadoc to test method Signed-off-by: Stefan Klotz <stefan.klotz@bosch-si.com> * Prevent Multi-Assignments from being disabled via Repo Config UI Signed-off-by: Stefan Behl <stefan.behl@bosch-si.com> * Add link to Provisioning State Machine Signed-off-by: Stefan Behl <stefan.behl@bosch-si.com> * test that Multiassignment can not be disabled via mgmt-api Signed-off-by: Stefan Klotz <stefan.klotz@bosch-si.com> * refactor AmqpMessageHandlerService code Signed-off-by: Stefan Klotz <stefan.klotz@bosch-si.com> * Prevent Multi-Assignments feature from being disabled via Mgmt REST API Signed-off-by: Stefan Behl <stefan.behl@bosch-si.com> * add license header, remove unused instance variables Signed-off-by: Stefan Klotz <stefan.klotz@bosch-si.com> * fix tenantConfigurationManagement mock in test Signed-off-by: Stefan Klotz <stefan.klotz@bosch-si.com> * return empty list instead of null Signed-off-by: Stefan Klotz <stefan.klotz@bosch-si.com> * add ddi test for multiassignment, fix old test Signed-off-by: Stefan Klotz <stefan.klotz@bosch-si.com> * Prevent autoclose from being modified if Multi-Assignments is enabled # WARNING: head commit changed in the meantime Signed-off-by: Stefan Behl <stefan.behl@bosch-si.com> * Add test for autoClose /multiAssign Signed-off-by: Stefan Behl <stefan.behl@bosch-si.com> * Javadoc improvements Signed-off-by: Stefan Behl <stefan.behl@bosch-si.com> * change test method that waits for dmf messages to be dispatched Signed-off-by: Stefan Klotz <stefan.klotz@bosch-si.com> * clean up code Signed-off-by: Stefan Klotz <stefan.klotz@bosch-si.com> * Fix UI-related PR review findings Signed-off-by: Stefan Behl <stefan.behl@bosch-si.com> * Fix PR review findings Signed-off-by: Stefan Behl <stefan.behl@bosch-si.com> * Fix PR review findings Signed-off-by: Stefan Behl <stefan.behl@bosch-si.com> * Fix PR review findings Signed-off-by: Stefan Behl <stefan.behl@bosch-si.com> * Fix PR review findings, Sonar issues, and test failures Signed-off-by: Stefan Behl <stefan.behl@bosch-si.com> * Fix PR review findings Signed-off-by: Stefan Behl <stefan.behl@bosch-si.com> * Fix PR review findings Signed-off-by: Stefan Behl <stefan.behl@bosch-si.com> * Fix PR review findings Signed-off-by: Stefan Behl <stefan.behl@bosch-si.com> * Fix Sonar findings Signed-off-by: Stefan Behl <stefan.behl@bosch-si.com> * Fix PR review findings Signed-off-by: Stefan Behl <stefan.behl@bosch-si.com> * Fix PR review findings Signed-off-by: Stefan Behl <stefan.behl@bosch-si.com> * Fix PR review findings Signed-off-by: Stefan Behl <stefan.behl@bosch-si.com>
This commit is contained in:
committed by
Dominic Schabel
parent
f16f986eed
commit
1ac40a7a95
@@ -1039,7 +1039,7 @@ public class ControllerManagementTest extends AbstractJpaIntegrationTest {
|
||||
final DistributionSet testDs = testdataFactory.createDistributionSet("1");
|
||||
final List<Target> testTarget = testdataFactory.createTargets(1);
|
||||
|
||||
final Long actionId = assignDistributionSet(testDs, testTarget).getActions().get(0);
|
||||
final Long actionId = assignDistributionSet(testDs, testTarget).getActionIds().get(0);
|
||||
|
||||
controllerManagement.addUpdateActionStatus(entityFactory.actionStatus().create(actionId)
|
||||
.status(Action.Status.RUNNING).messages(Lists.newArrayList("proceeding message 1")));
|
||||
@@ -1068,7 +1068,7 @@ public class ControllerManagementTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
// test for informational status
|
||||
final Long actionId1 = assignDistributionSet(testdataFactory.createDistributionSet("ds1"),
|
||||
testdataFactory.createTargets(1, "t1")).getActions().get(0);
|
||||
testdataFactory.createTargets(1, "t1")).getActionIds().get(0);
|
||||
assertThat(actionId1).isNotNull();
|
||||
for (int i = 0; i < maxStatusEntries; ++i) {
|
||||
controllerManagement.addInformationalActionStatus(entityFactory.actionStatus().create(actionId1)
|
||||
@@ -1079,7 +1079,7 @@ public class ControllerManagementTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
// test for update status (and mixed case)
|
||||
final Long actionId2 = assignDistributionSet(testdataFactory.createDistributionSet("ds2"),
|
||||
testdataFactory.createTargets(1, "t2")).getActions().get(0);
|
||||
testdataFactory.createTargets(1, "t2")).getActionIds().get(0);
|
||||
assertThat(actionId2).isNotEqualTo(actionId1);
|
||||
for (int i = 0; i < maxStatusEntries; ++i) {
|
||||
controllerManagement.addUpdateActionStatus(entityFactory.actionStatus().create(actionId2)
|
||||
@@ -1102,7 +1102,7 @@ public class ControllerManagementTest extends AbstractJpaIntegrationTest {
|
||||
final int maxMessages = quotaManagement.getMaxMessagesPerActionStatus();
|
||||
|
||||
final Long actionId = assignDistributionSet(testdataFactory.createDistributionSet("ds1"),
|
||||
testdataFactory.createTargets(1)).getActions().get(0);
|
||||
testdataFactory.createTargets(1)).getActionIds().get(0);
|
||||
assertThat(actionId).isNotNull();
|
||||
|
||||
final List<String> messages = Lists.newArrayList();
|
||||
@@ -1258,19 +1258,22 @@ public class ControllerManagementTest extends AbstractJpaIntegrationTest {
|
||||
IntStream.range(0, maxMessages).forEach(i -> controllerManagement
|
||||
.addUpdateActionStatus(entityFactory.actionStatus().create(actionId).status(Status.DOWNLOADED)));
|
||||
fail("No QuotaExceededException thrown for too many DOWNLOADED updateActionStatus updates");
|
||||
} catch (QuotaExceededException e) { }
|
||||
} catch (final QuotaExceededException e) {
|
||||
}
|
||||
|
||||
try {
|
||||
IntStream.range(0, maxMessages).forEach(i -> controllerManagement
|
||||
.addUpdateActionStatus(entityFactory.actionStatus().create(actionId).status(Status.ERROR)));
|
||||
fail("No QuotaExceededException thrown for too many ERROR updateActionStatus updates");
|
||||
} catch (QuotaExceededException e) { }
|
||||
} catch (final QuotaExceededException e) {
|
||||
}
|
||||
|
||||
try {
|
||||
IntStream.range(0, maxMessages).forEach(i -> controllerManagement
|
||||
.addUpdateActionStatus(entityFactory.actionStatus().create(actionId).status(Status.FINISHED)));
|
||||
fail("No QuotaExceededException thrown for too many FINISHED updateActionStatus updates");
|
||||
} catch (QuotaExceededException e) { }
|
||||
} catch (final QuotaExceededException e) {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -1290,19 +1293,22 @@ public class ControllerManagementTest extends AbstractJpaIntegrationTest {
|
||||
IntStream.range(0, maxMessages).forEach(i -> controllerManagement
|
||||
.addUpdateActionStatus(entityFactory.actionStatus().create(actionId).status(Status.DOWNLOADED)));
|
||||
fail("No QuotaExceededException thrown for too many DOWNLOADED updateActionStatus updates");
|
||||
} catch (QuotaExceededException e) { }
|
||||
} catch (final QuotaExceededException e) {
|
||||
}
|
||||
|
||||
try {
|
||||
IntStream.range(0, maxMessages).forEach(i -> controllerManagement
|
||||
.addUpdateActionStatus(entityFactory.actionStatus().create(actionId).status(Status.ERROR)));
|
||||
fail("No QuotaExceededException thrown for too many ERROR updateActionStatus updates");
|
||||
} catch (QuotaExceededException e) { }
|
||||
} catch (final QuotaExceededException e) {
|
||||
}
|
||||
|
||||
try {
|
||||
IntStream.range(0, maxMessages).forEach(i -> controllerManagement
|
||||
.addUpdateActionStatus(entityFactory.actionStatus().create(actionId).status(Status.FINISHED)));
|
||||
fail("No QuotaExceededException thrown for too many FINISHED updateActionStatus updates");
|
||||
} catch (QuotaExceededException e) { }
|
||||
} catch (final QuotaExceededException e) {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -1386,7 +1392,7 @@ public class ControllerManagementTest extends AbstractJpaIntegrationTest {
|
||||
final Long forcedDistributionSetId = testdataFactory.createDistributionSet("forcedDs1").getId();
|
||||
final DistributionSetAssignmentResult assignmentResult =
|
||||
assignDistributionSet(forcedDistributionSetId, DEFAULT_CONTROLLER_ID, Action.ActionType.SOFT);
|
||||
addUpdateActionStatus(assignmentResult.getActions().get(0), DEFAULT_CONTROLLER_ID, Status.FINISHED);
|
||||
addUpdateActionStatus(assignmentResult.getActions().get(0).getId(), DEFAULT_CONTROLLER_ID, Status.FINISHED);
|
||||
assertAssignedDistributionSetId(DEFAULT_CONTROLLER_ID, forcedDistributionSetId);
|
||||
assertInstalledDistributionSetId(DEFAULT_CONTROLLER_ID, forcedDistributionSetId);
|
||||
assertNoActiveActionsExistsForControllerId(DEFAULT_CONTROLLER_ID);
|
||||
@@ -1426,4 +1432,4 @@ public class ControllerManagementTest extends AbstractJpaIntegrationTest {
|
||||
assertThat(actionRepository.activeActionExistsForControllerId(controllerId)).isEqualTo(false);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -25,6 +25,7 @@ import java.util.stream.Collectors;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
import org.eclipse.hawkbit.repository.ActionStatusFields;
|
||||
import org.eclipse.hawkbit.repository.event.remote.MultiActionEvent;
|
||||
import org.eclipse.hawkbit.repository.event.remote.TargetAssignDistributionSetEvent;
|
||||
import org.eclipse.hawkbit.repository.event.remote.entity.ActionCreatedEvent;
|
||||
import org.eclipse.hawkbit.repository.event.remote.entity.ActionUpdatedEvent;
|
||||
@@ -85,6 +86,10 @@ import io.qameta.allure.Story;
|
||||
@Feature("Component Tests - Repository")
|
||||
@Story("Deployment Management")
|
||||
public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
private static final boolean STATE_ACTIVE = true;
|
||||
private static final boolean STATE_INACTIVE = false;
|
||||
|
||||
private EventHandlerStub eventHandlerStub;
|
||||
|
||||
private CancelEventHandlerStub cancelEventHandlerStub;
|
||||
@@ -146,7 +151,7 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
new ArrayList<DistributionSetTag>());
|
||||
final List<Target> testTarget = testdataFactory.createTargets(1);
|
||||
// one action with one action status is generated
|
||||
final Long actionId = assignDistributionSet(testDs, testTarget).getActions().get(0);
|
||||
final Long actionId = assignDistributionSet(testDs, testTarget).getActionIds().get(0);
|
||||
final Action action = deploymentManagement.findActionWithDetails(actionId).get();
|
||||
|
||||
assertThat(action.getDistributionSet()).as("DistributionSet in action").isNotNull();
|
||||
@@ -163,7 +168,7 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
new ArrayList<DistributionSetTag>());
|
||||
final List<Target> testTarget = testdataFactory.createTargets(1);
|
||||
// one action with one action status is generated
|
||||
final Long actionId = assignDistributionSet(testDs, testTarget).getActions().get(0);
|
||||
final Long actionId = assignDistributionSet(testDs, testTarget).getActionIds().get(0);
|
||||
|
||||
// act
|
||||
final Slice<Action> actions = deploymentManagement.findActionsByTarget(testTarget.get(0).getControllerId(),
|
||||
@@ -212,7 +217,7 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
new ArrayList<DistributionSetTag>());
|
||||
final List<Target> testTarget = testdataFactory.createTargets(1);
|
||||
// one action with one action status is generated
|
||||
final Long actionId = assignDistributionSet(testDs, testTarget).getActions().get(0);
|
||||
final Long actionId = assignDistributionSet(testDs, testTarget).getActionIds().get(0);
|
||||
final Slice<Action> actions = deploymentManagement.findActionsByTarget(testTarget.get(0).getControllerId(),
|
||||
PAGE);
|
||||
final ActionStatus expectedActionStatus = ((JpaAction) actions.getContent().get(0)).getActionStatus().get(0);
|
||||
@@ -231,7 +236,7 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
new ArrayList<DistributionSetTag>());
|
||||
final List<Target> testTarget = testdataFactory.createTargets(1);
|
||||
// one action with one action status is generated
|
||||
final Long actionId = assignDistributionSet(testDs, testTarget).getActions().get(0);
|
||||
final Long actionId = assignDistributionSet(testDs, testTarget).getActionIds().get(0);
|
||||
// create action-status entry with one message
|
||||
controllerManagement.addUpdateActionStatus(entityFactory.actionStatus().create(actionId)
|
||||
.status(Action.Status.FINISHED).messages(Arrays.asList("finished message")));
|
||||
@@ -485,8 +490,8 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
final List<Target> targets = deploymentManagement.offlineAssignedDistributionSet(ds.getId(), controllerIds)
|
||||
.getAssignedEntity();
|
||||
assertThat(actionRepository.count()).isEqualTo(20);
|
||||
assertThat(actionRepository.findByDistributionSetId(PAGE, ds.getId()))
|
||||
.as("Offline actions are not active").allMatch(action -> !action.isActive());
|
||||
assertThat(actionRepository.findByDistributionSetId(PAGE, ds.getId())).as("Offline actions are not active")
|
||||
.allMatch(action -> !action.isActive());
|
||||
assertThat(targetManagement.findByInstalledDistributionSet(PAGE, ds.getId()).getContent()).containsAll(targets)
|
||||
.hasSize(10).containsAll(targetManagement.findByAssignedDistributionSet(PAGE, ds.getId()))
|
||||
.as("InstallationDate set").allMatch(target -> target.getInstallationDate() >= current)
|
||||
@@ -515,26 +520,14 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
final DistributionSet ds1 = testdataFactory.createDistributionSet("1");
|
||||
assignDistributionSet(ds1, targets);
|
||||
|
||||
List<Action> assignmentOne = actionRepository.findByDistributionSetId(PAGE, ds1.getId()).getContent();
|
||||
assertThat(assignmentOne).hasSize(10).as("Is active").allMatch(Action::isActive)
|
||||
.as("Is assigned to DS " + ds1.getId())
|
||||
.allMatch(action -> action.getDistributionSet().getId().equals(ds1.getId())).as("Is running")
|
||||
.allMatch(action -> action.getStatus() == Status.RUNNING);
|
||||
assertDsExclusivelyAssignedToTargets(targets, ds1.getId(), STATE_ACTIVE, Status.RUNNING);
|
||||
|
||||
// Second assignment
|
||||
final DistributionSet ds2 = testdataFactory.createDistributionSet("2");
|
||||
assignDistributionSet(ds2, targets);
|
||||
|
||||
final List<Action> assignmentTwo = actionRepository.findByDistributionSetId(PAGE, ds2.getId()).getContent();
|
||||
assignmentOne = actionRepository.findByDistributionSetId(PAGE, ds1.getId()).getContent();
|
||||
assertThat(assignmentTwo).hasSize(10).as("Is active").allMatch(Action::isActive)
|
||||
.as("Is assigned to DS " + ds2.getId())
|
||||
.allMatch(action -> action.getDistributionSet().getId().equals(ds2.getId())).as("Is running")
|
||||
.allMatch(action -> action.getStatus() == Status.RUNNING);
|
||||
assertThat(assignmentOne).hasSize(10).as("Is active").allMatch(action -> !action.isActive())
|
||||
.as("Is assigned to DS " + ds1.getId())
|
||||
.allMatch(action -> action.getDistributionSet().getId().equals(ds1.getId())).as("Is cancelled")
|
||||
.allMatch(action -> action.getStatus() == Status.CANCELED);
|
||||
assertDsExclusivelyAssignedToTargets(targets, ds2.getId(), STATE_ACTIVE, Status.RUNNING);
|
||||
assertDsExclusivelyAssignedToTargets(targets, ds1.getId(), STATE_INACTIVE, Status.CANCELED);
|
||||
|
||||
assertThat(targetManagement.findByAssignedDistributionSet(PAGE, ds2.getId()).getContent()).hasSize(10)
|
||||
.as("InstallationDate not set").allMatch(target -> (target.getInstallationDate() == null));
|
||||
@@ -545,6 +538,44 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("If multi-assignment is enabled, verify that the previous Distribution Set assignment is not canceled when a new one is assigned.")
|
||||
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 10),
|
||||
@Expect(type = TargetUpdatedEvent.class, count = 20), @Expect(type = ActionCreatedEvent.class, count = 20),
|
||||
@Expect(type = DistributionSetCreatedEvent.class, count = 2),
|
||||
@Expect(type = SoftwareModuleCreatedEvent.class, count = 6),
|
||||
@Expect(type = MultiActionEvent.class, count = 2),
|
||||
@Expect(type = TargetAssignDistributionSetEvent.class, count = 0) })
|
||||
public void previousAssignmentsAreNotCanceledInMultiAssignMode() {
|
||||
enableMultiAssignments();
|
||||
final List<Target> targets = testdataFactory.createTargets(10);
|
||||
|
||||
// First assignment
|
||||
final DistributionSet ds1 = testdataFactory.createDistributionSet("Multi-assign-1");
|
||||
assignDistributionSet(ds1, targets);
|
||||
|
||||
assertDsExclusivelyAssignedToTargets(targets, ds1.getId(), STATE_ACTIVE, Status.RUNNING);
|
||||
|
||||
// Second assignment
|
||||
final DistributionSet ds2 = testdataFactory.createDistributionSet("Multi-assign-2");
|
||||
assignDistributionSet(ds2, targets);
|
||||
|
||||
assertDsExclusivelyAssignedToTargets(targets, ds2.getId(), STATE_ACTIVE, Status.RUNNING);
|
||||
assertDsExclusivelyAssignedToTargets(targets, ds1.getId(), STATE_ACTIVE, Status.RUNNING);
|
||||
}
|
||||
|
||||
private void assertDsExclusivelyAssignedToTargets(final List<Target> targets, final long dsId, final boolean active,
|
||||
final Status status) {
|
||||
final List<Action> assignment = actionRepository.findByDistributionSetId(PAGE, dsId).getContent();
|
||||
|
||||
assertThat(assignment).hasSize(10).allMatch(action -> action.isActive() == active)
|
||||
.as("Is assigned to DS " + dsId).allMatch(action -> action.getDistributionSet().getId().equals(dsId))
|
||||
.as("State is " + status).allMatch(action -> action.getStatus() == status);
|
||||
final long[] targetIds = targets.stream().mapToLong(Target::getId).toArray();
|
||||
assertThat(targetIds).as("All targets represented in assignment").containsExactlyInAnyOrder(
|
||||
assignment.stream().mapToLong(action -> action.getTarget().getId()).toArray());
|
||||
}
|
||||
|
||||
/**
|
||||
* test a simple deployment by calling the
|
||||
* {@link TargetRepository#assignDistributionSet(DistributionSet, Iterable)}
|
||||
@@ -992,7 +1023,7 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
ds.getId(), ActionType.SOFT,
|
||||
org.eclipse.hawkbit.repository.model.RepositoryModelConstants.NO_FORCE_TIME,
|
||||
Arrays.asList(target.getControllerId()));
|
||||
final Long actionId = assignDistributionSet.getActions().get(0);
|
||||
final Long actionId = assignDistributionSet.getActionIds().get(0);
|
||||
// verify preparation
|
||||
Action findAction = deploymentManagement.findAction(actionId).get();
|
||||
assertThat(findAction.getActionType()).as("action type is wrong").isEqualTo(ActionType.SOFT);
|
||||
@@ -1016,7 +1047,7 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
ds.getId(), ActionType.FORCED,
|
||||
org.eclipse.hawkbit.repository.model.RepositoryModelConstants.NO_FORCE_TIME,
|
||||
Arrays.asList(target.getControllerId()));
|
||||
final Long actionId = assignDistributionSet.getActions().get(0);
|
||||
final Long actionId = assignDistributionSet.getActionIds().get(0);
|
||||
// verify perparation
|
||||
Action findAction = deploymentManagement.findAction(actionId).get();
|
||||
assertThat(findAction.getActionType()).as("action type is wrong").isEqualTo(ActionType.FORCED);
|
||||
@@ -1087,14 +1118,12 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
assertThat(event).isNotNull();
|
||||
assertThat(event.getDistributionSetId()).isEqualTo(ds.getId());
|
||||
|
||||
List<Long> eventActionIds = event.getActions().values().stream().map(ActionProperties::getId)
|
||||
final List<Long> eventActionIds = event.getActions().values().stream().map(ActionProperties::getId)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
List<Long> targetActiveActionIds = targets.stream()
|
||||
final List<Long> targetActiveActionIds = targets.stream()
|
||||
.map(t -> deploymentManagement.findActiveActionsByTarget(PAGE, t.getControllerId()).getContent())
|
||||
.flatMap(List::stream)
|
||||
.map(Action::getId)
|
||||
.collect(Collectors.toList());
|
||||
.flatMap(List::stream).map(Action::getId).collect(Collectors.toList());
|
||||
assertThat(eventActionIds).containsOnlyElementsOf(targetActiveActionIds);
|
||||
}
|
||||
|
||||
@@ -1216,4 +1245,8 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
}
|
||||
}
|
||||
|
||||
private void enableMultiAssignments() {
|
||||
tenantConfigurationManagement.addOrUpdateConfiguration(TenantConfigurationKey.MULTI_ASSIGNMENTS_ENABLED, true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -104,7 +104,7 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
testdataFactory.createTarget(knownControllerId);
|
||||
final DistributionSetAssignmentResult assignmentResult = deploymentManagement.assignDistributionSet(
|
||||
knownDistributionSet.getId(), ActionType.FORCED, 0, Collections.singleton(knownControllerId));
|
||||
final Long manuallyAssignedActionId = assignmentResult.getActions().get(0);
|
||||
final Long manuallyAssignedActionId = assignmentResult.getActionIds().get(0);
|
||||
|
||||
// create rollout with the same distribution set already assigned
|
||||
// start rollout
|
||||
@@ -144,7 +144,7 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
testdataFactory.createTarget(knownControllerId);
|
||||
final DistributionSetAssignmentResult assignmentResult = deploymentManagement.assignDistributionSet(
|
||||
firstDistributionSet.getId(), ActionType.FORCED, 0, Collections.singleton(knownControllerId));
|
||||
final Long manuallyAssignedActionId = assignmentResult.getActions().get(0);
|
||||
final Long manuallyAssignedActionId = assignmentResult.getActionIds().get(0);
|
||||
|
||||
// create rollout with the same distribution set already assigned
|
||||
// start rollout
|
||||
|
||||
@@ -96,7 +96,7 @@ public class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
|
||||
final String assignedB = targBs.iterator().next().getControllerId();
|
||||
assignDistributionSet(setA.getId(), assignedB);
|
||||
final String installedC = targCs.iterator().next().getControllerId();
|
||||
final Long actionId = assignDistributionSet(installedSet.getId(), assignedC).getActions().get(0);
|
||||
final Long actionId = assignDistributionSet(installedSet.getId(), assignedC).getActionIds().get(0);
|
||||
|
||||
// add attributes to match against only attribute value or attribute
|
||||
// value and name
|
||||
@@ -701,7 +701,7 @@ public class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
|
||||
List<Target> installedtargets = testdataFactory.createTargets(10, "assigned", "assigned");
|
||||
|
||||
// set on installed and assign another one
|
||||
assignDistributionSet(installedSet, installedtargets).getActions().forEach(actionId -> controllerManagement
|
||||
assignDistributionSet(installedSet, installedtargets).getActionIds().forEach(actionId -> controllerManagement
|
||||
.addUpdateActionStatus(entityFactory.actionStatus().create(actionId).status(Status.FINISHED)));
|
||||
assignDistributionSet(assignedSet, installedtargets);
|
||||
|
||||
|
||||
@@ -477,7 +477,7 @@ public class TargetManagementTest extends AbstractJpaIntegrationTest {
|
||||
final DistributionSetAssignmentResult result = assignDistributionSet(set.getId(), "4711");
|
||||
|
||||
controllerManagement.addUpdateActionStatus(
|
||||
entityFactory.actionStatus().create(result.getActions().get(0)).status(Status.FINISHED));
|
||||
entityFactory.actionStatus().create(result.getActionIds().get(0)).status(Status.FINISHED));
|
||||
assignDistributionSet(set2.getId(), "4711");
|
||||
|
||||
target = targetManagement.getByControllerID("4711").get();
|
||||
|
||||
@@ -59,7 +59,7 @@ public class AutoAssignCheckerTest extends AbstractJpaIntegrationTest {
|
||||
testdataFactory.createTarget(knownControllerId);
|
||||
final DistributionSetAssignmentResult assignmentResult = deploymentManagement.assignDistributionSet(
|
||||
firstDistributionSet.getId(), ActionType.FORCED, 0, Collections.singleton(knownControllerId));
|
||||
final Long manuallyAssignedActionId = assignmentResult.getActions().get(0);
|
||||
final Long manuallyAssignedActionId = assignmentResult.getActionIds().get(0);
|
||||
|
||||
// target filter query that matches all targets
|
||||
final TargetFilterQuery targetFilterQuery = targetFilterQueryManagement
|
||||
|
||||
@@ -81,7 +81,7 @@ public class AutoActionCleanupTest extends AbstractJpaIntegrationTest {
|
||||
final DistributionSet ds2 = testdataFactory.createDistributionSet("ds2");
|
||||
|
||||
final Long action1 = deploymentManagement.assignDistributionSet(ds1.getId(), ActionType.FORCED, 0,
|
||||
Collections.singletonList(trg1.getControllerId())).getActions().get(0);
|
||||
Collections.singletonList(trg1.getControllerId())).getActionIds().get(0);
|
||||
deploymentManagement.assignDistributionSet(ds2.getId(), ActionType.FORCED, 0,
|
||||
Collections.singletonList(trg2.getControllerId()));
|
||||
|
||||
@@ -110,11 +110,11 @@ public class AutoActionCleanupTest extends AbstractJpaIntegrationTest {
|
||||
final DistributionSet ds2 = testdataFactory.createDistributionSet("ds2");
|
||||
|
||||
final Long action1 = deploymentManagement.assignDistributionSet(ds1.getId(), ActionType.FORCED, 0,
|
||||
Collections.singletonList(trg1.getControllerId())).getActions().get(0);
|
||||
Collections.singletonList(trg1.getControllerId())).getActionIds().get(0);
|
||||
final Long action2 = deploymentManagement.assignDistributionSet(ds2.getId(), ActionType.FORCED, 0,
|
||||
Collections.singletonList(trg2.getControllerId())).getActions().get(0);
|
||||
Collections.singletonList(trg2.getControllerId())).getActionIds().get(0);
|
||||
final Long action3 = deploymentManagement.assignDistributionSet(ds2.getId(), ActionType.FORCED, 0,
|
||||
Collections.singletonList(trg3.getControllerId())).getActions().get(0);
|
||||
Collections.singletonList(trg3.getControllerId())).getActionIds().get(0);
|
||||
|
||||
assertThat(actionRepository.count()).isEqualTo(3);
|
||||
|
||||
@@ -145,11 +145,11 @@ public class AutoActionCleanupTest extends AbstractJpaIntegrationTest {
|
||||
final DistributionSet ds2 = testdataFactory.createDistributionSet("ds2");
|
||||
|
||||
final Long action1 = deploymentManagement.assignDistributionSet(ds1.getId(), ActionType.FORCED, 0,
|
||||
Collections.singletonList(trg1.getControllerId())).getActions().get(0);
|
||||
Collections.singletonList(trg1.getControllerId())).getActionIds().get(0);
|
||||
final Long action2 = deploymentManagement.assignDistributionSet(ds2.getId(), ActionType.FORCED, 0,
|
||||
Collections.singletonList(trg2.getControllerId())).getActions().get(0);
|
||||
Collections.singletonList(trg2.getControllerId())).getActionIds().get(0);
|
||||
final Long action3 = deploymentManagement.assignDistributionSet(ds2.getId(), ActionType.FORCED, 0,
|
||||
Collections.singletonList(trg3.getControllerId())).getActions().get(0);
|
||||
Collections.singletonList(trg3.getControllerId())).getActionIds().get(0);
|
||||
|
||||
assertThat(actionRepository.count()).isEqualTo(3);
|
||||
|
||||
@@ -182,11 +182,11 @@ public class AutoActionCleanupTest extends AbstractJpaIntegrationTest {
|
||||
final DistributionSet ds2 = testdataFactory.createDistributionSet("ds2");
|
||||
|
||||
final Long action1 = deploymentManagement.assignDistributionSet(ds1.getId(), ActionType.FORCED, 0,
|
||||
Collections.singletonList(trg1.getControllerId())).getActions().get(0);
|
||||
Collections.singletonList(trg1.getControllerId())).getActionIds().get(0);
|
||||
final Long action2 = deploymentManagement.assignDistributionSet(ds2.getId(), ActionType.FORCED, 0,
|
||||
Collections.singletonList(trg2.getControllerId())).getActions().get(0);
|
||||
Collections.singletonList(trg2.getControllerId())).getActionIds().get(0);
|
||||
final Long action3 = deploymentManagement.assignDistributionSet(ds2.getId(), ActionType.FORCED, 0,
|
||||
Collections.singletonList(trg3.getControllerId())).getActions().get(0);
|
||||
Collections.singletonList(trg3.getControllerId())).getActionIds().get(0);
|
||||
|
||||
assertThat(actionRepository.count()).isEqualTo(3);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user