Skip to content

Commit

Permalink
IGNITE-24194 testCleanStates is flaky (#5075)
Browse files Browse the repository at this point in the history
  • Loading branch information
valepakh authored Jan 20, 2025
1 parent 60f6f58 commit 7942688
Showing 1 changed file with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ public void testDoubleQueue() {
}

@Test
public void testCleanStates() throws InterruptedException {
public void testCleanStates() {
assertThat(configuration.change(change -> change.changeStatesLifetimeMillis(100)), willCompleteSuccessfully());

stateMachine = new InMemoryComputeStateMachine(configuration, "testNode");
Expand All @@ -168,23 +168,26 @@ public void testCleanStates() throws InterruptedException {
jobId = stateMachine.initJob();
executeJob(false);
completeJob(false);
ConditionFactory await = await().timeout(300, TimeUnit.MILLISECONDS);
await.untilAsserted(() -> assertThat(stateMachine.currentState(jobId), is(nullValue())));
// Default poll delay is equal to the poll interval. Cleaner also has initial delay equal to the ttl.
// So the check will happen only twice with 300 ms and 100 ms poll interval. If it happens just after we schedule remove then it
// will miss the state removal since removal will happen on the second pass
ConditionFactory await = await().atMost(400, TimeUnit.MILLISECONDS);
await.until(() -> stateMachine.currentState(jobId), is(nullValue()));

jobId = stateMachine.initJob();
executeJob(false);
failJob(false);
await.untilAsserted(() -> assertThat(stateMachine.currentState(jobId), is(nullValue())));
await.until(() -> stateMachine.currentState(jobId), is(nullValue()));

jobId = stateMachine.initJob();
cancelJob(false);
await.untilAsserted(() -> assertThat(stateMachine.currentState(jobId), is(nullValue())));
await.until(() -> stateMachine.currentState(jobId), is(nullValue()));

jobId = stateMachine.initJob();
executeJob(false);
cancelingJob(false);
cancelJob(false);
await.untilAsserted(() -> assertThat(stateMachine.currentState(jobId), is(nullValue())));
await.until(() -> stateMachine.currentState(jobId), is(nullValue()));

stateMachine.stop();
}
Expand Down

0 comments on commit 7942688

Please sign in to comment.