Failf("got unexpected len(Status.LoadBalancer.Ingresss) for NodePort service: %v",service)
}
By("hitting the pod through the service's NodePort")
testReachable(ip,nodePort)
By("checking the LoadBalancer is closed")
testLoadBalancerNotReachable(ingress,80)
testLoadBalancerNotReachable(ingress1,80)
})
It("should prevent NodePort collisions",func(){
serviceName:="nodeport-collision"
serviceName2:=serviceName+"2"
ns:=namespaces[0]
baseName:="nodeport-collision-"
serviceName1:=baseName+"1"
serviceName2:=baseName+"2"
ns:=f.Namespace.Name
t:=NewWebserverTest(c,ns,serviceName)
t:=NewWebserverTest(c,ns,serviceName1)
deferfunc(){
deferGinkgoRecover()
errs:=t.Cleanup()
...
...
@@ -821,10 +721,9 @@ var _ = Describe("Services", func() {
}
}()
By("creating service "+serviceName1+" with type NodePort in namespace "+ns)
service:=t.BuildServiceSpec()
service.Spec.Type=api.ServiceTypeNodePort
By("creating service "+serviceName+" with type NodePort in namespace "+ns)
result,err:=t.CreateService(service)
Expect(err).NotTo(HaveOccurred())
...
...
@@ -839,23 +738,21 @@ var _ = Describe("Services", func() {
Failf("got unexpected Spec.Ports[0].nodePort for new service: %v",result)
}
By("creating service "+serviceName+" with conflicting NodePort")
By("creating service "+serviceName2+" with conflicting NodePort")
service2:=t.BuildServiceSpec()
service2.Name=serviceName2
service2.Spec.Type=api.ServiceTypeNodePort
service2.Spec.Ports[0].NodePort=port.NodePort
By("creating service "+serviceName2+" with conflicting NodePort")
result2,err:=t.CreateService(service2)
iferr==nil{
Failf("Created service with conflicting NodePort: %v",result2)
}
expectedErr:=fmt.Sprintf("Service \"%s\" is invalid: spec.ports[0].nodePort: invalid value '%d', Details: provided port is already allocated",serviceName2,port.NodePort)
expectedErr:=fmt.Sprintf("Service \"%s\" is invalid: spec.ports[0].nodePort: invalid value '%d', Details: provided port is already allocated",
Logf("Waiting for service %s in namespace %s to have a LoadBalancer ingress point (%v)",serviceName,namespace,time.Since(start))
}
i++
}
returnservice,fmt.Errorf("service %s in namespace %s doesn't have a LoadBalancer ingress point after %.2f seconds",serviceName,namespace,timeout.Seconds())
By(fmt.Sprintf("Successfully validated that service %s in namespace %s exposes endpoints %v (%v elapsed)",serviceName,namespace,expectedEndpoints,time.Since(start)))
Logf("successfully validated that service %s in namespace %s exposes endpoints %v (%v elapsed)",
Failf("Timed out waiting for service %s in namespace %s to expose endpoints %v (%v elapsed)",serviceName,namespace,expectedEndpoints,serviceStartTimeout)