mirror of https://github.com/status-im/consul.git
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.
This commit is contained in:
parent
d92f70f313
commit
d8db4bc086
|
@ -3,6 +3,7 @@ package consul
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"net"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/hashicorp/consul/testutil/retry"
|
"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 {
|
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 {
|
for _, m := range members {
|
||||||
maddr := fmt.Sprintf("%s:%d", m.Addr.String(), m.Port)
|
if got := fmt.Sprintf("%d", m.Port); got == want {
|
||||||
if maddr == addr {
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue