@@ -972,6 +972,9 @@ public void testDiffBasedPublishing() {
972972 }
973973
974974 private static class TimeAdvancer {
975+
976+ public static final int MAX_ADVANCE_MILLIS = 2000 ;
977+
975978 private final DeterministicTaskQueue deterministicTaskQueue ;
976979 private long elapsedTime ;
977980
@@ -981,18 +984,16 @@ private static class TimeAdvancer {
981984
982985 void advanceTime () {
983986 final long startTime = deterministicTaskQueue .getCurrentTimeMillis ();
984- if (deterministicTaskQueue .hasDeferredTasks () == false ) {
985- deterministicTaskQueue .scheduleAt (startTime + between (1000 , 2000 ), new Runnable () {
986- @ Override
987- public void run () {
988- }
989-
990- @ Override
991- public String toString () {
992- return "no-op task to advance time" ;
993- }
994- });
995- }
987+ deterministicTaskQueue .scheduleAt (startTime + between (1000 , MAX_ADVANCE_MILLIS ), new Runnable () {
988+ @ Override
989+ public void run () {
990+ }
991+
992+ @ Override
993+ public String toString () {
994+ return "no-op task to advance time" ;
995+ }
996+ });
996997 deterministicTaskQueue .advanceTime ();
997998 elapsedTime += deterministicTaskQueue .getCurrentTimeMillis () - startTime ;
998999 }
@@ -1033,7 +1034,7 @@ public void onFailure(String source, Exception e) {
10331034 }
10341035 });
10351036
1036- cluster .stabilise (DEFAULT_CLUSTER_STATE_UPDATE_DELAY );
1037+ cluster .stabilise (DEFAULT_CLUSTER_STATE_UPDATE_DELAY + TimeAdvancer . MAX_ADVANCE_MILLIS * 2 );
10371038
10381039 final ClusterStateUpdateStats stats1 = leader .coordinator .stats ().getClusterStateUpdateStats ();
10391040
@@ -1050,7 +1051,6 @@ public void onFailure(String source, Exception e) {
10501051 }
10511052 }
10521053
1053- @ AwaitsFix (bugUrl = "https://github.com/elastic/elasticsearch/issues/76840" )
10541054 public void testMasterStatsOnSuccessfulUpdate () {
10551055
10561056 final String customName = "delayed" ;
@@ -1124,7 +1124,7 @@ public void onFailure(String source, Exception e) {
11241124 }
11251125 });
11261126
1127- cluster .stabilise (DEFAULT_CLUSTER_STATE_UPDATE_DELAY );
1127+ cluster .stabilise (DEFAULT_CLUSTER_STATE_UPDATE_DELAY + TimeAdvancer . MAX_ADVANCE_MILLIS * 3 );
11281128
11291129 final ClusterStateUpdateStats stats1 = leader .coordinator .stats ().getClusterStateUpdateStats ();
11301130
@@ -1181,7 +1181,7 @@ public void onFailure(String source, Exception e) {
11811181 });
11821182
11831183 leader .blackhole ();
1184- cluster .stabilise (DEFAULT_STABILISATION_TIME );
1184+ cluster .stabilise (DEFAULT_STABILISATION_TIME + TimeAdvancer . MAX_ADVANCE_MILLIS * 2 );
11851185
11861186 final ClusterStateUpdateStats stats1 = leader .coordinator .stats ().getClusterStateUpdateStats ();
11871187
0 commit comments