6060
6161class TestNodeStateManager
6262{
63- public static final int GRACE_PERIOD_MILLIS = 200 ;
63+ public static final int GRACE_PERIOD_MILLIS = 1000 ;
6464 private FakeScheduledExecutorService executor ;
6565 private NodeStateManager nodeStateManager ;
6666 private TestingTicker ticker ;
@@ -94,7 +94,7 @@ void testDrain()
9494 ticker .increment (1 , SECONDS );
9595 executor .run ();
9696
97- await ().atMost (1 , SECONDS ).untilAsserted (() -> assertThat (nodeStateManager .getServerState ()).isEqualTo (DRAINED ));
97+ await ().atMost (5 , SECONDS ).untilAsserted (() -> assertThat (nodeStateManager .getServerState ()).isEqualTo (DRAINED ));
9898 }
9999
100100 @ Test
@@ -105,8 +105,8 @@ void testTransitionToShuttingDown()
105105 nodeStateManager .transitionState (NodeState .SHUTTING_DOWN );
106106 assertThat (nodeStateManager .getServerState ()).isEqualTo (NodeState .SHUTTING_DOWN );
107107
108- // here wait for at least 2 grace periods, and add some slack to reduce test flakyness
109- await ().atMost (4 * GRACE_PERIOD_MILLIS + 100 , MILLISECONDS ).until (() -> shutdownAction .isShuttingDown ());
108+ // here wait for at least 4 grace periods, and add some slack to reduce test flakyness
109+ await ().atMost (4 * GRACE_PERIOD_MILLIS + 1000 , MILLISECONDS ).until (() -> shutdownAction .isShuttingDown ());
110110 }
111111
112112 @ Test
@@ -117,7 +117,7 @@ void testCannotReactivateShuttingDown()
117117 nodeStateManager .transitionState (NodeState .SHUTTING_DOWN );
118118 assertThat (nodeStateManager .getServerState ()).isEqualTo (NodeState .SHUTTING_DOWN );
119119
120- // here wait for at least 2 grace periods, and add some slack to reduce test flakyness
120+ // here wait for at least 4 grace periods, and add some slack to reduce test flakyness
121121 await ().atMost (4 * GRACE_PERIOD_MILLIS , MILLISECONDS ).until (() -> shutdownAction .isShuttingDown ());
122122
123123 assertThatThrownBy (() -> nodeStateManager .transitionState (ACTIVE ))
@@ -144,9 +144,8 @@ void testImmediateTransitionToShuttingDownWhenDrained()
144144 nodeStateManager .transitionState (NodeState .SHUTTING_DOWN );
145145 assertThat (nodeStateManager .getServerState ()).isEqualTo (NodeState .SHUTTING_DOWN );
146146
147- // here only wait for minimal amount of time, as shutdown should be immediate
148147 await ().pollInterval (1 , MILLISECONDS )
149- .atMost (100 , MILLISECONDS ).until (() -> shutdownAction .isShuttingDown ());
148+ .atMost (1 , SECONDS ).until (() -> shutdownAction .isShuttingDown ());
150149 }
151150
152151 @ Test
@@ -171,7 +170,7 @@ void testWaitActiveTasksToFinishDuringShutdown()
171170 // make sure that nodeStateManager registered a listener for tasks to finish
172171 ticker .increment (1 , SECONDS );
173172 executor .run ();
174- await ().atMost (1 , SECONDS ).until (() -> sqlTasksObservable .getTasks ().size () == 1 );
173+ await ().atMost (5 , SECONDS ).until (() -> sqlTasksObservable .getTasks ().size () == 1 );
175174
176175 // simulate task completion after some time
177176 tasks .set (Collections .emptyList ());
@@ -213,7 +212,7 @@ void testWaitActiveTasksToFinishDuringDraining()
213212 .stateChanged (TaskState .FINISHED );
214213
215214 // when NodeStateManager sees task finished - it will drain after another drain period
216- await ().atMost (1 , SECONDS )
215+ await ().atMost (5 , SECONDS )
217216 .untilAsserted (() -> assertThat (nodeStateManager .getServerState ()).isEqualTo (DRAINED ));
218217 }
219218
0 commit comments