From a0f0e58373e5fccb6d96b135f3f0d352b566c034 Mon Sep 17 00:00:00 2001 From: Antonio Ojea Date: Tue, 19 May 2020 01:33:13 +0200 Subject: [PATCH] kubectl run test wait until pod terminates the test "executing a command with run and attach without stdin" is inherently flaky, there are several discussion but seems that it requires changing the way the kubectl run and attach works. The test fails if we are not able to attach before the container prints "stdin closed", but hasn't exited yet. Because the race seems difficult to solve, we can wait 5 seconds before printing to give time to kubectl to attach to the container. --- test/e2e/kubectl/kubectl.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/test/e2e/kubectl/kubectl.go b/test/e2e/kubectl/kubectl.go index 17c7104fbec..3f153c7b551 100644 --- a/test/e2e/kubectl/kubectl.go +++ b/test/e2e/kubectl/kubectl.go @@ -561,7 +561,12 @@ var _ = SIGDescribe("Kubectl client", func() { gomega.Expect(c.CoreV1().Pods(ns).Delete(context.TODO(), "run-test", metav1.DeleteOptions{})).To(gomega.BeNil()) ginkgo.By("executing a command with run and attach without stdin") - runOutput = framework.NewKubectlCommand(ns, fmt.Sprintf("--namespace=%v", ns), "run", "run-test-2", "--image="+busyboxImage, "--restart=OnFailure", "--attach=true", "--leave-stdin-open=true", "--", "sh", "-c", "cat && echo 'stdin closed'"). + // There is a race on this scenario described in #73099 + // It fails if we are not able to attach before the container prints + // "stdin closed", but hasn't exited yet. + // We wait 5 seconds before printing to give time to kubectl to attach + // to the container, this does not solve the race though. + runOutput = framework.NewKubectlCommand(ns, fmt.Sprintf("--namespace=%v", ns), "run", "run-test-2", "--image="+busyboxImage, "--restart=OnFailure", "--attach=true", "--leave-stdin-open=true", "--", "sh", "-c", "sleep 5; cat && echo 'stdin closed'"). WithStdinData("abcd1234"). ExecOrDie(ns) gomega.Expect(runOutput).ToNot(gomega.ContainSubstring("abcd1234"))