Drop client arguments from `WaitForLeader`
This commit is contained in:
parent
795fab8a61
commit
bdbe97545a
|
@ -17,15 +17,15 @@ func TestCatalogRegister(t *testing.T) {
|
||||||
defer srv.Shutdown()
|
defer srv.Shutdown()
|
||||||
defer srv.agent.Shutdown()
|
defer srv.agent.Shutdown()
|
||||||
|
|
||||||
|
testutil.WaitForLeader(t, srv.agent.RPC)
|
||||||
|
|
||||||
|
// Register node
|
||||||
args := &structs.RegisterRequest{
|
args := &structs.RegisterRequest{
|
||||||
Datacenter: "dc1",
|
Datacenter: "dc1",
|
||||||
Node: "foo",
|
Node: "foo",
|
||||||
Address: "127.0.0.1",
|
Address: "127.0.0.1",
|
||||||
}
|
}
|
||||||
|
|
||||||
testutil.WaitForLeader(t, srv.agent.RPC, args)
|
|
||||||
|
|
||||||
// Register node
|
|
||||||
req, err := http.NewRequest("GET", "/v1/catalog/register", nil)
|
req, err := http.NewRequest("GET", "/v1/catalog/register", nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("err: %v", err)
|
t.Fatalf("err: %v", err)
|
||||||
|
@ -49,14 +49,14 @@ func TestCatalogDeregister(t *testing.T) {
|
||||||
defer srv.Shutdown()
|
defer srv.Shutdown()
|
||||||
defer srv.agent.Shutdown()
|
defer srv.agent.Shutdown()
|
||||||
|
|
||||||
|
testutil.WaitForLeader(t, srv.agent.RPC)
|
||||||
|
|
||||||
|
// Register node
|
||||||
args := &structs.DeregisterRequest{
|
args := &structs.DeregisterRequest{
|
||||||
Datacenter: "dc1",
|
Datacenter: "dc1",
|
||||||
Node: "foo",
|
Node: "foo",
|
||||||
}
|
}
|
||||||
|
|
||||||
testutil.WaitForLeader(t, srv.agent.RPC, args)
|
|
||||||
|
|
||||||
// Register node
|
|
||||||
req, err := http.NewRequest("GET", "/v1/catalog/deregister", nil)
|
req, err := http.NewRequest("GET", "/v1/catalog/deregister", nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("err: %v", err)
|
t.Fatalf("err: %v", err)
|
||||||
|
@ -97,15 +97,15 @@ func TestCatalogNodes(t *testing.T) {
|
||||||
defer srv.Shutdown()
|
defer srv.Shutdown()
|
||||||
defer srv.agent.Shutdown()
|
defer srv.agent.Shutdown()
|
||||||
|
|
||||||
|
testutil.WaitForLeader(t, srv.agent.RPC)
|
||||||
|
|
||||||
|
// Register node
|
||||||
args := &structs.RegisterRequest{
|
args := &structs.RegisterRequest{
|
||||||
Datacenter: "dc1",
|
Datacenter: "dc1",
|
||||||
Node: "foo",
|
Node: "foo",
|
||||||
Address: "127.0.0.1",
|
Address: "127.0.0.1",
|
||||||
}
|
}
|
||||||
|
|
||||||
testutil.WaitForLeader(t, srv.agent.RPC, args)
|
|
||||||
|
|
||||||
// Register node
|
|
||||||
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)
|
||||||
|
@ -137,13 +137,13 @@ func TestCatalogNodes_Blocking(t *testing.T) {
|
||||||
defer srv.Shutdown()
|
defer srv.Shutdown()
|
||||||
defer srv.agent.Shutdown()
|
defer srv.agent.Shutdown()
|
||||||
|
|
||||||
|
testutil.WaitForLeader(t, srv.agent.RPC)
|
||||||
|
|
||||||
|
// Register node
|
||||||
args := &structs.DCSpecificRequest{
|
args := &structs.DCSpecificRequest{
|
||||||
Datacenter: "dc1",
|
Datacenter: "dc1",
|
||||||
}
|
}
|
||||||
|
|
||||||
testutil.WaitForLeader(t, srv.agent.RPC, args)
|
|
||||||
|
|
||||||
// Register node
|
|
||||||
var out structs.IndexedNodes
|
var out structs.IndexedNodes
|
||||||
if err := srv.agent.RPC("Catalog.ListNodes", *args, &out); err != nil {
|
if err := srv.agent.RPC("Catalog.ListNodes", *args, &out); err != nil {
|
||||||
t.Fatalf("err: %v", err)
|
t.Fatalf("err: %v", err)
|
||||||
|
@ -198,6 +198,9 @@ func TestCatalogServices(t *testing.T) {
|
||||||
defer srv.Shutdown()
|
defer srv.Shutdown()
|
||||||
defer srv.agent.Shutdown()
|
defer srv.agent.Shutdown()
|
||||||
|
|
||||||
|
testutil.WaitForLeader(t, srv.agent.RPC)
|
||||||
|
|
||||||
|
// Register node
|
||||||
args := &structs.RegisterRequest{
|
args := &structs.RegisterRequest{
|
||||||
Datacenter: "dc1",
|
Datacenter: "dc1",
|
||||||
Node: "foo",
|
Node: "foo",
|
||||||
|
@ -207,9 +210,6 @@ func TestCatalogServices(t *testing.T) {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
testutil.WaitForLeader(t, srv.agent.RPC, args)
|
|
||||||
|
|
||||||
// Register node
|
|
||||||
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)
|
||||||
|
@ -240,6 +240,9 @@ func TestCatalogServiceNodes(t *testing.T) {
|
||||||
defer srv.Shutdown()
|
defer srv.Shutdown()
|
||||||
defer srv.agent.Shutdown()
|
defer srv.agent.Shutdown()
|
||||||
|
|
||||||
|
testutil.WaitForLeader(t, srv.agent.RPC)
|
||||||
|
|
||||||
|
// Register node
|
||||||
args := &structs.RegisterRequest{
|
args := &structs.RegisterRequest{
|
||||||
Datacenter: "dc1",
|
Datacenter: "dc1",
|
||||||
Node: "foo",
|
Node: "foo",
|
||||||
|
@ -250,9 +253,6 @@ func TestCatalogServiceNodes(t *testing.T) {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
testutil.WaitForLeader(t, srv.agent.RPC, args)
|
|
||||||
|
|
||||||
// Register node
|
|
||||||
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)
|
||||||
|
@ -283,6 +283,9 @@ func TestCatalogNodeServices(t *testing.T) {
|
||||||
defer srv.Shutdown()
|
defer srv.Shutdown()
|
||||||
defer srv.agent.Shutdown()
|
defer srv.agent.Shutdown()
|
||||||
|
|
||||||
|
testutil.WaitForLeader(t, srv.agent.RPC)
|
||||||
|
|
||||||
|
// Register node
|
||||||
args := &structs.RegisterRequest{
|
args := &structs.RegisterRequest{
|
||||||
Datacenter: "dc1",
|
Datacenter: "dc1",
|
||||||
Node: "foo",
|
Node: "foo",
|
||||||
|
@ -293,9 +296,6 @@ func TestCatalogNodeServices(t *testing.T) {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
testutil.WaitForLeader(t, srv.agent.RPC, args)
|
|
||||||
|
|
||||||
// Register node
|
|
||||||
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)
|
||||||
|
|
|
@ -72,7 +72,7 @@ func TestDNS_NodeLookup(t *testing.T) {
|
||||||
Address: "127.0.0.1",
|
Address: "127.0.0.1",
|
||||||
}
|
}
|
||||||
|
|
||||||
testutil.WaitForLeader(t, srv.agent.RPC, args)
|
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 {
|
||||||
|
@ -136,7 +136,7 @@ func TestDNS_NodeLookup_PeriodName(t *testing.T) {
|
||||||
Address: "127.0.0.1",
|
Address: "127.0.0.1",
|
||||||
}
|
}
|
||||||
|
|
||||||
testutil.WaitForLeader(t, srv.agent.RPC, args)
|
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 {
|
||||||
|
@ -178,7 +178,7 @@ func TestDNS_NodeLookup_AAAA(t *testing.T) {
|
||||||
Address: "::4242:4242",
|
Address: "::4242:4242",
|
||||||
}
|
}
|
||||||
|
|
||||||
testutil.WaitForLeader(t, srv.agent.RPC, args)
|
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 {
|
||||||
|
@ -220,7 +220,7 @@ func TestDNS_NodeLookup_CNAME(t *testing.T) {
|
||||||
Address: "www.google.com",
|
Address: "www.google.com",
|
||||||
}
|
}
|
||||||
|
|
||||||
testutil.WaitForLeader(t, srv.agent.RPC, args)
|
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 {
|
||||||
|
@ -268,7 +268,7 @@ func TestDNS_ServiceLookup(t *testing.T) {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
testutil.WaitForLeader(t, srv.agent.RPC, args)
|
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 {
|
||||||
|
@ -329,7 +329,7 @@ func TestDNS_ServiceLookup_TagPeriod(t *testing.T) {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
testutil.WaitForLeader(t, srv.agent.RPC, args)
|
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 {
|
||||||
|
@ -390,7 +390,7 @@ func TestDNS_ServiceLookup_Dedup(t *testing.T) {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
testutil.WaitForLeader(t, srv.agent.RPC, args)
|
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 {
|
||||||
|
@ -467,7 +467,7 @@ func TestDNS_ServiceLookup_Dedup_SRV(t *testing.T) {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
testutil.WaitForLeader(t, srv.agent.RPC, args)
|
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 {
|
||||||
|
@ -601,7 +601,7 @@ func TestDNS_ServiceLookup_FilterCritical(t *testing.T) {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
testutil.WaitForLeader(t, srv.agent.RPC, args)
|
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 {
|
||||||
|
@ -660,7 +660,7 @@ func TestDNS_ServiceLookup_Randomize(t *testing.T) {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
testutil.WaitForLeader(t, srv.agent.RPC, args)
|
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 {
|
||||||
|
@ -723,7 +723,7 @@ func TestDNS_ServiceLookup_CNAME(t *testing.T) {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
testutil.WaitForLeader(t, srv.agent.RPC, args)
|
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 {
|
||||||
|
|
|
@ -16,11 +16,7 @@ func TestHealthChecksInState(t *testing.T) {
|
||||||
defer srv.Shutdown()
|
defer srv.Shutdown()
|
||||||
defer srv.agent.Shutdown()
|
defer srv.agent.Shutdown()
|
||||||
|
|
||||||
args := &structs.RegisterRequest{
|
testutil.WaitForLeader(t, srv.agent.RPC)
|
||||||
Datacenter: "dc1",
|
|
||||||
}
|
|
||||||
|
|
||||||
testutil.WaitForLeader(t, srv.agent.RPC, args)
|
|
||||||
|
|
||||||
req, err := http.NewRequest("GET", "/v1/health/state/passing?dc=dc1", nil)
|
req, err := http.NewRequest("GET", "/v1/health/state/passing?dc=dc1", nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -47,11 +43,7 @@ func TestHealthNodeChecks(t *testing.T) {
|
||||||
defer srv.Shutdown()
|
defer srv.Shutdown()
|
||||||
defer srv.agent.Shutdown()
|
defer srv.agent.Shutdown()
|
||||||
|
|
||||||
args := &structs.RegisterRequest{
|
testutil.WaitForLeader(t, srv.agent.RPC)
|
||||||
Datacenter: "dc1",
|
|
||||||
}
|
|
||||||
|
|
||||||
testutil.WaitForLeader(t, srv.agent.RPC, args)
|
|
||||||
|
|
||||||
req, err := http.NewRequest("GET",
|
req, err := http.NewRequest("GET",
|
||||||
fmt.Sprintf("/v1/health/node/%s?dc=dc1", srv.agent.config.NodeName), nil)
|
fmt.Sprintf("/v1/health/node/%s?dc=dc1", srv.agent.config.NodeName), nil)
|
||||||
|
@ -90,7 +82,7 @@ func TestHealthServiceChecks(t *testing.T) {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
testutil.WaitForLeader(t, srv.agent.RPC, args)
|
testutil.WaitForLeader(t, srv.agent.RPC)
|
||||||
|
|
||||||
// Create a service check
|
// Create a service check
|
||||||
var out struct{}
|
var out struct{}
|
||||||
|
@ -123,11 +115,7 @@ func TestHealthServiceNodes(t *testing.T) {
|
||||||
defer srv.Shutdown()
|
defer srv.Shutdown()
|
||||||
defer srv.agent.Shutdown()
|
defer srv.agent.Shutdown()
|
||||||
|
|
||||||
args := &structs.RegisterRequest{
|
testutil.WaitForLeader(t, srv.agent.RPC)
|
||||||
Datacenter: "dc1",
|
|
||||||
}
|
|
||||||
|
|
||||||
testutil.WaitForLeader(t, srv.agent.RPC, args)
|
|
||||||
|
|
||||||
req, err := http.NewRequest("GET", "/v1/health/service/consul?dc=dc1", nil)
|
req, err := http.NewRequest("GET", "/v1/health/service/consul?dc=dc1", nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -166,7 +154,7 @@ func TestHealthServiceNodes_PassingFilter(t *testing.T) {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
testutil.WaitForLeader(t, srv.agent.RPC, args)
|
testutil.WaitForLeader(t, srv.agent.RPC)
|
||||||
|
|
||||||
// Create a failing service check
|
// Create a failing service check
|
||||||
var out struct{}
|
var out struct{}
|
||||||
|
|
|
@ -18,11 +18,7 @@ func TestKVSEndpoint_PUT_GET_DELETE(t *testing.T) {
|
||||||
defer srv.Shutdown()
|
defer srv.Shutdown()
|
||||||
defer srv.agent.Shutdown()
|
defer srv.agent.Shutdown()
|
||||||
|
|
||||||
args := &structs.RegisterRequest{
|
testutil.WaitForLeader(t, srv.agent.RPC)
|
||||||
Datacenter: "dc1",
|
|
||||||
}
|
|
||||||
|
|
||||||
testutil.WaitForLeader(t, srv.agent.RPC, args)
|
|
||||||
|
|
||||||
keys := []string{
|
keys := []string{
|
||||||
"baz",
|
"baz",
|
||||||
|
@ -97,11 +93,7 @@ func TestKVSEndpoint_Recurse(t *testing.T) {
|
||||||
defer srv.Shutdown()
|
defer srv.Shutdown()
|
||||||
defer srv.agent.Shutdown()
|
defer srv.agent.Shutdown()
|
||||||
|
|
||||||
args := &structs.RegisterRequest{
|
testutil.WaitForLeader(t, srv.agent.RPC)
|
||||||
Datacenter: "dc1",
|
|
||||||
}
|
|
||||||
|
|
||||||
testutil.WaitForLeader(t, srv.agent.RPC, args)
|
|
||||||
|
|
||||||
keys := []string{
|
keys := []string{
|
||||||
"bar",
|
"bar",
|
||||||
|
@ -197,11 +189,7 @@ func TestKVSEndpoint_CAS(t *testing.T) {
|
||||||
defer srv.Shutdown()
|
defer srv.Shutdown()
|
||||||
defer srv.agent.Shutdown()
|
defer srv.agent.Shutdown()
|
||||||
|
|
||||||
args := &structs.RegisterRequest{
|
testutil.WaitForLeader(t, srv.agent.RPC)
|
||||||
Datacenter: "dc1",
|
|
||||||
}
|
|
||||||
|
|
||||||
testutil.WaitForLeader(t, srv.agent.RPC, args)
|
|
||||||
|
|
||||||
{
|
{
|
||||||
buf := bytes.NewBuffer([]byte("test"))
|
buf := bytes.NewBuffer([]byte("test"))
|
||||||
|
@ -298,11 +286,7 @@ func TestKVSEndpoint_ListKeys(t *testing.T) {
|
||||||
defer srv.Shutdown()
|
defer srv.Shutdown()
|
||||||
defer srv.agent.Shutdown()
|
defer srv.agent.Shutdown()
|
||||||
|
|
||||||
args := &structs.RegisterRequest{
|
testutil.WaitForLeader(t, srv.agent.RPC)
|
||||||
Datacenter: "dc1",
|
|
||||||
}
|
|
||||||
|
|
||||||
testutil.WaitForLeader(t, srv.agent.RPC, args)
|
|
||||||
|
|
||||||
keys := []string{
|
keys := []string{
|
||||||
"bar",
|
"bar",
|
||||||
|
|
|
@ -21,7 +21,7 @@ func TestAgentAntiEntropy_Services(t *testing.T) {
|
||||||
Address: "127.0.0.1",
|
Address: "127.0.0.1",
|
||||||
}
|
}
|
||||||
|
|
||||||
testutil.WaitForLeader(t, agent.RPC, args)
|
testutil.WaitForLeader(t, agent.RPC)
|
||||||
|
|
||||||
// Register info. Exists both, same (noop)
|
// Register info. Exists both, same (noop)
|
||||||
var out struct{}
|
var out struct{}
|
||||||
|
@ -142,7 +142,7 @@ func TestAgentAntiEntropy_Checks(t *testing.T) {
|
||||||
Address: "127.0.0.1",
|
Address: "127.0.0.1",
|
||||||
}
|
}
|
||||||
|
|
||||||
testutil.WaitForLeader(t, agent.RPC, args)
|
testutil.WaitForLeader(t, agent.RPC)
|
||||||
|
|
||||||
// Register info. Exists both, same (noop)
|
// Register info. Exists both, same (noop)
|
||||||
var out struct{}
|
var out struct{}
|
||||||
|
|
|
@ -259,8 +259,8 @@ func TestCatalogListNodes_StaleRaad(t *testing.T) {
|
||||||
QueryOptions: structs.QueryOptions{AllowStale: true},
|
QueryOptions: structs.QueryOptions{AllowStale: true},
|
||||||
}
|
}
|
||||||
|
|
||||||
testutil.WaitForLeader(t, client1.Call, args)
|
testutil.WaitForLeader(t, client1.Call)
|
||||||
testutil.WaitForLeader(t, client2.Call, args)
|
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
|
||||||
|
|
|
@ -2,6 +2,7 @@ package consul
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"github.com/hashicorp/consul/testutil"
|
||||||
"github.com/hashicorp/consul/consul/structs"
|
"github.com/hashicorp/consul/consul/structs"
|
||||||
"github.com/hashicorp/serf/serf"
|
"github.com/hashicorp/serf/serf"
|
||||||
"os"
|
"os"
|
||||||
|
@ -18,8 +19,8 @@ func TestLeader_RegisterMember(t *testing.T) {
|
||||||
defer os.RemoveAll(dir2)
|
defer os.RemoveAll(dir2)
|
||||||
defer c1.Shutdown()
|
defer c1.Shutdown()
|
||||||
|
|
||||||
// Wait until we have a leader
|
client := rpcClient(t, s1)
|
||||||
time.Sleep(100 * time.Millisecond)
|
testutil.WaitForLeader(t, client.Call)
|
||||||
|
|
||||||
// Try to join
|
// Try to join
|
||||||
addr := fmt.Sprintf("127.0.0.1:%d",
|
addr := fmt.Sprintf("127.0.0.1:%d",
|
||||||
|
|
|
@ -29,9 +29,12 @@ func WaitForResult(test testFn, error errorFn) {
|
||||||
|
|
||||||
type rpcFn func(string, interface {}, interface {}) error
|
type rpcFn func(string, interface {}, interface {}) error
|
||||||
|
|
||||||
func WaitForLeader(t *testing.T, rpc rpcFn, args interface{}) structs.IndexedNodes {
|
func WaitForLeader(t *testing.T, rpc rpcFn) structs.IndexedNodes {
|
||||||
var out structs.IndexedNodes
|
var out structs.IndexedNodes
|
||||||
WaitForResult(func() (bool, error) {
|
WaitForResult(func() (bool, error) {
|
||||||
|
args := &structs.RegisterRequest{
|
||||||
|
Datacenter: "dc1",
|
||||||
|
}
|
||||||
err := rpc("Catalog.ListNodes", args, &out)
|
err := rpc("Catalog.ListNodes", args, &out)
|
||||||
return out.QueryMeta.KnownLeader, err
|
return out.QueryMeta.KnownLeader, err
|
||||||
}, func(err error) {
|
}, func(err error) {
|
||||||
|
|
Loading…
Reference in New Issue