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
This commit is contained in:
David Turner 2019-09-23 10:46:25 +01:00
parent 363beefbcd
commit 7bc86f23ec

View File

@ -1216,9 +1216,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 {