Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@

class TestNodeStateManager
{
public static final int GRACE_PERIOD_MILLIS = 200;
public static final int GRACE_PERIOD_MILLIS = 1000;
private FakeScheduledExecutorService executor;
private NodeStateManager nodeStateManager;
private TestingTicker ticker;
Expand Down Expand Up @@ -94,7 +94,7 @@ void testDrain()
ticker.increment(1, SECONDS);
executor.run();

await().atMost(1, SECONDS).untilAsserted(() -> assertThat(nodeStateManager.getServerState()).isEqualTo(DRAINED));
await().atMost(5, SECONDS).untilAsserted(() -> assertThat(nodeStateManager.getServerState()).isEqualTo(DRAINED));
}

@Test
Expand All @@ -105,8 +105,8 @@ void testTransitionToShuttingDown()
nodeStateManager.transitionState(NodeState.SHUTTING_DOWN);
assertThat(nodeStateManager.getServerState()).isEqualTo(NodeState.SHUTTING_DOWN);

// here wait for at least 2 grace periods, and add some slack to reduce test flakyness
await().atMost(4 * GRACE_PERIOD_MILLIS + 100, MILLISECONDS).until(() -> shutdownAction.isShuttingDown());
// here wait for at least 4 grace periods, and add some slack to reduce test flakyness
Copy link

Copilot AI Oct 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Corrected spelling of 'flakyness' to 'flakiness'.

Copilot uses AI. Check for mistakes.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good idea

await().atMost(4 * GRACE_PERIOD_MILLIS + 1000, MILLISECONDS).until(() -> shutdownAction.isShuttingDown());
}

@Test
Expand All @@ -117,7 +117,7 @@ void testCannotReactivateShuttingDown()
nodeStateManager.transitionState(NodeState.SHUTTING_DOWN);
assertThat(nodeStateManager.getServerState()).isEqualTo(NodeState.SHUTTING_DOWN);

// here wait for at least 2 grace periods, and add some slack to reduce test flakyness
// here wait for at least 4 grace periods, and add some slack to reduce test flakyness
Copy link

Copilot AI Oct 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Corrected spelling of 'flakyness' to 'flakiness'.

Copilot uses AI. Check for mistakes.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

keen eye

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good idea

await().atMost(4 * GRACE_PERIOD_MILLIS, MILLISECONDS).until(() -> shutdownAction.isShuttingDown());

assertThatThrownBy(() -> nodeStateManager.transitionState(ACTIVE))
Expand All @@ -144,9 +144,8 @@ void testImmediateTransitionToShuttingDownWhenDrained()
nodeStateManager.transitionState(NodeState.SHUTTING_DOWN);
assertThat(nodeStateManager.getServerState()).isEqualTo(NodeState.SHUTTING_DOWN);

// here only wait for minimal amount of time, as shutdown should be immediate
await().pollInterval(1, MILLISECONDS)
.atMost(100, MILLISECONDS).until(() -> shutdownAction.isShuttingDown());
.atMost(1, SECONDS).until(() -> shutdownAction.isShuttingDown());
}

@Test
Expand All @@ -171,7 +170,7 @@ void testWaitActiveTasksToFinishDuringShutdown()
// make sure that nodeStateManager registered a listener for tasks to finish
ticker.increment(1, SECONDS);
executor.run();
await().atMost(1, SECONDS).until(() -> sqlTasksObservable.getTasks().size() == 1);
await().atMost(5, SECONDS).until(() -> sqlTasksObservable.getTasks().size() == 1);

// simulate task completion after some time
tasks.set(Collections.emptyList());
Expand Down Expand Up @@ -213,7 +212,7 @@ void testWaitActiveTasksToFinishDuringDraining()
.stateChanged(TaskState.FINISHED);

// when NodeStateManager sees task finished - it will drain after another drain period
await().atMost(1, SECONDS)
await().atMost(5, SECONDS)
.untilAsserted(() -> assertThat(nodeStateManager.getServerState()).isEqualTo(DRAINED));
}

Expand Down
Loading