mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 19:56:01 +00:00
Merge pull request #43727 from bowei/ping-instead-of-wget
Automatic merge from submit-queue 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.
This commit is contained in:
commit
d1bff958c2
@ -4982,11 +4982,21 @@ func LaunchWebserverPod(f *Framework, podName, nodeName string) (ip string) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// CheckConnectivityToHost launches a pod running wget on the
|
// CheckConnectivityToHost launches a pod to test connectivity to the specified
|
||||||
// specified node to test connectivity to the specified host. An
|
// host. An error will be returned if the host is not reachable from the pod.
|
||||||
// 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 {
|
func CheckConnectivityToHost(f *Framework, nodeName, podName, host string, timeout int) error {
|
||||||
contName := fmt.Sprintf("%s-container", podName)
|
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{
|
pod := &v1.Pod{
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Name: podName,
|
Name: podName,
|
||||||
@ -4996,7 +5006,7 @@ func CheckConnectivityToHost(f *Framework, nodeName, podName, host string, timeo
|
|||||||
{
|
{
|
||||||
Name: contName,
|
Name: contName,
|
||||||
Image: "gcr.io/google_containers/busybox:1.24",
|
Image: "gcr.io/google_containers/busybox:1.24",
|
||||||
Command: []string{"wget", fmt.Sprintf("--timeout=%d", timeout), "-s", host},
|
Command: command,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
NodeName: nodeName,
|
NodeName: nodeName,
|
||||||
@ -5015,7 +5025,7 @@ func CheckConnectivityToHost(f *Framework, nodeName, podName, host string, timeo
|
|||||||
if logErr != nil {
|
if logErr != nil {
|
||||||
Logf("Warning: Failed to get logs from pod %q: %v", pod.Name, logErr)
|
Logf("Warning: Failed to get logs from pod %q: %v", pod.Name, logErr)
|
||||||
} else {
|
} 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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,8 +44,9 @@ var _ = framework.KubeDescribe("Networking", func() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
It("should provide Internet connection for containers [Conformance]", func() {
|
It("should provide Internet connection for containers [Conformance]", func() {
|
||||||
By("Running container which tries to wget google.com")
|
By("Running container which tries to ping 8.8.8.8")
|
||||||
framework.ExpectNoError(framework.CheckConnectivityToHost(f, "", "wget-test", "google.com", 30))
|
framework.ExpectNoError(
|
||||||
|
framework.CheckConnectivityToHost(f, "", "ping-test", "8.8.8.8", 30))
|
||||||
})
|
})
|
||||||
|
|
||||||
// First test because it has no dependencies on variables created later on.
|
// First test because it has no dependencies on variables created later on.
|
||||||
|
Loading…
Reference in New Issue
Block a user