mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
commit
6e7baab32c
@ -1235,9 +1235,8 @@ func TestLeaderSupersedingWithCheckQuorum(t *testing.T) {
|
||||
c.checkQuorum = true
|
||||
|
||||
nt := newNetwork(a, b, c)
|
||||
setRandomizedElectionTimeout(b, b.electionTimeout+1)
|
||||
|
||||
// Prevent campaigning from b
|
||||
b.randomizedElectionTimeout = b.electionTimeout + 1
|
||||
for i := 0; i < b.electionTimeout; i++ {
|
||||
b.tick()
|
||||
}
|
||||
@ -1279,6 +1278,8 @@ func TestLeaderElectionWithCheckQuorum(t *testing.T) {
|
||||
c.checkQuorum = true
|
||||
|
||||
nt := newNetwork(a, b, c)
|
||||
setRandomizedElectionTimeout(a, a.electionTimeout+1)
|
||||
setRandomizedElectionTimeout(b, b.electionTimeout+2)
|
||||
|
||||
// Letting b's electionElapsed reach to timeout so that it can vote for a
|
||||
for i := 0; i < b.electionTimeout; i++ {
|
||||
@ -1324,6 +1325,8 @@ func TestFreeStuckCandidateWithCheckQuorum(t *testing.T) {
|
||||
c.checkQuorum = true
|
||||
|
||||
nt := newNetwork(a, b, c)
|
||||
setRandomizedElectionTimeout(b, b.electionTimeout+1)
|
||||
|
||||
for i := 0; i < b.electionTimeout; i++ {
|
||||
b.tick()
|
||||
}
|
||||
@ -1380,6 +1383,7 @@ func TestNonPromotableVoterWithCheckQuorum(t *testing.T) {
|
||||
b.checkQuorum = true
|
||||
|
||||
nt := newNetwork(a, b)
|
||||
setRandomizedElectionTimeout(b, b.electionTimeout+1)
|
||||
// Need to remove 2 again to make it a non-promotable node since newNetwork overwritten some internal states
|
||||
b.delProgress(2)
|
||||
|
||||
@ -1415,6 +1419,8 @@ func TestReadIndexWithCheckQuorum(t *testing.T) {
|
||||
c.checkQuorum = true
|
||||
|
||||
nt := newNetwork(a, b, c)
|
||||
setRandomizedElectionTimeout(b, b.electionTimeout+1)
|
||||
|
||||
for i := 0; i < b.electionTimeout; i++ {
|
||||
b.tick()
|
||||
}
|
||||
@ -2612,6 +2618,13 @@ func idsBySize(size int) []uint64 {
|
||||
return ids
|
||||
}
|
||||
|
||||
// setRandomizedElectionTimeout set up the value by caller instead of choosing
|
||||
// by system, in some test scenario we need to fill in some expected value to
|
||||
// ensure the certainty
|
||||
func setRandomizedElectionTimeout(r *raft, v int) {
|
||||
r.randomizedElectionTimeout = v
|
||||
}
|
||||
|
||||
func newTestConfig(id uint64, peers []uint64, election, heartbeat int, storage Storage) *Config {
|
||||
return &Config{
|
||||
ID: id,
|
||||
|
Loading…
x
Reference in New Issue
Block a user