e2e: Don't try to create a UDP LoadBalancer on AWS

AWS doesn't support type=LoadBalancer with UDP services.  For now, we
simply skip over the test with type=LoadBalancer on AWS for the UDP
service.

Fix #20911
This commit is contained in:
Justin Santa Barbara 2016-02-09 21:59:35 -05:00
parent 41a98b43e4
commit a0093eb503
2 changed files with 57 additions and 33 deletions

View File

@ -200,7 +200,7 @@ func (s *AWSCloud) ensureLoadBalancerHealthCheck(loadBalancer *elb.LoadBalancerD
expectedTimeout := int64(5) expectedTimeout := int64(5)
expectedInterval := int64(10) expectedInterval := int64(10)
// We only a TCP health-check on the first port // We only configure a TCP health-check on the first port
expectedTarget := "" expectedTarget := ""
for _, listener := range listeners { for _, listener := range listeners {
if listener.InstancePort == nil { if listener.InstancePort == nil {

View File

@ -418,6 +418,8 @@ var _ = Describe("Services", func() {
// requires cloud load-balancer support // requires cloud load-balancer support
SkipUnlessProviderIs("gce", "gke", "aws") SkipUnlessProviderIs("gce", "gke", "aws")
loadBalancerSupportsUDP := !providerIs("aws")
// This test is more monolithic than we'd like because LB turnup can be // This test is more monolithic than we'd like because LB turnup can be
// very slow, so we lumped all the tests into one LB lifecycle. // very slow, so we lumped all the tests into one LB lifecycle.
@ -510,10 +512,12 @@ var _ = Describe("Services", func() {
s.Spec.Type = api.ServiceTypeLoadBalancer s.Spec.Type = api.ServiceTypeLoadBalancer
}) })
By("changing the UDP service to type=LoadBalancer") if loadBalancerSupportsUDP {
udpService = jig.UpdateServiceOrFail(ns2, udpService.Name, func(s *api.Service) { By("changing the UDP service to type=LoadBalancer")
s.Spec.Type = api.ServiceTypeLoadBalancer udpService = jig.UpdateServiceOrFail(ns2, udpService.Name, func(s *api.Service) {
}) s.Spec.Type = api.ServiceTypeLoadBalancer
})
}
By("waiting for the TCP service to have a load balancer") By("waiting for the TCP service to have a load balancer")
// Wait for the load balancer to be created asynchronously // Wait for the load balancer to be created asynchronously
@ -528,7 +532,6 @@ var _ = Describe("Services", func() {
tcpIngressIP := getIngressPoint(&tcpService.Status.LoadBalancer.Ingress[0]) tcpIngressIP := getIngressPoint(&tcpService.Status.LoadBalancer.Ingress[0])
Logf("TCP load balancer: %s", tcpIngressIP) Logf("TCP load balancer: %s", tcpIngressIP)
By("waiting for the UDP service " + serviceName + " to have a load balancer")
if providerIs("gce", "gke") { if providerIs("gce", "gke") {
// Do this as early as possible, which overrides the `defer` above. // Do this as early as possible, which overrides the `defer` above.
// This is mostly out of fear of leaking the IP in a timeout case // This is mostly out of fear of leaking the IP in a timeout case
@ -545,19 +548,22 @@ var _ = Describe("Services", func() {
} }
} }
By("waiting for the UDP service to have a load balancer") var udpIngressIP string
// 2nd one should be faster since they ran in parallel. if loadBalancerSupportsUDP {
udpService = jig.WaitForLoadBalancerOrFail(ns2, udpService.Name) By("waiting for the UDP service to have a load balancer")
jig.SanityCheckService(udpService, api.ServiceTypeLoadBalancer) // 2nd one should be faster since they ran in parallel.
if udpService.Spec.Ports[0].NodePort != udpNodePort { udpService = jig.WaitForLoadBalancerOrFail(ns2, udpService.Name)
Failf("UDP Spec.Ports[0].NodePort changed (%d -> %d) when not expected", udpNodePort, udpService.Spec.Ports[0].NodePort) jig.SanityCheckService(udpService, api.ServiceTypeLoadBalancer)
} if udpService.Spec.Ports[0].NodePort != udpNodePort {
udpIngressIP := getIngressPoint(&udpService.Status.LoadBalancer.Ingress[0]) Failf("UDP Spec.Ports[0].NodePort changed (%d -> %d) when not expected", udpNodePort, udpService.Spec.Ports[0].NodePort)
Logf("UDP load balancer: %s", udpIngressIP) }
udpIngressIP = getIngressPoint(&udpService.Status.LoadBalancer.Ingress[0])
Logf("UDP load balancer: %s", udpIngressIP)
By("verifying that TCP and UDP use different load balancers") By("verifying that TCP and UDP use different load balancers")
if tcpIngressIP == udpIngressIP { if tcpIngressIP == udpIngressIP {
Failf("Load balancers are not different: %s", getIngressPoint(&tcpService.Status.LoadBalancer.Ingress[0])) Failf("Load balancers are not different: %s", getIngressPoint(&tcpService.Status.LoadBalancer.Ingress[0]))
}
} }
By("hitting the TCP service's NodePort") By("hitting the TCP service's NodePort")
@ -569,8 +575,10 @@ var _ = Describe("Services", func() {
By("hitting the TCP service's LoadBalancer") By("hitting the TCP service's LoadBalancer")
jig.TestReachableHTTP(tcpIngressIP, svcPort, loadBalancerLagTimeout) jig.TestReachableHTTP(tcpIngressIP, svcPort, loadBalancerLagTimeout)
By("hitting the UDP service's LoadBalancer") if loadBalancerSupportsUDP {
jig.TestReachableUDP(udpIngressIP, svcPort, loadBalancerLagTimeout) By("hitting the UDP service's LoadBalancer")
jig.TestReachableUDP(udpIngressIP, svcPort, loadBalancerLagTimeout)
}
// Change the services' node ports. // Change the services' node ports.
@ -589,13 +597,17 @@ var _ = Describe("Services", func() {
By("changing the UDP service's NodePort") By("changing the UDP service's NodePort")
udpService = jig.ChangeServiceNodePortOrFail(ns2, udpService.Name, udpNodePort) udpService = jig.ChangeServiceNodePortOrFail(ns2, udpService.Name, udpNodePort)
jig.SanityCheckService(udpService, api.ServiceTypeLoadBalancer) if loadBalancerSupportsUDP {
jig.SanityCheckService(udpService, api.ServiceTypeLoadBalancer)
} else {
jig.SanityCheckService(udpService, api.ServiceTypeNodePort)
}
udpNodePortOld := udpNodePort udpNodePortOld := udpNodePort
udpNodePort = udpService.Spec.Ports[0].NodePort udpNodePort = udpService.Spec.Ports[0].NodePort
if udpNodePort == udpNodePortOld { if udpNodePort == udpNodePortOld {
Failf("UDP Spec.Ports[0].NodePort (%d) did not change", udpNodePort) Failf("UDP Spec.Ports[0].NodePort (%d) did not change", udpNodePort)
} }
if getIngressPoint(&udpService.Status.LoadBalancer.Ingress[0]) != udpIngressIP { if loadBalancerSupportsUDP && getIngressPoint(&udpService.Status.LoadBalancer.Ingress[0]) != udpIngressIP {
Failf("UDP Status.LoadBalancer.Ingress changed (%s -> %s) when not expected", udpIngressIP, getIngressPoint(&udpService.Status.LoadBalancer.Ingress[0])) Failf("UDP Status.LoadBalancer.Ingress changed (%s -> %s) when not expected", udpIngressIP, getIngressPoint(&udpService.Status.LoadBalancer.Ingress[0]))
} }
Logf("UDP node port: %d", udpNodePort) Logf("UDP node port: %d", udpNodePort)
@ -615,8 +627,10 @@ var _ = Describe("Services", func() {
By("hitting the TCP service's LoadBalancer") By("hitting the TCP service's LoadBalancer")
jig.TestReachableHTTP(tcpIngressIP, svcPort, loadBalancerLagTimeout) jig.TestReachableHTTP(tcpIngressIP, svcPort, loadBalancerLagTimeout)
By("hitting the UDP service's LoadBalancer") if loadBalancerSupportsUDP {
jig.TestReachableUDP(udpIngressIP, svcPort, loadBalancerLagTimeout) By("hitting the UDP service's LoadBalancer")
jig.TestReachableUDP(udpIngressIP, svcPort, loadBalancerLagTimeout)
}
// Change the services' main ports. // Change the services' main ports.
@ -641,14 +655,18 @@ var _ = Describe("Services", func() {
udpService = jig.UpdateServiceOrFail(ns2, udpService.Name, func(s *api.Service) { udpService = jig.UpdateServiceOrFail(ns2, udpService.Name, func(s *api.Service) {
s.Spec.Ports[0].Port++ s.Spec.Ports[0].Port++
}) })
jig.SanityCheckService(udpService, api.ServiceTypeLoadBalancer) if loadBalancerSupportsUDP {
jig.SanityCheckService(udpService, api.ServiceTypeLoadBalancer)
} else {
jig.SanityCheckService(udpService, api.ServiceTypeNodePort)
}
if udpService.Spec.Ports[0].Port != svcPort { if udpService.Spec.Ports[0].Port != svcPort {
Failf("UDP Spec.Ports[0].Port (%d) did not change", udpService.Spec.Ports[0].Port) Failf("UDP Spec.Ports[0].Port (%d) did not change", udpService.Spec.Ports[0].Port)
} }
if udpService.Spec.Ports[0].NodePort != udpNodePort { if udpService.Spec.Ports[0].NodePort != udpNodePort {
Failf("UDP Spec.Ports[0].NodePort (%d) changed", udpService.Spec.Ports[0].NodePort) Failf("UDP Spec.Ports[0].NodePort (%d) changed", udpService.Spec.Ports[0].NodePort)
} }
if getIngressPoint(&udpService.Status.LoadBalancer.Ingress[0]) != udpIngressIP { if loadBalancerSupportsUDP && getIngressPoint(&udpService.Status.LoadBalancer.Ingress[0]) != udpIngressIP {
Failf("UDP Status.LoadBalancer.Ingress changed (%s -> %s) when not expected", udpIngressIP, getIngressPoint(&udpService.Status.LoadBalancer.Ingress[0])) Failf("UDP Status.LoadBalancer.Ingress changed (%s -> %s) when not expected", udpIngressIP, getIngressPoint(&udpService.Status.LoadBalancer.Ingress[0]))
} }
@ -663,8 +681,10 @@ var _ = Describe("Services", func() {
By("hitting the TCP service's LoadBalancer") By("hitting the TCP service's LoadBalancer")
jig.TestReachableHTTP(tcpIngressIP, svcPort, loadBalancerCreateTimeout) // this may actually recreate the LB jig.TestReachableHTTP(tcpIngressIP, svcPort, loadBalancerCreateTimeout) // this may actually recreate the LB
By("hitting the UDP service's LoadBalancer") if loadBalancerSupportsUDP {
jig.TestReachableUDP(udpIngressIP, svcPort, loadBalancerCreateTimeout) // this may actually recreate the LB) By("hitting the UDP service's LoadBalancer")
jig.TestReachableUDP(udpIngressIP, svcPort, loadBalancerCreateTimeout) // this may actually recreate the LB)
}
// Change the services back to ClusterIP. // Change the services back to ClusterIP.
@ -682,9 +702,11 @@ var _ = Describe("Services", func() {
s.Spec.Type = api.ServiceTypeClusterIP s.Spec.Type = api.ServiceTypeClusterIP
s.Spec.Ports[0].NodePort = 0 s.Spec.Ports[0].NodePort = 0
}) })
// Wait for the load balancer to be destroyed asynchronously if loadBalancerSupportsUDP {
udpService = jig.WaitForLoadBalancerDestroyOrFail(ns2, udpService.Name, udpIngressIP, svcPort) // Wait for the load balancer to be destroyed asynchronously
jig.SanityCheckService(udpService, api.ServiceTypeClusterIP) udpService = jig.WaitForLoadBalancerDestroyOrFail(ns2, udpService.Name, udpIngressIP, svcPort)
jig.SanityCheckService(udpService, api.ServiceTypeClusterIP)
}
By("checking the TCP NodePort is closed") By("checking the TCP NodePort is closed")
jig.TestNotReachableHTTP(nodeIP, tcpNodePort, kubeProxyLagTimeout) jig.TestNotReachableHTTP(nodeIP, tcpNodePort, kubeProxyLagTimeout)
@ -695,8 +717,10 @@ var _ = Describe("Services", func() {
By("checking the TCP LoadBalancer is closed") By("checking the TCP LoadBalancer is closed")
jig.TestNotReachableHTTP(tcpIngressIP, svcPort, loadBalancerLagTimeout) jig.TestNotReachableHTTP(tcpIngressIP, svcPort, loadBalancerLagTimeout)
By("checking the UDP LoadBalancer is closed") if loadBalancerSupportsUDP {
jig.TestNotReachableUDP(udpIngressIP, svcPort, loadBalancerLagTimeout) By("checking the UDP LoadBalancer is closed")
jig.TestNotReachableUDP(udpIngressIP, svcPort, loadBalancerLagTimeout)
}
}) })
It("should prevent NodePort collisions", func() { It("should prevent NodePort collisions", func() {