Skip to content

Commit

Permalink
raft: fix flaky leader index in waitLeader function
Browse files Browse the repository at this point in the history
Fixes #127413.

This commit bypasses the larger rebase in #122133 to pick up the test
flake fix in etcd-io/raft#188. There was some
discussion in etcd-io/raft#181 about alternatives
for fixing this test. For now, we stick with a direct cherry-pick.

Release note: None
  • Loading branch information
nvanbenschoten committed Sep 4, 2024
1 parent e80b68d commit c429d4e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pkg/raft/rafttest/node_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ func TestPause(t *testing.T) {

func waitLeader(ns []*node) int {
var l map[pb.PeerID]struct{}
var lindex int
var lindex = -1

for {
l = make(map[pb.PeerID]struct{})
Expand All @@ -152,7 +152,7 @@ func waitLeader(ns []*node) int {
}
}

if len(l) == 1 {
if len(l) == 1 && lindex != -1 {
return lindex
}
}
Expand Down

0 comments on commit c429d4e

Please sign in to comment.