Skip to content

Commit 3c4d2a5

Browse files
authored
Merge pull request kubernetes#78731 from claudiubelu/tests-hostnetwork
Sets HostNetwork to False for tests which do not require it
2 parents 47c7b99 + e465e10 commit 3c4d2a5

File tree

5 files changed

+34
-130
lines changed

5 files changed

+34
-130
lines changed

test/e2e/common/networking.go

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,28 +32,26 @@ var _ = ginkgo.Describe("[sig-network] Networking", func() {
3232
// expect exactly one unique hostname. Each of these endpoints reports
3333
// its own hostname.
3434
/*
35-
Release : v1.9
35+
Release : v1.9, v1.18
3636
Testname: Networking, intra pod http
3737
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.
3838
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.
39-
This test is marked LinuxOnly since HostNetwork is not supported on other platforms like Windows.
4039
*/
41-
framework.ConformanceIt("should function for intra-pod communication: http [LinuxOnly] [NodeConformance]", func() {
42-
config := e2enetwork.NewCoreNetworkingTestConfig(f, true)
40+
framework.ConformanceIt("should function for intra-pod communication: http [NodeConformance]", func() {
41+
config := e2enetwork.NewCoreNetworkingTestConfig(f, false)
4342
for _, endpointPod := range config.EndpointPods {
4443
config.DialFromTestContainer("http", endpointPod.Status.PodIP, e2enetwork.EndpointHTTPPort, config.MaxTries, 0, sets.NewString(endpointPod.Name))
4544
}
4645
})
4746

4847
/*
49-
Release : v1.9
48+
Release : v1.9, v1.18
5049
Testname: Networking, intra pod udp
5150
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.
5251
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.
53-
This test is marked LinuxOnly since HostNetwork is not supported on other platforms like Windows.
5452
*/
55-
framework.ConformanceIt("should function for intra-pod communication: udp [LinuxOnly] [NodeConformance]", func() {
56-
config := e2enetwork.NewCoreNetworkingTestConfig(f, true)
53+
framework.ConformanceIt("should function for intra-pod communication: udp [NodeConformance]", func() {
54+
config := e2enetwork.NewCoreNetworkingTestConfig(f, false)
5755
for _, endpointPod := range config.EndpointPods {
5856
config.DialFromTestContainer("udp", endpointPod.Status.PodIP, e2enetwork.EndpointUDPPort, config.MaxTries, 0, sets.NewString(endpointPod.Name))
5957
}

test/e2e/framework/network/utils.go

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ const (
8282
var NetexecImageName = imageutils.GetE2EImage(imageutils.Agnhost)
8383

8484
// NewNetworkingTestConfig creates and sets up a new test config helper.
85-
func NewNetworkingTestConfig(f *framework.Framework) *NetworkingTestConfig {
86-
config := &NetworkingTestConfig{f: f, Namespace: f.Namespace.Name, HostNetwork: true}
85+
func NewNetworkingTestConfig(f *framework.Framework, hostNetwork bool) *NetworkingTestConfig {
86+
config := &NetworkingTestConfig{f: f, Namespace: f.Namespace.Name, HostNetwork: hostNetwork}
8787
ginkgo.By(fmt.Sprintf("Performing setup for networking test in namespace %v", config.Namespace))
8888
config.setup(getServiceSelector())
8989
return config
@@ -232,7 +232,7 @@ func (config *NetworkingTestConfig) DialFromContainer(protocol, dialCommand, con
232232
responses := sets.NewString()
233233

234234
for i := 0; i < maxTries; i++ {
235-
stdout, stderr, err := config.f.ExecShellInPodWithFullOutput(config.HostTestContainerPod.Name, cmd)
235+
stdout, stderr, err := config.f.ExecShellInPodWithFullOutput(config.TestContainerPod.Name, cmd)
236236
if err != nil {
237237
// A failure to kubectl exec counts as a try, not a hard fail.
238238
// Also note that we will keep failing for maxTries in tests where
@@ -293,7 +293,7 @@ func (config *NetworkingTestConfig) GetEndpointsFromContainer(protocol, containe
293293
eps := sets.NewString()
294294

295295
for i := 0; i < tries; i++ {
296-
stdout, stderr, err := config.f.ExecShellInPodWithFullOutput(config.HostTestContainerPod.Name, cmd)
296+
stdout, stderr, err := config.f.ExecShellInPodWithFullOutput(config.TestContainerPod.Name, cmd)
297297
if err != nil {
298298
// A failure to kubectl exec counts as a try, not a hard fail.
299299
// Also note that we will keep failing for maxTries in tests where
@@ -561,20 +561,24 @@ func (config *NetworkingTestConfig) createTestPods() {
561561
hostTestContainerPod := e2epod.NewExecPodSpec(config.Namespace, hostTestPodName, config.HostNetwork)
562562

563563
config.createPod(testContainerPod)
564-
config.createPod(hostTestContainerPod)
564+
if config.HostNetwork {
565+
config.createPod(hostTestContainerPod)
566+
}
565567

566568
framework.ExpectNoError(config.f.WaitForPodRunning(testContainerPod.Name))
567-
framework.ExpectNoError(config.f.WaitForPodRunning(hostTestContainerPod.Name))
568569

569570
var err error
570571
config.TestContainerPod, err = config.getPodClient().Get(testContainerPod.Name, metav1.GetOptions{})
571572
if err != nil {
572573
framework.Failf("Failed to retrieve %s pod: %v", testContainerPod.Name, err)
573574
}
574575

575-
config.HostTestContainerPod, err = config.getPodClient().Get(hostTestContainerPod.Name, metav1.GetOptions{})
576-
if err != nil {
577-
framework.Failf("Failed to retrieve %s pod: %v", hostTestContainerPod.Name, err)
576+
if config.HostNetwork {
577+
framework.ExpectNoError(config.f.WaitForPodRunning(hostTestContainerPod.Name))
578+
config.HostTestContainerPod, err = config.getPodClient().Get(hostTestContainerPod.Name, metav1.GetOptions{})
579+
if err != nil {
580+
framework.Failf("Failed to retrieve %s pod: %v", hostTestContainerPod.Name, err)
581+
}
578582
}
579583
}
580584

test/e2e/network/networking.go

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ var _ = SIGDescribe("Networking", func() {
148148
ginkgo.It("should check kube-proxy urls", func() {
149149
// TODO: this is overkill we just need the host networking pod
150150
// to hit kube-proxy urls.
151-
config := e2enetwork.NewNetworkingTestConfig(f)
151+
config := e2enetwork.NewNetworkingTestConfig(f, true)
152152

153153
ginkgo.By("checking kube-proxy URLs")
154154
config.GetSelfURL(ports.ProxyHealthzPort, "/healthz", "200 OK")
@@ -161,7 +161,7 @@ var _ = SIGDescribe("Networking", func() {
161161
ginkgo.Describe("Granular Checks: Services", func() {
162162

163163
ginkgo.It("should function for pod-Service: http", func() {
164-
config := e2enetwork.NewNetworkingTestConfig(f)
164+
config := e2enetwork.NewNetworkingTestConfig(f, false)
165165
ginkgo.By(fmt.Sprintf("dialing(http) %v --> %v:%v (config.clusterIP)", config.TestContainerPod.Name, config.ClusterIP, e2enetwork.ClusterHTTPPort))
166166
config.DialFromTestContainer("http", config.ClusterIP, e2enetwork.ClusterHTTPPort, config.MaxTries, 0, config.EndpointHostnames())
167167

@@ -170,7 +170,7 @@ var _ = SIGDescribe("Networking", func() {
170170
})
171171

172172
ginkgo.It("should function for pod-Service: udp", func() {
173-
config := e2enetwork.NewNetworkingTestConfig(f)
173+
config := e2enetwork.NewNetworkingTestConfig(f, false)
174174
ginkgo.By(fmt.Sprintf("dialing(udp) %v --> %v:%v (config.clusterIP)", config.TestContainerPod.Name, config.ClusterIP, e2enetwork.ClusterUDPPort))
175175
config.DialFromTestContainer("udp", config.ClusterIP, e2enetwork.ClusterUDPPort, config.MaxTries, 0, config.EndpointHostnames())
176176

@@ -179,7 +179,7 @@ var _ = SIGDescribe("Networking", func() {
179179
})
180180

181181
ginkgo.It("should function for node-Service: http", func() {
182-
config := e2enetwork.NewNetworkingTestConfig(f)
182+
config := e2enetwork.NewNetworkingTestConfig(f, true)
183183
ginkgo.By(fmt.Sprintf("dialing(http) %v (node) --> %v:%v (config.clusterIP)", config.NodeIP, config.ClusterIP, e2enetwork.ClusterHTTPPort))
184184
config.DialFromNode("http", config.ClusterIP, e2enetwork.ClusterHTTPPort, config.MaxTries, 0, config.EndpointHostnames())
185185

@@ -188,7 +188,7 @@ var _ = SIGDescribe("Networking", func() {
188188
})
189189

190190
ginkgo.It("should function for node-Service: udp", func() {
191-
config := e2enetwork.NewNetworkingTestConfig(f)
191+
config := e2enetwork.NewNetworkingTestConfig(f, true)
192192
ginkgo.By(fmt.Sprintf("dialing(udp) %v (node) --> %v:%v (config.clusterIP)", config.NodeIP, config.ClusterIP, e2enetwork.ClusterUDPPort))
193193
config.DialFromNode("udp", config.ClusterIP, e2enetwork.ClusterUDPPort, config.MaxTries, 0, config.EndpointHostnames())
194194

@@ -197,7 +197,7 @@ var _ = SIGDescribe("Networking", func() {
197197
})
198198

199199
ginkgo.It("should function for endpoint-Service: http", func() {
200-
config := e2enetwork.NewNetworkingTestConfig(f)
200+
config := e2enetwork.NewNetworkingTestConfig(f, false)
201201
ginkgo.By(fmt.Sprintf("dialing(http) %v (endpoint) --> %v:%v (config.clusterIP)", config.EndpointPods[0].Name, config.ClusterIP, e2enetwork.ClusterHTTPPort))
202202
config.DialFromEndpointContainer("http", config.ClusterIP, e2enetwork.ClusterHTTPPort, config.MaxTries, 0, config.EndpointHostnames())
203203

@@ -206,7 +206,7 @@ var _ = SIGDescribe("Networking", func() {
206206
})
207207

208208
ginkgo.It("should function for endpoint-Service: udp", func() {
209-
config := e2enetwork.NewNetworkingTestConfig(f)
209+
config := e2enetwork.NewNetworkingTestConfig(f, false)
210210
ginkgo.By(fmt.Sprintf("dialing(udp) %v (endpoint) --> %v:%v (config.clusterIP)", config.EndpointPods[0].Name, config.ClusterIP, e2enetwork.ClusterUDPPort))
211211
config.DialFromEndpointContainer("udp", config.ClusterIP, e2enetwork.ClusterUDPPort, config.MaxTries, 0, config.EndpointHostnames())
212212

@@ -215,7 +215,7 @@ var _ = SIGDescribe("Networking", func() {
215215
})
216216

217217
ginkgo.It("should update endpoints: http", func() {
218-
config := e2enetwork.NewNetworkingTestConfig(f)
218+
config := e2enetwork.NewNetworkingTestConfig(f, false)
219219
ginkgo.By(fmt.Sprintf("dialing(http) %v --> %v:%v (config.clusterIP)", config.TestContainerPod.Name, config.ClusterIP, e2enetwork.ClusterHTTPPort))
220220
config.DialFromTestContainer("http", config.ClusterIP, e2enetwork.ClusterHTTPPort, config.MaxTries, 0, config.EndpointHostnames())
221221

@@ -226,7 +226,7 @@ var _ = SIGDescribe("Networking", func() {
226226
})
227227

228228
ginkgo.It("should update endpoints: udp", func() {
229-
config := e2enetwork.NewNetworkingTestConfig(f)
229+
config := e2enetwork.NewNetworkingTestConfig(f, false)
230230
ginkgo.By(fmt.Sprintf("dialing(udp) %v --> %v:%v (config.clusterIP)", config.TestContainerPod.Name, config.ClusterIP, e2enetwork.ClusterUDPPort))
231231
config.DialFromTestContainer("udp", config.ClusterIP, e2enetwork.ClusterUDPPort, config.MaxTries, 0, config.EndpointHostnames())
232232

@@ -238,7 +238,7 @@ var _ = SIGDescribe("Networking", func() {
238238

239239
// Slow because we confirm that the nodePort doesn't serve traffic, which requires a period of polling.
240240
ginkgo.It("should update nodePort: http [Slow]", func() {
241-
config := e2enetwork.NewNetworkingTestConfig(f)
241+
config := e2enetwork.NewNetworkingTestConfig(f, true)
242242
ginkgo.By(fmt.Sprintf("dialing(http) %v (node) --> %v:%v (nodeIP)", config.NodeIP, config.NodeIP, config.NodeHTTPPort))
243243
config.DialFromNode("http", config.NodeIP, config.NodeHTTPPort, config.MaxTries, 0, config.EndpointHostnames())
244244

@@ -250,7 +250,7 @@ var _ = SIGDescribe("Networking", func() {
250250

251251
// Slow because we confirm that the nodePort doesn't serve traffic, which requires a period of polling.
252252
ginkgo.It("should update nodePort: udp [Slow]", func() {
253-
config := e2enetwork.NewNetworkingTestConfig(f)
253+
config := e2enetwork.NewNetworkingTestConfig(f, true)
254254
ginkgo.By(fmt.Sprintf("dialing(udp) %v (node) --> %v:%v (nodeIP)", config.NodeIP, config.NodeIP, config.NodeUDPPort))
255255
config.DialFromNode("udp", config.NodeIP, config.NodeUDPPort, config.MaxTries, 0, config.EndpointHostnames())
256256

@@ -262,7 +262,7 @@ var _ = SIGDescribe("Networking", func() {
262262

263263
// [LinuxOnly]: Windows does not support session affinity.
264264
ginkgo.It("should function for client IP based session affinity: http [LinuxOnly]", func() {
265-
config := e2enetwork.NewNetworkingTestConfig(f)
265+
config := e2enetwork.NewNetworkingTestConfig(f, false)
266266
ginkgo.By(fmt.Sprintf("dialing(http) %v --> %v:%v", config.TestContainerPod.Name, config.SessionAffinityService.Spec.ClusterIP, e2enetwork.ClusterHTTPPort))
267267

268268
// Check if number of endpoints returned are exactly one.
@@ -280,7 +280,7 @@ var _ = SIGDescribe("Networking", func() {
280280

281281
// [LinuxOnly]: Windows does not support session affinity.
282282
ginkgo.It("should function for client IP based session affinity: udp [LinuxOnly]", func() {
283-
config := e2enetwork.NewNetworkingTestConfig(f)
283+
config := e2enetwork.NewNetworkingTestConfig(f, false)
284284
ginkgo.By(fmt.Sprintf("dialing(udp) %v --> %v:%v", config.TestContainerPod.Name, config.SessionAffinityService.Spec.ClusterIP, e2enetwork.ClusterUDPPort))
285285

286286
// Check if number of endpoints returned are exactly one.
@@ -297,14 +297,14 @@ var _ = SIGDescribe("Networking", func() {
297297
})
298298

299299
ginkgo.It("should be able to handle large requests: http", func() {
300-
config := e2enetwork.NewNetworkingTestConfig(f)
300+
config := e2enetwork.NewNetworkingTestConfig(f, false)
301301
ginkgo.By(fmt.Sprintf("dialing(http) %v --> %v:%v (config.clusterIP)", config.TestContainerPod.Name, config.ClusterIP, e2enetwork.ClusterHTTPPort))
302302
message := strings.Repeat("42", 1000)
303303
config.DialEchoFromTestContainer("http", config.ClusterIP, e2enetwork.ClusterHTTPPort, config.MaxTries, 0, message)
304304
})
305305

306306
ginkgo.It("should be able to handle large requests: udp", func() {
307-
config := e2enetwork.NewNetworkingTestConfig(f)
307+
config := e2enetwork.NewNetworkingTestConfig(f, false)
308308
ginkgo.By(fmt.Sprintf("dialing(udp) %v --> %v:%v (config.clusterIP)", config.TestContainerPod.Name, config.ClusterIP, e2enetwork.ClusterUDPPort))
309309
message := "n" + strings.Repeat("o", 1999)
310310
config.DialEchoFromTestContainer("udp", config.ClusterIP, e2enetwork.ClusterUDPPort, config.MaxTries, 0, message)

test/e2e/windows/BUILD

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ go_library(
1212
"gmsa_kubelet.go",
1313
"hybrid_network.go",
1414
"memory_limits.go",
15-
"networking.go",
1615
"security_context.go",
1716
"service.go",
1817
"utils.go",
@@ -28,7 +27,6 @@ go_library(
2827
"//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
2928
"//staging/src/k8s.io/apimachinery/pkg/labels:go_default_library",
3029
"//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library",
31-
"//staging/src/k8s.io/apimachinery/pkg/util/sets:go_default_library",
3230
"//staging/src/k8s.io/apimachinery/pkg/util/uuid:go_default_library",
3331
"//staging/src/k8s.io/apimachinery/pkg/watch:go_default_library",
3432
"//staging/src/k8s.io/client-go/kubernetes:go_default_library",
@@ -38,7 +36,6 @@ go_library(
3836
"//test/e2e/framework:go_default_library",
3937
"//test/e2e/framework/kubectl:go_default_library",
4038
"//test/e2e/framework/metrics:go_default_library",
41-
"//test/e2e/framework/network:go_default_library",
4239
"//test/e2e/framework/node:go_default_library",
4340
"//test/e2e/framework/pod:go_default_library",
4441
"//test/e2e/framework/service:go_default_library",

0 commit comments

Comments
 (0)