ServiceIP allocation test is flaky

Choose a possible IP out of a list, instead of assuming it
can't be chosen randomly.
This commit is contained in:
Clayton Coleman
2015-05-11 13:05:56 -04:00
parent 63b821aeb6
commit 6ba6af2d1c

View File

@@ -530,11 +530,19 @@ func TestServiceRegistryIPAllocation(t *testing.T) {
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{
ObjectMeta: api.ObjectMeta{Name: "quux"},
Spec: api.ServiceSpec{
Selector: map[string]string{"bar": "baz"},
PortalIP: "1.2.3.93",
PortalIP: testIP,
SessionAffinity: api.AffinityTypeNone,
Ports: []api.ServicePort{{
Port: 6502,
@@ -548,7 +556,7 @@ func TestServiceRegistryIPAllocation(t *testing.T) {
t.Fatal(err)
}
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)
}
}