@@ -2119,6 +2119,37 @@ func TestRaft_PreVoteMixedCluster(t *testing.T) {
2119
2119
2120
2120
}
2121
2121
2122
+ func TestRaft_PreVoteAvoidElectionWithPartition (t * testing.T ) {
2123
+ // Make a prevote cluster.
2124
+ conf := inmemConfig (t )
2125
+ conf .PreVote = true
2126
+ c := MakeCluster (5 , t , conf )
2127
+ defer c .Close ()
2128
+
2129
+ oldLeaderTerm := c .Leader ().getCurrentTerm ()
2130
+ followers := c .Followers ()
2131
+ require .Len (t , followers , 4 )
2132
+
2133
+ //Partition a node and wait enough for it to increase its term
2134
+ c .Partition ([]ServerAddress {followers [0 ].localAddr })
2135
+ time .Sleep (10 * c .propagateTimeout )
2136
+
2137
+ // Check the leader is stable and the followers are as expected
2138
+ leaderTerm := c .Leader ().getCurrentTerm ()
2139
+ require .Equal (t , leaderTerm , oldLeaderTerm )
2140
+ require .Len (t , c .WaitForFollowers (3 ), 3 )
2141
+
2142
+ // reconnect the partitioned node
2143
+ c .FullyConnect ()
2144
+ time .Sleep (3 * c .propagateTimeout )
2145
+
2146
+ // Check that the number of followers increase and
2147
+ require .Len (t , c .Followers (), 4 )
2148
+ leaderTerm = c .Leader ().getCurrentTerm ()
2149
+ require .Equal (t , leaderTerm , oldLeaderTerm )
2150
+
2151
+ }
2152
+
2122
2153
func TestRaft_VotingGrant_WhenLeaderAvailable (t * testing.T ) {
2123
2154
conf := inmemConfig (t )
2124
2155
conf .ProtocolVersion = 3
0 commit comments