Skip to content

Commit 8d2fc8c

Browse files
committed
fix join.getLastAcceptedTerm() == lastAcceptedTerm && join.getLastAcceptedVersion() > getLastAcceptedVersion()
1 parent 8b7af72 commit 8d2fc8c

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,8 +218,9 @@ public void testJoinWinsElection() {
218218
StartJoinRequest startJoinRequest2 = new StartJoinRequest(node2, randomLongBetween(startJoinRequest1.getTerm() + 1, 10));
219219
Join v1 = cs1.handleStartJoin(startJoinRequest2);
220220

221-
Join join = new Join(node1, node1, v1.getTerm(), randomLongBetween(0, state2.term()),
222-
randomLongBetween(0, state2.version()));
221+
boolean sameTermButBetterVersion = randomBoolean();
222+
Join join = new Join(node1, node1, v1.getTerm(), sameTermButBetterVersion ? state2.term() : randomLongBetween(0, state2.term()),
223+
sameTermButBetterVersion ? randomLongBetween(0, state2.version()) : randomLongBetween(0, 20));
223224
assertTrue(cs1.handleJoin(join));
224225
assertTrue(cs1.electionWon());
225226
assertTrue(cs1.containsJoinVoteFor(node1));

0 commit comments

Comments
 (0)