mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-12 05:21:58 +00:00
windows-tests: Add retries to Windows assertConsistentConnectivity
func
Add retry logic to the `assertConsistentConnectivity` function from the `test/e2e/windows/hybrid_network.go` file. Signed-off-by: Ionut Balutoiu <ibalutoiu@cloudbasesolutions.com>
This commit is contained in:
parent
ae2e0c00b5
commit
8e5b959e12
@ -69,10 +69,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)
|
||||
|
||||
})
|
||||
|
||||
@ -84,7 +84,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)
|
||||
})
|
||||
|
||||
ginkgo.It("should provide Internet connection for Windows containers using DNS [Feature:Networking-DNS]", func(ctx context.Context) {
|
||||
@ -95,7 +95,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)
|
||||
})
|
||||
|
||||
})
|
||||
@ -106,14 +106,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
|
||||
|
@ -111,13 +111,13 @@ var _ = sigDescribe("[Feature:Windows] [Excluded:WindowsDocker] [MinimumKubeletV
|
||||
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
|
||||
|
||||
@ -201,7 +201,7 @@ var _ = sigDescribe("[Feature:Windows] [Excluded:WindowsDocker] [MinimumKubeletV
|
||||
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)
|
||||
|
||||
})
|
||||
}))
|
||||
|
Loading…
Reference in New Issue
Block a user