Fixed flaky tests (#4626)

This commit is contained in:
Pierre Souchay 2018-09-04 13:31:51 +02:00 committed by Freddy
parent ef73855dce
commit e974ebd62e
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"
`)
defer a.Shutdown()
testrpc.WaitForTestAgent(t, a.RPC, "dc1")
svc := &structs.NodeService{
ID: "redis",

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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