Skip to content

Commit

Permalink
Ensure different group schedule and start event on rollout start
Browse files Browse the repository at this point in the history
Signed-off-by: Avgustin Marinov <[email protected]>
  • Loading branch information
avgustinmm committed Dec 12, 2024
1 parent f813be8 commit 1612335
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@

@Feature("Component Tests - Device Management Federation API")
@Story("Amqp Message Dispatcher Service")
public class AmqpMessageDispatcherServiceIntegrationTest extends AbstractAmqpServiceIntegrationTest {
class AmqpMessageDispatcherServiceIntegrationTest extends AbstractAmqpServiceIntegrationTest {

private static final String TARGET_PREFIX = "Dmf_disp_";

Expand All @@ -101,7 +101,7 @@ public class AmqpMessageDispatcherServiceIntegrationTest extends AbstractAmqpSer
@Expect(type = SoftwareModuleUpdatedEvent.class, count = 9), // implicit lock
@Expect(type = TargetUpdatedEvent.class, count = 1),
@Expect(type = TargetPollEvent.class, count = 1) })
public void sendDownloadAndInstallStatus() {
void sendDownloadAndInstallStatus() {
final String controllerId = TARGET_PREFIX + "sendDownloadAndInstallStatus";
registerTargetAndAssignDistributionSet(controllerId);

Expand All @@ -121,7 +121,7 @@ public void sendDownloadAndInstallStatus() {
@Expect(type = SoftwareModuleUpdatedEvent.class, count = 9), // implicit lock
@Expect(type = TargetUpdatedEvent.class, count = 1),
@Expect(type = TargetPollEvent.class, count = 1) })
public void sendDownloadStatusBeforeMaintenanceWindowStartTime() {
void sendDownloadStatusBeforeMaintenanceWindowStartTime() {
final String controllerId = TARGET_PREFIX + "sendDownloadStatusBeforeWindowStartTime";

registerAndAssertTargetWithExistingTenant(controllerId);
Expand All @@ -146,7 +146,7 @@ public void sendDownloadStatusBeforeMaintenanceWindowStartTime() {
@Expect(type = SoftwareModuleUpdatedEvent.class, count = 9), // implicit lock
@Expect(type = TargetUpdatedEvent.class, count = 1),
@Expect(type = TargetPollEvent.class, count = 1) })
public void sendDownloadAndInstallStatusMessageDuringMaintenanceWindow() {
void sendDownloadAndInstallStatusMessageDuringMaintenanceWindow() {
final String controllerId = TARGET_PREFIX + "sendDAndIStatusMessageDuringWindow";

registerAndAssertTargetWithExistingTenant(controllerId);
Expand All @@ -173,7 +173,7 @@ public void sendDownloadAndInstallStatusMessageDuringMaintenanceWindow() {
@Expect(type = SoftwareModuleUpdatedEvent.class, count = 18), // implicit lock
@Expect(type = TargetUpdatedEvent.class, count = 2),
@Expect(type = TargetPollEvent.class, count = 3) })
public void assignDistributionSetMultipleTimes() {
void assignDistributionSetMultipleTimes() {
final String controllerId = TARGET_PREFIX + "assignDistributionSetMultipleTimes";

final DistributionSetAssignmentResult assignmentResult = registerTargetAndAssignDistributionSet(controllerId);
Expand Down Expand Up @@ -221,7 +221,7 @@ public void assignDistributionSetMultipleTimes() {
@Expect(type = TargetUpdatedEvent.class, count = 2),
@Expect(type = TargetPollEvent.class, count = 1),
@Expect(type = TenantConfigurationCreatedEvent.class, count = 1) })
public void assignMultipleDsInMultiAssignMode() {
void assignMultipleDsInMultiAssignMode() {
enableMultiAssignments();
final String controllerId = TARGET_PREFIX + "assignMultipleDsInMultiAssignMode";
registerAndAssertTargetWithExistingTenant(controllerId);
Expand All @@ -239,7 +239,7 @@ public void assignMultipleDsInMultiAssignMode() {

@Test
@Description("Verify payload of multi action messages.")
public void assertMultiActionMessagePayloads() {
void assertMultiActionMessagePayloads() {
final int expectedWeightIfNotSet = 1000;
final int weight1 = 600;
final String controllerId = UUID.randomUUID().toString();
Expand Down Expand Up @@ -303,7 +303,7 @@ public void assertMultiActionMessagePayloads() {
@Expect(type = TargetUpdatedEvent.class, count = 2),
@Expect(type = TargetPollEvent.class, count = 1),
@Expect(type = TenantConfigurationCreatedEvent.class, count = 1) })
public void cancelActionInMultiAssignMode() {
void cancelActionInMultiAssignMode() {
enableMultiAssignments();
final String controllerId = TARGET_PREFIX + "cancelActionInMultiAssignMode";
registerAndAssertTargetWithExistingTenant(controllerId);
Expand Down Expand Up @@ -341,7 +341,7 @@ public void cancelActionInMultiAssignMode() {
@Expect(type = TargetUpdatedEvent.class, count = 3),
@Expect(type = TargetPollEvent.class, count = 1),
@Expect(type = TenantConfigurationCreatedEvent.class, count = 1) })
public void finishActionInMultiAssignMode() {
void finishActionInMultiAssignMode() {
enableMultiAssignments();
final String controllerId = TARGET_PREFIX + "finishActionInMultiAssignMode";
registerAndAssertTargetWithExistingTenant(controllerId);
Expand Down Expand Up @@ -373,7 +373,7 @@ public void finishActionInMultiAssignMode() {
@Expect(type = TargetUpdatedEvent.class, count = 2),
@Expect(type = TargetPollEvent.class, count = 1),
@Expect(type = TenantConfigurationCreatedEvent.class, count = 1) })
public void assignDsMultipleTimesInMultiAssignMode() {
void assignDsMultipleTimesInMultiAssignMode() {
enableMultiAssignments();
final String controllerId = TARGET_PREFIX + "assignDsMultipleTimesInMultiAssignMode";
registerAndAssertTargetWithExistingTenant(controllerId);
Expand Down Expand Up @@ -405,11 +405,11 @@ public void assignDsMultipleTimesInMultiAssignMode() {
@Expect(type = TargetUpdatedEvent.class, count = 1),
@Expect(type = TargetPollEvent.class, count = 1),
@Expect(type = RolloutCreatedEvent.class, count = 2),
@Expect(type = RolloutUpdatedEvent.class, count = 6),
@Expect(type = RolloutUpdatedEvent.class, count = 4),
@Expect(type = RolloutGroupCreatedEvent.class, count = 2),
@Expect(type = RolloutGroupUpdatedEvent.class, count = 4),
@Expect(type = TenantConfigurationCreatedEvent.class, count = 1) })
public void startRolloutsWithSameDsInMultiAssignMode() {
void startRolloutsWithSameDsInMultiAssignMode() {
enableMultiAssignments();
final String controllerId = TARGET_PREFIX + "startRolloutsWithSameDsInMultiAssignMode";

Expand Down Expand Up @@ -444,9 +444,9 @@ public void startRolloutsWithSameDsInMultiAssignMode() {
@Expect(type = RolloutCreatedEvent.class, count = 3),
@Expect(type = RolloutUpdatedEvent.class, count = 9),
@Expect(type = RolloutGroupCreatedEvent.class, count = 3),
@Expect(type = RolloutGroupUpdatedEvent.class, count = 6),
@Expect(type = RolloutGroupUpdatedEvent.class, count = 9),
@Expect(type = TenantConfigurationCreatedEvent.class, count = 1) })
public void startMultipleRolloutsAndFinishInMultiAssignMode() {
void startMultipleRolloutsAndFinishInMultiAssignMode() {
enableMultiAssignments();
final String controllerId = TARGET_PREFIX + "startMultipleRolloutsAndFinishInMultiAssignMode";

Expand Down Expand Up @@ -492,7 +492,7 @@ public void startMultipleRolloutsAndFinishInMultiAssignMode() {
@Expect(type = SoftwareModuleUpdatedEvent.class, count = 9), // implicit lock
@Expect(type = TargetUpdatedEvent.class, count = 1),
@Expect(type = TargetPollEvent.class, count = 2) })
public void sendCancelStatus() {
void sendCancelStatus() {
final String controllerId = TARGET_PREFIX + "sendCancelStatus";

final Long actionId = registerTargetAndCancelActionId(controllerId);
Expand All @@ -508,7 +508,7 @@ public void sendCancelStatus() {
@Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetPollEvent.class, count = 1),
@Expect(type = TargetDeletedEvent.class, count = 1) })
public void sendDeleteMessage() {
void sendDeleteMessage() {
final String controllerId = TARGET_PREFIX + "sendDeleteMessage";

registerAndAssertTargetWithExistingTenant(controllerId);
Expand All @@ -530,7 +530,7 @@ public void sendDeleteMessage() {
@Expect(type = TargetUpdatedEvent.class, count = 4),
@Expect(type = TargetAttributesRequestedEvent.class, count = 1),
@Expect(type = TargetPollEvent.class, count = 1) })
public void attributeRequestAfterSuccessfulUpdate() {
void attributeRequestAfterSuccessfulUpdate() {
final String controllerId = TARGET_PREFIX + "attributeUpdateRequest";
registerAndAssertTargetWithExistingTenant(controllerId);

Expand All @@ -557,7 +557,7 @@ public void attributeRequestAfterSuccessfulUpdate() {
@Expect(type = SoftwareModuleUpdatedEvent.class, count = 9), // implicit lock
@Expect(type = TargetUpdatedEvent.class, count = 1),
@Expect(type = TargetPollEvent.class, count = 1) })
public void downloadOnlyAssignmentSendsDownloadMessageTopic() {
void downloadOnlyAssignmentSendsDownloadMessageTopic() {
final String controllerId = TARGET_PREFIX + "registerTargets_1";
final DistributionSet distributionSet = createTargetAndDistributionSetAndAssign(controllerId, DOWNLOAD_ONLY);

Expand All @@ -580,13 +580,13 @@ public void downloadOnlyAssignmentSendsDownloadMessageTopic() {

@Test
@Description("Verify payload of batch assignment download and install message.")
public void assertBatchAssignmentsDownloadAndInstall() {
void assertBatchAssignmentsDownloadAndInstall() {
assertBatchAssignmentsMessagePayload(BATCH_DOWNLOAD_AND_INSTALL);
}

@Test
@Description("Verify payload of batch assignments download only message.")
public void assertBatchAssignmentsDownloadOnly() {
void assertBatchAssignmentsDownloadOnly() {
assertBatchAssignmentsMessagePayload(BATCH_DOWNLOAD);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,11 @@ private void startFirstRolloutGroup(final Rollout rollout) {
private boolean ensureAllGroupsAreScheduled(final Rollout rollout) {
final JpaRollout jpaRollout = (JpaRollout) rollout;
final List<JpaRolloutGroup> groupsToBeScheduled = rolloutGroupRepository.findByRolloutAndStatus(rollout, RolloutGroupStatus.READY);
if (groupsToBeScheduled.isEmpty()) {
return true;
}
final long scheduledGroups = groupsToBeScheduled.stream().filter(group -> scheduleRolloutGroup(jpaRollout, group)).count();
entityManager.flush(); // flush groups so scheduled group to start to have scheduled event
return scheduledGroups == groupsToBeScheduled.size();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1816,7 +1816,7 @@ void deleteRolloutWhichHasNeverStartedIsHardDeleted() {
@Expect(type = RolloutCreatedEvent.class, count = 1),
@Expect(type = RolloutUpdatedEvent.class, count = 6),
@Expect(type = RolloutDeletedEvent.class, count = 1),
@Expect(type = RolloutGroupUpdatedEvent.class, count = 10),
@Expect(type = RolloutGroupUpdatedEvent.class, count = 11),
@Expect(type = RolloutGroupCreatedEvent.class, count = 5) })
void deleteRolloutWhichHasBeenStartedBeforeIsSoftDeleted() {
final int amountTargetsForRollout = 10;
Expand Down

0 comments on commit 1612335

Please sign in to comment.