Skip to content

Commit 2b31cfa

Browse files
committed
[Java] Properly fix shouldStartClusterThenElectNewLeaderAfterPartition test intermittency, i.e. await election termination before sending more messages into the Cluster. This is to deal with cases of unexpected vote request which leads to multiple rounds of elections being executed.
1 parent 3b034cb commit 2b31cfa

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

aeron-system-tests/src/test/java/io/aeron/cluster/ClusterNetworkPartitionTest.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,14 +107,15 @@ void shouldStartClusterThenElectNewLeaderAfterPartition()
107107
cluster.sendMessages(50); // will be sent to the old leader
108108
Tests.await(() -> firstLeader.appendPosition() > initialLeaderLogPosition);
109109

110-
final TestNode secondLeader = cluster.awaitLeaderWithoutElectionTerminationCheck(firstLeader.index());
111-
assertNotEquals(firstLeader.index(), secondLeader.index());
110+
final TestNode interimLeader = cluster.awaitLeaderWithoutElectionTerminationCheck(firstLeader.index());
111+
assertNotEquals(firstLeader.index(), interimLeader.index());
112112

113113
cluster.awaitNodeState(firstLeader, (n) -> n.electionState() == ElectionState.CANVASS);
114114

115115
IpTables.flushChain(CHAIN_NAME);
116116

117-
cluster.awaitNodeState(firstLeader, (n) -> n.electionState() == ElectionState.CLOSED);
117+
final TestNode finalLeader = cluster.awaitLeader(); // ensure no more elections
118+
assertNotEquals(firstLeader.index(), finalLeader.index());
118119

119120
cluster.reconnectClient();
120121
cluster.sendAndAwaitMessages(100, 200);

0 commit comments

Comments
 (0)