Skip to content

Commit ca44649

Browse files
authored
Fix LeaderCheckerTests#testFollowerBehaviour (#83897) (#83952)
This test computes the expected message by tracking the different kinds of failures generated by a mock transport service. This tracking counts consecutive failures so is reset on success, but it is not explicitly reset when starting the second pass. This was usually fine since we start the second pass with a long sequence of checks that do not fail which would reset the tracking. Rarely however this sequence was too short to contain any success responses, so the counters would not be reset as needed. This commit makes sure we run at least `leaderCheckRetryCount` iterations without a failure to ensure that at least one of them succeeds. Closes #83857 Closes #83924
1 parent baa7180 commit ca44649

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

server/src/test/java/org/elasticsearch/cluster/coordination/LeaderCheckerTests.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,9 @@ public String toString() {
205205
leaderChecker.updateLeader(leader2);
206206
{
207207
checkCount.set(0);
208-
final long maxCheckCount = randomLongBetween(2, 1000);
208+
// run at least leaderCheckRetryCount iterations to ensure at least one success so that we reset the counters and clear out
209+
// anything left over from the previous run
210+
final long maxCheckCount = randomLongBetween(leaderCheckRetryCount, 1000);
209211
logger.info("--> checking again that no failure is detected in {} checks", maxCheckCount);
210212
while (checkCount.get() < maxCheckCount) {
211213
deterministicTaskQueue.runAllRunnableTasks();

0 commit comments

Comments
 (0)