Skip to content

Commit

Permalink
tiny improvement
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Leung <[email protected]>
  • Loading branch information
rleungx committed Jun 24, 2022
1 parent 95d8400 commit 58069a7
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions server/testutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,13 +122,16 @@ func NewTestMultiConfig(c *assertutil.Checker, count int) []*config.Config {
func MustWaitLeader(re *require.Assertions, svrs []*Server) *Server {
var leader *Server
testutil.Eventually(re, func() bool {
for _, s := range svrs {
if !s.IsClosed() && s.member.IsLeader() {
leader = s
return true
for _, svr := range svrs {
// All servers' GetLeader should return the same leader.
if svr.GetLeader() == nil || (leader != nil && svr.GetLeader().GetMemberId() != leader.GetLeader().GetMemberId()) {
return false
}
if leader == nil && !svr.IsClosed() {
leader = svr
}
}
return false
return true
})
return leader
}

0 comments on commit 58069a7

Please sign in to comment.