Adds Windows-related Networking tests

Creating pods with HostNetwork is not currently supported on
Windows Kubelet, and thus, ones without HostNetwork are created instead.
This commit is contained in:
Claudiu Belu 2018-10-08 01:41:06 -07:00
parent 3c2a4f0362
commit 00e2582c67
7 changed files with 113 additions and 16 deletions

View File

@ -38,7 +38,7 @@ var _ = Describe("[sig-network] Networking", func() {
This test is marked LinuxOnly since HostNetwork is not supported on other platforms like Windows. 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() { framework.ConformanceIt("should function for intra-pod communication: http [LinuxOnly] [NodeConformance]", func() {
config := framework.NewCoreNetworkingTestConfig(f) config := framework.NewCoreNetworkingTestConfig(f, true)
for _, endpointPod := range config.EndpointPods { for _, endpointPod := range config.EndpointPods {
config.DialFromTestContainer("http", endpointPod.Status.PodIP, framework.EndpointHttpPort, config.MaxTries, 0, sets.NewString(endpointPod.Name)) config.DialFromTestContainer("http", endpointPod.Status.PodIP, framework.EndpointHttpPort, config.MaxTries, 0, sets.NewString(endpointPod.Name))
} }
@ -52,7 +52,7 @@ var _ = Describe("[sig-network] Networking", func() {
This test is marked LinuxOnly since HostNetwork is not supported on other platforms like Windows. 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() { framework.ConformanceIt("should function for intra-pod communication: udp [LinuxOnly] [NodeConformance]", func() {
config := framework.NewCoreNetworkingTestConfig(f) config := framework.NewCoreNetworkingTestConfig(f, true)
for _, endpointPod := range config.EndpointPods { for _, endpointPod := range config.EndpointPods {
config.DialFromTestContainer("udp", endpointPod.Status.PodIP, framework.EndpointUdpPort, config.MaxTries, 0, sets.NewString(endpointPod.Name)) config.DialFromTestContainer("udp", endpointPod.Status.PodIP, framework.EndpointUdpPort, config.MaxTries, 0, sets.NewString(endpointPod.Name))
} }
@ -66,7 +66,7 @@ var _ = Describe("[sig-network] Networking", func() {
This test is marked LinuxOnly since HostNetwork is not supported on other platforms like Windows. This test is marked LinuxOnly since HostNetwork is not supported on other platforms like Windows.
*/ */
framework.ConformanceIt("should function for node-pod communication: http [LinuxOnly] [NodeConformance]", func() { framework.ConformanceIt("should function for node-pod communication: http [LinuxOnly] [NodeConformance]", func() {
config := framework.NewCoreNetworkingTestConfig(f) config := framework.NewCoreNetworkingTestConfig(f, true)
for _, endpointPod := range config.EndpointPods { for _, endpointPod := range config.EndpointPods {
config.DialFromNode("http", endpointPod.Status.PodIP, framework.EndpointHttpPort, config.MaxTries, 0, sets.NewString(endpointPod.Name)) config.DialFromNode("http", endpointPod.Status.PodIP, framework.EndpointHttpPort, config.MaxTries, 0, sets.NewString(endpointPod.Name))
} }
@ -80,7 +80,7 @@ var _ = Describe("[sig-network] Networking", func() {
This test is marked LinuxOnly since HostNetwork is not supported on other platforms like Windows. This test is marked LinuxOnly since HostNetwork is not supported on other platforms like Windows.
*/ */
framework.ConformanceIt("should function for node-pod communication: udp [LinuxOnly] [NodeConformance]", func() { framework.ConformanceIt("should function for node-pod communication: udp [LinuxOnly] [NodeConformance]", func() {
config := framework.NewCoreNetworkingTestConfig(f) config := framework.NewCoreNetworkingTestConfig(f, true)
for _, endpointPod := range config.EndpointPods { for _, endpointPod := range config.EndpointPods {
config.DialFromNode("udp", endpointPod.Status.PodIP, framework.EndpointUdpPort, config.MaxTries, 0, sets.NewString(endpointPod.Name)) config.DialFromNode("udp", endpointPod.Status.PodIP, framework.EndpointUdpPort, config.MaxTries, 0, sets.NewString(endpointPod.Name))
} }

View File

@ -69,15 +69,15 @@ var NetexecImageName = imageutils.GetE2EImage(imageutils.Netexec)
// NewNetworkingTestConfig creates and sets up a new test config helper. // NewNetworkingTestConfig creates and sets up a new test config helper.
func NewNetworkingTestConfig(f *Framework) *NetworkingTestConfig { func NewNetworkingTestConfig(f *Framework) *NetworkingTestConfig {
config := &NetworkingTestConfig{f: f, Namespace: f.Namespace.Name} config := &NetworkingTestConfig{f: f, Namespace: f.Namespace.Name, HostNetwork: true}
By(fmt.Sprintf("Performing setup for networking test in namespace %v", config.Namespace)) By(fmt.Sprintf("Performing setup for networking test in namespace %v", config.Namespace))
config.setup(getServiceSelector()) config.setup(getServiceSelector())
return config return config
} }
// NewNetworkingTestNodeE2EConfig creates and sets up a new test config helper for Node E2E. // NewNetworkingTestNodeE2EConfig creates and sets up a new test config helper for Node E2E.
func NewCoreNetworkingTestConfig(f *Framework) *NetworkingTestConfig { func NewCoreNetworkingTestConfig(f *Framework, hostNetwork bool) *NetworkingTestConfig {
config := &NetworkingTestConfig{f: f, Namespace: f.Namespace.Name} config := &NetworkingTestConfig{f: f, Namespace: f.Namespace.Name, HostNetwork: hostNetwork}
By(fmt.Sprintf("Performing setup for networking test in namespace %v", config.Namespace)) By(fmt.Sprintf("Performing setup for networking test in namespace %v", config.Namespace))
config.setupCore(getServiceSelector()) config.setupCore(getServiceSelector())
return config return config
@ -98,9 +98,10 @@ type NetworkingTestConfig struct {
// TestContaienrPod is a test pod running the netexec image. It is capable // TestContaienrPod is a test pod running the netexec image. It is capable
// of executing tcp/udp requests against ip:port. // of executing tcp/udp requests against ip:port.
TestContainerPod *v1.Pod TestContainerPod *v1.Pod
// HostTestContainerPod is a pod running with hostNetworking=true, and the // HostTestContainerPod is a pod running using the hostexec image.
// hostexec image.
HostTestContainerPod *v1.Pod HostTestContainerPod *v1.Pod
// if the HostTestContainerPod is running with HostNetwork=true.
HostNetwork bool
// EndpointPods are the pods belonging to the Service created by this // EndpointPods are the pods belonging to the Service created by this
// test config. Each invocation of `setup` creates a service with // test config. Each invocation of `setup` creates a service with
// 1 pod per node running the netexecImage. // 1 pod per node running the netexecImage.
@ -513,7 +514,7 @@ func (config *NetworkingTestConfig) DeleteNodePortService() {
func (config *NetworkingTestConfig) createTestPods() { func (config *NetworkingTestConfig) createTestPods() {
testContainerPod := config.createTestPodSpec() testContainerPod := config.createTestPodSpec()
hostTestContainerPod := NewHostExecPodSpec(config.Namespace, hostTestPodName) hostTestContainerPod := NewExecPodSpec(config.Namespace, hostTestPodName, config.HostNetwork)
config.createPod(testContainerPod) config.createPod(testContainerPod)
config.createPod(hostTestContainerPod) config.createPod(hostTestContainerPod)

View File

@ -3382,8 +3382,8 @@ func NodeAddresses(nodelist *v1.NodeList, addrType v1.NodeAddressType) []string
return hosts return hosts
} }
// NewHostExecPodSpec returns the pod spec of hostexec pod // NewExecPodSpec returns the pod spec of hostexec pod
func NewHostExecPodSpec(ns, name string) *v1.Pod { func NewExecPodSpec(ns, name string, hostNetwork bool) *v1.Pod {
immediate := int64(0) immediate := int64(0)
pod := &v1.Pod{ pod := &v1.Pod{
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
@ -3398,7 +3398,7 @@ func NewHostExecPodSpec(ns, name string) *v1.Pod {
ImagePullPolicy: v1.PullIfNotPresent, ImagePullPolicy: v1.PullIfNotPresent,
}, },
}, },
HostNetwork: true, HostNetwork: hostNetwork,
SecurityContext: &v1.PodSecurityContext{}, SecurityContext: &v1.PodSecurityContext{},
TerminationGracePeriodSeconds: &immediate, TerminationGracePeriodSeconds: &immediate,
}, },
@ -3441,7 +3441,7 @@ func RunHostCmdWithRetries(ns, name, cmd string, interval, timeout time.Duration
// LaunchHostExecPod launches a hostexec pod in the given namespace and waits // LaunchHostExecPod launches a hostexec pod in the given namespace and waits
// until it's Running // until it's Running
func LaunchHostExecPod(client clientset.Interface, ns, name string) *v1.Pod { func LaunchHostExecPod(client clientset.Interface, ns, name string) *v1.Pod {
hostExecPod := NewHostExecPodSpec(ns, name) hostExecPod := NewExecPodSpec(ns, name, true)
pod, err := client.CoreV1().Pods(ns).Create(hostExecPod) pod, err := client.CoreV1().Pods(ns).Create(hostExecPod)
ExpectNoError(err) ExpectNoError(err)
err = WaitForPodRunningInNamespace(client, pod) err = WaitForPodRunningInNamespace(client, pod)

View File

@ -824,7 +824,7 @@ func setupLocalVolumeDirectory(config *localTestConfig, node *v1.Node) *localTes
// launchNodeExecPodForLocalPV launches a hostexec pod for local PV and waits // launchNodeExecPodForLocalPV launches a hostexec pod for local PV and waits
// until it's Running. // until it's Running.
func launchNodeExecPodForLocalPV(client clientset.Interface, ns, node string) *v1.Pod { func launchNodeExecPodForLocalPV(client clientset.Interface, ns, node string) *v1.Pod {
hostExecPod := framework.NewHostExecPodSpec(ns, fmt.Sprintf("hostexec-%s", node)) hostExecPod := framework.NewExecPodSpec(ns, fmt.Sprintf("hostexec-%s", node), true)
hostExecPod.Spec.NodeName = node hostExecPod.Spec.NodeName = node
hostExecPod.Spec.Volumes = []v1.Volume{ hostExecPod.Spec.Volumes = []v1.Volume{
{ {

View File

@ -50,7 +50,7 @@ func (h *hostExecutor) launchNodeExecPod(node string) *v1.Pod {
f := h.Framework f := h.Framework
cs := f.ClientSet cs := f.ClientSet
ns := f.Namespace ns := f.Namespace
hostExecPod := framework.NewHostExecPodSpec(ns.Name, fmt.Sprintf("hostexec-%s", node)) hostExecPod := framework.NewExecPodSpec(ns.Name, fmt.Sprintf("hostexec-%s", node), true)
hostExecPod.Spec.NodeName = node hostExecPod.Spec.NodeName = node
hostExecPod.Spec.Volumes = []v1.Volume{ hostExecPod.Spec.Volumes = []v1.Volume{
{ {

View File

@ -7,6 +7,7 @@ go_library(
srcs = [ srcs = [
"density.go", "density.go",
"framework.go", "framework.go",
"networking.go",
], ],
importpath = "k8s.io/kubernetes/test/e2e/windows", importpath = "k8s.io/kubernetes/test/e2e/windows",
visibility = ["//visibility:public"], visibility = ["//visibility:public"],
@ -15,6 +16,7 @@ go_library(
"//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_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/labels:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/runtime: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/util/uuid:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/watch:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/watch:go_default_library",
"//staging/src/k8s.io/client-go/tools/cache:go_default_library", "//staging/src/k8s.io/client-go/tools/cache:go_default_library",

View File

@ -0,0 +1,94 @@
/*
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"
. "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 _ = Describe("[sig-network] [sig-windows] Networking", func() {
f := framework.NewDefaultFramework("pod-network-test")
BeforeEach(func() {
// NOTE(claudiub): These tests are Windows specific.
framework.SkipUnlessNodeOSDistroIs("windows")
})
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.
*/
It("should function for intra-pod communication: http", func() {
config := framework.NewCoreNetworkingTestConfig(f, false)
for _, endpointPod := range config.EndpointPods {
config.DialFromTestContainer("http", endpointPod.Status.PodIP, framework.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.
*/
It("should function for intra-pod communication: udp", func() {
config := framework.NewCoreNetworkingTestConfig(f, false)
for _, endpointPod := range config.EndpointPods {
config.DialFromTestContainer("udp", endpointPod.Status.PodIP, framework.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.
*/
It("should function for node-pod communication: http", func() {
config := framework.NewCoreNetworkingTestConfig(f, false)
for _, endpointPod := range config.EndpointPods {
config.DialFromNode("http", endpointPod.Status.PodIP, framework.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.
*/
It("should function for node-pod communication: udp", func() {
config := framework.NewCoreNetworkingTestConfig(f, false)
for _, endpointPod := range config.EndpointPods {
config.DialFromNode("udp", endpointPod.Status.PodIP, framework.EndpointUdpPort, config.MaxTries, 0, sets.NewString(endpointPod.Name))
}
})
})
})