@@ -31,7 +31,6 @@ import (
31
31
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
32
32
"k8s.io/apimachinery/pkg/runtime"
33
33
"k8s.io/apimachinery/pkg/util/sets"
34
- "k8s.io/apimachinery/pkg/util/wait"
35
34
utilfeature "k8s.io/apiserver/pkg/util/feature"
36
35
"k8s.io/client-go/informers"
37
36
"k8s.io/client-go/kubernetes"
@@ -995,16 +994,14 @@ func TestFrameworkHandler_IterateOverWaitingPods(t *testing.T) {
995
994
fakeClient := fake .NewSimpleClientset (objs ... )
996
995
informerFactory := informers .NewSharedInformerFactory (fakeClient , 0 )
997
996
eventBroadcaster := events .NewBroadcaster (& events.EventSinkImpl {Interface : fakeClient .EventsV1 ()})
998
- defer eventBroadcaster .Shutdown ()
999
997
eventRecorder := eventBroadcaster .NewRecorder (scheme .Scheme , fakePermit )
1000
998
1001
999
outOfTreeRegistry := frameworkruntime.Registry {
1002
1000
fakePermit : newFakePermitPlugin (eventRecorder ),
1003
1001
}
1004
1002
1005
1003
_ , 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 )
1008
1005
defer cancel ()
1009
1006
1010
1007
scheduler , err := New (
@@ -1052,23 +1049,17 @@ func TestFrameworkHandler_IterateOverWaitingPods(t *testing.T) {
1052
1049
// Wait all pods in waitSchedulingPods to be scheduled.
1053
1050
wg .Wait ()
1054
1051
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 ())
1068
1062
}
1069
- return true , nil
1070
- }); err != nil {
1071
- t .Fatal ("got unexpected result" )
1072
1063
}
1073
1064
})
1074
1065
}
0 commit comments