diff --git a/agent/catalog_endpoint_test.go b/agent/catalog_endpoint_test.go index cd8aaf0cf199..b52ce848fbd7 100644 --- a/agent/catalog_endpoint_test.go +++ b/agent/catalog_endpoint_test.go @@ -740,6 +740,7 @@ func TestCatalogServiceNodes_DistanceSort(t *testing.T) { t.Parallel() a := NewTestAgent(t.Name(), "") defer a.Shutdown() + testrpc.WaitForLeader(t, a.RPC, "dc1") // Register nodes. args := &structs.RegisterRequest{ @@ -831,6 +832,7 @@ func TestCatalogServiceNodes_ConnectProxy(t *testing.T) { assert := assert.New(t) a := NewTestAgent(t.Name(), "") defer a.Shutdown() + testrpc.WaitForLeader(t, a.RPC, "dc1") // Register args := structs.TestRegisterRequestProxy(t) @@ -860,6 +862,7 @@ func TestCatalogConnectServiceNodes_good(t *testing.T) { assert := assert.New(t) a := NewTestAgent(t.Name(), "") defer a.Shutdown() + testrpc.WaitForLeader(t, a.RPC, "dc1") // Register args := structs.TestRegisterRequestProxy(t) diff --git a/command/connect/proxy/register_test.go b/command/connect/proxy/register_test.go index 636c7229bb5c..5534e7482870 100644 --- a/command/connect/proxy/register_test.go +++ b/command/connect/proxy/register_test.go @@ -46,16 +46,18 @@ func TestRegisterMonitor_heartbeat(t *testing.T) { testrpc.WaitForTestAgent(t, a.RPC, "dc1") m, _ := testMonitor(t, client) defer m.Close() + retry.Run(t, func(r *retry.R) { + // Get the check and verify that it is passing + checks, err := client.Agent().Checks() + require.NoError(err) + require.Contains(checks, m.checkID()) + require.Equal("passing", checks[m.checkID()].Status) + // Purposely fail the TTL check, verify it becomes healthy again + require.NoError(client.Agent().FailTTL(m.checkID(), "")) + }) - // Get the check and verify that it is passing - checks, err := client.Agent().Checks() - require.NoError(err) - require.Contains(checks, m.checkID()) - require.Equal("passing", checks[m.checkID()].Status) - - // Purposely fail the TTL check, verify it becomes healthy again - require.NoError(client.Agent().FailTTL(m.checkID(), "")) retry.Run(t, func(r *retry.R) { + checks, err := client.Agent().Checks() if err != nil { r.Fatalf("err: %s", err) diff --git a/command/watch/watch_test.go b/command/watch/watch_test.go index 735418fff7b5..8dabbb8912ef 100644 --- a/command/watch/watch_test.go +++ b/command/watch/watch_test.go @@ -4,9 +4,8 @@ import ( "strings" "testing" - "github.com/hashicorp/consul/testrpc" - "github.com/hashicorp/consul/agent" + "github.com/hashicorp/consul/testrpc" "github.com/mitchellh/cli" )