Fix on ipv6

This commit is contained in:
Alex Dadgar 2017-10-18 18:36:53 -07:00
parent 593536664e
commit fa55f3bc21
1 changed files with 10 additions and 8 deletions

View File

@ -1,7 +1,6 @@
package agent package agent
import ( import (
"fmt"
"io/ioutil" "io/ioutil"
"net" "net"
"os" "os"
@ -764,7 +763,7 @@ func TestConfig_normalizeAddrs(t *testing.T) {
}, },
Addresses: &Addresses{}, Addresses: &Addresses{},
AdvertiseAddrs: &AdvertiseAddrs{ AdvertiseAddrs: &AdvertiseAddrs{
RPC: "{{ GetPrivateIP }}:8888", RPC: "{{ GetPrivateIP }}",
}, },
Server: &ServerConfig{ Server: &ServerConfig{
Enabled: true, Enabled: true,
@ -775,16 +774,19 @@ func TestConfig_normalizeAddrs(t *testing.T) {
t.Fatalf("unable to normalize addresses: %s", err) t.Fatalf("unable to normalize addresses: %s", err)
} }
if c.AdvertiseAddrs.HTTP != fmt.Sprintf("%s:4646", c.BindAddr) { exp := net.JoinHostPort(c.BindAddr, "4646")
t.Fatalf("expected HTTP advertise address %s:4646, got %s", c.BindAddr, c.AdvertiseAddrs.HTTP) if c.AdvertiseAddrs.HTTP != exp {
t.Fatalf("expected HTTP advertise address %s, got %s", exp, c.AdvertiseAddrs.HTTP)
} }
if c.AdvertiseAddrs.RPC != fmt.Sprintf("%s:8888", c.BindAddr) { exp = net.JoinHostPort(c.BindAddr, "4647")
t.Fatalf("expected RPC advertise address %s:8888, got %s", c.BindAddr, c.AdvertiseAddrs.RPC) if c.AdvertiseAddrs.RPC != exp {
t.Fatalf("expected RPC advertise address %s, got %s", exp, c.AdvertiseAddrs.RPC)
} }
if c.AdvertiseAddrs.Serf != fmt.Sprintf("%s:4648", c.BindAddr) { exp = net.JoinHostPort(c.BindAddr, "4648")
t.Fatalf("expected Serf advertise address %s:4648, got %s", c.BindAddr, c.AdvertiseAddrs.Serf) if c.AdvertiseAddrs.Serf != exp {
t.Fatalf("expected Serf advertise address %s, got %s", exp, c.AdvertiseAddrs.Serf)
} }
// allow to advertise 127.0.0.1 in non-dev mode, if explicitly configured to do so // allow to advertise 127.0.0.1 in non-dev mode, if explicitly configured to do so