Fixed flaky tests (#4626)

This commit is contained in:
Pierre Souchay 2018-09-04 13:31:51 +02:00 committed by Freddy
parent 80b6653a8e
commit 92acdaa94c
8 changed files with 17 additions and 2 deletions

View File

@ -2179,6 +2179,7 @@ func TestAgent_Service_Reap(t *testing.T) {
check_deregister_interval_min = "0s" check_deregister_interval_min = "0s"
`) `)
defer a.Shutdown() defer a.Shutdown()
testrpc.WaitForTestAgent(t, a.RPC, "dc1")
svc := &structs.NodeService{ svc := &structs.NodeService{
ID: "redis", ID: "redis",

View File

@ -27,7 +27,7 @@ func TestConnectCASetConfigCommand(t *testing.T) {
a := agent.NewTestAgent(t.Name(), ``) a := agent.NewTestAgent(t.Name(), ``)
defer a.Shutdown() defer a.Shutdown()
testrpc.WaitForLeader(t, a.RPC, "dc1") testrpc.WaitForTestAgent(t, a.RPC, "dc1")
ui := cli.NewMockUi() ui := cli.NewMockUi()
c := New(ui) c := New(ui)
args := []string{ args := []string{

View File

@ -4,6 +4,8 @@ import (
"strings" "strings"
"testing" "testing"
"github.com/hashicorp/consul/testrpc"
"github.com/hashicorp/consul/agent" "github.com/hashicorp/consul/agent"
"github.com/mitchellh/cli" "github.com/mitchellh/cli"
) )
@ -19,6 +21,7 @@ func TestOperatorAutopilotGetConfigCommand(t *testing.T) {
t.Parallel() t.Parallel()
a := agent.NewTestAgent(t.Name(), ``) a := agent.NewTestAgent(t.Name(), ``)
defer a.Shutdown() defer a.Shutdown()
testrpc.WaitForTestAgent(t, a.RPC, "dc1")
ui := cli.NewMockUi() ui := cli.NewMockUi()
c := New(ui) c := New(ui)

View File

@ -5,6 +5,8 @@ import (
"testing" "testing"
"time" "time"
"github.com/hashicorp/consul/testrpc"
"github.com/hashicorp/consul/agent" "github.com/hashicorp/consul/agent"
"github.com/hashicorp/consul/agent/consul/autopilot" "github.com/hashicorp/consul/agent/consul/autopilot"
"github.com/hashicorp/consul/agent/structs" "github.com/hashicorp/consul/agent/structs"
@ -22,6 +24,7 @@ func TestOperatorAutopilotSetConfigCommand(t *testing.T) {
t.Parallel() t.Parallel()
a := agent.NewTestAgent(t.Name(), ``) a := agent.NewTestAgent(t.Name(), ``)
defer a.Shutdown() defer a.Shutdown()
testrpc.WaitForTestAgent(t, a.RPC, "dc1")
ui := cli.NewMockUi() ui := cli.NewMockUi()
c := New(ui) c := New(ui)

View File

@ -26,8 +26,8 @@ func TestProxy_public(t *testing.T) {
a := agent.NewTestAgent(t.Name(), "") a := agent.NewTestAgent(t.Name(), "")
defer a.Shutdown() defer a.Shutdown()
testrpc.WaitForTestAgent(t, a.RPC, "dc1")
client := a.Client() client := a.Client()
testrpc.WaitForLeader(t, a.RPC, "dc1")
// Register the service so we can get a leaf cert // Register the service so we can get a leaf cert
_, err := client.Catalog().Register(&api.CatalogRegistration{ _, err := client.Catalog().Register(&api.CatalogRegistration{

View File

@ -18,6 +18,7 @@ import (
"github.com/hashicorp/consul/agent" "github.com/hashicorp/consul/agent"
"github.com/hashicorp/consul/agent/connect" "github.com/hashicorp/consul/agent/connect"
"github.com/hashicorp/consul/api" "github.com/hashicorp/consul/api"
"github.com/hashicorp/consul/testrpc"
"github.com/hashicorp/consul/testutil/retry" "github.com/hashicorp/consul/testutil/retry"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
) )
@ -128,6 +129,7 @@ func TestService_ServerTLSConfig(t *testing.T) {
a := agent.NewTestAgent("007", "") a := agent.NewTestAgent("007", "")
defer a.Shutdown() defer a.Shutdown()
testrpc.WaitForTestAgent(t, a.RPC, "dc1")
client := a.Client() client := a.Client()
agent := client.Agent() agent := client.Agent()

View File

@ -6,6 +6,8 @@ import (
"encoding/pem" "encoding/pem"
"testing" "testing"
"github.com/hashicorp/consul/testrpc"
"github.com/hashicorp/consul/agent" "github.com/hashicorp/consul/agent"
"github.com/hashicorp/consul/agent/connect" "github.com/hashicorp/consul/agent/connect"
"github.com/hashicorp/consul/api" "github.com/hashicorp/consul/api"
@ -143,6 +145,7 @@ func TestServerSideVerifier(t *testing.T) {
// Setup a local test agent to query // Setup a local test agent to query
agent := agent.NewTestAgent("test-consul", "") agent := agent.NewTestAgent("test-consul", "")
defer agent.Shutdown() defer agent.Shutdown()
testrpc.WaitForTestAgent(t, agent.RPC, "dc1")
cfg := api.DefaultConfig() cfg := api.DefaultConfig()
cfg.Address = agent.HTTPAddr() cfg.Address = agent.HTTPAddr()

View File

@ -7,6 +7,8 @@ import (
"testing" "testing"
"time" "time"
"github.com/hashicorp/consul/testrpc"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/hashicorp/consul/agent" "github.com/hashicorp/consul/agent"
@ -532,6 +534,7 @@ func TestConnectRootsWatch(t *testing.T) {
// NewTestAgent will bootstrap a new CA // NewTestAgent will bootstrap a new CA
a := agent.NewTestAgent(t.Name(), "") a := agent.NewTestAgent(t.Name(), "")
defer a.Shutdown() defer a.Shutdown()
testrpc.WaitForTestAgent(t, a.RPC, "dc1")
var originalCAID string var originalCAID string
invoke := makeInvokeCh() invoke := makeInvokeCh()