Skip to content

Commit

Permalink
(fix#411).TestLeaderStopAndReElectWithPriority unittest run failure. (s…
Browse files Browse the repository at this point in the history
…ofastack#458)

* (fix#411).TestLeaderStopAndReElectWithPriority unittest run failure.
  • Loading branch information
zongtanghu authored May 26, 2020
1 parent f36254e commit baa3b69
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions jraft-core/src/test/java/com/alipay/sofa/jraft/core/NodeTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -1048,8 +1048,22 @@ public void testLeaderStopAndReElectWithPriority() throws Exception {
leader = cluster.getLeader();

assertNotNull(leader);
assertEquals(60, leader.getNodeId().getPeerId().getPriority());
assertEquals(100, leader.getNodeTargetPriority());

// get current leader priority value
int leaderPriority = leader.getNodeId().getPeerId().getPriority();

// get current leader log size
int peer1LogSize = cluster.getFsmByPeer(peers.get(1)).getLogs().size();
int peer2LogSize = cluster.getFsmByPeer(peers.get(2)).getLogs().size();

// if the leader is lower priority value
if (leaderPriority == 10) {
// we just compare the two peers' log size value;
assertTrue(peer2LogSize > peer1LogSize);
} else {
assertEquals(60, leader.getNodeId().getPeerId().getPriority());
assertEquals(100, leader.getNodeTargetPriority());
}

cluster.stopAll();
}
Expand Down

0 comments on commit baa3b69

Please sign in to comment.