diff --git a/test/e2e/network/service.go b/test/e2e/network/service.go index c1bbdb52801..421684baf0e 100644 --- a/test/e2e/network/service.go +++ b/test/e2e/network/service.go @@ -108,7 +108,7 @@ var _ = SIGDescribe("Services", func() { */ framework.ConformanceIt("should provide secure master service ", func() { _, err := cs.CoreV1().Services(metav1.NamespaceDefault).Get("kubernetes", metav1.GetOptions{}) - Expect(err).NotTo(HaveOccurred()) + Expect(err).NotTo(HaveOccurred(), "failed to fetch the service object for the service named kubernetes") }) /* @@ -128,7 +128,7 @@ var _ = SIGDescribe("Services", func() { By("creating service " + serviceName + " in namespace " + ns) defer func() { err := cs.CoreV1().Services(ns).Delete(serviceName, nil) - Expect(err).NotTo(HaveOccurred()) + Expect(err).NotTo(HaveOccurred(), "failed to delete service: %s in namespace: %s", serviceName, ns) }() ports := []v1.ServicePort{{ Port: 80, @@ -136,7 +136,7 @@ var _ = SIGDescribe("Services", func() { }} _, err := jig.CreateServiceWithServicePort(labels, ns, ports) - Expect(err).NotTo(HaveOccurred()) + Expect(err).NotTo(HaveOccurred(), "failed to create service with ServicePorts in namespace: %s", ns) framework.ValidateEndpointsOrFail(cs, ns, serviceName, framework.PortsByPodName{}) @@ -144,7 +144,7 @@ var _ = SIGDescribe("Services", func() { defer func() { for name := range names { err := cs.CoreV1().Pods(ns).Delete(name, nil) - Expect(err).NotTo(HaveOccurred()) + Expect(err).NotTo(HaveOccurred(), "failed to delete pod: %s in namespace: %s", name, ns) } }() @@ -181,7 +181,7 @@ var _ = SIGDescribe("Services", func() { defer func() { err := cs.CoreV1().Services(ns).Delete(serviceName, nil) - Expect(err).NotTo(HaveOccurred()) + Expect(err).NotTo(HaveOccurred(), "failed to delete service: %s in namespace: %s", serviceName, ns) }() labels := map[string]string{"foo": "bar"} @@ -203,7 +203,7 @@ var _ = SIGDescribe("Services", func() { }, } _, err := jig.CreateServiceWithServicePort(labels, ns, ports) - Expect(err).NotTo(HaveOccurred()) + Expect(err).NotTo(HaveOccurred(), "failed to create service with ServicePorts in namespace: %s", ns) port1 := 100 port2 := 101 framework.ValidateEndpointsOrFail(cs, ns, serviceName, framework.PortsByPodName{}) @@ -212,7 +212,7 @@ var _ = SIGDescribe("Services", func() { defer func() { for name := range names { err := cs.CoreV1().Pods(ns).Delete(name, nil) - Expect(err).NotTo(HaveOccurred()) + Expect(err).NotTo(HaveOccurred(), "failed to delete pod: %s in namespace: %s", name, ns) } }() @@ -272,7 +272,7 @@ var _ = SIGDescribe("Services", func() { defer func() { framework.Logf("Cleaning up the sourceip test service") err := cs.CoreV1().Services(ns).Delete(serviceName, nil) - Expect(err).NotTo(HaveOccurred()) + Expect(err).NotTo(HaveOccurred(), "failed to delete service: %s in namespace: %s", serviceName, ns) }() serviceIp := tcpService.Spec.ClusterIP framework.Logf("sourceip-test cluster ip: %s", serviceIp) @@ -293,7 +293,7 @@ var _ = SIGDescribe("Services", func() { defer func() { framework.Logf("Cleaning up the echo server pod") err := cs.CoreV1().Pods(ns).Delete(serverPodName, nil) - Expect(err).NotTo(HaveOccurred()) + Expect(err).NotTo(HaveOccurred(), "failed to delete pod: %s on node: %s", serverPodName, node1.Name) }() // Waiting for service to expose endpoint. @@ -322,13 +322,13 @@ var _ = SIGDescribe("Services", func() { By("creating service1 in namespace " + ns) podNames1, svc1IP, err := framework.StartServeHostnameService(cs, internalClientset, getServeHostnameService("service1"), ns, numPods) - Expect(err).NotTo(HaveOccurred()) + Expect(err).NotTo(HaveOccurred(), "failed to create replication controller with service: %s in the namespace: %s", svc1IP, ns) By("creating service2 in namespace " + ns) podNames2, svc2IP, err := framework.StartServeHostnameService(cs, internalClientset, getServeHostnameService("service2"), ns, numPods) - Expect(err).NotTo(HaveOccurred()) + Expect(err).NotTo(HaveOccurred(), "failed to create replication controller with service: %s in the namespace: %s", svc2IP, ns) hosts, err := framework.NodeSSHHosts(cs) - Expect(err).NotTo(HaveOccurred()) + Expect(err).NotTo(HaveOccurred(), "failed to find external/internal IPs for every node") if len(hosts) == 0 { framework.Failf("No ssh-able nodes") } @@ -352,7 +352,7 @@ var _ = SIGDescribe("Services", func() { // Start another service and verify both are up. By("creating service3 in namespace " + ns) podNames3, svc3IP, err := framework.StartServeHostnameService(cs, internalClientset, getServeHostnameService("service3"), ns, numPods) - Expect(err).NotTo(HaveOccurred()) + Expect(err).NotTo(HaveOccurred(), "failed to create replication controller with service: %s in the namespace: %s", svc3IP, ns) if svc2IP == svc3IP { framework.Failf("service IPs conflict: %v", svc2IP) @@ -379,20 +379,20 @@ var _ = SIGDescribe("Services", func() { framework.ExpectNoError(framework.StopServeHostnameService(f.ClientSet, ns, svc1)) }() podNames1, svc1IP, err := framework.StartServeHostnameService(cs, internalClientset, getServeHostnameService(svc1), ns, numPods) - Expect(err).NotTo(HaveOccurred()) + Expect(err).NotTo(HaveOccurred(), "failed to create replication controller with service: %s in the namespace: %s", svc1IP, ns) defer func() { framework.ExpectNoError(framework.StopServeHostnameService(f.ClientSet, ns, svc2)) }() podNames2, svc2IP, err := framework.StartServeHostnameService(cs, internalClientset, getServeHostnameService(svc2), ns, numPods) - Expect(err).NotTo(HaveOccurred()) + Expect(err).NotTo(HaveOccurred(), "failed to create replication controller with service: %s in the namespace: %s", svc2IP, ns) if svc1IP == svc2IP { framework.Failf("VIPs conflict: %v", svc1IP) } hosts, err := framework.NodeSSHHosts(cs) - Expect(err).NotTo(HaveOccurred()) + Expect(err).NotTo(HaveOccurred(), "failed to find external/internal IPs for every node") if len(hosts) == 0 { framework.Failf("No ssh-able nodes") } @@ -432,10 +432,10 @@ var _ = SIGDescribe("Services", func() { framework.ExpectNoError(framework.StopServeHostnameService(f.ClientSet, ns, "service1")) }() podNames1, svc1IP, err := framework.StartServeHostnameService(cs, internalClientset, getServeHostnameService("service1"), ns, numPods) - Expect(err).NotTo(HaveOccurred()) + Expect(err).NotTo(HaveOccurred(), "failed to create replication controller with service: %s in the namespace: %s", svc1IP, ns) hosts, err := framework.NodeSSHHosts(cs) - Expect(err).NotTo(HaveOccurred()) + Expect(err).NotTo(HaveOccurred(), "failed to find external/internal IPs for every node") if len(hosts) == 0 { framework.Failf("No ssh-able nodes") } @@ -459,7 +459,7 @@ var _ = SIGDescribe("Services", func() { framework.ExpectNoError(framework.StopServeHostnameService(f.ClientSet, ns, "service2")) }() podNames2, svc2IP, err := framework.StartServeHostnameService(cs, internalClientset, getServeHostnameService("service2"), ns, numPods) - Expect(err).NotTo(HaveOccurred()) + Expect(err).NotTo(HaveOccurred(), "failed to create replication controller with service: %s in the namespace: %s", svc2IP, ns) if svc1IP == svc2IP { framework.Failf("VIPs conflict: %v", svc1IP) @@ -527,7 +527,7 @@ var _ = SIGDescribe("Services", func() { By("creating a second namespace") namespacePtr, err := f.CreateNamespace("services", nil) - Expect(err).NotTo(HaveOccurred()) + Expect(err).NotTo(HaveOccurred(), "failed to create namespace") ns2 := namespacePtr.Name // LB2 in ns2 on UDP framework.Logf("namespace for UDP test: %s", ns2) @@ -592,7 +592,7 @@ var _ = SIGDescribe("Services", func() { By("creating a static load balancer IP") staticIPName = fmt.Sprintf("e2e-external-lb-test-%s", framework.RunId) gceCloud, err := gce.GetGCECloud() - Expect(err).NotTo(HaveOccurred()) + Expect(err).NotTo(HaveOccurred(), "failed to get GCE cloud provider") err = gceCloud.ReserveRegionAddress(&compute.Address{Name: staticIPName}, gceCloud.Region()) defer func() { @@ -603,9 +603,9 @@ var _ = SIGDescribe("Services", func() { } } }() - Expect(err).NotTo(HaveOccurred()) + Expect(err).NotTo(HaveOccurred(), "failed to create region address: %s", staticIPName) reservedAddr, err := gceCloud.GetRegionAddress(staticIPName, gceCloud.Region()) - Expect(err).NotTo(HaveOccurred()) + Expect(err).NotTo(HaveOccurred(), "failed to get region address: %s", staticIPName) requestedIP = reservedAddr.Address framework.Logf("Allocated static load balancer IP: %s", requestedIP) @@ -649,7 +649,7 @@ var _ = SIGDescribe("Services", func() { By("demoting the static IP to ephemeral") if staticIPName != "" { gceCloud, err := gce.GetGCECloud() - Expect(err).NotTo(HaveOccurred()) + Expect(err).NotTo(HaveOccurred(), "failed to get GCE cloud provider") // Deleting it after it is attached "demotes" it to an // ephemeral IP, which can be auto-released. if err := gceCloud.DeleteRegionAddress(staticIPName, gceCloud.Region()); err != nil { @@ -844,7 +844,7 @@ var _ = SIGDescribe("Services", func() { defer func() { framework.Logf("Cleaning up the updating NodePorts test service") err := cs.CoreV1().Services(ns).Delete(serviceName, nil) - Expect(err).NotTo(HaveOccurred()) + Expect(err).NotTo(HaveOccurred(), "failed to delete service: %s in namespace: %s", serviceName, ns) }() jig.SanityCheckService(tcpService, v1.ServiceTypeClusterIP) svcPort := int(tcpService.Spec.Ports[0].Port) @@ -891,7 +891,7 @@ var _ = SIGDescribe("Services", func() { defer func() { framework.Logf("Cleaning up the ExternalName to ClusterIP test service") err := cs.CoreV1().Services(ns).Delete(serviceName, nil) - Expect(err).NotTo(HaveOccurred()) + Expect(err).NotTo(HaveOccurred(), "failed to delete service %s in namespace %s", serviceName, ns) }() jig.SanityCheckService(externalNameService, v1.ServiceTypeExternalName) By("changing the ExternalName service to type=ClusterIP") @@ -915,7 +915,7 @@ var _ = SIGDescribe("Services", func() { defer func() { framework.Logf("Cleaning up the ExternalName to NodePort test service") err := cs.CoreV1().Services(ns).Delete(serviceName, nil) - Expect(err).NotTo(HaveOccurred()) + Expect(err).NotTo(HaveOccurred(), "failed to delete service %s in namespace %s", serviceName, ns) }() jig.SanityCheckService(externalNameService, v1.ServiceTypeExternalName) By("changing the ExternalName service to type=NodePort") @@ -939,7 +939,7 @@ var _ = SIGDescribe("Services", func() { defer func() { framework.Logf("Cleaning up the ClusterIP to ExternalName test service") err := cs.CoreV1().Services(ns).Delete(serviceName, nil) - Expect(err).NotTo(HaveOccurred()) + Expect(err).NotTo(HaveOccurred(), "failed to delete service %s in namespace %s", serviceName, ns) }() jig.SanityCheckService(clusterIPService, v1.ServiceTypeClusterIP) By("changing the ClusterIP service to type=ExternalName") @@ -963,7 +963,7 @@ var _ = SIGDescribe("Services", func() { defer func() { framework.Logf("Cleaning up the NodePort to ExternalName test service") err := cs.CoreV1().Services(ns).Delete(serviceName, nil) - Expect(err).NotTo(HaveOccurred()) + Expect(err).NotTo(HaveOccurred(), "failed to delete service %s in namespace %s", serviceName, ns) }() jig.SanityCheckService(nodePortService, v1.ServiceTypeNodePort) By("changing the NodePort service to type=ExternalName") @@ -1013,7 +1013,7 @@ var _ = SIGDescribe("Services", func() { }, } result, err := t.CreateService(service) - Expect(err).NotTo(HaveOccurred()) + Expect(err).NotTo(HaveOccurred(), "failed to create service: %s in namespace: %s", serviceName, ns) if len(result.Spec.Ports) != 2 { framework.Failf("got unexpected len(Spec.Ports) for new service: %v", result) @@ -1043,7 +1043,7 @@ var _ = SIGDescribe("Services", func() { service := t.BuildServiceSpec() service.Spec.Type = v1.ServiceTypeNodePort result, err := t.CreateService(service) - Expect(err).NotTo(HaveOccurred()) + Expect(err).NotTo(HaveOccurred(), "failed to create service: %s in namespace: %s", serviceName1, ns) if result.Spec.Type != v1.ServiceTypeNodePort { framework.Failf("got unexpected Spec.Type for new service: %v", result) @@ -1070,11 +1070,11 @@ var _ = SIGDescribe("Services", func() { By("deleting service " + serviceName1 + " to release NodePort") err = t.DeleteService(serviceName1) - Expect(err).NotTo(HaveOccurred()) + Expect(err).NotTo(HaveOccurred(), "failed to delete service: %s in namespace: %s", serviceName1, ns) By("creating service " + serviceName2 + " with no-longer-conflicting NodePort") _, err = t.CreateService(service2) - Expect(err).NotTo(HaveOccurred()) + Expect(err).NotTo(HaveOccurred(), "failed to create service: %s in namespace: %s", serviceName1, ns) }) It("should check NodePort out-of-range", func() { @@ -1096,7 +1096,7 @@ var _ = SIGDescribe("Services", func() { By("creating service " + serviceName + " with type NodePort in namespace " + ns) service, err := t.CreateService(service) - Expect(err).NotTo(HaveOccurred()) + Expect(err).NotTo(HaveOccurred(), "failed to create service: %s in namespace: %s", serviceName, ns) if service.Spec.Type != v1.ServiceTypeNodePort { framework.Failf("got unexpected Spec.Type for new service: %v", service) @@ -1132,7 +1132,7 @@ var _ = SIGDescribe("Services", func() { By("deleting original service " + serviceName) err = t.DeleteService(serviceName) - Expect(err).NotTo(HaveOccurred()) + Expect(err).NotTo(HaveOccurred(), "failed to delete service: %s in namespace: %s", serviceName, ns) By(fmt.Sprintf("creating service "+serviceName+" with out-of-range NodePort %d", outOfRangeNodePort)) service = t.BuildServiceSpec() @@ -1164,7 +1164,7 @@ var _ = SIGDescribe("Services", func() { By("creating service " + serviceName + " with type NodePort in namespace " + ns) service, err := t.CreateService(service) - Expect(err).NotTo(HaveOccurred()) + Expect(err).NotTo(HaveOccurred(), "failed to create service: %s in namespace: %s", serviceName, ns) if service.Spec.Type != v1.ServiceTypeNodePort { framework.Failf("got unexpected Spec.Type for new service: %v", service) @@ -1183,7 +1183,7 @@ var _ = SIGDescribe("Services", func() { By("deleting original service " + serviceName) err = t.DeleteService(serviceName) - Expect(err).NotTo(HaveOccurred()) + Expect(err).NotTo(HaveOccurred(), "failed to delete service: %s in namespace: %s", serviceName, ns) hostExec := framework.LaunchHostExecPod(f.ClientSet, f.Namespace.Name, "hostexec") cmd := fmt.Sprintf(`! ss -ant46 'sport = :%d' | tail -n +2 | grep LISTEN`, nodePort) @@ -1205,7 +1205,7 @@ var _ = SIGDescribe("Services", func() { service.Spec.Type = v1.ServiceTypeNodePort service.Spec.Ports[0].NodePort = nodePort service, err = t.CreateService(service) - Expect(err).NotTo(HaveOccurred()) + Expect(err).NotTo(HaveOccurred(), "failed to create service: %s in namespace: %s", serviceName, ns) }) It("should create endpoints for unready pods", func() { @@ -1377,9 +1377,9 @@ var _ = SIGDescribe("Services", func() { dropPodName := framework.CreateExecPodOrFail(cs, namespace, "execpod-drop", nil) acceptPod, err := cs.CoreV1().Pods(namespace).Get(acceptPodName, metav1.GetOptions{}) - Expect(err).NotTo(HaveOccurred()) + Expect(err).NotTo(HaveOccurred(), "failed to fetch pod: %s in namespace: %s", acceptPodName, namespace) dropPod, err := cs.CoreV1().Pods(namespace).Get(dropPodName, metav1.GetOptions{}) - Expect(err).NotTo(HaveOccurred()) + Expect(err).NotTo(HaveOccurred(), "failed to fetch pod: %s in namespace: %s", dropPodName, namespace) By("creating a pod to be part of the service " + serviceName) // This container is an nginx container listening on port 80 @@ -1707,17 +1707,17 @@ var _ = SIGDescribe("Services", func() { svcDisabled := getServeHostnameService("service-disabled") svcDisabled.ObjectMeta.Labels = serviceProxyNameLabels _, svcDisabledIP, err := framework.StartServeHostnameService(cs, internalClientset, svcDisabled, ns, numPods) - Expect(err).NotTo(HaveOccurred()) + Expect(err).NotTo(HaveOccurred(), "failed to create replication controller with service: %s in the namespace: %s", svcDisabledIP, ns) By("creating service in namespace " + ns) svcToggled := getServeHostnameService("service") podToggledNames, svcToggledIP, err := framework.StartServeHostnameService(cs, internalClientset, svcToggled, ns, numPods) - Expect(err).NotTo(HaveOccurred()) + Expect(err).NotTo(HaveOccurred(), "failed to create replication controller with service: %s in the namespace: %s", svcToggledIP, ns) jig := framework.NewServiceTestJig(cs, svcToggled.ObjectMeta.Name) hosts, err := framework.NodeSSHHosts(cs) - Expect(err).NotTo(HaveOccurred()) + Expect(err).NotTo(HaveOccurred(), "failed to find external/internal IPs for every node") if len(hosts) == 0 { framework.Failf("No ssh-able nodes") } @@ -1932,7 +1932,7 @@ var _ = SIGDescribe("ESIPP [Slow] [DisabledForLargeClusters]", func() { }) defer func() { err := cs.CoreV1().Pods(namespace).Delete(execPodName, nil) - Expect(err).NotTo(HaveOccurred()) + Expect(err).NotTo(HaveOccurred(), "failed to delete pod: %s", execPodName) }() execPod, err := f.ClientSet.CoreV1().Pods(namespace).Get(execPodName, metav1.GetOptions{}) framework.ExpectNoError(err) @@ -2067,7 +2067,7 @@ func execSourceipTest(f *framework.Framework, c clientset.Interface, ns, nodeNam defer func() { framework.Logf("Cleaning up the exec pod") err := c.CoreV1().Pods(ns).Delete(execPodName, nil) - Expect(err).NotTo(HaveOccurred()) + Expect(err).NotTo(HaveOccurred(), "failed to delete pod: %s", execPodName) }() execPod, err := f.ClientSet.CoreV1().Pods(ns).Get(execPodName, metav1.GetOptions{}) framework.ExpectNoError(err) @@ -2115,13 +2115,13 @@ func execAffinityTestForNonLBService(f *framework.Framework, cs clientset.Interf serviceType := svc.Spec.Type svc.Spec.SessionAffinity = v1.ServiceAffinityClientIP _, _, err := framework.StartServeHostnameService(cs, f.InternalClientset, svc, ns, numPods) - Expect(err).NotTo(HaveOccurred()) + Expect(err).NotTo(HaveOccurred(), "failed to create replication controller with service in the namespace: %s", ns) defer func() { framework.StopServeHostnameService(cs, ns, serviceName) }() jig := framework.NewServiceTestJig(cs, serviceName) svc, err = jig.Client.CoreV1().Services(ns).Get(serviceName, metav1.GetOptions{}) - Expect(err).NotTo(HaveOccurred()) + Expect(err).NotTo(HaveOccurred(), "failed to fetch service: %s in namespace: %s", serviceName, ns) var svcIp string if serviceType == v1.ServiceTypeNodePort { nodes := framework.GetReadySchedulableNodesOrDie(cs) @@ -2137,10 +2137,10 @@ func execAffinityTestForNonLBService(f *framework.Framework, cs clientset.Interf defer func() { framework.Logf("Cleaning up the exec pod") err := cs.CoreV1().Pods(ns).Delete(execPodName, nil) - Expect(err).NotTo(HaveOccurred()) + Expect(err).NotTo(HaveOccurred(), "failed to delete pod: %s in namespace: %s", execPodName, ns) }() execPod, err := cs.CoreV1().Pods(ns).Get(execPodName, metav1.GetOptions{}) - Expect(err).NotTo(HaveOccurred()) + Expect(err).NotTo(HaveOccurred(), "failed to fetch pod: %s in namespace: %s", execPodName, ns) if !isTransitionTest { Expect(framework.CheckAffinity(jig, execPod, svcIp, servicePort, true, false)).To(BeTrue()) @@ -2166,7 +2166,7 @@ func execAffinityTestForLBService(f *framework.Framework, cs clientset.Interface By("creating service in namespace " + ns) svc.Spec.SessionAffinity = v1.ServiceAffinityClientIP _, _, err := framework.StartServeHostnameService(cs, f.InternalClientset, svc, ns, numPods) - Expect(err).NotTo(HaveOccurred()) + Expect(err).NotTo(HaveOccurred(), "failed to create replication controller with service in the namespace: %s", ns) jig := framework.NewServiceTestJig(cs, serviceName) By("waiting for loadbalancer for service " + ns + "/" + serviceName) svc = jig.WaitForLoadBalancerOrFail(ns, serviceName, framework.LoadBalancerCreateTimeoutDefault)