@@ -533,25 +533,13 @@ var _ = SIGDescribe("Kubectl client", func() {
533
533
nsFlag := fmt .Sprintf ("--namespace=%v" , ns )
534
534
535
535
ginkgo .By ("executing a command with run and attach with stdin" )
536
- runOutput := framework .NewKubectlCommand (nsFlag , "run" , "run-test" , "--image=" + busyboxImage , "--restart=OnFailure" , "--attach=true" , "--stdin" , "--" , "sh" , "-c" , "cat && echo 'stdin closed'" ).
537
- WithStdinData ("abcd1234" ).
536
+ // We wait for a non-empty line so we know kubectl has attached
537
+ runOutput := framework .NewKubectlCommand (nsFlag , "run" , "run-test" , "--image=" + busyboxImage , "--restart=OnFailure" , "--attach=true" , "--stdin" , "--" , "sh" , "-c" , "while [ -z \" $s\" ]; do read s; sleep 1; done; echo read:$s && cat && echo 'stdin closed'" ).
538
+ WithStdinData ("value\n abcd1234" ).
538
539
ExecOrDie ()
539
-
540
- g := func (pods []* v1.Pod ) sort.Interface { return sort .Reverse (controller .ActivePods (pods )) }
541
- runTestPod , _ , err := polymorphichelpers .GetFirstPod (f .ClientSet .CoreV1 (), ns , "run=run-test" , 1 * time .Minute , g )
542
- gomega .Expect (err ).To (gomega .BeNil ())
543
- // NOTE: we cannot guarantee our output showed up in the container logs before stdin was closed, so we have
544
- // to loop test.
545
- err = wait .PollImmediate (time .Second , time .Minute , func () (bool , error ) {
546
- if ! e2epod .CheckPodsRunningReady (c , ns , []string {runTestPod .Name }, 1 * time .Second ) {
547
- e2elog .Failf ("Pod %q of Job %q should still be running" , runTestPod .Name , "run-test" )
548
- }
549
- logOutput := framework .RunKubectlOrDie (nsFlag , "logs" , runTestPod .Name )
550
- gomega .Expect (runOutput ).To (gomega .ContainSubstring ("abcd1234" ))
551
- gomega .Expect (runOutput ).To (gomega .ContainSubstring ("stdin closed" ))
552
- return strings .Contains (logOutput , "abcd1234" ), nil
553
- })
554
- gomega .Expect (err ).To (gomega .BeNil ())
540
+ gomega .Expect (runOutput ).To (gomega .ContainSubstring ("read:value" ))
541
+ gomega .Expect (runOutput ).To (gomega .ContainSubstring ("abcd1234" ))
542
+ gomega .Expect (runOutput ).To (gomega .ContainSubstring ("stdin closed" ))
555
543
556
544
gomega .Expect (c .BatchV1 ().Jobs (ns ).Delete ("run-test" , nil )).To (gomega .BeNil ())
557
545
@@ -568,8 +556,8 @@ var _ = SIGDescribe("Kubectl client", func() {
568
556
WithStdinData ("abcd1234\n " ).
569
557
ExecOrDie ()
570
558
gomega .Expect (runOutput ).ToNot (gomega .ContainSubstring ("stdin closed" ))
571
- g = func (pods []* v1.Pod ) sort.Interface { return sort .Reverse (controller .ActivePods (pods )) }
572
- runTestPod , _ , err = polymorphichelpers .GetFirstPod (f .ClientSet .CoreV1 (), ns , "run=run-test-3" , 1 * time .Minute , g )
559
+ g : = func (pods []* v1.Pod ) sort.Interface { return sort .Reverse (controller .ActivePods (pods )) }
560
+ runTestPod , _ , err : = polymorphichelpers .GetFirstPod (f .ClientSet .CoreV1 (), ns , "run=run-test-3" , 1 * time .Minute , g )
573
561
gomega .Expect (err ).To (gomega .BeNil ())
574
562
if ! e2epod .CheckPodsRunningReady (c , ns , []string {runTestPod .Name }, time .Minute ) {
575
563
e2elog .Failf ("Pod %q of Job %q should still be running" , runTestPod .Name , "run-test-3" )
0 commit comments