Call jig.SanityCheckService automatically after changes

This commit is contained in:
Dan Winship 2019-08-01 06:19:15 -04:00
parent 85ebedd93e
commit 4dcc6229b1
7 changed files with 36 additions and 69 deletions

View File

@ -851,7 +851,6 @@ func (cont *NginxIngressController) Init() {
{Name: "stats", Port: 18080}} {Name: "stats", Port: 18080}}
}) })
cont.lbSvc = serviceJig.WaitForLoadBalancerOrFail(cont.Ns, "nginx-ingress-lb", e2eservice.GetServiceLoadBalancerCreationTimeout(cont.Client)) cont.lbSvc = serviceJig.WaitForLoadBalancerOrFail(cont.Ns, "nginx-ingress-lb", e2eservice.GetServiceLoadBalancerCreationTimeout(cont.Client))
serviceJig.SanityCheckService(cont.lbSvc, v1.ServiceTypeLoadBalancer)
read := func(file string) string { read := func(file string) string {
return string(testfiles.ReadOrDie(filepath.Join(IngressManifestPath, "nginx", file))) return string(testfiles.ReadOrDie(filepath.Join(IngressManifestPath, "nginx", file)))

View File

@ -15,7 +15,6 @@ go_library(
importpath = "k8s.io/kubernetes/test/e2e/framework/service", importpath = "k8s.io/kubernetes/test/e2e/framework/service",
visibility = ["//visibility:public"], visibility = ["//visibility:public"],
deps = [ deps = [
"//pkg/apis/core:go_default_library",
"//pkg/registry/core/service/portallocator:go_default_library", "//pkg/registry/core/service/portallocator:go_default_library",
"//staging/src/k8s.io/api/core/v1:go_default_library", "//staging/src/k8s.io/api/core/v1:go_default_library",
"//staging/src/k8s.io/api/policy/v1beta1:go_default_library", "//staging/src/k8s.io/api/policy/v1beta1:go_default_library",

View File

@ -40,7 +40,6 @@ import (
"k8s.io/apimachinery/pkg/watch" "k8s.io/apimachinery/pkg/watch"
clientset "k8s.io/client-go/kubernetes" clientset "k8s.io/client-go/kubernetes"
"k8s.io/client-go/tools/cache" "k8s.io/client-go/tools/cache"
api "k8s.io/kubernetes/pkg/apis/core"
"k8s.io/kubernetes/pkg/registry/core/service/portallocator" "k8s.io/kubernetes/pkg/registry/core/service/portallocator"
"k8s.io/kubernetes/test/e2e/framework" "k8s.io/kubernetes/test/e2e/framework"
e2enode "k8s.io/kubernetes/test/e2e/framework/node" e2enode "k8s.io/kubernetes/test/e2e/framework/node"
@ -106,6 +105,7 @@ func (j *TestJig) CreateTCPServiceWithPort(namespace string, tweak func(svc *v1.
if err != nil { if err != nil {
framework.Failf("Failed to create TCP Service %q: %v", svc.Name, err) framework.Failf("Failed to create TCP Service %q: %v", svc.Name, err)
} }
j.sanityCheckService(result, svc.Spec.Type)
return result return result
} }
@ -121,6 +121,7 @@ func (j *TestJig) CreateTCPServiceOrFail(namespace string, tweak func(svc *v1.Se
if err != nil { if err != nil {
framework.Failf("Failed to create TCP Service %q: %v", svc.Name, err) framework.Failf("Failed to create TCP Service %q: %v", svc.Name, err)
} }
j.sanityCheckService(result, svc.Spec.Type)
return result return result
} }
@ -136,6 +137,7 @@ func (j *TestJig) CreateUDPServiceOrFail(namespace string, tweak func(svc *v1.Se
if err != nil { if err != nil {
framework.Failf("Failed to create UDP Service %q: %v", svc.Name, err) framework.Failf("Failed to create UDP Service %q: %v", svc.Name, err)
} }
j.sanityCheckService(result, svc.Spec.Type)
return result return result
} }
@ -161,6 +163,7 @@ func (j *TestJig) CreateExternalNameServiceOrFail(namespace string, tweak func(s
if err != nil { if err != nil {
framework.Failf("Failed to create ExternalName Service %q: %v", svc.Name, err) framework.Failf("Failed to create ExternalName Service %q: %v", svc.Name, err)
} }
j.sanityCheckService(result, svc.Spec.Type)
return result return result
} }
@ -197,7 +200,6 @@ func (j *TestJig) CreateOnlyLocalNodePortService(namespace, serviceName string,
ginkgo.By("creating a pod to be part of the service " + serviceName) ginkgo.By("creating a pod to be part of the service " + serviceName)
j.RunOrFail(namespace, nil) j.RunOrFail(namespace, nil)
} }
j.SanityCheckService(svc, v1.ServiceTypeNodePort)
return svc return svc
} }
@ -207,11 +209,8 @@ func (j *TestJig) CreateOnlyLocalNodePortService(namespace, serviceName string,
// the standard netexec container used everywhere in this test. // the standard netexec container used everywhere in this test.
func (j *TestJig) CreateOnlyLocalLoadBalancerService(namespace, serviceName string, timeout time.Duration, createPod bool, func (j *TestJig) CreateOnlyLocalLoadBalancerService(namespace, serviceName string, timeout time.Duration, createPod bool,
tweak func(svc *v1.Service)) *v1.Service { tweak func(svc *v1.Service)) *v1.Service {
ginkgo.By("creating a service " + namespace + "/" + serviceName + " with type=LoadBalancer and ExternalTrafficPolicy=Local") j.CreateLoadBalancerService(namespace, serviceName, timeout, func(svc *v1.Service) {
j.CreateTCPServiceOrFail(namespace, func(svc *v1.Service) { ginkgo.By("setting ExternalTrafficPolicy=Local")
svc.Spec.Type = v1.ServiceTypeLoadBalancer
// We need to turn affinity off for our LB distribution tests
svc.Spec.SessionAffinity = v1.ServiceAffinityNone
svc.Spec.ExternalTrafficPolicy = v1.ServiceExternalTrafficPolicyTypeLocal svc.Spec.ExternalTrafficPolicy = v1.ServiceExternalTrafficPolicyTypeLocal
if tweak != nil { if tweak != nil {
tweak(svc) tweak(svc)
@ -223,28 +222,27 @@ func (j *TestJig) CreateOnlyLocalLoadBalancerService(namespace, serviceName stri
j.RunOrFail(namespace, nil) j.RunOrFail(namespace, nil)
} }
ginkgo.By("waiting for loadbalancer for service " + namespace + "/" + serviceName) ginkgo.By("waiting for loadbalancer for service " + namespace + "/" + serviceName)
svc := j.WaitForLoadBalancerOrFail(namespace, serviceName, timeout) return j.WaitForLoadBalancerOrFail(namespace, serviceName, timeout)
j.SanityCheckService(svc, v1.ServiceTypeLoadBalancer)
return svc
} }
// CreateLoadBalancerService creates a loadbalancer service and waits // CreateLoadBalancerService creates a loadbalancer service and waits
// for it to acquire an ingress IP. // for it to acquire an ingress IP.
func (j *TestJig) CreateLoadBalancerService(namespace, serviceName string, timeout time.Duration, tweak func(svc *v1.Service)) *v1.Service { func (j *TestJig) CreateLoadBalancerService(namespace, serviceName string, timeout time.Duration, tweak func(svc *v1.Service)) *v1.Service {
ginkgo.By("creating a service " + namespace + "/" + serviceName + " with type=LoadBalancer") ginkgo.By("creating a service " + namespace + "/" + serviceName + " with type=LoadBalancer")
j.CreateTCPServiceOrFail(namespace, func(svc *v1.Service) { svc := j.newServiceTemplate(namespace, v1.ProtocolTCP, 80)
svc.Spec.Type = v1.ServiceTypeLoadBalancer svc.Spec.Type = v1.ServiceTypeLoadBalancer
// We need to turn affinity off for our LB distribution tests // We need to turn affinity off for our LB distribution tests
svc.Spec.SessionAffinity = v1.ServiceAffinityNone svc.Spec.SessionAffinity = v1.ServiceAffinityNone
if tweak != nil { if tweak != nil {
tweak(svc) tweak(svc)
} }
}) _, err := j.Client.CoreV1().Services(namespace).Create(svc)
if err != nil {
framework.Failf("Failed to create LoadBalancer Service %q: %v", svc.Name, err)
}
ginkgo.By("waiting for loadbalancer for service " + namespace + "/" + serviceName) ginkgo.By("waiting for loadbalancer for service " + namespace + "/" + serviceName)
svc := j.WaitForLoadBalancerOrFail(namespace, serviceName, timeout) return j.WaitForLoadBalancerOrFail(namespace, serviceName, timeout)
j.SanityCheckService(svc, v1.ServiceTypeLoadBalancer)
return svc
} }
// GetEndpointNodes returns a map of nodenames:external-ip on which the // GetEndpointNodes returns a map of nodenames:external-ip on which the
@ -361,8 +359,12 @@ func (j *TestJig) WaitForAvailableEndpoint(namespace, serviceName string, timeou
framework.ExpectNoError(err, "No subset of available IP address found for the endpoint %s within timeout %v", serviceName, timeout) framework.ExpectNoError(err, "No subset of available IP address found for the endpoint %s within timeout %v", serviceName, timeout)
} }
// SanityCheckService performs sanity checks on the given service // sanityCheckService performs sanity checks on the given service; in particular, ensuring
func (j *TestJig) SanityCheckService(svc *v1.Service, svcType v1.ServiceType) { // that creating/updating a service allocates IPs, ports, etc, as needed.
func (j *TestJig) sanityCheckService(svc *v1.Service, svcType v1.ServiceType) {
if svcType == "" {
svcType = v1.ServiceTypeClusterIP
}
if svc.Spec.Type != svcType { if svc.Spec.Type != svcType {
framework.Failf("unexpected Spec.Type (%s) for service, expected %s", svc.Spec.Type, svcType) framework.Failf("unexpected Spec.Type (%s) for service, expected %s", svc.Spec.Type, svcType)
} }
@ -371,12 +373,12 @@ func (j *TestJig) SanityCheckService(svc *v1.Service, svcType v1.ServiceType) {
if svc.Spec.ExternalName != "" { if svc.Spec.ExternalName != "" {
framework.Failf("unexpected Spec.ExternalName (%s) for service, expected empty", svc.Spec.ExternalName) framework.Failf("unexpected Spec.ExternalName (%s) for service, expected empty", svc.Spec.ExternalName)
} }
if svc.Spec.ClusterIP != api.ClusterIPNone && svc.Spec.ClusterIP == "" { if svc.Spec.ClusterIP == "" {
framework.Failf("didn't get ClusterIP for non-ExternamName service") framework.Failf("didn't get ClusterIP for non-ExternalName service")
} }
} else { } else {
if svc.Spec.ClusterIP != "" { if svc.Spec.ClusterIP != "" {
framework.Failf("unexpected Spec.ClusterIP (%s) for ExternamName service, expected empty", svc.Spec.ClusterIP) framework.Failf("unexpected Spec.ClusterIP (%s) for ExternalName service, expected empty", svc.Spec.ClusterIP)
} }
} }
@ -422,9 +424,10 @@ func (j *TestJig) UpdateService(namespace, name string, update func(*v1.Service)
return nil, fmt.Errorf("failed to get Service %q: %v", name, err) return nil, fmt.Errorf("failed to get Service %q: %v", name, err)
} }
update(service) update(service)
service, err = j.Client.CoreV1().Services(namespace).Update(service) result, err := j.Client.CoreV1().Services(namespace).Update(service)
if err == nil { if err == nil {
return service, nil j.sanityCheckService(result, service.Spec.Type)
return result, nil
} }
if !errors.IsConflict(err) && !errors.IsServerTimeout(err) { if !errors.IsConflict(err) && !errors.IsServerTimeout(err) {
return nil, fmt.Errorf("failed to update Service %q: %v", name, err) return nil, fmt.Errorf("failed to update Service %q: %v", name, err)
@ -457,6 +460,7 @@ func (j *TestJig) WaitForNewIngressIPOrFail(namespace, name, existingIP string,
} }
return true return true
}) })
j.sanityCheckService(service, v1.ServiceTypeLoadBalancer)
return service return service
} }
@ -490,6 +494,7 @@ func (j *TestJig) WaitForLoadBalancerOrFail(namespace, name string, timeout time
service := j.waitForConditionOrFail(namespace, name, timeout, "have a load balancer", func(svc *v1.Service) bool { service := j.waitForConditionOrFail(namespace, name, timeout, "have a load balancer", func(svc *v1.Service) bool {
return len(svc.Status.LoadBalancer.Ingress) > 0 return len(svc.Status.LoadBalancer.Ingress) > 0
}) })
j.sanityCheckService(service, v1.ServiceTypeLoadBalancer)
return service return service
} }
@ -506,6 +511,7 @@ func (j *TestJig) WaitForLoadBalancerDestroyOrFail(namespace, name string, ip st
service := j.waitForConditionOrFail(namespace, name, timeout, "have no load balancer", func(svc *v1.Service) bool { service := j.waitForConditionOrFail(namespace, name, timeout, "have no load balancer", func(svc *v1.Service) bool {
return len(svc.Status.LoadBalancer.Ingress) == 0 return len(svc.Status.LoadBalancer.Ingress) == 0
}) })
j.sanityCheckService(service, v1.ServiceTypeLoadBalancer)
return service return service
} }
@ -838,7 +844,7 @@ func (j *TestJig) checkExternalServiceReachability(svc *v1.Service, pod *v1.Pod)
func (j *TestJig) CheckServiceReachability(namespace string, svc *v1.Service, pod *v1.Pod) { func (j *TestJig) CheckServiceReachability(namespace string, svc *v1.Service, pod *v1.Pod) {
svcType := svc.Spec.Type svcType := svc.Spec.Type
j.SanityCheckService(svc, svcType) j.sanityCheckService(svc, svcType)
switch svcType { switch svcType {
case v1.ServiceTypeClusterIP: case v1.ServiceTypeClusterIP:

View File

@ -154,7 +154,6 @@ func waitAndVerifyLBWithTier(jig *e2eservice.TestJig, ns, svcName, existingIP st
// Verify that the new ingress IP is the requested IP if it's set. // Verify that the new ingress IP is the requested IP if it's set.
framework.ExpectEqual(ingressIP, svc.Spec.LoadBalancerIP) framework.ExpectEqual(ingressIP, svc.Spec.LoadBalancerIP)
} }
jig.SanityCheckService(svc, v1.ServiceTypeLoadBalancer)
// If the IP has been used by previous test, sometimes we get the lingering // If the IP has been used by previous test, sometimes we get the lingering
// 404 errors even after the LB is long gone. Tolerate and retry until the // 404 errors even after the LB is long gone. Tolerate and retry until the
// the new LB is fully established since this feature is still Alpha in GCP. // the new LB is fully established since this feature is still Alpha in GCP.

View File

@ -274,7 +274,6 @@ var _ = SIGDescribe("Services", func() {
jig := e2eservice.NewTestJig(cs, serviceName) jig := e2eservice.NewTestJig(cs, serviceName)
servicePort := 8080 servicePort := 8080
tcpService := jig.CreateTCPServiceWithPort(ns, nil, int32(servicePort)) tcpService := jig.CreateTCPServiceWithPort(ns, nil, int32(servicePort))
jig.SanityCheckService(tcpService, v1.ServiceTypeClusterIP)
defer func() { defer func() {
framework.Logf("Cleaning up the sourceip test service") framework.Logf("Cleaning up the sourceip test service")
err := cs.CoreV1().Services(ns).Delete(serviceName, nil) err := cs.CoreV1().Services(ns).Delete(serviceName, nil)
@ -345,7 +344,6 @@ var _ = SIGDescribe("Services", func() {
jig := e2eservice.NewTestJig(cs, serviceName) jig := e2eservice.NewTestJig(cs, serviceName)
servicePort := 8080 servicePort := 8080
svc := jig.CreateTCPServiceWithPort(ns, nil, int32(servicePort)) svc := jig.CreateTCPServiceWithPort(ns, nil, int32(servicePort))
jig.SanityCheckService(svc, v1.ServiceTypeClusterIP)
serviceIP := svc.Spec.ClusterIP serviceIP := svc.Spec.ClusterIP
framework.Logf("hairpin-test cluster ip: %s", serviceIP) framework.Logf("hairpin-test cluster ip: %s", serviceIP)
@ -589,11 +587,9 @@ var _ = SIGDescribe("Services", func() {
ginkgo.By("creating a TCP service " + serviceName + " with type=ClusterIP in namespace " + ns1) ginkgo.By("creating a TCP service " + serviceName + " with type=ClusterIP in namespace " + ns1)
tcpService := jig.CreateTCPServiceOrFail(ns1, nil) tcpService := jig.CreateTCPServiceOrFail(ns1, nil)
jig.SanityCheckService(tcpService, v1.ServiceTypeClusterIP)
ginkgo.By("creating a UDP service " + serviceName + " with type=ClusterIP in namespace " + ns2) ginkgo.By("creating a UDP service " + serviceName + " with type=ClusterIP in namespace " + ns2)
udpService := jig.CreateUDPServiceOrFail(ns2, nil) udpService := jig.CreateUDPServiceOrFail(ns2, nil)
jig.SanityCheckService(udpService, v1.ServiceTypeClusterIP)
ginkgo.By("verifying that TCP and UDP use the same port") ginkgo.By("verifying that TCP and UDP use the same port")
if tcpService.Spec.Ports[0].Port != udpService.Spec.Ports[0].Port { if tcpService.Spec.Ports[0].Port != udpService.Spec.Ports[0].Port {
@ -614,7 +610,6 @@ var _ = SIGDescribe("Services", func() {
tcpService = jig.UpdateServiceOrFail(ns1, tcpService.Name, func(s *v1.Service) { tcpService = jig.UpdateServiceOrFail(ns1, tcpService.Name, func(s *v1.Service) {
s.Spec.Type = v1.ServiceTypeNodePort s.Spec.Type = v1.ServiceTypeNodePort
}) })
jig.SanityCheckService(tcpService, v1.ServiceTypeNodePort)
tcpNodePort := int(tcpService.Spec.Ports[0].NodePort) tcpNodePort := int(tcpService.Spec.Ports[0].NodePort)
framework.Logf("TCP node port: %d", tcpNodePort) framework.Logf("TCP node port: %d", tcpNodePort)
@ -622,7 +617,6 @@ var _ = SIGDescribe("Services", func() {
udpService = jig.UpdateServiceOrFail(ns2, udpService.Name, func(s *v1.Service) { udpService = jig.UpdateServiceOrFail(ns2, udpService.Name, func(s *v1.Service) {
s.Spec.Type = v1.ServiceTypeNodePort s.Spec.Type = v1.ServiceTypeNodePort
}) })
jig.SanityCheckService(udpService, v1.ServiceTypeNodePort)
udpNodePort := int(udpService.Spec.Ports[0].NodePort) udpNodePort := int(udpService.Spec.Ports[0].NodePort)
framework.Logf("UDP node port: %d", udpNodePort) framework.Logf("UDP node port: %d", udpNodePort)
@ -681,7 +675,6 @@ var _ = SIGDescribe("Services", func() {
ginkgo.By("waiting for the TCP service to have a load balancer") ginkgo.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
tcpService = jig.WaitForLoadBalancerOrFail(ns1, tcpService.Name, loadBalancerCreateTimeout) tcpService = jig.WaitForLoadBalancerOrFail(ns1, tcpService.Name, loadBalancerCreateTimeout)
jig.SanityCheckService(tcpService, v1.ServiceTypeLoadBalancer)
if int(tcpService.Spec.Ports[0].NodePort) != tcpNodePort { if int(tcpService.Spec.Ports[0].NodePort) != tcpNodePort {
framework.Failf("TCP Spec.Ports[0].NodePort changed (%d -> %d) when not expected", tcpNodePort, tcpService.Spec.Ports[0].NodePort) framework.Failf("TCP Spec.Ports[0].NodePort changed (%d -> %d) when not expected", tcpNodePort, tcpService.Spec.Ports[0].NodePort)
} }
@ -714,7 +707,6 @@ var _ = SIGDescribe("Services", func() {
ginkgo.By("waiting for the UDP service to have a load balancer") ginkgo.By("waiting for the UDP service to have a load balancer")
// 2nd one should be faster since they ran in parallel. // 2nd one should be faster since they ran in parallel.
udpService = jig.WaitForLoadBalancerOrFail(ns2, udpService.Name, loadBalancerCreateTimeout) udpService = jig.WaitForLoadBalancerOrFail(ns2, udpService.Name, loadBalancerCreateTimeout)
jig.SanityCheckService(udpService, v1.ServiceTypeLoadBalancer)
if int(udpService.Spec.Ports[0].NodePort) != udpNodePort { if int(udpService.Spec.Ports[0].NodePort) != udpNodePort {
framework.Failf("UDP Spec.Ports[0].NodePort changed (%d -> %d) when not expected", udpNodePort, udpService.Spec.Ports[0].NodePort) framework.Failf("UDP Spec.Ports[0].NodePort changed (%d -> %d) when not expected", udpNodePort, udpService.Spec.Ports[0].NodePort)
} }
@ -745,7 +737,6 @@ var _ = SIGDescribe("Services", func() {
ginkgo.By("changing the TCP service's NodePort") ginkgo.By("changing the TCP service's NodePort")
tcpService = jig.ChangeServiceNodePortOrFail(ns1, tcpService.Name, tcpNodePort) tcpService = jig.ChangeServiceNodePortOrFail(ns1, tcpService.Name, tcpNodePort)
jig.SanityCheckService(tcpService, v1.ServiceTypeLoadBalancer)
tcpNodePortOld := tcpNodePort tcpNodePortOld := tcpNodePort
tcpNodePort = int(tcpService.Spec.Ports[0].NodePort) tcpNodePort = int(tcpService.Spec.Ports[0].NodePort)
if tcpNodePort == tcpNodePortOld { if tcpNodePort == tcpNodePortOld {
@ -758,11 +749,6 @@ var _ = SIGDescribe("Services", func() {
ginkgo.By("changing the UDP service's NodePort") ginkgo.By("changing the UDP service's NodePort")
udpService = jig.ChangeServiceNodePortOrFail(ns2, udpService.Name, udpNodePort) udpService = jig.ChangeServiceNodePortOrFail(ns2, udpService.Name, udpNodePort)
if loadBalancerSupportsUDP {
jig.SanityCheckService(udpService, v1.ServiceTypeLoadBalancer)
} else {
jig.SanityCheckService(udpService, v1.ServiceTypeNodePort)
}
udpNodePortOld := udpNodePort udpNodePortOld := udpNodePort
udpNodePort = int(udpService.Spec.Ports[0].NodePort) udpNodePort = int(udpService.Spec.Ports[0].NodePort)
if udpNodePort == udpNodePortOld { if udpNodePort == udpNodePortOld {
@ -799,7 +785,6 @@ var _ = SIGDescribe("Services", func() {
tcpService = jig.UpdateServiceOrFail(ns1, tcpService.Name, func(s *v1.Service) { tcpService = jig.UpdateServiceOrFail(ns1, tcpService.Name, func(s *v1.Service) {
s.Spec.Ports[0].Port++ s.Spec.Ports[0].Port++
}) })
jig.SanityCheckService(tcpService, v1.ServiceTypeLoadBalancer)
svcPortOld := svcPort svcPortOld := svcPort
svcPort = int(tcpService.Spec.Ports[0].Port) svcPort = int(tcpService.Spec.Ports[0].Port)
if svcPort == svcPortOld { if svcPort == svcPortOld {
@ -816,11 +801,6 @@ var _ = SIGDescribe("Services", func() {
udpService = jig.UpdateServiceOrFail(ns2, udpService.Name, func(s *v1.Service) { udpService = jig.UpdateServiceOrFail(ns2, udpService.Name, func(s *v1.Service) {
s.Spec.Ports[0].Port++ s.Spec.Ports[0].Port++
}) })
if loadBalancerSupportsUDP {
jig.SanityCheckService(udpService, v1.ServiceTypeLoadBalancer)
} else {
jig.SanityCheckService(udpService, v1.ServiceTypeNodePort)
}
if int(udpService.Spec.Ports[0].Port) != svcPort { if int(udpService.Spec.Ports[0].Port) != svcPort {
framework.Failf("UDP Spec.Ports[0].Port (%d) did not change", udpService.Spec.Ports[0].Port) framework.Failf("UDP Spec.Ports[0].Port (%d) did not change", udpService.Spec.Ports[0].Port)
} }
@ -892,7 +872,6 @@ var _ = SIGDescribe("Services", func() {
}) })
// Wait for the load balancer to be destroyed asynchronously // Wait for the load balancer to be destroyed asynchronously
tcpService = jig.WaitForLoadBalancerDestroyOrFail(ns1, tcpService.Name, tcpIngressIP, svcPort, loadBalancerCreateTimeout) tcpService = jig.WaitForLoadBalancerDestroyOrFail(ns1, tcpService.Name, tcpIngressIP, svcPort, loadBalancerCreateTimeout)
jig.SanityCheckService(tcpService, v1.ServiceTypeClusterIP)
ginkgo.By("changing UDP service back to type=ClusterIP") ginkgo.By("changing UDP service back to type=ClusterIP")
udpService = jig.UpdateServiceOrFail(ns2, udpService.Name, func(s *v1.Service) { udpService = jig.UpdateServiceOrFail(ns2, udpService.Name, func(s *v1.Service) {
@ -902,7 +881,6 @@ var _ = SIGDescribe("Services", func() {
if loadBalancerSupportsUDP { if loadBalancerSupportsUDP {
// Wait for the load balancer to be destroyed asynchronously // Wait for the load balancer to be destroyed asynchronously
udpService = jig.WaitForLoadBalancerDestroyOrFail(ns2, udpService.Name, udpIngressIP, svcPort, loadBalancerCreateTimeout) udpService = jig.WaitForLoadBalancerDestroyOrFail(ns2, udpService.Name, udpIngressIP, svcPort, loadBalancerCreateTimeout)
jig.SanityCheckService(udpService, v1.ServiceTypeClusterIP)
} }
ginkgo.By("checking the TCP NodePort is closed") ginkgo.By("checking the TCP NodePort is closed")
@ -939,7 +917,6 @@ var _ = SIGDescribe("Services", func() {
err := cs.CoreV1().Services(ns).Delete(serviceName, nil) err := cs.CoreV1().Services(ns).Delete(serviceName, nil)
framework.ExpectNoError(err, "failed to delete service: %s in namespace: %s", serviceName, ns) framework.ExpectNoError(err, "failed to delete service: %s in namespace: %s", serviceName, ns)
}() }()
jig.SanityCheckService(tcpService, v1.ServiceTypeClusterIP)
framework.Logf("Service Port TCP: %v", tcpService.Spec.Ports[0].Port) framework.Logf("Service Port TCP: %v", tcpService.Spec.Ports[0].Port)
ginkgo.By("changing the TCP service to type=NodePort") ginkgo.By("changing the TCP service to type=NodePort")
@ -1006,7 +983,6 @@ var _ = SIGDescribe("Services", func() {
err := cs.CoreV1().Services(ns).Delete(serviceName, nil) err := cs.CoreV1().Services(ns).Delete(serviceName, nil)
framework.ExpectNoError(err, "failed to delete service %s in namespace %s", serviceName, ns) framework.ExpectNoError(err, "failed to delete service %s in namespace %s", serviceName, ns)
}() }()
jig.SanityCheckService(externalNameService, v1.ServiceTypeExternalName)
ginkgo.By("changing the ExternalName service to type=ClusterIP") ginkgo.By("changing the ExternalName service to type=ClusterIP")
clusterIPService := jig.UpdateServiceOrFail(ns, externalNameService.Name, func(s *v1.Service) { clusterIPService := jig.UpdateServiceOrFail(ns, externalNameService.Name, func(s *v1.Service) {
@ -1042,7 +1018,6 @@ var _ = SIGDescribe("Services", func() {
err := cs.CoreV1().Services(ns).Delete(serviceName, nil) err := cs.CoreV1().Services(ns).Delete(serviceName, nil)
framework.ExpectNoError(err, "failed to delete service %s in namespace %s", serviceName, ns) framework.ExpectNoError(err, "failed to delete service %s in namespace %s", serviceName, ns)
}() }()
jig.SanityCheckService(externalNameService, v1.ServiceTypeExternalName)
ginkgo.By("changing the ExternalName service to type=NodePort") ginkgo.By("changing the ExternalName service to type=NodePort")
nodePortService := jig.UpdateServiceOrFail(ns, externalNameService.Name, func(s *v1.Service) { nodePortService := jig.UpdateServiceOrFail(ns, externalNameService.Name, func(s *v1.Service) {
@ -1077,7 +1052,6 @@ var _ = SIGDescribe("Services", func() {
err := cs.CoreV1().Services(ns).Delete(serviceName, nil) err := cs.CoreV1().Services(ns).Delete(serviceName, nil)
framework.ExpectNoError(err, "failed to delete service %s in namespace %s", serviceName, ns) framework.ExpectNoError(err, "failed to delete service %s in namespace %s", serviceName, ns)
}() }()
jig.SanityCheckService(clusterIPService, v1.ServiceTypeClusterIP)
ginkgo.By("Creating active service to test reachability when its FQDN is referred as externalName for another service") ginkgo.By("Creating active service to test reachability when its FQDN is referred as externalName for another service")
externalServiceName := "externalsvc" externalServiceName := "externalsvc"
@ -1117,7 +1091,6 @@ var _ = SIGDescribe("Services", func() {
err := cs.CoreV1().Services(ns).Delete(serviceName, nil) err := cs.CoreV1().Services(ns).Delete(serviceName, nil)
framework.ExpectNoError(err, "failed to delete service %s in namespace %s", serviceName, ns) framework.ExpectNoError(err, "failed to delete service %s in namespace %s", serviceName, ns)
}() }()
jig.SanityCheckService(nodePortService, v1.ServiceTypeNodePort)
ginkgo.By("Creating active service to test reachability when its FQDN is referred as externalName for another service") ginkgo.By("Creating active service to test reachability when its FQDN is referred as externalName for another service")
externalServiceName := "externalsvc" externalServiceName := "externalsvc"
@ -1515,7 +1488,6 @@ var _ = SIGDescribe("Services", func() {
}() }()
svc = jig.WaitForLoadBalancerOrFail(namespace, serviceName, loadBalancerCreateTimeout) svc = jig.WaitForLoadBalancerOrFail(namespace, serviceName, loadBalancerCreateTimeout)
jig.SanityCheckService(svc, v1.ServiceTypeLoadBalancer)
// timeout when we haven't just created the load balancer // timeout when we haven't just created the load balancer
normalReachabilityTimeout := 2 * time.Minute normalReachabilityTimeout := 2 * time.Minute
@ -1589,7 +1561,6 @@ var _ = SIGDescribe("Services", func() {
}() }()
svc = jig.WaitForLoadBalancerOrFail(namespace, serviceName, createTimeout) svc = jig.WaitForLoadBalancerOrFail(namespace, serviceName, createTimeout)
jig.SanityCheckService(svc, v1.ServiceTypeLoadBalancer)
lbIngress := &svc.Status.LoadBalancer.Ingress[0] lbIngress := &svc.Status.LoadBalancer.Ingress[0]
svcPort := int(svc.Spec.Ports[0].Port) svcPort := int(svc.Spec.Ports[0].Port)
// should have an internal IP. // should have an internal IP.
@ -1638,7 +1609,6 @@ var _ = SIGDescribe("Services", func() {
framework.Failf("Loadbalancer IP not changed to external.") framework.Failf("Loadbalancer IP not changed to external.")
} }
// should have an external IP. // should have an external IP.
jig.SanityCheckService(svc, v1.ServiceTypeLoadBalancer)
gomega.Expect(isInternalEndpoint(lbIngress)).To(gomega.BeFalse()) gomega.Expect(isInternalEndpoint(lbIngress)).To(gomega.BeFalse())
ginkgo.By("hitting the external load balancer") ginkgo.By("hitting the external load balancer")
@ -1667,7 +1637,6 @@ var _ = SIGDescribe("Services", func() {
framework.Failf("Loadbalancer IP not changed to internal.") framework.Failf("Loadbalancer IP not changed to internal.")
} }
// should have the given static internal IP. // should have the given static internal IP.
jig.SanityCheckService(svc, v1.ServiceTypeLoadBalancer)
framework.ExpectEqual(e2eservice.GetIngressPoint(lbIngress), internalStaticIP) framework.ExpectEqual(e2eservice.GetIngressPoint(lbIngress), internalStaticIP)
} }
}) })
@ -2466,7 +2435,6 @@ func execAffinityTestForLBServiceWithOptionalTransition(f *framework.Framework,
jig := e2eservice.NewTestJig(cs, serviceName) jig := e2eservice.NewTestJig(cs, serviceName)
ginkgo.By("waiting for loadbalancer for service " + ns + "/" + serviceName) ginkgo.By("waiting for loadbalancer for service " + ns + "/" + serviceName)
svc = jig.WaitForLoadBalancerOrFail(ns, serviceName, e2eservice.LoadBalancerCreateTimeoutDefault) svc = jig.WaitForLoadBalancerOrFail(ns, serviceName, e2eservice.LoadBalancerCreateTimeoutDefault)
jig.SanityCheckService(svc, v1.ServiceTypeLoadBalancer)
defer func() { defer func() {
podNodePairs, err := e2enode.PodNodePairs(cs, ns) podNodePairs, err := e2enode.PodNodePairs(cs, ns)
framework.Logf("[pod,node] pairs: %+v; err: %v", podNodePairs, err) framework.Logf("[pod,node] pairs: %+v; err: %v", podNodePairs, err)

View File

@ -52,7 +52,6 @@ func (t *ServiceUpgradeTest) Setup(f *framework.Framework) {
s.Spec.Type = v1.ServiceTypeLoadBalancer s.Spec.Type = v1.ServiceTypeLoadBalancer
}) })
tcpService = jig.WaitForLoadBalancerOrFail(ns.Name, tcpService.Name, e2eservice.LoadBalancerCreateTimeoutDefault) tcpService = jig.WaitForLoadBalancerOrFail(ns.Name, tcpService.Name, e2eservice.LoadBalancerCreateTimeoutDefault)
jig.SanityCheckService(tcpService, v1.ServiceTypeLoadBalancer)
// Get info to hit it with // Get info to hit it with
tcpIngressIP := e2eservice.GetIngressPoint(&tcpService.Status.LoadBalancer.Ingress[0]) tcpIngressIP := e2eservice.GetIngressPoint(&tcpService.Status.LoadBalancer.Ingress[0])
@ -111,11 +110,9 @@ func (t *ServiceUpgradeTest) test(f *framework.Framework, done <-chan struct{},
<-done <-done
} }
// Sanity check and hit it once more // Hit it once more
ginkgo.By("hitting the pod through the service's LoadBalancer") ginkgo.By("hitting the pod through the service's LoadBalancer")
e2eservice.TestReachableHTTP(t.tcpIngressIP, t.svcPort, e2eservice.LoadBalancerLagTimeoutDefault) e2eservice.TestReachableHTTP(t.tcpIngressIP, t.svcPort, e2eservice.LoadBalancerLagTimeoutDefault)
t.jig.SanityCheckService(t.tcpService, v1.ServiceTypeLoadBalancer)
if testFinalizer { if testFinalizer {
defer func() { defer func() {
ginkgo.By("Check that service can be deleted with finalizer") ginkgo.By("Check that service can be deleted with finalizer")

View File

@ -54,7 +54,6 @@ var _ = SIGDescribe("Services", func() {
e2eservice := jig.CreateTCPServiceOrFail(ns, func(svc *v1.Service) { e2eservice := jig.CreateTCPServiceOrFail(ns, func(svc *v1.Service) {
svc.Spec.Type = v1.ServiceTypeNodePort svc.Spec.Type = v1.ServiceTypeNodePort
}) })
jig.SanityCheckService(e2eservice, v1.ServiceTypeNodePort)
nodePort := int(e2eservice.Spec.Ports[0].NodePort) nodePort := int(e2eservice.Spec.Ports[0].NodePort)
ginkgo.By("creating Pod to be part of service " + serviceName) ginkgo.By("creating Pod to be part of service " + serviceName)