Require datacenter argument for `WaitForLeader`

pull/136/head
William Tisäter 2014-05-09 01:17:35 +02:00
parent 05243b35cd
commit 78145ecfd5
7 changed files with 32 additions and 32 deletions

View File

@ -17,7 +17,7 @@ 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) testutil.WaitForLeader(t, srv.agent.RPC, "dc1")
// Register node // Register node
req, err := http.NewRequest("GET", "/v1/catalog/register", nil) req, err := http.NewRequest("GET", "/v1/catalog/register", nil)
@ -47,7 +47,7 @@ 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) testutil.WaitForLeader(t, srv.agent.RPC, "dc1")
// Register node // Register node
req, err := http.NewRequest("GET", "/v1/catalog/deregister", nil) req, err := http.NewRequest("GET", "/v1/catalog/deregister", nil)
@ -93,7 +93,7 @@ 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) testutil.WaitForLeader(t, srv.agent.RPC, "dc1")
// Register node // Register node
args := &structs.RegisterRequest{ args := &structs.RegisterRequest{
@ -133,7 +133,7 @@ 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) testutil.WaitForLeader(t, srv.agent.RPC, "dc1")
// Register node // Register node
args := &structs.DCSpecificRequest{ args := &structs.DCSpecificRequest{
@ -194,7 +194,7 @@ 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) testutil.WaitForLeader(t, srv.agent.RPC, "dc1")
// Register node // Register node
args := &structs.RegisterRequest{ args := &structs.RegisterRequest{
@ -236,7 +236,7 @@ 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) testutil.WaitForLeader(t, srv.agent.RPC, "dc1")
// Register node // Register node
args := &structs.RegisterRequest{ args := &structs.RegisterRequest{
@ -279,7 +279,7 @@ 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) testutil.WaitForLeader(t, srv.agent.RPC, "dc1")
// Register node // Register node
args := &structs.RegisterRequest{ args := &structs.RegisterRequest{

View File

@ -65,7 +65,7 @@ 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) testutil.WaitForLeader(t, srv.agent.RPC, "dc1")
// Register node // Register node
args := &structs.RegisterRequest{ args := &structs.RegisterRequest{
@ -129,7 +129,7 @@ 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) testutil.WaitForLeader(t, srv.agent.RPC, "dc1")
// Register node with period in name // Register node with period in name
args := &structs.RegisterRequest{ args := &structs.RegisterRequest{
@ -171,7 +171,7 @@ 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) testutil.WaitForLeader(t, srv.agent.RPC, "dc1")
// Register node // Register node
args := &structs.RegisterRequest{ args := &structs.RegisterRequest{
@ -213,7 +213,7 @@ 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) testutil.WaitForLeader(t, srv.agent.RPC, "dc1")
// Register node // Register node
args := &structs.RegisterRequest{ args := &structs.RegisterRequest{
@ -256,7 +256,7 @@ 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) testutil.WaitForLeader(t, srv.agent.RPC, "dc1")
// Register node // Register node
args := &structs.RegisterRequest{ args := &structs.RegisterRequest{
@ -317,7 +317,7 @@ 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) testutil.WaitForLeader(t, srv.agent.RPC, "dc1")
// Register node // Register node
args := &structs.RegisterRequest{ args := &structs.RegisterRequest{
@ -378,7 +378,7 @@ 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) testutil.WaitForLeader(t, srv.agent.RPC, "dc1")
// Register node // Register node
args := &structs.RegisterRequest{ args := &structs.RegisterRequest{
@ -455,7 +455,7 @@ 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) testutil.WaitForLeader(t, srv.agent.RPC, "dc1")
// Register node // Register node
args := &structs.RegisterRequest{ args := &structs.RegisterRequest{
@ -584,7 +584,7 @@ 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) testutil.WaitForLeader(t, srv.agent.RPC, "dc1")
// Register nodes // Register nodes
args := &structs.RegisterRequest{ args := &structs.RegisterRequest{
@ -648,7 +648,7 @@ 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) testutil.WaitForLeader(t, srv.agent.RPC, "dc1")
// Register nodes // Register nodes
for i := 0; i < 3*maxServiceResponses; i++ { for i := 0; i < 3*maxServiceResponses; i++ {
@ -712,7 +712,7 @@ 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) testutil.WaitForLeader(t, srv.agent.RPC, "dc1")
// Register node // Register node
args := &structs.RegisterRequest{ args := &structs.RegisterRequest{

View File

@ -16,7 +16,7 @@ func TestHealthChecksInState(t *testing.T) {
defer srv.Shutdown() defer srv.Shutdown()
defer srv.agent.Shutdown() defer srv.agent.Shutdown()
testutil.WaitForLeader(t, srv.agent.RPC) testutil.WaitForLeader(t, srv.agent.RPC, "dc1")
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 {
@ -43,7 +43,7 @@ func TestHealthNodeChecks(t *testing.T) {
defer srv.Shutdown() defer srv.Shutdown()
defer srv.agent.Shutdown() defer srv.agent.Shutdown()
testutil.WaitForLeader(t, srv.agent.RPC) testutil.WaitForLeader(t, srv.agent.RPC, "dc1")
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)
@ -71,7 +71,7 @@ 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) testutil.WaitForLeader(t, srv.agent.RPC, "dc1")
// Create a service check // Create a service check
args := &structs.RegisterRequest{ args := &structs.RegisterRequest{
@ -115,7 +115,7 @@ func TestHealthServiceNodes(t *testing.T) {
defer srv.Shutdown() defer srv.Shutdown()
defer srv.agent.Shutdown() defer srv.agent.Shutdown()
testutil.WaitForLeader(t, srv.agent.RPC) testutil.WaitForLeader(t, srv.agent.RPC, "dc1")
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 {
@ -142,7 +142,7 @@ 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) testutil.WaitForLeader(t, srv.agent.RPC, "dc1")
// Create a failing service check // Create a failing service check
args := &structs.RegisterRequest{ args := &structs.RegisterRequest{

View File

@ -18,7 +18,7 @@ func TestKVSEndpoint_PUT_GET_DELETE(t *testing.T) {
defer srv.Shutdown() defer srv.Shutdown()
defer srv.agent.Shutdown() defer srv.agent.Shutdown()
testutil.WaitForLeader(t, srv.agent.RPC) testutil.WaitForLeader(t, srv.agent.RPC, "dc1")
keys := []string{ keys := []string{
"baz", "baz",
@ -93,7 +93,7 @@ func TestKVSEndpoint_Recurse(t *testing.T) {
defer srv.Shutdown() defer srv.Shutdown()
defer srv.agent.Shutdown() defer srv.agent.Shutdown()
testutil.WaitForLeader(t, srv.agent.RPC) testutil.WaitForLeader(t, srv.agent.RPC, "dc1")
keys := []string{ keys := []string{
"bar", "bar",
@ -189,7 +189,7 @@ func TestKVSEndpoint_CAS(t *testing.T) {
defer srv.Shutdown() defer srv.Shutdown()
defer srv.agent.Shutdown() defer srv.agent.Shutdown()
testutil.WaitForLeader(t, srv.agent.RPC) testutil.WaitForLeader(t, srv.agent.RPC, "dc1")
{ {
buf := bytes.NewBuffer([]byte("test")) buf := bytes.NewBuffer([]byte("test"))
@ -286,7 +286,7 @@ func TestKVSEndpoint_ListKeys(t *testing.T) {
defer srv.Shutdown() defer srv.Shutdown()
defer srv.agent.Shutdown() defer srv.agent.Shutdown()
testutil.WaitForLeader(t, srv.agent.RPC) testutil.WaitForLeader(t, srv.agent.RPC, "dc1")
keys := []string{ keys := []string{
"bar", "bar",

View File

@ -15,7 +15,7 @@ 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) testutil.WaitForLeader(t, agent.RPC, "dc1")
// Register info // Register info
args := &structs.RegisterRequest{ args := &structs.RegisterRequest{
@ -137,7 +137,7 @@ 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) testutil.WaitForLeader(t, agent.RPC, "dc1")
// Register info // Register info
args := &structs.RegisterRequest{ args := &structs.RegisterRequest{

View File

@ -20,7 +20,7 @@ func TestLeader_RegisterMember(t *testing.T) {
defer c1.Shutdown() defer c1.Shutdown()
client := rpcClient(t, s1) client := rpcClient(t, s1)
testutil.WaitForLeader(t, client.Call) testutil.WaitForLeader(t, client.Call, "dc1")
// Try to join // Try to join
addr := fmt.Sprintf("127.0.0.1:%d", addr := fmt.Sprintf("127.0.0.1:%d",

View File

@ -29,11 +29,11 @@ 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) structs.IndexedNodes { func WaitForLeader(t *testing.T, rpc rpcFn, dc string) structs.IndexedNodes {
var out structs.IndexedNodes var out structs.IndexedNodes
WaitForResult(func() (bool, error) { WaitForResult(func() (bool, error) {
args := &structs.RegisterRequest{ args := &structs.RegisterRequest{
Datacenter: "dc1", Datacenter: dc,
} }
err := rpc("Catalog.ListNodes", args, &out) err := rpc("Catalog.ListNodes", args, &out)
return out.QueryMeta.KnownLeader, err return out.QueryMeta.KnownLeader, err