Skip to content

Commit

Permalink
Merge pull request kubernetes#18532 from thockin/deflake-svcs-e2e
Browse files Browse the repository at this point in the history
Deflake services e2e
  • Loading branch information
wojtek-t committed Dec 11, 2015
2 parents caf4b1e + ad22d00 commit 6e29e84
Showing 1 changed file with 20 additions and 13 deletions.
33 changes: 20 additions & 13 deletions test/e2e/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -504,29 +504,36 @@ var _ = Describe("Services", func() {
By("hitting the pod through the service's LoadBalancer")
testLoadBalancerReachable(ingress1, 80)

By("changing service " + serviceName + " update NodePort")
nodePort2 := nodePort1 - 1
if !ServiceNodePortRange.Contains(nodePort2) {
//Check for (unlikely) assignment at bottom of range
nodePort2 = nodePort1 + 1
By("changing service " + serviceName + ": update NodePort")
nodePort2 := 0
for i := 1; i < ServiceNodePortRange.Size; i++ {
offs1 := nodePort1 - ServiceNodePortRange.Base
offs2 := (offs1 + i) % ServiceNodePortRange.Size
nodePort2 = ServiceNodePortRange.Base + offs2
service, err = updateService(f.Client, f.Namespace.Name, serviceName, func(s *api.Service) {
s.Spec.Ports[0].NodePort = nodePort2
})
if err != nil && strings.Contains(err.Error(), "provided port is already allocated") {
Logf("nodePort %d is busy, will retry", nodePort2)
continue
}
// Otherwise err was nil or err was a real error
break
}
service, err = updateService(f.Client, f.Namespace.Name, serviceName, func(s *api.Service) {
s.Spec.Ports[0].NodePort = nodePort2
})
Expect(err).NotTo(HaveOccurred())

if service.Spec.Type != api.ServiceTypeLoadBalancer {
Failf("got unexpected Spec.Type for updated-NodePort service: %v", service)
Failf("got unexpected Spec.Type for updated-LoadBalancer service: %v", service)
}
if len(service.Spec.Ports) != 1 {
Failf("got unexpected len(Spec.Ports) for updated-NodePort service: %v", service)
Failf("got unexpected len(Spec.Ports) for updated-LoadBalancer service: %v", service)
}
port = service.Spec.Ports[0]
if port.NodePort != nodePort2 {
Failf("got unexpected Spec.Ports[0].nodePort for NodePort service: %v", service)
Failf("got unexpected Spec.Ports[0].nodePort for LoadBalancer service: %v", service)
}
if len(service.Status.LoadBalancer.Ingress) != 1 {
Failf("got unexpected len(Status.LoadBalancer.Ingress) for NodePort service: %v", service)
Failf("got unexpected len(Status.LoadBalancer.Ingress) for LoadBalancer service: %v", service)
}

By("hitting the pod through the service's updated NodePort")
Expand All @@ -541,7 +548,7 @@ var _ = Describe("Services", func() {
Expect(err).NotTo(HaveOccurred())

ingress2 := service.Status.LoadBalancer.Ingress[0]
if testLoadBalancerReachableInTime(ingress2, 80, 5*time.Second) {
if testLoadBalancerReachable(ingress2, 80) {
break
}

Expand Down

0 comments on commit 6e29e84

Please sign in to comment.