Unflake the TestACLEndpoint_TokenList test
In order to do this I added a waitForLeaderEstablishment helper which does the right thing to ensure that leader establishment has finished. fixup
This commit is contained in:
parent
8af12bf4f4
commit
185654b075
|
@ -2070,6 +2070,7 @@ func TestACLEndpoint_TokenList(t *testing.T) {
|
|||
defer codec.Close()
|
||||
|
||||
testrpc.WaitForLeader(t, s1.RPC, "dc1")
|
||||
waitForLeaderEstablishment(t, s1)
|
||||
|
||||
acl := ACL{srv: s1}
|
||||
|
||||
|
|
|
@ -41,6 +41,21 @@ func uniqueNodeName(name string) string {
|
|||
return fmt.Sprintf("%s-node-%d", name, atomic.AddInt64(&id, 1))
|
||||
}
|
||||
|
||||
// This will find the leader of a list of servers and verify that leader establishment has completed
|
||||
func waitForLeaderEstablishment(t *testing.T, servers ...*Server) {
|
||||
t.Helper()
|
||||
retry.Run(t, func(r *retry.R) {
|
||||
hasLeader := false
|
||||
for _, srv := range servers {
|
||||
if srv.IsLeader() {
|
||||
hasLeader = true
|
||||
require.True(r, srv.isReadyForConsistentReads(), "Leader %s hasn't finished establishing leadership yet", srv.config.NodeName)
|
||||
}
|
||||
}
|
||||
require.True(r, hasLeader, "Cluster has not elected a leader yet")
|
||||
})
|
||||
}
|
||||
|
||||
func testServerConfig(t *testing.T) (string, *Config) {
|
||||
dir := testutil.TempDir(t, "consul")
|
||||
config := DefaultConfig()
|
||||
|
|
Loading…
Reference in New Issue