From f7a28c3904a14e9163bdef800a777420fad0396a Mon Sep 17 00:00:00 2001 From: Antonio Ojea Date: Tue, 22 Sep 2020 21:53:10 +0200 Subject: [PATCH 1/3] Revert "Merge pull request #93837 from jayunit100/DialFromContainerB" This reverts commit 61490bba46ee2ad39690c682db0bee425b21798e, reversing changes made to 9ecab1b4b2a76aa998dea2bdfa9eb9d892103f42. Some methods from the networking e2e tools are dialing from a containter to another container, and failing the test if there was no connectivity. This PR modified the methods to return an error instead of failing the test. However, these methods were used by other tests in the framework, and they are not checking if the method returns an error, expecting that the method fail the test. With this change, any connectivity problem will go unnoticed on the tests that are not asserting the error, so we need to revert to previous state. --- test/e2e/common/networking.go | 48 ++++------------------------- test/e2e/framework/network/utils.go | 25 ++++++--------- 2 files changed, 16 insertions(+), 57 deletions(-) diff --git a/test/e2e/common/networking.go b/test/e2e/common/networking.go index f08520f9e9d..97010b2d734 100644 --- a/test/e2e/common/networking.go +++ b/test/e2e/common/networking.go @@ -18,7 +18,6 @@ package common import ( "github.com/onsi/ginkgo" - v1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/util/sets" "k8s.io/kubernetes/test/e2e/framework" e2enetwork "k8s.io/kubernetes/test/e2e/framework/network" @@ -29,45 +28,6 @@ var _ = ginkgo.Describe("[sig-network] Networking", func() { ginkgo.Describe("Granular Checks: Pods", func() { - checkNodeConnectivity := func(config *e2enetwork.NetworkingTestConfig, protocol string, port int) { - // breadth first poll to quickly estimate failure. - failedPodsByHost := map[string][]*v1.Pod{} - // First time, we'll quickly try all pods, breadth first. - for _, endpointPod := range config.EndpointPods { - framework.Logf("Breadth first check of %v on host %v...", endpointPod.Status.PodIP, endpointPod.Status.HostIP) - if err := config.DialFromTestContainer(protocol, endpointPod.Status.PodIP, port, 1, 0, sets.NewString(endpointPod.Name)); err != nil { - if _, ok := failedPodsByHost[endpointPod.Status.HostIP]; !ok { - failedPodsByHost[endpointPod.Status.HostIP] = []*v1.Pod{} - } - failedPodsByHost[endpointPod.Status.HostIP] = append(failedPodsByHost[endpointPod.Status.HostIP], endpointPod) - framework.Logf("...failed...will try again in next pass") - } - } - errors := []error{} - // Second time, we pass through pods more carefully... - framework.Logf("Going to retry %v out of %v pods....", len(failedPodsByHost), len(config.EndpointPods)) - for host, failedPods := range failedPodsByHost { - framework.Logf("Doublechecking %v pods in host %v which werent seen the first time.", len(failedPods), host) - for _, endpointPod := range failedPods { - framework.Logf("Now attempting to probe pod [[[ %v ]]]", endpointPod.Status.PodIP) - if err := config.DialFromTestContainer(protocol, endpointPod.Status.PodIP, port, config.MaxTries, 0, sets.NewString(endpointPod.Name)); err != nil { - errors = append(errors, err) - } else { - framework.Logf("Was able to reach %v on %v ", endpointPod.Status.PodIP, endpointPod.Status.HostIP) - } - framework.Logf("... Done probing pod [[[ %v ]]]", endpointPod.Status.PodIP) - } - framework.Logf("succeeded at polling %v out of %v connections", len(config.EndpointPods)-len(errors), len(config.EndpointPods)) - } - if len(errors) > 0 { - framework.Logf("pod polling failure summary:") - for _, e := range errors { - framework.Logf("Collected error: %v", e) - } - framework.Failf("failed, %v out of %v connections failed", len(errors), len(config.EndpointPods)) - } - } - // Try to hit all endpoints through a test container, retry 5 times, // expect exactly one unique hostname. Each of these endpoints reports // its own hostname. @@ -79,7 +39,9 @@ var _ = ginkgo.Describe("[sig-network] Networking", func() { */ framework.ConformanceIt("should function for intra-pod communication: http [NodeConformance]", func() { config := e2enetwork.NewCoreNetworkingTestConfig(f, false) - checkNodeConnectivity(config, "http", e2enetwork.EndpointHTTPPort) + for _, endpointPod := range config.EndpointPods { + config.DialFromTestContainer("http", endpointPod.Status.PodIP, e2enetwork.EndpointHTTPPort, config.MaxTries, 0, sets.NewString(endpointPod.Name)) + } }) /* @@ -90,7 +52,9 @@ var _ = ginkgo.Describe("[sig-network] Networking", func() { */ framework.ConformanceIt("should function for intra-pod communication: udp [NodeConformance]", func() { config := e2enetwork.NewCoreNetworkingTestConfig(f, false) - checkNodeConnectivity(config, "udp", e2enetwork.EndpointUDPPort) + for _, endpointPod := range config.EndpointPods { + config.DialFromTestContainer("udp", endpointPod.Status.PodIP, e2enetwork.EndpointUDPPort, config.MaxTries, 0, sets.NewString(endpointPod.Name)) + } }) /* diff --git a/test/e2e/framework/network/utils.go b/test/e2e/framework/network/utils.go index 2540d54f777..a3d00304940 100644 --- a/test/e2e/framework/network/utils.go +++ b/test/e2e/framework/network/utils.go @@ -167,17 +167,17 @@ type NetexecDialResponse struct { } // DialFromEndpointContainer executes a curl via kubectl exec in an endpoint container. -func (config *NetworkingTestConfig) DialFromEndpointContainer(protocol, targetIP string, targetPort, maxTries, minTries int, expectedEps sets.String) error { - return config.DialFromContainer(protocol, echoHostname, config.EndpointPods[0].Status.PodIP, targetIP, EndpointHTTPPort, targetPort, maxTries, minTries, expectedEps) +func (config *NetworkingTestConfig) DialFromEndpointContainer(protocol, targetIP string, targetPort, maxTries, minTries int, expectedEps sets.String) { + config.DialFromContainer(protocol, echoHostname, config.EndpointPods[0].Status.PodIP, targetIP, EndpointHTTPPort, targetPort, maxTries, minTries, expectedEps) } // DialFromTestContainer executes a curl via kubectl exec in a test container. -func (config *NetworkingTestConfig) DialFromTestContainer(protocol, targetIP string, targetPort, maxTries, minTries int, expectedEps sets.String) error { - return config.DialFromContainer(protocol, echoHostname, config.TestContainerPod.Status.PodIP, targetIP, testContainerHTTPPort, targetPort, maxTries, minTries, expectedEps) +func (config *NetworkingTestConfig) DialFromTestContainer(protocol, targetIP string, targetPort, maxTries, minTries int, expectedEps sets.String) { + config.DialFromContainer(protocol, echoHostname, config.TestContainerPod.Status.PodIP, targetIP, testContainerHTTPPort, targetPort, maxTries, minTries, expectedEps) } // DialEchoFromTestContainer executes a curl via kubectl exec in a test container. The response is expected to match the echoMessage. -func (config *NetworkingTestConfig) DialEchoFromTestContainer(protocol, targetIP string, targetPort, maxTries, minTries int, echoMessage string) error { +func (config *NetworkingTestConfig) DialEchoFromTestContainer(protocol, targetIP string, targetPort, maxTries, minTries int, echoMessage string) { expectedResponse := sets.NewString() expectedResponse.Insert(echoMessage) var dialCommand string @@ -191,7 +191,7 @@ func (config *NetworkingTestConfig) DialEchoFromTestContainer(protocol, targetIP } else { dialCommand = fmt.Sprintf("echo%%20%s", echoMessage) } - return config.DialFromContainer(protocol, dialCommand, config.TestContainerPod.Status.PodIP, targetIP, testContainerHTTPPort, targetPort, maxTries, minTries, expectedResponse) + config.DialFromContainer(protocol, dialCommand, config.TestContainerPod.Status.PodIP, targetIP, testContainerHTTPPort, targetPort, maxTries, minTries, expectedResponse) } // diagnoseMissingEndpoints prints debug information about the endpoints that @@ -248,8 +248,7 @@ func makeCURLDialCommand(ipPort, dialCmd, protocol, targetIP string, targetPort // maxTries == minTries will confirm that we see the expected endpoints and no // more for maxTries. Use this if you want to eg: fail a readiness check on a // pod and confirm it doesn't show up as an endpoint. -// Returns nil if no error, or error message if failed after trying maxTries. -func (config *NetworkingTestConfig) DialFromContainer(protocol, dialCommand, containerIP, targetIP string, containerHTTPPort, targetPort, maxTries, minTries int, expectedResponses sets.String) error { +func (config *NetworkingTestConfig) DialFromContainer(protocol, dialCommand, containerIP, targetIP string, containerHTTPPort, targetPort, maxTries, minTries int, expectedResponses sets.String) { ipPort := net.JoinHostPort(containerIP, strconv.Itoa(containerHTTPPort)) cmd := makeCURLDialCommand(ipPort, dialCommand, protocol, targetIP, targetPort) @@ -274,19 +273,16 @@ func (config *NetworkingTestConfig) DialFromContainer(protocol, dialCommand, con // Check against i+1 so we exit if minTries == maxTries. if (responses.Equal(expectedResponses) || responses.Len() == 0 && expectedResponses.Len() == 0) && i+1 >= minTries { - framework.Logf("reached %v after %v/%v tries", targetIP, i, maxTries) - return nil + return } // TODO: get rid of this delay #36281 time.Sleep(hitEndpointRetryDelay) } + if dialCommand == echoHostname { config.diagnoseMissingEndpoints(responses) } - returnMsg := fmt.Errorf("did not find expected responses... \nTries %d\nCommand %v\nretrieved %v\nexpected %v", maxTries, cmd, responses, expectedResponses) - framework.Logf("encountered error during dial (%v)", returnMsg) - return returnMsg - + framework.Failf("Failed to find expected responses:\nTries %d\nCommand %v\nretrieved %v\nexpected %v\n", maxTries, cmd, responses, expectedResponses) } // GetEndpointsFromTestContainer executes a curl via kubectl exec in a test container. @@ -681,7 +677,6 @@ func (config *NetworkingTestConfig) setupCore(selector map[string]string) { epCount := len(config.EndpointPods) config.MaxTries = epCount*epCount + testTries - framework.Logf("Setting MaxTries for pod polling to %v for networking test based on endpoint count %v", config.MaxTries, epCount) } // setup includes setupCore and also sets up services From 64548b3cfa70199e376a112c45ac7d118495f816 Mon Sep 17 00:00:00 2001 From: jay vyas Date: Wed, 23 Sep 2020 09:09:38 -0500 Subject: [PATCH 2/3] Adding back in the breadth-first-polling logic. "Revert "Merge pull request #93837 from jayunit100/DialFromContainerB"" This reverts commit f7a28c3904a14e9163bdef800a777420fad0396a. --- test/e2e/common/networking.go | 48 +++++++++++++++++++++++++---- test/e2e/framework/network/utils.go | 25 +++++++++------ 2 files changed, 57 insertions(+), 16 deletions(-) diff --git a/test/e2e/common/networking.go b/test/e2e/common/networking.go index 97010b2d734..f08520f9e9d 100644 --- a/test/e2e/common/networking.go +++ b/test/e2e/common/networking.go @@ -18,6 +18,7 @@ package common import ( "github.com/onsi/ginkgo" + v1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/util/sets" "k8s.io/kubernetes/test/e2e/framework" e2enetwork "k8s.io/kubernetes/test/e2e/framework/network" @@ -28,6 +29,45 @@ var _ = ginkgo.Describe("[sig-network] Networking", func() { ginkgo.Describe("Granular Checks: Pods", func() { + checkNodeConnectivity := func(config *e2enetwork.NetworkingTestConfig, protocol string, port int) { + // breadth first poll to quickly estimate failure. + failedPodsByHost := map[string][]*v1.Pod{} + // First time, we'll quickly try all pods, breadth first. + for _, endpointPod := range config.EndpointPods { + framework.Logf("Breadth first check of %v on host %v...", endpointPod.Status.PodIP, endpointPod.Status.HostIP) + if err := config.DialFromTestContainer(protocol, endpointPod.Status.PodIP, port, 1, 0, sets.NewString(endpointPod.Name)); err != nil { + if _, ok := failedPodsByHost[endpointPod.Status.HostIP]; !ok { + failedPodsByHost[endpointPod.Status.HostIP] = []*v1.Pod{} + } + failedPodsByHost[endpointPod.Status.HostIP] = append(failedPodsByHost[endpointPod.Status.HostIP], endpointPod) + framework.Logf("...failed...will try again in next pass") + } + } + errors := []error{} + // Second time, we pass through pods more carefully... + framework.Logf("Going to retry %v out of %v pods....", len(failedPodsByHost), len(config.EndpointPods)) + for host, failedPods := range failedPodsByHost { + framework.Logf("Doublechecking %v pods in host %v which werent seen the first time.", len(failedPods), host) + for _, endpointPod := range failedPods { + framework.Logf("Now attempting to probe pod [[[ %v ]]]", endpointPod.Status.PodIP) + if err := config.DialFromTestContainer(protocol, endpointPod.Status.PodIP, port, config.MaxTries, 0, sets.NewString(endpointPod.Name)); err != nil { + errors = append(errors, err) + } else { + framework.Logf("Was able to reach %v on %v ", endpointPod.Status.PodIP, endpointPod.Status.HostIP) + } + framework.Logf("... Done probing pod [[[ %v ]]]", endpointPod.Status.PodIP) + } + framework.Logf("succeeded at polling %v out of %v connections", len(config.EndpointPods)-len(errors), len(config.EndpointPods)) + } + if len(errors) > 0 { + framework.Logf("pod polling failure summary:") + for _, e := range errors { + framework.Logf("Collected error: %v", e) + } + framework.Failf("failed, %v out of %v connections failed", len(errors), len(config.EndpointPods)) + } + } + // Try to hit all endpoints through a test container, retry 5 times, // expect exactly one unique hostname. Each of these endpoints reports // its own hostname. @@ -39,9 +79,7 @@ var _ = ginkgo.Describe("[sig-network] Networking", func() { */ framework.ConformanceIt("should function for intra-pod communication: http [NodeConformance]", func() { config := e2enetwork.NewCoreNetworkingTestConfig(f, false) - for _, endpointPod := range config.EndpointPods { - config.DialFromTestContainer("http", endpointPod.Status.PodIP, e2enetwork.EndpointHTTPPort, config.MaxTries, 0, sets.NewString(endpointPod.Name)) - } + checkNodeConnectivity(config, "http", e2enetwork.EndpointHTTPPort) }) /* @@ -52,9 +90,7 @@ var _ = ginkgo.Describe("[sig-network] Networking", func() { */ framework.ConformanceIt("should function for intra-pod communication: udp [NodeConformance]", func() { config := e2enetwork.NewCoreNetworkingTestConfig(f, false) - for _, endpointPod := range config.EndpointPods { - config.DialFromTestContainer("udp", endpointPod.Status.PodIP, e2enetwork.EndpointUDPPort, config.MaxTries, 0, sets.NewString(endpointPod.Name)) - } + checkNodeConnectivity(config, "udp", e2enetwork.EndpointUDPPort) }) /* diff --git a/test/e2e/framework/network/utils.go b/test/e2e/framework/network/utils.go index a3d00304940..2540d54f777 100644 --- a/test/e2e/framework/network/utils.go +++ b/test/e2e/framework/network/utils.go @@ -167,17 +167,17 @@ type NetexecDialResponse struct { } // DialFromEndpointContainer executes a curl via kubectl exec in an endpoint container. -func (config *NetworkingTestConfig) DialFromEndpointContainer(protocol, targetIP string, targetPort, maxTries, minTries int, expectedEps sets.String) { - config.DialFromContainer(protocol, echoHostname, config.EndpointPods[0].Status.PodIP, targetIP, EndpointHTTPPort, targetPort, maxTries, minTries, expectedEps) +func (config *NetworkingTestConfig) DialFromEndpointContainer(protocol, targetIP string, targetPort, maxTries, minTries int, expectedEps sets.String) error { + return config.DialFromContainer(protocol, echoHostname, config.EndpointPods[0].Status.PodIP, targetIP, EndpointHTTPPort, targetPort, maxTries, minTries, expectedEps) } // DialFromTestContainer executes a curl via kubectl exec in a test container. -func (config *NetworkingTestConfig) DialFromTestContainer(protocol, targetIP string, targetPort, maxTries, minTries int, expectedEps sets.String) { - config.DialFromContainer(protocol, echoHostname, config.TestContainerPod.Status.PodIP, targetIP, testContainerHTTPPort, targetPort, maxTries, minTries, expectedEps) +func (config *NetworkingTestConfig) DialFromTestContainer(protocol, targetIP string, targetPort, maxTries, minTries int, expectedEps sets.String) error { + return config.DialFromContainer(protocol, echoHostname, config.TestContainerPod.Status.PodIP, targetIP, testContainerHTTPPort, targetPort, maxTries, minTries, expectedEps) } // DialEchoFromTestContainer executes a curl via kubectl exec in a test container. The response is expected to match the echoMessage. -func (config *NetworkingTestConfig) DialEchoFromTestContainer(protocol, targetIP string, targetPort, maxTries, minTries int, echoMessage string) { +func (config *NetworkingTestConfig) DialEchoFromTestContainer(protocol, targetIP string, targetPort, maxTries, minTries int, echoMessage string) error { expectedResponse := sets.NewString() expectedResponse.Insert(echoMessage) var dialCommand string @@ -191,7 +191,7 @@ func (config *NetworkingTestConfig) DialEchoFromTestContainer(protocol, targetIP } else { dialCommand = fmt.Sprintf("echo%%20%s", echoMessage) } - config.DialFromContainer(protocol, dialCommand, config.TestContainerPod.Status.PodIP, targetIP, testContainerHTTPPort, targetPort, maxTries, minTries, expectedResponse) + return config.DialFromContainer(protocol, dialCommand, config.TestContainerPod.Status.PodIP, targetIP, testContainerHTTPPort, targetPort, maxTries, minTries, expectedResponse) } // diagnoseMissingEndpoints prints debug information about the endpoints that @@ -248,7 +248,8 @@ func makeCURLDialCommand(ipPort, dialCmd, protocol, targetIP string, targetPort // maxTries == minTries will confirm that we see the expected endpoints and no // more for maxTries. Use this if you want to eg: fail a readiness check on a // pod and confirm it doesn't show up as an endpoint. -func (config *NetworkingTestConfig) DialFromContainer(protocol, dialCommand, containerIP, targetIP string, containerHTTPPort, targetPort, maxTries, minTries int, expectedResponses sets.String) { +// Returns nil if no error, or error message if failed after trying maxTries. +func (config *NetworkingTestConfig) DialFromContainer(protocol, dialCommand, containerIP, targetIP string, containerHTTPPort, targetPort, maxTries, minTries int, expectedResponses sets.String) error { ipPort := net.JoinHostPort(containerIP, strconv.Itoa(containerHTTPPort)) cmd := makeCURLDialCommand(ipPort, dialCommand, protocol, targetIP, targetPort) @@ -273,16 +274,19 @@ func (config *NetworkingTestConfig) DialFromContainer(protocol, dialCommand, con // Check against i+1 so we exit if minTries == maxTries. if (responses.Equal(expectedResponses) || responses.Len() == 0 && expectedResponses.Len() == 0) && i+1 >= minTries { - return + framework.Logf("reached %v after %v/%v tries", targetIP, i, maxTries) + return nil } // TODO: get rid of this delay #36281 time.Sleep(hitEndpointRetryDelay) } - if dialCommand == echoHostname { config.diagnoseMissingEndpoints(responses) } - framework.Failf("Failed to find expected responses:\nTries %d\nCommand %v\nretrieved %v\nexpected %v\n", maxTries, cmd, responses, expectedResponses) + returnMsg := fmt.Errorf("did not find expected responses... \nTries %d\nCommand %v\nretrieved %v\nexpected %v", maxTries, cmd, responses, expectedResponses) + framework.Logf("encountered error during dial (%v)", returnMsg) + return returnMsg + } // GetEndpointsFromTestContainer executes a curl via kubectl exec in a test container. @@ -677,6 +681,7 @@ func (config *NetworkingTestConfig) setupCore(selector map[string]string) { epCount := len(config.EndpointPods) config.MaxTries = epCount*epCount + testTries + framework.Logf("Setting MaxTries for pod polling to %v for networking test based on endpoint count %v", config.MaxTries, epCount) } // setup includes setupCore and also sets up services From 60c8a36a7bb72685ef9d01adcc785d1426691004 Mon Sep 17 00:00:00 2001 From: jay vyas Date: Wed, 23 Sep 2020 09:32:51 -0500 Subject: [PATCH 3/3] Add failure logic to tests that rely on side-effect-free dial functions. --- test/e2e/framework/network/utils.go | 6 +- test/e2e/network/networking.go | 125 +++++++++++++++++++++------- 2 files changed, 96 insertions(+), 35 deletions(-) diff --git a/test/e2e/framework/network/utils.go b/test/e2e/framework/network/utils.go index 2540d54f777..aec7386b2fa 100644 --- a/test/e2e/framework/network/utils.go +++ b/test/e2e/framework/network/utils.go @@ -166,17 +166,17 @@ type NetexecDialResponse struct { Errors []string `json:"errors"` } -// DialFromEndpointContainer executes a curl via kubectl exec in an endpoint container. +// DialFromEndpointContainer executes a curl via kubectl exec in an endpoint container. Returns an error to be handled by the caller. func (config *NetworkingTestConfig) DialFromEndpointContainer(protocol, targetIP string, targetPort, maxTries, minTries int, expectedEps sets.String) error { return config.DialFromContainer(protocol, echoHostname, config.EndpointPods[0].Status.PodIP, targetIP, EndpointHTTPPort, targetPort, maxTries, minTries, expectedEps) } -// DialFromTestContainer executes a curl via kubectl exec in a test container. +// DialFromTestContainer executes a curl via kubectl exec in a test container. Returns an error to be handled by the caller. func (config *NetworkingTestConfig) DialFromTestContainer(protocol, targetIP string, targetPort, maxTries, minTries int, expectedEps sets.String) error { return config.DialFromContainer(protocol, echoHostname, config.TestContainerPod.Status.PodIP, targetIP, testContainerHTTPPort, targetPort, maxTries, minTries, expectedEps) } -// DialEchoFromTestContainer executes a curl via kubectl exec in a test container. The response is expected to match the echoMessage. +// DialEchoFromTestContainer executes a curl via kubectl exec in a test container. The response is expected to match the echoMessage, Returns an error to be handled by the caller. func (config *NetworkingTestConfig) DialEchoFromTestContainer(protocol, targetIP string, targetPort, maxTries, minTries int, echoMessage string) error { expectedResponse := sets.NewString() expectedResponse.Insert(echoMessage) diff --git a/test/e2e/network/networking.go b/test/e2e/network/networking.go index 459ee1bad25..f1a2b7ebd29 100644 --- a/test/e2e/network/networking.go +++ b/test/e2e/network/networking.go @@ -164,19 +164,31 @@ var _ = SIGDescribe("Networking", func() { ginkgo.It("should function for pod-Service: http", func() { config := e2enetwork.NewNetworkingTestConfig(f, false, false) ginkgo.By(fmt.Sprintf("dialing(http) %v --> %v:%v (config.clusterIP)", config.TestContainerPod.Name, config.ClusterIP, e2enetwork.ClusterHTTPPort)) - config.DialFromTestContainer("http", config.ClusterIP, e2enetwork.ClusterHTTPPort, config.MaxTries, 0, config.EndpointHostnames()) - + err := config.DialFromTestContainer("http", config.ClusterIP, e2enetwork.ClusterHTTPPort, config.MaxTries, 0, config.EndpointHostnames()) + if err != nil { + framework.Failf("failed dialing endpoint, %v", err) + } ginkgo.By(fmt.Sprintf("dialing(http) %v --> %v:%v (nodeIP)", config.TestContainerPod.Name, config.NodeIP, config.NodeHTTPPort)) - config.DialFromTestContainer("http", config.NodeIP, config.NodeHTTPPort, config.MaxTries, 0, config.EndpointHostnames()) + + err = config.DialFromTestContainer("http", config.NodeIP, config.NodeHTTPPort, config.MaxTries, 0, config.EndpointHostnames()) + if err != nil { + framework.Failf("failed dialing endpoint, %v", err) + } }) ginkgo.It("should function for pod-Service: udp", func() { config := e2enetwork.NewNetworkingTestConfig(f, false, false) ginkgo.By(fmt.Sprintf("dialing(udp) %v --> %v:%v (config.clusterIP)", config.TestContainerPod.Name, config.ClusterIP, e2enetwork.ClusterUDPPort)) - config.DialFromTestContainer("udp", config.ClusterIP, e2enetwork.ClusterUDPPort, config.MaxTries, 0, config.EndpointHostnames()) + err := config.DialFromTestContainer("udp", config.ClusterIP, e2enetwork.ClusterUDPPort, config.MaxTries, 0, config.EndpointHostnames()) + if err != nil { + framework.Failf("failed dialing endpoint, %v", err) + } ginkgo.By(fmt.Sprintf("dialing(udp) %v --> %v:%v (nodeIP)", config.TestContainerPod.Name, config.NodeIP, config.NodeUDPPort)) - config.DialFromTestContainer("udp", config.NodeIP, config.NodeUDPPort, config.MaxTries, 0, config.EndpointHostnames()) + err = config.DialFromTestContainer("udp", config.NodeIP, config.NodeUDPPort, config.MaxTries, 0, config.EndpointHostnames()) + if err != nil { + framework.Failf("failed dialing endpoint, %v", err) + } }) // Once basic tests checking for the sctp module not to be loaded are implemented, this @@ -184,17 +196,21 @@ var _ = SIGDescribe("Networking", func() { ginkgo.It("should function for pod-Service: sctp [Feature:SCTPConnectivity][Disruptive]", func() { config := e2enetwork.NewNetworkingTestConfig(f, false, true) ginkgo.By(fmt.Sprintf("dialing(sctp) %v --> %v:%v (config.clusterIP)", config.TestContainerPod.Name, config.ClusterIP, e2enetwork.ClusterSCTPPort)) - config.DialFromTestContainer("sctp", config.ClusterIP, e2enetwork.ClusterSCTPPort, config.MaxTries, 0, config.EndpointHostnames()) - + err := config.DialFromTestContainer("sctp", config.ClusterIP, e2enetwork.ClusterSCTPPort, config.MaxTries, 0, config.EndpointHostnames()) + if err != nil { + framework.Failf("failed dialing endpoint, %v", err) + } ginkgo.By(fmt.Sprintf("dialing(sctp) %v --> %v:%v (nodeIP)", config.TestContainerPod.Name, config.NodeIP, config.NodeSCTPPort)) - config.DialFromTestContainer("sctp", config.NodeIP, config.NodeSCTPPort, config.MaxTries, 0, config.EndpointHostnames()) + err = config.DialFromTestContainer("sctp", config.NodeIP, config.NodeSCTPPort, config.MaxTries, 0, config.EndpointHostnames()) + if err != nil { + framework.Failf("failed dialing endpoint, %v", err) + } }) ginkgo.It("should function for node-Service: http", func() { config := e2enetwork.NewNetworkingTestConfig(f, true, false) ginkgo.By(fmt.Sprintf("dialing(http) %v (node) --> %v:%v (config.clusterIP)", config.NodeIP, config.ClusterIP, e2enetwork.ClusterHTTPPort)) config.DialFromNode("http", config.ClusterIP, e2enetwork.ClusterHTTPPort, config.MaxTries, 0, config.EndpointHostnames()) - ginkgo.By(fmt.Sprintf("dialing(http) %v (node) --> %v:%v (nodeIP)", config.NodeIP, config.NodeIP, config.NodeHTTPPort)) config.DialFromNode("http", config.NodeIP, config.NodeHTTPPort, config.MaxTries, 0, config.EndpointHostnames()) }) @@ -211,19 +227,30 @@ var _ = SIGDescribe("Networking", func() { ginkgo.It("should function for endpoint-Service: http", func() { config := e2enetwork.NewNetworkingTestConfig(f, false, false) ginkgo.By(fmt.Sprintf("dialing(http) %v (endpoint) --> %v:%v (config.clusterIP)", config.EndpointPods[0].Name, config.ClusterIP, e2enetwork.ClusterHTTPPort)) - config.DialFromEndpointContainer("http", config.ClusterIP, e2enetwork.ClusterHTTPPort, config.MaxTries, 0, config.EndpointHostnames()) - + err := config.DialFromEndpointContainer("http", config.ClusterIP, e2enetwork.ClusterHTTPPort, config.MaxTries, 0, config.EndpointHostnames()) + if err != nil { + framework.Failf("failed dialing endpoint, %v", err) + } ginkgo.By(fmt.Sprintf("dialing(http) %v (endpoint) --> %v:%v (nodeIP)", config.EndpointPods[0].Name, config.NodeIP, config.NodeHTTPPort)) - config.DialFromEndpointContainer("http", config.NodeIP, config.NodeHTTPPort, config.MaxTries, 0, config.EndpointHostnames()) + err = config.DialFromEndpointContainer("http", config.NodeIP, config.NodeHTTPPort, config.MaxTries, 0, config.EndpointHostnames()) + if err != nil { + framework.Failf("failed dialing endpoint, %v", err) + } }) ginkgo.It("should function for endpoint-Service: udp", func() { config := e2enetwork.NewNetworkingTestConfig(f, false, false) ginkgo.By(fmt.Sprintf("dialing(udp) %v (endpoint) --> %v:%v (config.clusterIP)", config.EndpointPods[0].Name, config.ClusterIP, e2enetwork.ClusterUDPPort)) - config.DialFromEndpointContainer("udp", config.ClusterIP, e2enetwork.ClusterUDPPort, config.MaxTries, 0, config.EndpointHostnames()) + err := config.DialFromEndpointContainer("udp", config.ClusterIP, e2enetwork.ClusterUDPPort, config.MaxTries, 0, config.EndpointHostnames()) + if err != nil { + framework.Failf("failed dialing endpoint, %v", err) + } ginkgo.By(fmt.Sprintf("dialing(udp) %v (endpoint) --> %v:%v (nodeIP)", config.EndpointPods[0].Name, config.NodeIP, config.NodeUDPPort)) - config.DialFromEndpointContainer("udp", config.NodeIP, config.NodeUDPPort, config.MaxTries, 0, config.EndpointHostnames()) + err = config.DialFromEndpointContainer("udp", config.NodeIP, config.NodeUDPPort, config.MaxTries, 0, config.EndpointHostnames()) + if err != nil { + framework.Failf("failed dialing endpoint, %v", err) + } }) // This test ensures that in a situation where multiple services exist with the same selector, @@ -235,49 +262,74 @@ var _ = SIGDescribe("Networking", func() { // original service should work ginkgo.By(fmt.Sprintf("dialing(http) %v (endpoint) --> %v:%v (config.clusterIP)", config.EndpointPods[0].Name, config.ClusterIP, e2enetwork.ClusterHTTPPort)) - config.DialFromEndpointContainer("http", config.ClusterIP, e2enetwork.ClusterHTTPPort, config.MaxTries, 0, config.EndpointHostnames()) - + err := config.DialFromEndpointContainer("http", config.ClusterIP, e2enetwork.ClusterHTTPPort, config.MaxTries, 0, config.EndpointHostnames()) + if err != nil { + framework.Failf("failed dialing endpoint, %v", err) + } ginkgo.By(fmt.Sprintf("dialing(http) %v (endpoint) --> %v:%v (nodeIP)", config.EndpointPods[0].Name, config.NodeIP, config.NodeHTTPPort)) - config.DialFromEndpointContainer("http", config.NodeIP, config.NodeHTTPPort, config.MaxTries, 0, config.EndpointHostnames()) - + err = config.DialFromEndpointContainer("http", config.NodeIP, config.NodeHTTPPort, config.MaxTries, 0, config.EndpointHostnames()) + if err != nil { + framework.Failf("failed dialing endpoint, %v", err) + } // Dial second service ginkgo.By(fmt.Sprintf("dialing(http) %v (endpoint) --> %v:%v (svc2.clusterIP)", config.EndpointPods[0].Name, svc2.Spec.ClusterIP, e2enetwork.ClusterHTTPPort)) - config.DialFromEndpointContainer("http", svc2.Spec.ClusterIP, e2enetwork.ClusterHTTPPort, config.MaxTries, 0, config.EndpointHostnames()) + err = config.DialFromEndpointContainer("http", svc2.Spec.ClusterIP, e2enetwork.ClusterHTTPPort, config.MaxTries, 0, config.EndpointHostnames()) + if err != nil { + framework.Failf("failed dialing endpoint, %v", err) + } ginkgo.By(fmt.Sprintf("dialing(http) %v (endpoint) --> %v:%v (nodeIP)", config.EndpointPods[0].Name, config.NodeIP, httpPort)) - config.DialFromEndpointContainer("http", config.NodeIP, httpPort, config.MaxTries, 0, config.EndpointHostnames()) + err = config.DialFromEndpointContainer("http", config.NodeIP, httpPort, config.MaxTries, 0, config.EndpointHostnames()) + if err != nil { + framework.Failf("failed dialing endpoint, %v", err) + } ginkgo.By("deleting the original node port service") config.DeleteNodePortService() // Second service should continue to function unaffected ginkgo.By(fmt.Sprintf("dialing(http) %v (endpoint) --> %v:%v (svc2.clusterIP)", config.EndpointPods[0].Name, svc2.Spec.ClusterIP, e2enetwork.ClusterHTTPPort)) - config.DialFromEndpointContainer("http", svc2.Spec.ClusterIP, e2enetwork.ClusterHTTPPort, config.MaxTries, 0, config.EndpointHostnames()) - + err = config.DialFromEndpointContainer("http", svc2.Spec.ClusterIP, e2enetwork.ClusterHTTPPort, config.MaxTries, 0, config.EndpointHostnames()) + if err != nil { + framework.Failf("failed dialing endpoint, %v", err) + } ginkgo.By(fmt.Sprintf("dialing(http) %v (endpoint) --> %v:%v (nodeIP)", config.EndpointPods[0].Name, config.NodeIP, httpPort)) - config.DialFromEndpointContainer("http", config.NodeIP, httpPort, config.MaxTries, 0, config.EndpointHostnames()) + err = config.DialFromEndpointContainer("http", config.NodeIP, httpPort, config.MaxTries, 0, config.EndpointHostnames()) + if err != nil { + framework.Failf("failed dialing endpoint, %v", err) + } }) ginkgo.It("should update endpoints: http", func() { config := e2enetwork.NewNetworkingTestConfig(f, false, false) ginkgo.By(fmt.Sprintf("dialing(http) %v --> %v:%v (config.clusterIP)", config.TestContainerPod.Name, config.ClusterIP, e2enetwork.ClusterHTTPPort)) - config.DialFromTestContainer("http", config.ClusterIP, e2enetwork.ClusterHTTPPort, config.MaxTries, 0, config.EndpointHostnames()) - + err := config.DialFromTestContainer("http", config.ClusterIP, e2enetwork.ClusterHTTPPort, config.MaxTries, 0, config.EndpointHostnames()) + if err != nil { + framework.Failf("failed dialing endpoint, %v", err) + } config.DeleteNetProxyPod() ginkgo.By(fmt.Sprintf("dialing(http) %v --> %v:%v (config.clusterIP)", config.TestContainerPod.Name, config.ClusterIP, e2enetwork.ClusterHTTPPort)) - config.DialFromTestContainer("http", config.ClusterIP, e2enetwork.ClusterHTTPPort, config.MaxTries, config.MaxTries, config.EndpointHostnames()) + err = config.DialFromTestContainer("http", config.ClusterIP, e2enetwork.ClusterHTTPPort, config.MaxTries, config.MaxTries, config.EndpointHostnames()) + if err != nil { + framework.Failf("failed dialing endpoint, %v", err) + } }) ginkgo.It("should update endpoints: udp", func() { config := e2enetwork.NewNetworkingTestConfig(f, false, false) ginkgo.By(fmt.Sprintf("dialing(udp) %v --> %v:%v (config.clusterIP)", config.TestContainerPod.Name, config.ClusterIP, e2enetwork.ClusterUDPPort)) - config.DialFromTestContainer("udp", config.ClusterIP, e2enetwork.ClusterUDPPort, config.MaxTries, 0, config.EndpointHostnames()) - + err := config.DialFromTestContainer("udp", config.ClusterIP, e2enetwork.ClusterUDPPort, config.MaxTries, 0, config.EndpointHostnames()) + if err != nil { + framework.Failf("failed dialing endpoint, %v", err) + } config.DeleteNetProxyPod() ginkgo.By(fmt.Sprintf("dialing(udp) %v --> %v:%v (config.clusterIP)", config.TestContainerPod.Name, config.ClusterIP, e2enetwork.ClusterUDPPort)) - config.DialFromTestContainer("udp", config.ClusterIP, e2enetwork.ClusterUDPPort, config.MaxTries, config.MaxTries, config.EndpointHostnames()) + err = config.DialFromTestContainer("udp", config.ClusterIP, e2enetwork.ClusterUDPPort, config.MaxTries, config.MaxTries, config.EndpointHostnames()) + if err != nil { + framework.Failf("failed dialing endpoint, %v", err) + } }) // Slow because we confirm that the nodePort doesn't serve traffic, which requires a period of polling. @@ -344,14 +396,20 @@ var _ = SIGDescribe("Networking", func() { config := e2enetwork.NewNetworkingTestConfig(f, false, false) ginkgo.By(fmt.Sprintf("dialing(http) %v --> %v:%v (config.clusterIP)", config.TestContainerPod.Name, config.ClusterIP, e2enetwork.ClusterHTTPPort)) message := strings.Repeat("42", 1000) - config.DialEchoFromTestContainer("http", config.ClusterIP, e2enetwork.ClusterHTTPPort, config.MaxTries, 0, message) + err := config.DialEchoFromTestContainer("http", config.ClusterIP, e2enetwork.ClusterHTTPPort, config.MaxTries, 0, message) + if err != nil { + framework.Failf("failed dialing endpoint, %v", err) + } }) ginkgo.It("should be able to handle large requests: udp", func() { config := e2enetwork.NewNetworkingTestConfig(f, false, false) ginkgo.By(fmt.Sprintf("dialing(udp) %v --> %v:%v (config.clusterIP)", config.TestContainerPod.Name, config.ClusterIP, e2enetwork.ClusterUDPPort)) message := "n" + strings.Repeat("o", 1999) - config.DialEchoFromTestContainer("udp", config.ClusterIP, e2enetwork.ClusterUDPPort, config.MaxTries, 0, message) + err := config.DialEchoFromTestContainer("udp", config.ClusterIP, e2enetwork.ClusterUDPPort, config.MaxTries, 0, message) + if err != nil { + framework.Failf("failed dialing endpoint, %v", err) + } }) }) @@ -361,7 +419,10 @@ var _ = SIGDescribe("Networking", func() { config := e2enetwork.NewNetworkingTestConfig(f, false, true) ginkgo.By(fmt.Sprintf("dialing(sctp) %v --> %v:%v (config.clusterIP)", config.TestContainerPod.Name, config.ClusterIP, e2enetwork.ClusterSCTPPort)) message := "hello" - config.DialEchoFromTestContainer("sctp", config.TestContainerPod.Status.PodIP, e2enetwork.EndpointSCTPPort, config.MaxTries, 0, message) + err := config.DialEchoFromTestContainer("sctp", config.TestContainerPod.Status.PodIP, e2enetwork.EndpointSCTPPort, config.MaxTries, 0, message) + if err != nil { + framework.Failf("failed dialing endpoint, %v", err) + } }) ginkgo.It("should recreate its iptables rules if they are deleted [Disruptive]", func() {