Skip to content

Commit 05e33f6

Browse files
authored
Reinstate testLeaderDisconnectionWithDisconnectEventDetectedQuickly (#95415)
This test now works for atomic-register coordinators, with a slightly weaker time bound. Relates #95409
1 parent 6215f2e commit 05e33f6

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,17 @@
4545

4646
@TestLogging(reason = "these tests do a lot of log-worthy things but we usually don't care", value = "org.elasticsearch:FATAL")
4747
public class AtomicRegisterCoordinatorTests extends CoordinatorTests {
48+
4849
@Override
49-
@AwaitsFix(bugUrl = "ES-5645")
5050
public void testLeaderDisconnectionWithDisconnectEventDetectedQuickly() {
51-
// In this test the leader still has access to the register, therefore it is still considered as a leader.
51+
// must allow a little extra time for the heartbeat to expire before the election can happen
52+
testLeaderDisconnectionWithDisconnectEventDetectedQuickly(
53+
Settings.builder()
54+
.put(MAX_MISSED_HEARTBEATS.getKey(), 1)
55+
.put(HEARTBEAT_FREQUENCY.getKey(), TimeValue.timeValueSeconds(1))
56+
.build(),
57+
TimeValue.timeValueSeconds(1)
58+
);
5259
}
5360

5461
@Override

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,11 @@ public void testNodesJoinAfterStableCluster() {
219219
}
220220

221221
public void testLeaderDisconnectionWithDisconnectEventDetectedQuickly() {
222-
try (Cluster cluster = new Cluster(randomIntBetween(3, 5))) {
222+
testLeaderDisconnectionWithDisconnectEventDetectedQuickly(Settings.EMPTY, TimeValue.ZERO);
223+
}
224+
225+
protected void testLeaderDisconnectionWithDisconnectEventDetectedQuickly(Settings settings, TimeValue extraStabilisationTime) {
226+
try (Cluster cluster = new Cluster(randomIntBetween(3, 5), true, settings)) {
223227
cluster.runRandomly();
224228
cluster.stabilise();
225229

@@ -238,6 +242,8 @@ public void testLeaderDisconnectionWithDisconnectEventDetectedQuickly() {
238242
+ DEFAULT_CLUSTER_STATE_UPDATE_DELAY
239243
// then wait for the followup reconfiguration
240244
+ DEFAULT_CLUSTER_STATE_UPDATE_DELAY
245+
// plus possibly some extra time according to the config
246+
+ extraStabilisationTime.millis()
241247
);
242248
assertThat(cluster.getAnyLeader().getId(), not(equalTo(originalLeader.getId())));
243249
}

0 commit comments

Comments
 (0)