Skip to content

Commit

Permalink
Update hybrid_network.go
Browse files Browse the repository at this point in the history
Add By clauses to windows networking test so that we always know where it failed and how
  • Loading branch information
jayunit100 committed Jan 7, 2021
1 parent 5a17c7a commit 9aca5f8
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions test/e2e/windows/hybrid_network.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand All @@ -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
}
Expand Down

0 comments on commit 9aca5f8

Please sign in to comment.