From d3e4959104618285611453369c9a911cbf6f0d70 Mon Sep 17 00:00:00 2001 From: Bowei Du Date: Mon, 27 Mar 2017 17:18:55 -0700 Subject: [PATCH] Use ping to ip instead of wget google.com in net connectivity check This is a flakey test and this commit reduces the number of dependent systems involved with the flake. --- test/e2e/framework/util.go | 20 +++++++++++++++----- test/e2e/networking.go | 5 +++-- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/test/e2e/framework/util.go b/test/e2e/framework/util.go index 8781cf6aacc..10ee7084eda 100644 --- a/test/e2e/framework/util.go +++ b/test/e2e/framework/util.go @@ -4982,11 +4982,21 @@ func LaunchWebserverPod(f *Framework, podName, nodeName string) (ip string) { return } -// CheckConnectivityToHost launches a pod running wget on the -// specified node to test connectivity to the specified host. An -// error will be returned if the host is not reachable from the pod. +// CheckConnectivityToHost launches a pod to test connectivity to the specified +// host. An error will be returned if the host is not reachable from the pod. +// +// An empty nodeName will use the schedule to choose where the pod is executed. func CheckConnectivityToHost(f *Framework, nodeName, podName, host string, timeout int) error { contName := fmt.Sprintf("%s-container", podName) + + command := []string{ + "ping", + "-c", "3", // send 3 pings + "-W", "2", // wait at most 2 seconds for a reply + "-w", strconv.Itoa(timeout), + host, + } + pod := &v1.Pod{ ObjectMeta: metav1.ObjectMeta{ Name: podName, @@ -4996,7 +5006,7 @@ func CheckConnectivityToHost(f *Framework, nodeName, podName, host string, timeo { Name: contName, Image: "gcr.io/google_containers/busybox:1.24", - Command: []string{"wget", fmt.Sprintf("--timeout=%d", timeout), "-s", host}, + Command: command, }, }, NodeName: nodeName, @@ -5015,7 +5025,7 @@ func CheckConnectivityToHost(f *Framework, nodeName, podName, host string, timeo if logErr != nil { Logf("Warning: Failed to get logs from pod %q: %v", pod.Name, logErr) } else { - Logf("pod %s/%s \"wget\" logs:\n%s", f.Namespace.Name, pod.Name, logs) + Logf("pod %s/%s logs:\n%s", f.Namespace.Name, pod.Name, logs) } } diff --git a/test/e2e/networking.go b/test/e2e/networking.go index 619db459c58..15d722ad627 100644 --- a/test/e2e/networking.go +++ b/test/e2e/networking.go @@ -44,8 +44,9 @@ var _ = framework.KubeDescribe("Networking", func() { }) It("should provide Internet connection for containers [Conformance]", func() { - By("Running container which tries to wget google.com") - framework.ExpectNoError(framework.CheckConnectivityToHost(f, "", "wget-test", "google.com", 30)) + By("Running container which tries to ping 8.8.8.8") + framework.ExpectNoError( + framework.CheckConnectivityToHost(f, "", "ping-test", "8.8.8.8", 30)) }) // First test because it has no dependencies on variables created later on.