From 189b95819b18556118fd2d94544406f8b9d7b130 Mon Sep 17 00:00:00 2001 From: Lin ZiHao <1343152653@qq.com> Date: Thu, 7 May 2020 14:47:10 +0800 Subject: [PATCH] update raft_test TestLeaderElection2AA (#159) * update raft_test TestLeaderElection2AA change expected state to StateCandidate. since implementation of prevote is not required --- raft/raft_paper_test.go | 5 ----- raft/raft_test.go | 12 ++---------- 2 files changed, 2 insertions(+), 15 deletions(-) diff --git a/raft/raft_paper_test.go b/raft/raft_paper_test.go index f9846b36..ad200ed4 100644 --- a/raft/raft_paper_test.go +++ b/raft/raft_paper_test.go @@ -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}, diff --git a/raft/raft_test.go b/raft/raft_test.go index 68cfe877..febe719f 100644 --- a/raft/raft_test.go +++ b/raft/raft_test.go @@ -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 {