SSH tunnels fallback to LegacyHostIP
This commit is contained in:
@@ -46,3 +46,27 @@ func TestGetServersToValidate(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestFindExternalAddress(t *testing.T) {
|
||||
expectedIP := "172.0.0.1"
|
||||
|
||||
nodes := []*api.Node{new(api.Node), new(api.Node), new(api.Node)}
|
||||
nodes[0].Status.Addresses = []api.NodeAddress{{"ExternalIP", expectedIP}}
|
||||
nodes[1].Status.Addresses = []api.NodeAddress{{"LegacyHostIP", expectedIP}}
|
||||
nodes[2].Status.Addresses = []api.NodeAddress{{"ExternalIP", expectedIP}, {"LegacyHostIP", "172.0.0.2"}}
|
||||
|
||||
for _, node := range nodes {
|
||||
ip, err := findExternalAddress(node)
|
||||
if err != nil {
|
||||
t.Errorf("error getting node external address: %s", err)
|
||||
}
|
||||
if ip != expectedIP {
|
||||
t.Errorf("expected ip to be %s, but was %s", expectedIP, ip)
|
||||
}
|
||||
}
|
||||
|
||||
_, err := findExternalAddress(new(api.Node))
|
||||
if err == nil {
|
||||
t.Errorf("expected findExternalAddress to fail on a node with missing ip information")
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user