Merge pull request #120254 from ionutbalutoiu/windows-tests/conn-check-retries
windows-tests: Add retries to Windows `assertConsistentConnectivity` …
This commit is contained in:
		@@ -70,10 +70,10 @@ var _ = sigDescribe("Hybrid cluster network", skipUnlessWindows(func() {
 | 
			
		||||
			ginkgo.By("verifying pod internal connectivity to the cluster dataplane")
 | 
			
		||||
 | 
			
		||||
			ginkgo.By("checking connectivity from Linux to Windows")
 | 
			
		||||
			assertConsistentConnectivity(ctx, f, linuxPod.ObjectMeta.Name, linuxOS, linuxCheck(windowsPod.Status.PodIP, 80))
 | 
			
		||||
			assertConsistentConnectivity(ctx, f, linuxPod.ObjectMeta.Name, linuxOS, linuxCheck(windowsPod.Status.PodIP, 80), internalMaxTries)
 | 
			
		||||
 | 
			
		||||
			ginkgo.By("checking connectivity from Windows to Linux")
 | 
			
		||||
			assertConsistentConnectivity(ctx, f, windowsPod.ObjectMeta.Name, windowsOS, windowsCheck(linuxPod.Status.PodIP))
 | 
			
		||||
			assertConsistentConnectivity(ctx, f, windowsPod.ObjectMeta.Name, windowsOS, windowsCheck(linuxPod.Status.PodIP), internalMaxTries)
 | 
			
		||||
 | 
			
		||||
		})
 | 
			
		||||
 | 
			
		||||
@@ -85,7 +85,7 @@ var _ = sigDescribe("Hybrid cluster network", skipUnlessWindows(func() {
 | 
			
		||||
			ginkgo.By("verifying pod external connectivity to the internet")
 | 
			
		||||
 | 
			
		||||
			ginkgo.By("checking connectivity to 8.8.8.8 53 (google.com) from Linux")
 | 
			
		||||
			assertConsistentConnectivity(ctx, f, linuxPod.ObjectMeta.Name, linuxOS, linuxCheck("8.8.8.8", 53))
 | 
			
		||||
			assertConsistentConnectivity(ctx, f, linuxPod.ObjectMeta.Name, linuxOS, linuxCheck("8.8.8.8", 53), externalMaxTries)
 | 
			
		||||
		})
 | 
			
		||||
 | 
			
		||||
		f.It("should provide Internet connection for Windows containers using DNS", feature.NetworkingDNS, func(ctx context.Context) {
 | 
			
		||||
@@ -96,7 +96,7 @@ var _ = sigDescribe("Hybrid cluster network", skipUnlessWindows(func() {
 | 
			
		||||
			ginkgo.By("verifying pod external connectivity to the internet")
 | 
			
		||||
 | 
			
		||||
			ginkgo.By("checking connectivity to 8.8.8.8 53 (google.com) from Windows")
 | 
			
		||||
			assertConsistentConnectivity(ctx, f, windowsPod.ObjectMeta.Name, windowsOS, windowsCheck("www.google.com"))
 | 
			
		||||
			assertConsistentConnectivity(ctx, f, windowsPod.ObjectMeta.Name, windowsOS, windowsCheck("www.google.com"), externalMaxTries)
 | 
			
		||||
		})
 | 
			
		||||
 | 
			
		||||
	})
 | 
			
		||||
@@ -107,14 +107,20 @@ var (
 | 
			
		||||
	duration       = "10s"
 | 
			
		||||
	pollInterval   = "1s"
 | 
			
		||||
	timeoutSeconds = 10
 | 
			
		||||
 | 
			
		||||
	externalMaxTries = 10
 | 
			
		||||
	internalMaxTries = 1
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
func assertConsistentConnectivity(ctx context.Context, f *framework.Framework, podName string, os string, cmd []string) {
 | 
			
		||||
func assertConsistentConnectivity(ctx context.Context, f *framework.Framework, podName string, os string, cmd []string, maxTries int) {
 | 
			
		||||
	connChecker := 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
 | 
			
		||||
		stdout, stderr, err := e2epod.ExecCommandInContainerWithFullOutput(f, podName, os+"-container", cmd...)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
		var err error
 | 
			
		||||
		for i := 0; i < maxTries; i++ {
 | 
			
		||||
			ginkgo.By(fmt.Sprintf("checking connectivity of %s-container in %s", os, podName))
 | 
			
		||||
			stdout, stderr, err := e2epod.ExecCommandInContainerWithFullOutput(f, podName, os+"-container", cmd...)
 | 
			
		||||
			if err == nil {
 | 
			
		||||
				break
 | 
			
		||||
			}
 | 
			
		||||
			framework.Logf("Encountered error while running command: %v.\nStdout: %s\nStderr: %s\nErr: %v", cmd, stdout, stderr, err)
 | 
			
		||||
		}
 | 
			
		||||
		return err
 | 
			
		||||
 
 | 
			
		||||
@@ -112,13 +112,13 @@ var _ = sigDescribe(feature.Windows, "[Excluded:WindowsDocker] [MinimumKubeletVe
 | 
			
		||||
		nginxPod = e2epod.NewPodClient(f).CreateSync(ctx, nginxPod)
 | 
			
		||||
 | 
			
		||||
		ginkgo.By("checking connectivity to 8.8.8.8 53 (google.com) from Linux")
 | 
			
		||||
		assertConsistentConnectivity(ctx, f, nginxPod.ObjectMeta.Name, "linux", linuxCheck("8.8.8.8", 53))
 | 
			
		||||
		assertConsistentConnectivity(ctx, f, nginxPod.ObjectMeta.Name, "linux", linuxCheck("8.8.8.8", 53), externalMaxTries)
 | 
			
		||||
 | 
			
		||||
		ginkgo.By("checking connectivity to www.google.com from Windows")
 | 
			
		||||
		assertConsistentConnectivity(ctx, f, agnPod.ObjectMeta.Name, "windows", windowsCheck("www.google.com"))
 | 
			
		||||
		assertConsistentConnectivity(ctx, f, agnPod.ObjectMeta.Name, "windows", windowsCheck("www.google.com"), externalMaxTries)
 | 
			
		||||
 | 
			
		||||
		ginkgo.By("checking connectivity from Linux to Windows for the first time")
 | 
			
		||||
		assertConsistentConnectivity(ctx, f, nginxPod.ObjectMeta.Name, "linux", linuxCheck(agnPod.Status.PodIP, 80))
 | 
			
		||||
		assertConsistentConnectivity(ctx, f, nginxPod.ObjectMeta.Name, "linux", linuxCheck(agnPod.Status.PodIP, 80), internalMaxTries)
 | 
			
		||||
 | 
			
		||||
		initialRestartCount := podutil.GetExistingContainerStatus(agnPod.Status.ContainerStatuses, "windows-container").RestartCount
 | 
			
		||||
 | 
			
		||||
@@ -202,7 +202,7 @@ var _ = sigDescribe(feature.Windows, "[Excluded:WindowsDocker] [MinimumKubeletVe
 | 
			
		||||
		agnPodOut, err := f.ClientSet.CoreV1().Pods(f.Namespace.Name).Get(ctx, agnPod.Name, metav1.GetOptions{})
 | 
			
		||||
		gomega.Expect(agnPodOut.Status.Phase).To(gomega.Equal(v1.PodRunning))
 | 
			
		||||
		framework.ExpectNoError(err, "getting pod info after reboot")
 | 
			
		||||
		assertConsistentConnectivity(ctx, f, nginxPod.ObjectMeta.Name, "linux", linuxCheck(agnPodOut.Status.PodIP, 80))
 | 
			
		||||
		assertConsistentConnectivity(ctx, f, nginxPod.ObjectMeta.Name, "linux", linuxCheck(agnPodOut.Status.PodIP, 80), internalMaxTries)
 | 
			
		||||
 | 
			
		||||
		// create another host process pod to check system boot time
 | 
			
		||||
		checkPod := &v1.Pod{
 | 
			
		||||
 
 | 
			
		||||
@@ -82,7 +82,7 @@ var _ = sigDescribe("Services", skipUnlessWindows(func() {
 | 
			
		||||
		// Admission controllers may sometimes do the wrong thing
 | 
			
		||||
		gomega.Expect(testPod.Spec.NodeSelector).To(gomega.HaveKeyWithValue("kubernetes.io/os", "windows"), "pod.spec.nodeSelector")
 | 
			
		||||
		ginkgo.By(fmt.Sprintf("checking connectivity Pod to curl http://%s:%d", nodeIP, nodePort))
 | 
			
		||||
		assertConsistentConnectivity(ctx, f, testPod.ObjectMeta.Name, windowsOS, windowsCheck(fmt.Sprintf("http://%s", net.JoinHostPort(nodeIP, strconv.Itoa(nodePort)))))
 | 
			
		||||
		assertConsistentConnectivity(ctx, f, testPod.ObjectMeta.Name, windowsOS, windowsCheck(fmt.Sprintf("http://%s", net.JoinHostPort(nodeIP, strconv.Itoa(nodePort)))), internalMaxTries)
 | 
			
		||||
 | 
			
		||||
	})
 | 
			
		||||
}))
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user