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