mirror of
https://github.com/talent-plan/tinykv.git
synced 2025-03-15 12:20:40 +08:00
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:
parent
4adae7912e
commit
189b95819b
@ -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},
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user