diff --git a/test/e2e/framework/pod/wait.go b/test/e2e/framework/pod/wait.go index 6aa1b1be32f..cf4997641e7 100644 --- a/test/e2e/framework/pod/wait.go +++ b/test/e2e/framework/pod/wait.go @@ -335,8 +335,8 @@ func RunningReady(p *v1.Pod) bool { } // WaitForPodsRunning waits for a given `timeout` to evaluate if a certain amount of pods in given `ns` are running. -func WaitForPodsRunning(c clientset.Interface, ns string, num int, timeout time.Duration) error { - _, err := WaitForPods(context.TODO(), c, ns, metav1.ListOptions{}, Range{MinMatching: num, MaxMatching: num}, timeout, +func WaitForPodsRunning(ctx context.Context, c clientset.Interface, ns string, num int, timeout time.Duration) error { + _, err := WaitForPods(ctx, c, ns, metav1.ListOptions{}, Range{MinMatching: num, MaxMatching: num}, timeout, "be running and ready", func(pod *v1.Pod) bool { ready, _ := testutils.PodRunningReady(pod) return ready @@ -345,8 +345,8 @@ func WaitForPodsRunning(c clientset.Interface, ns string, num int, timeout time. } // WaitForPodsSchedulingGated waits for a given `timeout` to evaluate if a certain amount of pods in given `ns` stay in scheduling gated state. -func WaitForPodsSchedulingGated(c clientset.Interface, ns string, num int, timeout time.Duration) error { - _, err := WaitForPods(context.TODO(), c, ns, metav1.ListOptions{}, Range{MinMatching: num, MaxMatching: num}, timeout, +func WaitForPodsSchedulingGated(ctx context.Context, c clientset.Interface, ns string, num int, timeout time.Duration) error { + _, err := WaitForPods(ctx, c, ns, metav1.ListOptions{}, Range{MinMatching: num, MaxMatching: num}, timeout, "be in scheduling gated state", func(pod *v1.Pod) bool { for _, condition := range pod.Status.Conditions { if condition.Type == v1.PodScheduled && condition.Reason == v1.PodReasonSchedulingGated { @@ -360,8 +360,8 @@ func WaitForPodsSchedulingGated(c clientset.Interface, ns string, num int, timeo // WaitForPodsWithSchedulingGates waits for a given `timeout` to evaluate if a certain amount of pods in given `ns` // match the given `schedulingGates`stay in scheduling gated state. -func WaitForPodsWithSchedulingGates(c clientset.Interface, ns string, num int, timeout time.Duration, schedulingGates []v1.PodSchedulingGate) error { - _, err := WaitForPods(context.TODO(), c, ns, metav1.ListOptions{}, Range{MinMatching: num, MaxMatching: num}, timeout, +func WaitForPodsWithSchedulingGates(ctx context.Context, c clientset.Interface, ns string, num int, timeout time.Duration, schedulingGates []v1.PodSchedulingGate) error { + _, err := WaitForPods(ctx, c, ns, metav1.ListOptions{}, Range{MinMatching: num, MaxMatching: num}, timeout, "have certain scheduling gates", func(pod *v1.Pod) bool { return reflect.DeepEqual(pod.Spec.SchedulingGates, schedulingGates) }) diff --git a/test/e2e/scheduling/predicates.go b/test/e2e/scheduling/predicates.go index 3761cde4a22..02e420e4166 100644 --- a/test/e2e/scheduling/predicates.go +++ b/test/e2e/scheduling/predicates.go @@ -829,7 +829,7 @@ var _ = SIGDescribe("SchedulerPredicates", framework.WithSerial(), func() { ginkgo.By("Expect all pods stay in pending state") podList, err := e2epod.WaitForNumberOfPods(ctx, cs, ns, replicas, time.Minute) framework.ExpectNoError(err) - framework.ExpectNoError(e2epod.WaitForPodsSchedulingGated(cs, ns, replicas, time.Minute)) + framework.ExpectNoError(e2epod.WaitForPodsSchedulingGated(ctx, cs, ns, replicas, time.Minute)) ginkgo.By("Remove one scheduling gate") want := []v1.PodSchedulingGate{{Name: "bar"}} @@ -843,8 +843,8 @@ var _ = SIGDescribe("SchedulerPredicates", framework.WithSerial(), func() { } ginkgo.By("Expect all pods carry one scheduling gate and are still in pending state") - framework.ExpectNoError(e2epod.WaitForPodsWithSchedulingGates(cs, ns, replicas, time.Minute, want)) - framework.ExpectNoError(e2epod.WaitForPodsSchedulingGated(cs, ns, replicas, time.Minute)) + framework.ExpectNoError(e2epod.WaitForPodsWithSchedulingGates(ctx, cs, ns, replicas, time.Minute, want)) + framework.ExpectNoError(e2epod.WaitForPodsSchedulingGated(ctx, cs, ns, replicas, time.Minute)) ginkgo.By("Remove the remaining scheduling gates") for _, pod := range pods { @@ -855,7 +855,7 @@ var _ = SIGDescribe("SchedulerPredicates", framework.WithSerial(), func() { } ginkgo.By("Expect all pods are scheduled and running") - framework.ExpectNoError(e2epod.WaitForPodsRunning(cs, ns, replicas, time.Minute)) + framework.ExpectNoError(e2epod.WaitForPodsRunning(ctx, cs, ns, replicas, time.Minute)) }) })