Commit 6ba6af2d authored by Clayton Coleman's avatar Clayton Coleman

ServiceIP allocation test is flaky

Choose a possible IP out of a list, instead of assuming it can't be chosen randomly.
parent 63b821ae
...@@ -530,11 +530,19 @@ func TestServiceRegistryIPAllocation(t *testing.T) { ...@@ -530,11 +530,19 @@ func TestServiceRegistryIPAllocation(t *testing.T) {
t.Errorf("Unexpected PortalIP: %s", created_service_2.Spec.PortalIP) t.Errorf("Unexpected PortalIP: %s", created_service_2.Spec.PortalIP)
} }
testIPs := []string{"1.2.3.93", "1.2.3.94", "1.2.3.95", "1.2.3.96"}
testIP := ""
for _, ip := range testIPs {
if !rest.portals.(*ipallocator.Range).Has(net.ParseIP(ip)) {
testIP = ip
}
}
svc3 := &api.Service{ svc3 := &api.Service{
ObjectMeta: api.ObjectMeta{Name: "quux"}, ObjectMeta: api.ObjectMeta{Name: "quux"},
Spec: api.ServiceSpec{ Spec: api.ServiceSpec{
Selector: map[string]string{"bar": "baz"}, Selector: map[string]string{"bar": "baz"},
PortalIP: "1.2.3.93", PortalIP: testIP,
SessionAffinity: api.AffinityTypeNone, SessionAffinity: api.AffinityTypeNone,
Ports: []api.ServicePort{{ Ports: []api.ServicePort{{
Port: 6502, Port: 6502,
...@@ -548,7 +556,7 @@ func TestServiceRegistryIPAllocation(t *testing.T) { ...@@ -548,7 +556,7 @@ func TestServiceRegistryIPAllocation(t *testing.T) {
t.Fatal(err) t.Fatal(err)
} }
created_service_3 := created_svc3.(*api.Service) created_service_3 := created_svc3.(*api.Service)
if created_service_3.Spec.PortalIP != "1.2.3.93" { // specific IP if created_service_3.Spec.PortalIP != testIP { // specific IP
t.Errorf("Unexpected PortalIP: %s", created_service_3.Spec.PortalIP) t.Errorf("Unexpected PortalIP: %s", created_service_3.Spec.PortalIP)
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment