mirror of https://github.com/status-im/consul.git
Move `WaitForLeader` calls to top of test
This commit is contained in:
parent
0ed5599ffe
commit
93c7103bb5
|
@ -65,6 +65,8 @@ func TestDNS_NodeLookup(t *testing.T) {
|
|||
defer os.RemoveAll(dir)
|
||||
defer srv.agent.Shutdown()
|
||||
|
||||
testutil.WaitForLeader(t, srv.agent.RPC)
|
||||
|
||||
// Register node
|
||||
args := &structs.RegisterRequest{
|
||||
Datacenter: "dc1",
|
||||
|
@ -72,8 +74,6 @@ func TestDNS_NodeLookup(t *testing.T) {
|
|||
Address: "127.0.0.1",
|
||||
}
|
||||
|
||||
testutil.WaitForLeader(t, srv.agent.RPC)
|
||||
|
||||
var out struct{}
|
||||
if err := srv.agent.RPC("Catalog.Register", args, &out); err != nil {
|
||||
t.Fatalf("err: %v", err)
|
||||
|
@ -129,6 +129,8 @@ func TestDNS_NodeLookup_PeriodName(t *testing.T) {
|
|||
defer os.RemoveAll(dir)
|
||||
defer srv.agent.Shutdown()
|
||||
|
||||
testutil.WaitForLeader(t, srv.agent.RPC)
|
||||
|
||||
// Register node with period in name
|
||||
args := &structs.RegisterRequest{
|
||||
Datacenter: "dc1",
|
||||
|
@ -136,8 +138,6 @@ func TestDNS_NodeLookup_PeriodName(t *testing.T) {
|
|||
Address: "127.0.0.1",
|
||||
}
|
||||
|
||||
testutil.WaitForLeader(t, srv.agent.RPC)
|
||||
|
||||
var out struct{}
|
||||
if err := srv.agent.RPC("Catalog.Register", args, &out); err != nil {
|
||||
t.Fatalf("err: %v", err)
|
||||
|
@ -171,6 +171,8 @@ func TestDNS_NodeLookup_AAAA(t *testing.T) {
|
|||
defer os.RemoveAll(dir)
|
||||
defer srv.agent.Shutdown()
|
||||
|
||||
testutil.WaitForLeader(t, srv.agent.RPC)
|
||||
|
||||
// Register node
|
||||
args := &structs.RegisterRequest{
|
||||
Datacenter: "dc1",
|
||||
|
@ -178,8 +180,6 @@ func TestDNS_NodeLookup_AAAA(t *testing.T) {
|
|||
Address: "::4242:4242",
|
||||
}
|
||||
|
||||
testutil.WaitForLeader(t, srv.agent.RPC)
|
||||
|
||||
var out struct{}
|
||||
if err := srv.agent.RPC("Catalog.Register", args, &out); err != nil {
|
||||
t.Fatalf("err: %v", err)
|
||||
|
@ -213,6 +213,8 @@ func TestDNS_NodeLookup_CNAME(t *testing.T) {
|
|||
defer os.RemoveAll(dir)
|
||||
defer srv.agent.Shutdown()
|
||||
|
||||
testutil.WaitForLeader(t, srv.agent.RPC)
|
||||
|
||||
// Register node
|
||||
args := &structs.RegisterRequest{
|
||||
Datacenter: "dc1",
|
||||
|
@ -220,8 +222,6 @@ func TestDNS_NodeLookup_CNAME(t *testing.T) {
|
|||
Address: "www.google.com",
|
||||
}
|
||||
|
||||
testutil.WaitForLeader(t, srv.agent.RPC)
|
||||
|
||||
var out struct{}
|
||||
if err := srv.agent.RPC("Catalog.Register", args, &out); err != nil {
|
||||
t.Fatalf("err: %v", err)
|
||||
|
@ -256,6 +256,8 @@ func TestDNS_ServiceLookup(t *testing.T) {
|
|||
defer os.RemoveAll(dir)
|
||||
defer srv.agent.Shutdown()
|
||||
|
||||
testutil.WaitForLeader(t, srv.agent.RPC)
|
||||
|
||||
// Register node
|
||||
args := &structs.RegisterRequest{
|
||||
Datacenter: "dc1",
|
||||
|
@ -268,8 +270,6 @@ func TestDNS_ServiceLookup(t *testing.T) {
|
|||
},
|
||||
}
|
||||
|
||||
testutil.WaitForLeader(t, srv.agent.RPC)
|
||||
|
||||
var out struct{}
|
||||
if err := srv.agent.RPC("Catalog.Register", args, &out); err != nil {
|
||||
t.Fatalf("err: %v", err)
|
||||
|
@ -317,6 +317,8 @@ func TestDNS_ServiceLookup_TagPeriod(t *testing.T) {
|
|||
defer os.RemoveAll(dir)
|
||||
defer srv.agent.Shutdown()
|
||||
|
||||
testutil.WaitForLeader(t, srv.agent.RPC)
|
||||
|
||||
// Register node
|
||||
args := &structs.RegisterRequest{
|
||||
Datacenter: "dc1",
|
||||
|
@ -329,8 +331,6 @@ func TestDNS_ServiceLookup_TagPeriod(t *testing.T) {
|
|||
},
|
||||
}
|
||||
|
||||
testutil.WaitForLeader(t, srv.agent.RPC)
|
||||
|
||||
var out struct{}
|
||||
if err := srv.agent.RPC("Catalog.Register", args, &out); err != nil {
|
||||
t.Fatalf("err: %v", err)
|
||||
|
@ -378,6 +378,8 @@ func TestDNS_ServiceLookup_Dedup(t *testing.T) {
|
|||
defer os.RemoveAll(dir)
|
||||
defer srv.agent.Shutdown()
|
||||
|
||||
testutil.WaitForLeader(t, srv.agent.RPC)
|
||||
|
||||
// Register node
|
||||
args := &structs.RegisterRequest{
|
||||
Datacenter: "dc1",
|
||||
|
@ -390,8 +392,6 @@ func TestDNS_ServiceLookup_Dedup(t *testing.T) {
|
|||
},
|
||||
}
|
||||
|
||||
testutil.WaitForLeader(t, srv.agent.RPC)
|
||||
|
||||
var out struct{}
|
||||
if err := srv.agent.RPC("Catalog.Register", args, &out); err != nil {
|
||||
t.Fatalf("err: %v", err)
|
||||
|
@ -455,6 +455,8 @@ func TestDNS_ServiceLookup_Dedup_SRV(t *testing.T) {
|
|||
defer os.RemoveAll(dir)
|
||||
defer srv.agent.Shutdown()
|
||||
|
||||
testutil.WaitForLeader(t, srv.agent.RPC)
|
||||
|
||||
// Register node
|
||||
args := &structs.RegisterRequest{
|
||||
Datacenter: "dc1",
|
||||
|
@ -467,8 +469,6 @@ func TestDNS_ServiceLookup_Dedup_SRV(t *testing.T) {
|
|||
},
|
||||
}
|
||||
|
||||
testutil.WaitForLeader(t, srv.agent.RPC)
|
||||
|
||||
var out struct{}
|
||||
if err := srv.agent.RPC("Catalog.Register", args, &out); err != nil {
|
||||
t.Fatalf("err: %v", err)
|
||||
|
@ -584,6 +584,8 @@ func TestDNS_ServiceLookup_FilterCritical(t *testing.T) {
|
|||
defer os.RemoveAll(dir)
|
||||
defer srv.agent.Shutdown()
|
||||
|
||||
testutil.WaitForLeader(t, srv.agent.RPC)
|
||||
|
||||
// Register nodes
|
||||
args := &structs.RegisterRequest{
|
||||
Datacenter: "dc1",
|
||||
|
@ -601,8 +603,6 @@ func TestDNS_ServiceLookup_FilterCritical(t *testing.T) {
|
|||
},
|
||||
}
|
||||
|
||||
testutil.WaitForLeader(t, srv.agent.RPC)
|
||||
|
||||
var out struct{}
|
||||
if err := srv.agent.RPC("Catalog.Register", args, &out); err != nil {
|
||||
t.Fatalf("err: %v", err)
|
||||
|
@ -648,6 +648,8 @@ func TestDNS_ServiceLookup_Randomize(t *testing.T) {
|
|||
defer os.RemoveAll(dir)
|
||||
defer srv.agent.Shutdown()
|
||||
|
||||
testutil.WaitForLeader(t, srv.agent.RPC)
|
||||
|
||||
// Register nodes
|
||||
for i := 0; i < 3*maxServiceResponses; i++ {
|
||||
args := &structs.RegisterRequest{
|
||||
|
@ -660,8 +662,6 @@ func TestDNS_ServiceLookup_Randomize(t *testing.T) {
|
|||
},
|
||||
}
|
||||
|
||||
testutil.WaitForLeader(t, srv.agent.RPC)
|
||||
|
||||
var out struct{}
|
||||
if err := srv.agent.RPC("Catalog.Register", args, &out); err != nil {
|
||||
t.Fatalf("err: %v", err)
|
||||
|
@ -712,6 +712,8 @@ func TestDNS_ServiceLookup_CNAME(t *testing.T) {
|
|||
defer os.RemoveAll(dir)
|
||||
defer srv.agent.Shutdown()
|
||||
|
||||
testutil.WaitForLeader(t, srv.agent.RPC)
|
||||
|
||||
// Register node
|
||||
args := &structs.RegisterRequest{
|
||||
Datacenter: "dc1",
|
||||
|
@ -723,8 +725,6 @@ func TestDNS_ServiceLookup_CNAME(t *testing.T) {
|
|||
},
|
||||
}
|
||||
|
||||
testutil.WaitForLeader(t, srv.agent.RPC)
|
||||
|
||||
var out struct{}
|
||||
if err := srv.agent.RPC("Catalog.Register", args, &out); err != nil {
|
||||
t.Fatalf("err: %v", err)
|
||||
|
|
|
@ -71,6 +71,9 @@ func TestHealthServiceChecks(t *testing.T) {
|
|||
defer srv.Shutdown()
|
||||
defer srv.agent.Shutdown()
|
||||
|
||||
testutil.WaitForLeader(t, srv.agent.RPC)
|
||||
|
||||
// Create a service check
|
||||
args := &structs.RegisterRequest{
|
||||
Datacenter: "dc1",
|
||||
Node: srv.agent.config.NodeName,
|
||||
|
@ -82,9 +85,6 @@ func TestHealthServiceChecks(t *testing.T) {
|
|||
},
|
||||
}
|
||||
|
||||
testutil.WaitForLeader(t, srv.agent.RPC)
|
||||
|
||||
// Create a service check
|
||||
var out struct{}
|
||||
if err := srv.agent.RPC("Catalog.Register", args, &out); err != nil {
|
||||
t.Fatalf("err: %v", err)
|
||||
|
@ -142,6 +142,9 @@ func TestHealthServiceNodes_PassingFilter(t *testing.T) {
|
|||
defer srv.Shutdown()
|
||||
defer srv.agent.Shutdown()
|
||||
|
||||
testutil.WaitForLeader(t, srv.agent.RPC)
|
||||
|
||||
// Create a failing service check
|
||||
args := &structs.RegisterRequest{
|
||||
Datacenter: "dc1",
|
||||
Node: srv.agent.config.NodeName,
|
||||
|
@ -154,9 +157,6 @@ func TestHealthServiceNodes_PassingFilter(t *testing.T) {
|
|||
},
|
||||
}
|
||||
|
||||
testutil.WaitForLeader(t, srv.agent.RPC)
|
||||
|
||||
// Create a failing service check
|
||||
var out struct{}
|
||||
if err := srv.agent.RPC("Catalog.Register", args, &out); err != nil {
|
||||
t.Fatalf("err: %v", err)
|
||||
|
|
|
@ -15,15 +15,16 @@ func TestAgentAntiEntropy_Services(t *testing.T) {
|
|||
defer os.RemoveAll(dir)
|
||||
defer agent.Shutdown()
|
||||
|
||||
testutil.WaitForLeader(t, agent.RPC)
|
||||
|
||||
// Register info
|
||||
args := &structs.RegisterRequest{
|
||||
Datacenter: "dc1",
|
||||
Node: agent.config.NodeName,
|
||||
Address: "127.0.0.1",
|
||||
}
|
||||
|
||||
testutil.WaitForLeader(t, agent.RPC)
|
||||
|
||||
// Register info. Exists both, same (noop)
|
||||
// Exists both, same (noop)
|
||||
var out struct{}
|
||||
srv1 := &structs.NodeService{
|
||||
ID: "mysql",
|
||||
|
@ -136,15 +137,16 @@ func TestAgentAntiEntropy_Checks(t *testing.T) {
|
|||
defer os.RemoveAll(dir)
|
||||
defer agent.Shutdown()
|
||||
|
||||
testutil.WaitForLeader(t, agent.RPC)
|
||||
|
||||
// Register info
|
||||
args := &structs.RegisterRequest{
|
||||
Datacenter: "dc1",
|
||||
Node: agent.config.NodeName,
|
||||
Address: "127.0.0.1",
|
||||
}
|
||||
|
||||
testutil.WaitForLeader(t, agent.RPC)
|
||||
|
||||
// Register info. Exists both, same (noop)
|
||||
// Exists both, same (noop)
|
||||
var out struct{}
|
||||
chk1 := &structs.HealthCheck{
|
||||
Node: agent.config.NodeName,
|
||||
|
|
|
@ -254,14 +254,14 @@ func TestCatalogListNodes_StaleRaad(t *testing.T) {
|
|||
t.Fatalf("err: %v", err)
|
||||
}
|
||||
|
||||
testutil.WaitForLeader(t, client1.Call)
|
||||
testutil.WaitForLeader(t, client2.Call)
|
||||
|
||||
args := structs.DCSpecificRequest{
|
||||
Datacenter: "dc1",
|
||||
QueryOptions: structs.QueryOptions{AllowStale: true},
|
||||
}
|
||||
|
||||
testutil.WaitForLeader(t, client1.Call)
|
||||
testutil.WaitForLeader(t, client2.Call)
|
||||
|
||||
// Use the follower as the client
|
||||
var client *rpc.Client
|
||||
if !s1.IsLeader() {
|
||||
|
|
Loading…
Reference in New Issue