From e465e1089d102e112a677dbe2270b67a91db6618 Mon Sep 17 00:00:00 2001 From: Claudiu Belu Date: Mon, 8 Oct 2018 01:41:06 -0700 Subject: [PATCH] Sets HostNetwork to False for tests which do not require it Some tests are setting HostNetwork=true, even if it is not required for them to pass. This patch will set the HostNetwork to false for those tests, allowing them to be run on Windows nodes as well. --- test/e2e/common/networking.go | 14 ++--- test/e2e/framework/network/utils.go | 22 ++++--- test/e2e/network/networking.go | 30 ++++----- test/e2e/windows/BUILD | 3 - test/e2e/windows/networking.go | 95 ----------------------------- 5 files changed, 34 insertions(+), 130 deletions(-) delete mode 100644 test/e2e/windows/networking.go diff --git a/test/e2e/common/networking.go b/test/e2e/common/networking.go index e8d7ff3e504..868977f5404 100644 --- a/test/e2e/common/networking.go +++ b/test/e2e/common/networking.go @@ -32,28 +32,26 @@ var _ = ginkgo.Describe("[sig-network] Networking", func() { // expect exactly one unique hostname. Each of these endpoints reports // its own hostname. /* - Release : v1.9 + Release : v1.9, v1.18 Testname: Networking, intra pod http Description: Create a hostexec pod that is capable of curl to netcat commands. Create a test Pod that will act as a webserver front end exposing ports 8080 for tcp and 8081 for udp. The netserver service proxies are created on specified number of nodes. The kubectl exec on the webserver container MUST reach a http port on the each of service proxy endpoints in the cluster and the request MUST be successful. Container will execute curl command to reach the service port within specified max retry limit and MUST result in reporting unique hostnames. - This test is marked LinuxOnly since HostNetwork is not supported on other platforms like Windows. */ - framework.ConformanceIt("should function for intra-pod communication: http [LinuxOnly] [NodeConformance]", func() { - config := e2enetwork.NewCoreNetworkingTestConfig(f, true) + 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)) } }) /* - Release : v1.9 + Release : v1.9, v1.18 Testname: Networking, intra pod udp Description: Create a hostexec pod that is capable of curl to netcat commands. Create a test Pod that will act as a webserver front end exposing ports 8080 for tcp and 8081 for udp. The netserver service proxies are created on specified number of nodes. The kubectl exec on the webserver container MUST reach a udp port on the each of service proxy endpoints in the cluster and the request MUST be successful. Container will execute curl command to reach the service port within specified max retry limit and MUST result in reporting unique hostnames. - This test is marked LinuxOnly since HostNetwork is not supported on other platforms like Windows. */ - framework.ConformanceIt("should function for intra-pod communication: udp [LinuxOnly] [NodeConformance]", func() { - config := e2enetwork.NewCoreNetworkingTestConfig(f, true) + 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)) } diff --git a/test/e2e/framework/network/utils.go b/test/e2e/framework/network/utils.go index f3204dfaefb..0eddde4dfaf 100644 --- a/test/e2e/framework/network/utils.go +++ b/test/e2e/framework/network/utils.go @@ -82,8 +82,8 @@ const ( var NetexecImageName = imageutils.GetE2EImage(imageutils.Agnhost) // NewNetworkingTestConfig creates and sets up a new test config helper. -func NewNetworkingTestConfig(f *framework.Framework) *NetworkingTestConfig { - config := &NetworkingTestConfig{f: f, Namespace: f.Namespace.Name, HostNetwork: true} +func NewNetworkingTestConfig(f *framework.Framework, hostNetwork bool) *NetworkingTestConfig { + config := &NetworkingTestConfig{f: f, Namespace: f.Namespace.Name, HostNetwork: hostNetwork} ginkgo.By(fmt.Sprintf("Performing setup for networking test in namespace %v", config.Namespace)) config.setup(getServiceSelector()) return config @@ -232,7 +232,7 @@ func (config *NetworkingTestConfig) DialFromContainer(protocol, dialCommand, con responses := sets.NewString() for i := 0; i < maxTries; i++ { - stdout, stderr, err := config.f.ExecShellInPodWithFullOutput(config.HostTestContainerPod.Name, cmd) + stdout, stderr, err := config.f.ExecShellInPodWithFullOutput(config.TestContainerPod.Name, cmd) if err != nil { // A failure to kubectl exec counts as a try, not a hard fail. // Also note that we will keep failing for maxTries in tests where @@ -293,7 +293,7 @@ func (config *NetworkingTestConfig) GetEndpointsFromContainer(protocol, containe eps := sets.NewString() for i := 0; i < tries; i++ { - stdout, stderr, err := config.f.ExecShellInPodWithFullOutput(config.HostTestContainerPod.Name, cmd) + stdout, stderr, err := config.f.ExecShellInPodWithFullOutput(config.TestContainerPod.Name, cmd) if err != nil { // A failure to kubectl exec counts as a try, not a hard fail. // Also note that we will keep failing for maxTries in tests where @@ -561,10 +561,11 @@ func (config *NetworkingTestConfig) createTestPods() { hostTestContainerPod := e2epod.NewExecPodSpec(config.Namespace, hostTestPodName, config.HostNetwork) config.createPod(testContainerPod) - config.createPod(hostTestContainerPod) + if config.HostNetwork { + config.createPod(hostTestContainerPod) + } framework.ExpectNoError(config.f.WaitForPodRunning(testContainerPod.Name)) - framework.ExpectNoError(config.f.WaitForPodRunning(hostTestContainerPod.Name)) var err error config.TestContainerPod, err = config.getPodClient().Get(testContainerPod.Name, metav1.GetOptions{}) @@ -572,9 +573,12 @@ func (config *NetworkingTestConfig) createTestPods() { framework.Failf("Failed to retrieve %s pod: %v", testContainerPod.Name, err) } - config.HostTestContainerPod, err = config.getPodClient().Get(hostTestContainerPod.Name, metav1.GetOptions{}) - if err != nil { - framework.Failf("Failed to retrieve %s pod: %v", hostTestContainerPod.Name, err) + if config.HostNetwork { + framework.ExpectNoError(config.f.WaitForPodRunning(hostTestContainerPod.Name)) + config.HostTestContainerPod, err = config.getPodClient().Get(hostTestContainerPod.Name, metav1.GetOptions{}) + if err != nil { + framework.Failf("Failed to retrieve %s pod: %v", hostTestContainerPod.Name, err) + } } } diff --git a/test/e2e/network/networking.go b/test/e2e/network/networking.go index cdd8e08dfa7..7b06535b69b 100644 --- a/test/e2e/network/networking.go +++ b/test/e2e/network/networking.go @@ -148,7 +148,7 @@ var _ = SIGDescribe("Networking", func() { ginkgo.It("should check kube-proxy urls", func() { // TODO: this is overkill we just need the host networking pod // to hit kube-proxy urls. - config := e2enetwork.NewNetworkingTestConfig(f) + config := e2enetwork.NewNetworkingTestConfig(f, true) ginkgo.By("checking kube-proxy URLs") config.GetSelfURL(ports.ProxyHealthzPort, "/healthz", "200 OK") @@ -161,7 +161,7 @@ var _ = SIGDescribe("Networking", func() { ginkgo.Describe("Granular Checks: Services", func() { ginkgo.It("should function for pod-Service: http", func() { - config := e2enetwork.NewNetworkingTestConfig(f) + config := e2enetwork.NewNetworkingTestConfig(f, 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()) @@ -170,7 +170,7 @@ var _ = SIGDescribe("Networking", func() { }) ginkgo.It("should function for pod-Service: udp", func() { - config := e2enetwork.NewNetworkingTestConfig(f) + config := e2enetwork.NewNetworkingTestConfig(f, 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()) @@ -179,7 +179,7 @@ var _ = SIGDescribe("Networking", func() { }) ginkgo.It("should function for node-Service: http", func() { - config := e2enetwork.NewNetworkingTestConfig(f) + config := e2enetwork.NewNetworkingTestConfig(f, true) 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()) @@ -188,7 +188,7 @@ var _ = SIGDescribe("Networking", func() { }) ginkgo.It("should function for node-Service: udp", func() { - config := e2enetwork.NewNetworkingTestConfig(f) + config := e2enetwork.NewNetworkingTestConfig(f, true) ginkgo.By(fmt.Sprintf("dialing(udp) %v (node) --> %v:%v (config.clusterIP)", config.NodeIP, config.ClusterIP, e2enetwork.ClusterUDPPort)) config.DialFromNode("udp", config.ClusterIP, e2enetwork.ClusterUDPPort, config.MaxTries, 0, config.EndpointHostnames()) @@ -197,7 +197,7 @@ var _ = SIGDescribe("Networking", func() { }) ginkgo.It("should function for endpoint-Service: http", func() { - config := e2enetwork.NewNetworkingTestConfig(f) + config := e2enetwork.NewNetworkingTestConfig(f, 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()) @@ -206,7 +206,7 @@ var _ = SIGDescribe("Networking", func() { }) ginkgo.It("should function for endpoint-Service: udp", func() { - config := e2enetwork.NewNetworkingTestConfig(f) + config := e2enetwork.NewNetworkingTestConfig(f, 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()) @@ -215,7 +215,7 @@ var _ = SIGDescribe("Networking", func() { }) ginkgo.It("should update endpoints: http", func() { - config := e2enetwork.NewNetworkingTestConfig(f) + config := e2enetwork.NewNetworkingTestConfig(f, 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()) @@ -226,7 +226,7 @@ var _ = SIGDescribe("Networking", func() { }) ginkgo.It("should update endpoints: udp", func() { - config := e2enetwork.NewNetworkingTestConfig(f) + config := e2enetwork.NewNetworkingTestConfig(f, 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()) @@ -238,7 +238,7 @@ var _ = SIGDescribe("Networking", func() { // Slow because we confirm that the nodePort doesn't serve traffic, which requires a period of polling. ginkgo.It("should update nodePort: http [Slow]", func() { - config := e2enetwork.NewNetworkingTestConfig(f) + config := e2enetwork.NewNetworkingTestConfig(f, true) 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()) @@ -250,7 +250,7 @@ var _ = SIGDescribe("Networking", func() { // Slow because we confirm that the nodePort doesn't serve traffic, which requires a period of polling. ginkgo.It("should update nodePort: udp [Slow]", func() { - config := e2enetwork.NewNetworkingTestConfig(f) + config := e2enetwork.NewNetworkingTestConfig(f, true) ginkgo.By(fmt.Sprintf("dialing(udp) %v (node) --> %v:%v (nodeIP)", config.NodeIP, config.NodeIP, config.NodeUDPPort)) config.DialFromNode("udp", config.NodeIP, config.NodeUDPPort, config.MaxTries, 0, config.EndpointHostnames()) @@ -262,7 +262,7 @@ var _ = SIGDescribe("Networking", func() { // [LinuxOnly]: Windows does not support session affinity. ginkgo.It("should function for client IP based session affinity: http [LinuxOnly]", func() { - config := e2enetwork.NewNetworkingTestConfig(f) + config := e2enetwork.NewNetworkingTestConfig(f, false) ginkgo.By(fmt.Sprintf("dialing(http) %v --> %v:%v", config.TestContainerPod.Name, config.SessionAffinityService.Spec.ClusterIP, e2enetwork.ClusterHTTPPort)) // Check if number of endpoints returned are exactly one. @@ -280,7 +280,7 @@ var _ = SIGDescribe("Networking", func() { // [LinuxOnly]: Windows does not support session affinity. ginkgo.It("should function for client IP based session affinity: udp [LinuxOnly]", func() { - config := e2enetwork.NewNetworkingTestConfig(f) + config := e2enetwork.NewNetworkingTestConfig(f, false) ginkgo.By(fmt.Sprintf("dialing(udp) %v --> %v:%v", config.TestContainerPod.Name, config.SessionAffinityService.Spec.ClusterIP, e2enetwork.ClusterUDPPort)) // Check if number of endpoints returned are exactly one. @@ -297,14 +297,14 @@ var _ = SIGDescribe("Networking", func() { }) ginkgo.It("should be able to handle large requests: http", func() { - config := e2enetwork.NewNetworkingTestConfig(f) + config := e2enetwork.NewNetworkingTestConfig(f, 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) }) ginkgo.It("should be able to handle large requests: udp", func() { - config := e2enetwork.NewNetworkingTestConfig(f) + config := e2enetwork.NewNetworkingTestConfig(f, 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) diff --git a/test/e2e/windows/BUILD b/test/e2e/windows/BUILD index 7919d013b9a..d697d3e6fc6 100644 --- a/test/e2e/windows/BUILD +++ b/test/e2e/windows/BUILD @@ -12,7 +12,6 @@ go_library( "gmsa_kubelet.go", "hybrid_network.go", "memory_limits.go", - "networking.go", "security_context.go", "service.go", "utils.go", @@ -28,7 +27,6 @@ go_library( "//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/labels:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library", - "//staging/src/k8s.io/apimachinery/pkg/util/sets:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/util/uuid:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/watch:go_default_library", "//staging/src/k8s.io/client-go/kubernetes:go_default_library", @@ -38,7 +36,6 @@ go_library( "//test/e2e/framework:go_default_library", "//test/e2e/framework/kubelet:go_default_library", "//test/e2e/framework/metrics:go_default_library", - "//test/e2e/framework/network:go_default_library", "//test/e2e/framework/node:go_default_library", "//test/e2e/framework/pod:go_default_library", "//test/e2e/framework/service:go_default_library", diff --git a/test/e2e/windows/networking.go b/test/e2e/windows/networking.go deleted file mode 100644 index 77345480a54..00000000000 --- a/test/e2e/windows/networking.go +++ /dev/null @@ -1,95 +0,0 @@ -/* -Copyright 2018 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package windows - -import ( - "k8s.io/apimachinery/pkg/util/sets" - "k8s.io/kubernetes/test/e2e/framework" - e2enetwork "k8s.io/kubernetes/test/e2e/framework/network" - - "github.com/onsi/ginkgo" -) - -// NOTE(claudiub): Spawning Pods With HostNetwork enabled is not currently supported by Windows Kubelet. -// TODO(claudiub): Remove this test suite once this PR merges: -// https://github.com/kubernetes/kubernetes/pull/69525 -var _ = ginkgo.Describe("[sig-network] [sig-windows] Networking", func() { - f := framework.NewDefaultFramework("pod-network-test") - - ginkgo.BeforeEach(func() { - // NOTE(claudiub): These tests are Windows specific. - framework.SkipUnlessNodeOSDistroIs("windows") - }) - - ginkgo.Describe("Granular Checks: Pods", func() { - - // 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. - /* - Release : v1.14 - Testname: Networking, intra pod http - Description: Create a hostexec pod that is capable of curl to netcat commands. Create a test Pod that will act as a webserver front end exposing ports 8080 for tcp and 8081 for udp. The netserver service proxies are created on specified number of nodes. - The kubectl exec on the webserver container MUST reach a http port on the each of service proxy endpoints in the cluster and the request MUST be successful. Container will execute curl command to reach the service port within specified max retry limit and MUST result in reporting unique hostnames. - */ - ginkgo.It("should function for intra-pod communication: http", 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)) - } - }) - - /* - Release : v1.14 - Testname: Networking, intra pod udp - Description: Create a hostexec pod that is capable of curl to netcat commands. Create a test Pod that will act as a webserver front end exposing ports 8080 for tcp and 8081 for udp. The netserver service proxies are created on specified number of nodes. - The kubectl exec on the webserver container MUST reach a udp port on the each of service proxy endpoints in the cluster and the request MUST be successful. Container will execute curl command to reach the service port within specified max retry limit and MUST result in reporting unique hostnames. - */ - ginkgo.It("should function for intra-pod communication: udp", 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)) - } - }) - - /* - Release : v1.14 - Testname: Networking, intra pod http, from node - Description: Create a hostexec pod that is capable of curl to netcat commands. Create a test Pod that will act as a webserver front end exposing ports 8080 for tcp and 8081 for udp. The netserver service proxies are created on specified number of nodes. - The kubectl exec on the webserver container MUST reach a http port on the each of service proxy endpoints in the cluster using a http post(protocol=tcp) and the request MUST be successful. Container will execute curl command to reach the service port within specified max retry limit and MUST result in reporting unique hostnames. - */ - ginkgo.It("should function for node-pod communication: http", func() { - config := e2enetwork.NewCoreNetworkingTestConfig(f, false) - for _, endpointPod := range config.EndpointPods { - config.DialFromNode("http", endpointPod.Status.PodIP, e2enetwork.EndpointHTTPPort, config.MaxTries, 0, sets.NewString(endpointPod.Name)) - } - }) - - /* - Release : v1.14 - Testname: Networking, intra pod http, from node - Description: Create a hostexec pod that is capable of curl to netcat commands. Create a test Pod that will act as a webserver front end exposing ports 8080 for tcp and 8081 for udp. The netserver service proxies are created on specified number of nodes. - The kubectl exec on the webserver container MUST reach a http port on the each of service proxy endpoints in the cluster using a http post(protocol=udp) and the request MUST be successful. Container will execute curl command to reach the service port within specified max retry limit and MUST result in reporting unique hostnames. - */ - ginkgo.It("should function for node-pod communication: udp", func() { - config := e2enetwork.NewCoreNetworkingTestConfig(f, false) - for _, endpointPod := range config.EndpointPods { - config.DialFromNode("udp", endpointPod.Status.PodIP, e2enetwork.EndpointUDPPort, config.MaxTries, 0, sets.NewString(endpointPod.Name)) - } - }) - }) -})