Skip to content

Commit a67d1dc

Browse files
committed
Revert "Fix flaky test on multi profiles waiting pod"
This reverts commit 5b072a5.
1 parent fe9e469 commit a67d1dc

File tree

1 file changed

+11
-20
lines changed

1 file changed

+11
-20
lines changed

pkg/scheduler/scheduler_test.go

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ import (
3131
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
3232
"k8s.io/apimachinery/pkg/runtime"
3333
"k8s.io/apimachinery/pkg/util/sets"
34-
"k8s.io/apimachinery/pkg/util/wait"
3534
utilfeature "k8s.io/apiserver/pkg/util/feature"
3635
"k8s.io/client-go/informers"
3736
"k8s.io/client-go/kubernetes"
@@ -995,16 +994,14 @@ func TestFrameworkHandler_IterateOverWaitingPods(t *testing.T) {
995994
fakeClient := fake.NewSimpleClientset(objs...)
996995
informerFactory := informers.NewSharedInformerFactory(fakeClient, 0)
997996
eventBroadcaster := events.NewBroadcaster(&events.EventSinkImpl{Interface: fakeClient.EventsV1()})
998-
defer eventBroadcaster.Shutdown()
999997
eventRecorder := eventBroadcaster.NewRecorder(scheme.Scheme, fakePermit)
1000998

1001999
outOfTreeRegistry := frameworkruntime.Registry{
10021000
fakePermit: newFakePermitPlugin(eventRecorder),
10031001
}
10041002

10051003
_, ctx := ktesting.NewTestContext(t)
1006-
// timeout equals to the permit plugin waiting time.
1007-
ctx, cancel := context.WithTimeout(ctx, 100*time.Second)
1004+
ctx, cancel := context.WithCancel(ctx)
10081005
defer cancel()
10091006

10101007
scheduler, err := New(
@@ -1052,23 +1049,17 @@ func TestFrameworkHandler_IterateOverWaitingPods(t *testing.T) {
10521049
// Wait all pods in waitSchedulingPods to be scheduled.
10531050
wg.Wait()
10541051

1055-
// When permit plugin emits the event, pod may not been added to the waitingPods pool yet, so we use pollUntil here.
1056-
if err := wait.PollUntilContextCancel(ctx, 100*time.Microsecond, true, func(context.Context) (done bool, err error) {
1057-
// Ensure that all waitingPods in scheduler can be obtained from any profiles.
1058-
for _, fwk := range scheduler.Profiles {
1059-
actualPodNamesInWaitingPods := sets.NewString()
1060-
fwk.IterateOverWaitingPods(func(pod framework.WaitingPod) {
1061-
actualPodNamesInWaitingPods.Insert(pod.GetPod().Name)
1062-
})
1063-
// Validate the name of pods in waitingPods matches expectations.
1064-
if actualPodNamesInWaitingPods.Len() != len(tc.expectPodNamesInWaitingPods) ||
1065-
!actualPodNamesInWaitingPods.HasAll(tc.expectPodNamesInWaitingPods...) {
1066-
return false, fmt.Errorf("Unexpected waitingPods in scheduler profile %s, expect: %#v, got: %#v", fwk.ProfileName(), tc.expectPodNamesInWaitingPods, actualPodNamesInWaitingPods.List())
1067-
}
1052+
// Ensure that all waitingPods in scheduler can be obtained from any profiles.
1053+
for _, fwk := range scheduler.Profiles {
1054+
actualPodNamesInWaitingPods := sets.NewString()
1055+
fwk.IterateOverWaitingPods(func(pod framework.WaitingPod) {
1056+
actualPodNamesInWaitingPods.Insert(pod.GetPod().Name)
1057+
})
1058+
// Validate the name of pods in waitingPods matches expectations.
1059+
if actualPodNamesInWaitingPods.Len() != len(tc.expectPodNamesInWaitingPods) ||
1060+
!actualPodNamesInWaitingPods.HasAll(tc.expectPodNamesInWaitingPods...) {
1061+
t.Fatalf("Unexpected waitingPods in scheduler profile %s, expect: %#v, got: %#v", fwk.ProfileName(), tc.expectPodNamesInWaitingPods, actualPodNamesInWaitingPods.List())
10681062
}
1069-
return true, nil
1070-
}); err != nil {
1071-
t.Fatal("got unexpected result")
10721063
}
10731064
})
10741065
}

0 commit comments

Comments
 (0)