update raft_test TestLeaderElection2AA (#159)

* update raft_test TestLeaderElection2AA

change expected state to StateCandidate. since implementation of prevote is not required
This commit is contained in:
Lin ZiHao 2020-05-07 14:47:10 +08:00 committed by GitHub
parent 4adae7912e
commit 189b95819b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 15 deletions

View File

@ -181,11 +181,6 @@ func TestLeaderElectionInOneRoundRPC2AA(t *testing.T) {
{5, map[uint64]bool{2: true, 3: true, 4: true}, StateLeader},
{5, map[uint64]bool{2: true, 3: true}, StateLeader},
// return to follower state if it receives vote denial from a majority
{3, map[uint64]bool{2: false, 3: false}, StateFollower},
{5, map[uint64]bool{2: false, 3: false, 4: false, 5: false}, StateFollower},
{5, map[uint64]bool{2: true, 3: false, 4: false, 5: false}, StateFollower},
// stay in candidate if it does not obtain the majority
{3, map[uint64]bool{}, StateCandidate},
{5, map[uint64]bool{2: true}, StateCandidate},

View File

@ -66,8 +66,6 @@ func TestProgressLeader2AB(t *testing.T) {
func TestLeaderElection2AA(t *testing.T) {
var cfg func(*Config)
candState := StateCandidate
candTerm := uint64(1)
tests := []struct {
*network
state StateType
@ -75,15 +73,9 @@ func TestLeaderElection2AA(t *testing.T) {
}{
{newNetworkWithConfig(cfg, nil, nil, nil), StateLeader, 1},
{newNetworkWithConfig(cfg, nil, nil, nopStepper), StateLeader, 1},
{newNetworkWithConfig(cfg, nil, nopStepper, nopStepper), candState, candTerm},
{newNetworkWithConfig(cfg, nil, nopStepper, nopStepper, nil), candState, candTerm},
{newNetworkWithConfig(cfg, nil, nopStepper, nopStepper), StateCandidate, 1},
{newNetworkWithConfig(cfg, nil, nopStepper, nopStepper, nil), StateCandidate, 1},
{newNetworkWithConfig(cfg, nil, nopStepper, nopStepper, nil, nil), StateLeader, 1},
// three logs further along than 0, but in the same term so rejections
// are returned instead of the votes being ignored.
{newNetworkWithConfig(cfg,
nil, entsWithConfig(cfg, 1), entsWithConfig(cfg, 1), entsWithConfig(cfg, 1, 1), nil),
StateFollower, 1},
}
for i, tt := range tests {