mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
raft: fix flaky test
We recently changed the randomized election timeout from (et, 2*et-1] tp [et, 2*et-2], where et is user set election timeout. So 2*et might trigger two elections instead of one. We need to fix the test code accordingly. Thanks for Tikv guys for finding this issue. We probably need to randomize etcd/raft test more.
This commit is contained in:
parent
a8139e2b0e
commit
2fa5b913fe
@ -159,7 +159,7 @@ func testNonleaderStartElection(t *testing.T, state StateType) {
|
||||
r.becomeCandidate()
|
||||
}
|
||||
|
||||
for i := 0; i < 2*et; i++ {
|
||||
for i := 1; i < 2*et; i++ {
|
||||
r.tick()
|
||||
}
|
||||
|
||||
@ -785,7 +785,7 @@ func TestVoteRequest(t *testing.T) {
|
||||
})
|
||||
r.readMessages()
|
||||
|
||||
for i := 0; i < r.electionTimeout*2; i++ {
|
||||
for i := 1; i < r.electionTimeout*2; i++ {
|
||||
r.tickElection()
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user