From 81e416e70b92f14db02eec2c891a29cd9f2e7655 Mon Sep 17 00:00:00 2001 From: James Phillips Date: Sun, 7 Feb 2016 11:26:19 -0800 Subject: [PATCH] Adds a test to make sure the local sync doesn't clobber tagged addresses. --- command/agent/local_test.go | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/command/agent/local_test.go b/command/agent/local_test.go index 0d6f8f53e..58a2f2329 100644 --- a/command/agent/local_test.go +++ b/command/agent/local_test.go @@ -120,6 +120,12 @@ func TestAgentAntiEntropy_Services(t *testing.T) { t.Fatalf("err: %v", err) } + // Make sure we sent along our tagged addresses when we synced. + addrs := services.NodeServices.Node.TaggedAddresses + if len(addrs) == 0 || !reflect.DeepEqual(addrs, conf.TaggedAddresses) { + t.Fatalf("bad: %v", addrs) + } + // We should have 6 services (consul included) if len(services.NodeServices.Services) != 6 { t.Fatalf("bad: %v", services.NodeServices.Services) @@ -627,6 +633,23 @@ func TestAgentAntiEntropy_Checks(t *testing.T) { t.Fatalf("should be in sync: %v %v", name, status) } } + + // Make sure we sent along our tagged addresses when we synced. + { + req := structs.NodeSpecificRequest{ + Datacenter: "dc1", + Node: agent.config.NodeName, + } + var services structs.IndexedNodeServices + if err := agent.RPC("Catalog.NodeServices", &req, &services); err != nil { + t.Fatalf("err: %v", err) + } + + addrs := services.NodeServices.Node.TaggedAddresses + if len(addrs) == 0 || !reflect.DeepEqual(addrs, conf.TaggedAddresses) { + t.Fatalf("bad: %v", addrs) + } + } } func TestAgentAntiEntropy_Check_DeferSync(t *testing.T) {