Adapt cancel flow (#1274)
* Adapt assignment events to communicate mass cancel operations within one event. Signed-off-by: Michael Herdt <Michael.Herdt@bosch.io> * Fix edge cases identified by test failures. Adapt tests and reduce amount of published cancel events. Signed-off-by: Michael Herdt <Michael.Herdt@bosch.io> * Fix license header Signed-off-by: Michael Herdt <Michael.Herdt@bosch.io> * Refactor visibility of methods in assignment strategy classes. Avoid having empty action status messages. Signed-off-by: Michael Herdt <Michael.Herdt@bosch.io> * Fix api docs Signed-off-by: Michael Herdt <Michael.Herdt@bosch.io> Signed-off-by: Michael Herdt <Michael.Herdt@bosch.io> Co-authored-by: Bogdan Bondar <Bogdan.Bondar@bosch.io>
This commit is contained in:
@@ -119,6 +119,31 @@ public class RemoteTenantAwareEventTest extends AbstractRemoteEventTest {
|
||||
assertTargetAssignDistributionSetEvent(action, remoteEventJackson);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Verifies that a TargetAssignDistributionSetEvent can be properly serialized and deserialized")
|
||||
public void testCancelTargetAssignmentEvent() {
|
||||
|
||||
final DistributionSet dsA = testdataFactory.createDistributionSet("");
|
||||
|
||||
final JpaAction generateAction = new JpaAction();
|
||||
generateAction.setActionType(ActionType.FORCED);
|
||||
generateAction.setTarget(testdataFactory.createTarget("Test"));
|
||||
generateAction.setDistributionSet(dsA);
|
||||
generateAction.setStatus(Status.RUNNING);
|
||||
generateAction.setInitiatedBy(tenantAware.getCurrentUsername());
|
||||
|
||||
final Action action = actionRepository.save(generateAction);
|
||||
|
||||
final CancelTargetAssignmentEvent cancelEvent = new CancelTargetAssignmentEvent(action,
|
||||
serviceMatcher.getServiceId());
|
||||
|
||||
final CancelTargetAssignmentEvent remoteEventProtoStuff = createProtoStuffEvent(cancelEvent);
|
||||
assertCancelTargetAssignmentEvent(action, remoteEventProtoStuff);
|
||||
|
||||
final CancelTargetAssignmentEvent remoteEventJackson = createJacksonEvent(cancelEvent);
|
||||
assertCancelTargetAssignmentEvent(action, remoteEventJackson);
|
||||
}
|
||||
|
||||
private void assertTargetAssignDistributionSetEvent(final Action action,
|
||||
final TargetAssignDistributionSetEvent underTest) {
|
||||
|
||||
@@ -128,4 +153,12 @@ public class RemoteTenantAwareEventTest extends AbstractRemoteEventTest {
|
||||
assertThat(actionProperties).isEqualToComparingFieldByField(new ActionProperties(action));
|
||||
assertThat(underTest.getDistributionSetId()).isEqualTo(action.getDistributionSet().getId());
|
||||
}
|
||||
|
||||
private void assertCancelTargetAssignmentEvent(final Action action, final CancelTargetAssignmentEvent underTest) {
|
||||
assertThat(underTest.getActions().size()).isEqualTo(1);
|
||||
final ActionProperties actionProperties = underTest.getActions().get(action.getTarget().getControllerId());
|
||||
assertThat(actionProperties).isNotNull();
|
||||
assertThat(actionProperties).isEqualToComparingFieldByField(new ActionProperties(action));
|
||||
assertThat(underTest.getActionPropertiesForController(action.getTarget().getControllerId())).isPresent();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,17 +36,6 @@ public class TargetEventTest extends AbstractRemoteEntityEventTest<Target> {
|
||||
assertAndCreateRemoteEvent(TargetUpdatedEvent.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Verifies that cancel target assignment event works")
|
||||
public void testCancelTargetAssignmentEvent() {
|
||||
final Target target = createEntity();
|
||||
final CancelTargetAssignmentEvent assignmentEvent = new CancelTargetAssignmentEvent(target, 1L, "node");
|
||||
final CancelTargetAssignmentEvent underTest = (CancelTargetAssignmentEvent) assertEntity(target,
|
||||
assignmentEvent);
|
||||
|
||||
assertThat(underTest.getActionId()).isNotNull();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Target createEntity() {
|
||||
return testdataFactory.createTarget("12345");
|
||||
|
||||
@@ -44,7 +44,7 @@ import org.eclipse.hawkbit.repository.event.remote.TargetDeletedEvent;
|
||||
import org.eclipse.hawkbit.repository.event.remote.TargetPollEvent;
|
||||
import org.eclipse.hawkbit.repository.event.remote.entity.ActionCreatedEvent;
|
||||
import org.eclipse.hawkbit.repository.event.remote.entity.ActionUpdatedEvent;
|
||||
import org.eclipse.hawkbit.repository.event.remote.entity.CancelTargetAssignmentEvent;
|
||||
import org.eclipse.hawkbit.repository.event.remote.CancelTargetAssignmentEvent;
|
||||
import org.eclipse.hawkbit.repository.event.remote.entity.DistributionSetCreatedEvent;
|
||||
import org.eclipse.hawkbit.repository.event.remote.entity.SoftwareModuleCreatedEvent;
|
||||
import org.eclipse.hawkbit.repository.event.remote.entity.SoftwareModuleUpdatedEvent;
|
||||
|
||||
@@ -32,7 +32,7 @@ import org.eclipse.hawkbit.repository.event.remote.MultiActionCancelEvent;
|
||||
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;
|
||||
import org.eclipse.hawkbit.repository.event.remote.entity.CancelTargetAssignmentEvent;
|
||||
import org.eclipse.hawkbit.repository.event.remote.CancelTargetAssignmentEvent;
|
||||
import org.eclipse.hawkbit.repository.event.remote.entity.DistributionSetCreatedEvent;
|
||||
import org.eclipse.hawkbit.repository.event.remote.entity.DistributionSetUpdatedEvent;
|
||||
import org.eclipse.hawkbit.repository.event.remote.entity.SoftwareModuleCreatedEvent;
|
||||
@@ -265,7 +265,7 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
@Expect(type = TargetUpdatedEvent.class, count = 40),
|
||||
@Expect(type = TargetAssignDistributionSetEvent.class, count = 2),
|
||||
@Expect(type = ActionCreatedEvent.class, count = 40),
|
||||
@Expect(type = CancelTargetAssignmentEvent.class, count = 20),
|
||||
@Expect(type = CancelTargetAssignmentEvent.class, count = 1),
|
||||
@Expect(type = ActionUpdatedEvent.class, count = 20),
|
||||
@Expect(type = DistributionSetCreatedEvent.class, count = 2),
|
||||
@Expect(type = SoftwareModuleCreatedEvent.class, count = 6) })
|
||||
@@ -945,11 +945,11 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
@Expect(type = TargetUpdatedEvent.class, count = 3 * 4),
|
||||
@Expect(type = ActionCreatedEvent.class, count = 3 * 4),
|
||||
@Expect(type = ActionUpdatedEvent.class, count = 4 * 2),
|
||||
@Expect(type = CancelTargetAssignmentEvent.class, count = 4 * 2),
|
||||
@Expect(type = CancelTargetAssignmentEvent.class, count = 2),
|
||||
@Expect(type = DistributionSetCreatedEvent.class, count = 3),
|
||||
@Expect(type = SoftwareModuleCreatedEvent.class, count = 9),
|
||||
@Expect(type = TargetAssignDistributionSetEvent.class, count = 3) })
|
||||
void multipleDeployments() throws InterruptedException {
|
||||
void multipleDeployments() {
|
||||
final String undeployedTargetPrefix = "undep-T";
|
||||
final int noOfUndeployedTargets = 5;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user