Skip to content

Commit

Permalink
Bmoric/improve flakiness (#9853)
Browse files Browse the repository at this point in the history
Improve some test that were flaky because of their asynchronous nature.
  • Loading branch information
benmoriceau committed Feb 1, 2022
1 parent eccee12 commit 0ed15f2
Showing 1 changed file with 8 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ public void deleteSync() {
}

@Nested
@DisplayName("Test which without a long running child workflow")
@DisplayName("Test which with a long running child workflow")
class SynchronousWorkflow {

@BeforeEach
Expand Down Expand Up @@ -399,14 +399,14 @@ public void manualRun() {
WorkflowClient.start(workflow::run, input);
testEnv.sleep(Duration.ofMinutes(2L));
workflow.submitManualSync();
testEnv.shutdown();

final Queue<ChangedStateEvent> events = testStateListener.events(testId);

Assertions.assertThat(events)
.filteredOn(changedStateEvent -> changedStateEvent.getField() == StateField.SKIPPED_SCHEDULING && changedStateEvent.isValue())
.isEmpty();

testEnv.shutdown();
}

@Test
Expand All @@ -428,9 +428,10 @@ public void cancelRunning() {

WorkflowClient.start(workflow::run, input);
workflow.submitManualSync();
testEnv.sleep(Duration.ofSeconds(30L));
testEnv.sleep(Duration.ofSeconds(10L));
workflow.cancelJob();
testEnv.sleep(Duration.ofMinutes(1L));
testEnv.sleep(Duration.ofMinutes(2L));
testEnv.shutdown();

final Queue<ChangedStateEvent> events = testStateListener.events(testId);

Expand All @@ -439,8 +440,6 @@ public void cancelRunning() {
.hasSizeGreaterThanOrEqualTo(1);

Mockito.verify(mJobCreationAndStatusUpdateActivity).jobCancelled(Mockito.any());

testEnv.shutdown();
}

@Test
Expand All @@ -464,6 +463,7 @@ public void resetStart() {
testEnv.sleep(Duration.ofSeconds(30L));
workflow.resetConnection();
testEnv.sleep(Duration.ofSeconds(90L));
testEnv.shutdown();

final Queue<ChangedStateEvent> events = testStateListener.events(testId);

Expand All @@ -473,7 +473,6 @@ public void resetStart() {

Mockito.verify(mJobCreationAndStatusUpdateActivity).jobSuccess(Mockito.any());

testEnv.shutdown();
}

@Test
Expand All @@ -497,7 +496,8 @@ public void resetCancelRunningWorkflow() {
workflow.submitManualSync();
testEnv.sleep(Duration.ofSeconds(30L));
workflow.resetConnection();
testEnv.sleep(Duration.ofSeconds(30L));
testEnv.sleep(Duration.ofMinutes(2L));
testEnv.shutdown();

final Queue<ChangedStateEvent> events = testStateListener.events(testId);

Expand All @@ -507,7 +507,6 @@ public void resetCancelRunningWorkflow() {

Mockito.verify(mJobCreationAndStatusUpdateActivity).jobCancelled(Mockito.any());

testEnv.shutdown();
}

@Test
Expand Down

0 comments on commit 0ed15f2

Please sign in to comment.