소스 검색

Wait longer for leader failure in logs test (#46958)

`testLogsWarningPeriodicallyIfClusterNotFormed` simulates a leader failure and
waits for long enough that a failing leader check is scheduled. However it does
not wait for the failing check to actually fail, which requires another two
actions and therefore might take up to 200ms more. Unlucky timing would result
in this test failing, for instance:

    ./gradle ':server:test' \
      --tests "org.elasticsearch.cluster.coordination.CoordinatorTests.testLogsWarningPeriodicallyIfClusterNotFormed" \
      -Dtests.jvm.argline="-Dhppc.bitmixer=DETERMINISTIC" \
      -Dtests.seed=F18CDD0EBEB5653:E9BC1A8B062E697A

This commit adds the extra delay needed for the leader failure to complete as
expected.

Fixes #46920
David Turner 6 년 전
부모
커밋
da905a0323
1개의 변경된 파일7개의 추가작업 그리고 1개의 파일을 삭제
  1. 7 1
      server/src/test/java/org/elasticsearch/cluster/coordination/CoordinatorTests.java

+ 7 - 1
server/src/test/java/org/elasticsearch/cluster/coordination/CoordinatorTests.java

@@ -1215,9 +1215,15 @@ public class CoordinatorTests extends AbstractCoordinatorTestCase {
                 clusterNode.disconnect();
             }
 
-            cluster.runFor(defaultMillis(LEADER_CHECK_INTERVAL_SETTING) + defaultMillis(LEADER_CHECK_TIMEOUT_SETTING),
+            cluster.runFor(defaultMillis(LEADER_CHECK_TIMEOUT_SETTING) // to wait for any in-flight check to time out
+                    + defaultMillis(LEADER_CHECK_INTERVAL_SETTING) // to wait for the next check to be sent
+                    + 2 * DEFAULT_DELAY_VARIABILITY, // to send the failing check and receive the disconnection response
                 "waiting for leader failure");
 
+            for (final ClusterNode clusterNode : cluster.clusterNodes) {
+                assertThat(clusterNode.getId() + " is CANDIDATE", clusterNode.coordinator.getMode(), is(CANDIDATE));
+            }
+
             for (int i = scaledRandomIntBetween(1, 10); i >= 0; i--) {
                 final MockLogAppender mockLogAppender = new MockLogAppender();
                 try {