mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 19:56:01 +00:00
Merge pull request #97209 from jayunit100/patch-17
Update hybrid_network.go
This commit is contained in:
commit
981afd2bff
@ -50,19 +50,27 @@ var _ = SIGDescribe("Hybrid cluster network", func() {
|
||||
ginkgo.Context("for all supported CNIs", func() {
|
||||
|
||||
ginkgo.It("should have stable networking for Linux and Windows pods", func() {
|
||||
ginkgo.By("creating linux and windows pods")
|
||||
|
||||
linuxPod := createTestPod(f, linuxBusyBoxImage, linuxOS)
|
||||
ginkgo.By("creating a linux pod and waiting for it to be running")
|
||||
linuxPod = f.PodClient().CreateSync(linuxPod)
|
||||
|
||||
windowsPod := createTestPod(f, windowsBusyBoximage, windowsOS)
|
||||
|
||||
windowsPod.Spec.Containers[0].Args = []string{"test-webserver"}
|
||||
ginkgo.By("creating a windows pod and waiting for it to be running")
|
||||
windowsPod = f.PodClient().CreateSync(windowsPod)
|
||||
|
||||
ginkgo.By("verifying pod external connectivity to the internet")
|
||||
|
||||
ginkgo.By("checking connectivity to 8.8.8.8 53 (google.com) from Linux")
|
||||
assertConsistentConnectivity(f, linuxPod.ObjectMeta.Name, linuxOS, linuxCheck("8.8.8.8", 53))
|
||||
|
||||
ginkgo.By("checking connectivity to www.google.com from Windows")
|
||||
assertConsistentConnectivity(f, windowsPod.ObjectMeta.Name, windowsOS, windowsCheck("www.google.com"))
|
||||
|
||||
ginkgo.By("verifying pod internal connectivity to the cluster dataplane")
|
||||
|
||||
ginkgo.By("checking connectivity from Linux to Windows")
|
||||
assertConsistentConnectivity(f, linuxPod.ObjectMeta.Name, linuxOS, linuxCheck(windowsPod.Status.PodIP, 80))
|
||||
|
||||
@ -75,27 +83,28 @@ var _ = SIGDescribe("Hybrid cluster network", func() {
|
||||
})
|
||||
|
||||
var (
|
||||
duration = "10s"
|
||||
pollInterval = "1s"
|
||||
timeout = 10 // seconds
|
||||
duration = "10s"
|
||||
pollInterval = "1s"
|
||||
timeoutSeconds = 10
|
||||
)
|
||||
|
||||
func assertConsistentConnectivity(f *framework.Framework, podName string, os string, cmd []string) {
|
||||
gomega.Consistently(func() error {
|
||||
ginkgo.By(fmt.Sprintf("checking connectivity of %s-container in %s", os, podName))
|
||||
// TODO, we should be retrying this similar to what is done in DialFromNode, in the test/e2e/networking/networking.go tests
|
||||
_, _, err := f.ExecCommandInContainerWithFullOutput(podName, os+"-container", cmd...)
|
||||
return err
|
||||
}, duration, pollInterval).ShouldNot(gomega.HaveOccurred())
|
||||
}
|
||||
|
||||
func linuxCheck(address string, port int) []string {
|
||||
nc := fmt.Sprintf("nc -vz %s %v -w %v", address, port, timeout)
|
||||
nc := fmt.Sprintf("nc -vz %s %v -w %v", address, port, timeoutSeconds)
|
||||
cmd := []string{"/bin/sh", "-c", nc}
|
||||
return cmd
|
||||
}
|
||||
|
||||
func windowsCheck(address string) []string {
|
||||
curl := fmt.Sprintf("curl.exe %s --connect-timeout %v --fail", address, timeout)
|
||||
curl := fmt.Sprintf("curl.exe %s --connect-timeout %v --fail", address, timeoutSeconds)
|
||||
cmd := []string{"cmd", "/c", curl}
|
||||
return cmd
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user