@@ -267,6 +267,34 @@ public void testJoinDoesNotWinElection() {
267267 assertFalse (cs1 .handleJoin (join ));
268268 }
269269
270+ public void testJoinDoesNotWinElectionWhenOnlyCommittedConfigQuorum () {
271+ VotingConfiguration configNode1 = new VotingConfiguration (Collections .singleton (node1 .getId ()));
272+ VotingConfiguration configNode2 = new VotingConfiguration (Collections .singleton (node2 .getId ()));
273+ ClusterState state1 = clusterState (0L , 1L , node1 , configNode1 , configNode2 , 42L );
274+ cs1 .setInitialState (state1 );
275+
276+ StartJoinRequest startJoinRequest = new StartJoinRequest (node1 , randomLongBetween (1 , 5 ));
277+ Join join = cs1 .handleStartJoin (startJoinRequest );
278+ assertTrue (cs1 .handleJoin (join ));
279+ assertFalse (cs1 .electionWon ());
280+ assertEquals (cs1 .getLastPublishedVersion (), 0L );
281+ assertFalse (cs1 .handleJoin (join ));
282+ }
283+
284+ public void testJoinDoesNotWinElectionWhenOnlyLastAcceptedConfigQuorum () {
285+ VotingConfiguration configNode1 = new VotingConfiguration (Collections .singleton (node1 .getId ()));
286+ VotingConfiguration configNode2 = new VotingConfiguration (Collections .singleton (node2 .getId ()));
287+ ClusterState state1 = clusterState (0L , 1L , node1 , configNode2 , configNode1 , 42L );
288+ cs1 .setInitialState (state1 );
289+
290+ StartJoinRequest startJoinRequest = new StartJoinRequest (node1 , randomLongBetween (1 , 5 ));
291+ Join join = cs1 .handleStartJoin (startJoinRequest );
292+ assertTrue (cs1 .handleJoin (join ));
293+ assertFalse (cs1 .electionWon ());
294+ assertEquals (cs1 .getLastPublishedVersion (), 0L );
295+ assertFalse (cs1 .handleJoin (join ));
296+ }
297+
270298 public void testHandleClientValue () {
271299 VotingConfiguration initialConfig = new VotingConfiguration (Collections .singleton (node1 .getId ()));
272300 ClusterState state1 = clusterState (0L , 1L , node1 , initialConfig , initialConfig , 42L );
0 commit comments