Skip to content

Commit c19ffb7

Browse files
authored
Merge pull request kubernetes#128464 from sanposhiho/flaky-sched-one
fix: flake TestSchedulerScheduleOne
2 parents ac25b64 + bd8e9dd commit c19ffb7

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

pkg/scheduler/schedule_one_test.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -852,7 +852,11 @@ func TestSchedulerScheduleOne(t *testing.T) {
852852
if diff := cmp.Diff(item.expectBind, gotBinding); diff != "" {
853853
t.Errorf("got binding diff (-want, +got): %s", diff)
854854
}
855-
if len(queue.InFlightPods()) != 0 {
855+
// We have to use wait here
856+
// because the Pod goes to the binding cycle in some test cases and the inflight pods might not be empty immediately at this point in such case.
857+
if err := wait.PollUntilContextTimeout(ctx, time.Millisecond*200, wait.ForeverTestTimeout, false, func(ctx context.Context) (bool, error) {
858+
return len(queue.InFlightPods()) == 0, nil
859+
}); err != nil {
856860
t.Errorf("in-flight pods should be always empty after SchedulingOne. It has %v Pods", len(queue.InFlightPods()))
857861
}
858862
stopFunc()

0 commit comments

Comments
 (0)