From e2935e75092a142261a8f76aa5d33e099278e2ce Mon Sep 17 00:00:00 2001 From: James Phillips Date: Tue, 4 Jul 2017 20:06:44 -0700 Subject: [PATCH] test: Changes WAN/LAN join confirmer to use port number vs. address. This fixes TestServer_JoinSeparateLanAndWanAddresses which sets bogus advertise addresses as part of the test. Port numbers uniquely identify members since everything is running on localhost. --- agent/consul/helper_test.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/agent/consul/helper_test.go b/agent/consul/helper_test.go index 9575e3f5b..6c2e3c2bf 100644 --- a/agent/consul/helper_test.go +++ b/agent/consul/helper_test.go @@ -3,6 +3,7 @@ package consul import ( "errors" "fmt" + "net" "testing" "github.com/hashicorp/consul/testutil/retry" @@ -119,9 +120,15 @@ func seeEachOther(a, b []serf.Member, addra, addrb string) bool { } func serfMembersContains(members []serf.Member, addr string) bool { + // There are tests that manipulate the advertise address, so we just + // compare port numbers here, since that uniquely identifies a member + // as we use the loopback interface for everything. + _, want, err := net.SplitHostPort(addr) + if err != nil { + panic(err) + } for _, m := range members { - maddr := fmt.Sprintf("%s:%d", m.Addr.String(), m.Port) - if maddr == addr { + if got := fmt.Sprintf("%d", m.Port); got == want { return true } }