Skip to content

Commit 63411a1

Browse files
authored
Merge pull request kubernetes#86732 from oomichi/move-WaitForFailure
Move WaitForFailure() to the test
2 parents f5034a6 + 253a85d commit 63411a1

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

test/e2e/common/security_context.go

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package common
1919
import (
2020
"fmt"
2121
"strings"
22+
"time"
2223

2324
v1 "k8s.io/api/core/v1"
2425
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -191,7 +192,7 @@ var _ = framework.KubeDescribe("Security Context", func() {
191192
))
192193

193194
if readOnlyRootFilesystem {
194-
podClient.WaitForFailure(podName, framework.PodStartTimeout)
195+
waitForFailure(f, podName, framework.PodStartTimeout)
195196
} else {
196197
podClient.WaitForSuccess(podName, framework.PodStartTimeout)
197198
}
@@ -366,3 +367,19 @@ var _ = framework.KubeDescribe("Security Context", func() {
366367
})
367368
})
368369
})
370+
371+
// waitForFailure waits for pod to fail.
372+
func waitForFailure(f *framework.Framework, name string, timeout time.Duration) {
373+
gomega.Expect(e2epod.WaitForPodCondition(f.ClientSet, f.Namespace.Name, name, "success or failure", timeout,
374+
func(pod *v1.Pod) (bool, error) {
375+
switch pod.Status.Phase {
376+
case v1.PodFailed:
377+
return true, nil
378+
case v1.PodSucceeded:
379+
return true, fmt.Errorf("pod %q successed with reason: %q, message: %q", name, pod.Status.Reason, pod.Status.Message)
380+
default:
381+
return false, nil
382+
}
383+
},
384+
)).To(gomega.Succeed(), "wait for pod %q to fail", name)
385+
}

test/e2e/framework/pods.go

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -199,23 +199,6 @@ func (c *PodClient) WaitForSuccess(name string, timeout time.Duration) {
199199
)).To(gomega.Succeed(), "wait for pod %q to success", name)
200200
}
201201

202-
// WaitForFailure waits for pod to fail.
203-
func (c *PodClient) WaitForFailure(name string, timeout time.Duration) {
204-
f := c.f
205-
gomega.Expect(e2epod.WaitForPodCondition(f.ClientSet, f.Namespace.Name, name, "success or failure", timeout,
206-
func(pod *v1.Pod) (bool, error) {
207-
switch pod.Status.Phase {
208-
case v1.PodFailed:
209-
return true, nil
210-
case v1.PodSucceeded:
211-
return true, fmt.Errorf("pod %q successed with reason: %q, message: %q", name, pod.Status.Reason, pod.Status.Message)
212-
default:
213-
return false, nil
214-
}
215-
},
216-
)).To(gomega.Succeed(), "wait for pod %q to fail", name)
217-
}
218-
219202
// WaitForFinish waits for pod to finish running, regardless of success or failure.
220203
func (c *PodClient) WaitForFinish(name string, timeout time.Duration) {
221204
f := c.f

0 commit comments

Comments
 (0)