Skip to content

Commit 627e83c

Browse files
committed
Passed context for Wait methods in integration test utils
1 parent 2d32348 commit 627e83c

File tree

8 files changed

+68
-69
lines changed

8 files changed

+68
-69
lines changed

test/integration/scheduler/eventhandler/eventhandler_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ func TestUpdateNodeEvent(t *testing.T) {
131131
t.Fatalf("Error updating the node: %v", err)
132132
}
133133

134-
if err := testutils.WaitForPodToSchedule(testCtx.ClientSet, pod); err != nil {
134+
if err := testutils.WaitForPodToSchedule(testCtx.Ctx, testCtx.ClientSet, pod); err != nil {
135135
t.Errorf("Pod %v was not scheduled: %v", pod.Name, err)
136136
}
137137
}

test/integration/scheduler/filters/filters_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2165,7 +2165,7 @@ func TestUnschedulablePodBecomesSchedulable(t *testing.T) {
21652165
if err := tt.update(testCtx.ClientSet, testCtx.NS.Name); err != nil {
21662166
t.Fatal(err)
21672167
}
2168-
if err := testutils.WaitForPodToSchedule(testCtx.ClientSet, pod); err != nil {
2168+
if err := testutils.WaitForPodToSchedule(testCtx.Ctx, testCtx.ClientSet, pod); err != nil {
21692169
t.Errorf("Pod %v was not scheduled: %v", pod.Name, err)
21702170
}
21712171
// Make sure pending queue is empty.

test/integration/scheduler/plugins/plugins_test.go

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -693,7 +693,7 @@ func TestPreFilterPlugin(t *testing.T) {
693693
t.Errorf("Expected a scheduling error, but got: %v", err)
694694
}
695695
} else {
696-
if err = testutils.WaitForPodToSchedule(testCtx.ClientSet, pod); err != nil {
696+
if err = testutils.WaitForPodToSchedule(testCtx.Ctx, testCtx.ClientSet, pod); err != nil {
697697
t.Errorf("Expected the pod to be scheduled. error: %v", err)
698698
}
699699
}
@@ -873,7 +873,7 @@ func TestPostFilterPlugin(t *testing.T) {
873873
t.Errorf("Expected the score plugin to be called at least %v times, but got %v.", tt.expectScoreNumCalled, numScoreCalled)
874874
}
875875
} else {
876-
if err = testutils.WaitForPodToSchedule(testCtx.ClientSet, pod); err != nil {
876+
if err = testutils.WaitForPodToSchedule(testCtx.Ctx, testCtx.ClientSet, pod); err != nil {
877877
t.Errorf("Expected the pod to be scheduled. error: %v", err)
878878
}
879879
if numFilterCalled := filterPlugin.deepCopy().numFilterCalled; numFilterCalled != tt.expectFilterNumCalled {
@@ -935,7 +935,7 @@ func TestScorePlugin(t *testing.T) {
935935
t.Errorf("Expected a scheduling error, but got: %v", err)
936936
}
937937
} else {
938-
if err = testutils.WaitForPodToSchedule(testCtx.ClientSet, pod); err != nil {
938+
if err = testutils.WaitForPodToSchedule(testCtx.Ctx, testCtx.ClientSet, pod); err != nil {
939939
t.Errorf("Expected the pod to be scheduled. error: %v", err)
940940
} else {
941941
p, err := testutils.GetPod(testCtx.ClientSet, pod.Name, pod.Namespace)
@@ -971,7 +971,7 @@ func TestNormalizeScorePlugin(t *testing.T) {
971971
t.Fatalf("Error while creating a test pod: %v", err)
972972
}
973973

974-
if err = testutils.WaitForPodToSchedule(testCtx.ClientSet, pod); err != nil {
974+
if err = testutils.WaitForPodToSchedule(testCtx.Ctx, testCtx.ClientSet, pod); err != nil {
975975
t.Errorf("Expected the pod to be scheduled. error: %v", err)
976976
}
977977

@@ -1027,7 +1027,7 @@ func TestReservePluginReserve(t *testing.T) {
10271027
t.Errorf("Didn't expect the pod to be scheduled. error: %v", err)
10281028
}
10291029
} else {
1030-
if err = testutils.WaitForPodToSchedule(testCtx.ClientSet, pod); err != nil {
1030+
if err = testutils.WaitForPodToSchedule(testCtx.Ctx, testCtx.ClientSet, pod); err != nil {
10311031
t.Errorf("Expected the pod to be scheduled. error: %v", err)
10321032
}
10331033
}
@@ -1147,7 +1147,7 @@ func TestPrebindPlugin(t *testing.T) {
11471147

11481148
if test.fail {
11491149
if test.succeedOnRetry {
1150-
if err = testutils.WaitForPodToScheduleWithTimeout(testCtx.ClientSet, pod, 10*time.Second); err != nil {
1150+
if err = testutils.WaitForPodToScheduleWithTimeout(testCtx.Ctx, testCtx.ClientSet, pod, 10*time.Second); err != nil {
11511151
t.Errorf("Expected the pod to be schedulable on retry, but got an error: %v", err)
11521152
}
11531153
} else if err = wait.PollUntilContextTimeout(testCtx.Ctx, 10*time.Millisecond, 30*time.Second, false,
@@ -1158,7 +1158,7 @@ func TestPrebindPlugin(t *testing.T) {
11581158
if err = testutils.WaitForPodUnschedulable(testCtx.Ctx, testCtx.ClientSet, pod); err != nil {
11591159
t.Errorf("Expected the pod to be unschedulable")
11601160
}
1161-
} else if err = testutils.WaitForPodToSchedule(testCtx.ClientSet, pod); err != nil {
1161+
} else if err = testutils.WaitForPodToSchedule(testCtx.Ctx, testCtx.ClientSet, pod); err != nil {
11621162
t.Errorf("Expected the pod to be scheduled. error: %v", err)
11631163
}
11641164

@@ -1314,7 +1314,7 @@ func TestUnReserveReservePlugins(t *testing.T) {
13141314
}
13151315
}
13161316
} else {
1317-
if err = testutils.WaitForPodToSchedule(testCtx.ClientSet, pod); err != nil {
1317+
if err = testutils.WaitForPodToSchedule(testCtx.Ctx, testCtx.ClientSet, pod); err != nil {
13181318
t.Errorf("Expected the pod to be scheduled. error: %v", err)
13191319
}
13201320

@@ -1396,7 +1396,7 @@ func TestUnReservePermitPlugins(t *testing.T) {
13961396
t.Errorf("Reserve Plugin %s numUnreserveCalled = %d, want 1.", reservePlugin.name, reservePlugin.numUnreserveCalled)
13971397
}
13981398
} else {
1399-
if err = testutils.WaitForPodToSchedule(testCtx.ClientSet, pod); err != nil {
1399+
if err = testutils.WaitForPodToSchedule(testCtx.Ctx, testCtx.ClientSet, pod); err != nil {
14001400
t.Errorf("Expected the pod to be scheduled. error: %v", err)
14011401
}
14021402

@@ -1468,7 +1468,7 @@ func TestUnReservePreBindPlugins(t *testing.T) {
14681468
t.Errorf("Reserve Plugin %s numUnreserveCalled = %d, want 1.", reservePlugin.name, reservePlugin.numUnreserveCalled)
14691469
}
14701470
} else {
1471-
if err = testutils.WaitForPodToSchedule(testCtx.ClientSet, pod); err != nil {
1471+
if err = testutils.WaitForPodToSchedule(testCtx.Ctx, testCtx.ClientSet, pod); err != nil {
14721472
t.Errorf("Expected the pod to be scheduled. error: %v", err)
14731473
}
14741474

@@ -1540,7 +1540,7 @@ func TestUnReserveBindPlugins(t *testing.T) {
15401540
t.Errorf("Reserve Plugin %s numUnreserveCalled = %d, want 1.", reservePlugin.name, reservePlugin.numUnreserveCalled)
15411541
}
15421542
} else {
1543-
if err = testutils.WaitForPodToSchedule(testCtx.ClientSet, pod); err != nil {
1543+
if err = testutils.WaitForPodToSchedule(testCtx.Ctx, testCtx.ClientSet, pod); err != nil {
15441544
t.Errorf("Expected the pod to be scheduled. error: %v", err)
15451545
}
15461546

@@ -1688,7 +1688,7 @@ func TestBindPlugin(t *testing.T) {
16881688

16891689
if test.expectBoundByScheduler || test.expectBoundByPlugin {
16901690
// bind plugins skipped to bind the pod
1691-
if err = testutils.WaitForPodToSchedule(testCtx.ClientSet, pod); err != nil {
1691+
if err = testutils.WaitForPodToSchedule(testCtx.Ctx, testCtx.ClientSet, pod); err != nil {
16921692
t.Fatalf("Expected the pod to be scheduled. error: %v", err)
16931693
}
16941694
pod, err = testCtx.ClientSet.CoreV1().Pods(pod.Namespace).Get(testCtx.Ctx, pod.Name, metav1.GetOptions{})
@@ -1810,7 +1810,7 @@ func TestPostBindPlugin(t *testing.T) {
18101810
t.Errorf("Didn't expect the postbind plugin to be called %d times.", postBindPlugin.numPostBindCalled)
18111811
}
18121812
} else {
1813-
if err = testutils.WaitForPodToSchedule(testCtx.ClientSet, pod); err != nil {
1813+
if err = testutils.WaitForPodToSchedule(testCtx.Ctx, testCtx.ClientSet, pod); err != nil {
18141814
t.Errorf("Expected the pod to be scheduled. error: %v", err)
18151815
}
18161816
select {
@@ -1909,7 +1909,7 @@ func TestPermitPlugin(t *testing.T) {
19091909
t.Errorf("Didn't expect the pod to be scheduled. error: %v", err)
19101910
}
19111911
} else {
1912-
if err = testutils.WaitForPodToSchedule(testCtx.ClientSet, pod); err != nil {
1912+
if err = testutils.WaitForPodToSchedule(testCtx.Ctx, testCtx.ClientSet, pod); err != nil {
19131913
t.Errorf("Expected the pod to be scheduled. error: %v", err)
19141914
}
19151915
}
@@ -1966,7 +1966,7 @@ func TestMultiplePermitPlugins(t *testing.T) {
19661966
}
19671967

19681968
perPlugin2.allowAllPods()
1969-
if err = testutils.WaitForPodToSchedule(testCtx.ClientSet, pod); err != nil {
1969+
if err = testutils.WaitForPodToSchedule(testCtx.Ctx, testCtx.ClientSet, pod); err != nil {
19701970
t.Errorf("Expected the pod to be scheduled. error: %v", err)
19711971
}
19721972

@@ -2083,10 +2083,10 @@ func TestCoSchedulingWithPermitPlugin(t *testing.T) {
20832083
permitPlugin.waitingPod, permitPlugin.rejectingPod)
20842084
}
20852085
} else {
2086-
if err = testutils.WaitForPodToSchedule(testCtx.ClientSet, podA); err != nil {
2086+
if err = testutils.WaitForPodToSchedule(testCtx.Ctx, testCtx.ClientSet, podA); err != nil {
20872087
t.Errorf("Expected the first pod to be scheduled. error: %v", err)
20882088
}
2089-
if err = testutils.WaitForPodToSchedule(testCtx.ClientSet, podB); err != nil {
2089+
if err = testutils.WaitForPodToSchedule(testCtx.Ctx, testCtx.ClientSet, podB); err != nil {
20902090
t.Errorf("Expected the second pod to be scheduled. error: %v", err)
20912091
}
20922092
if !((permitPlugin.waitingPod == podA.Name && permitPlugin.allowingPod == podB.Name) ||
@@ -2150,7 +2150,7 @@ func TestFilterPlugin(t *testing.T) {
21502150
t.Errorf("Expected the filter plugin to be called at least 1 time, but got %v.", filterPlugin.numFilterCalled)
21512151
}
21522152
} else {
2153-
if err = testutils.WaitForPodToSchedule(testCtx.ClientSet, pod); err != nil {
2153+
if err = testutils.WaitForPodToSchedule(testCtx.Ctx, testCtx.ClientSet, pod); err != nil {
21542154
t.Errorf("Expected the pod to be scheduled. error: %v", err)
21552155
}
21562156
if filterPlugin.numFilterCalled != 1 {
@@ -2204,7 +2204,7 @@ func TestPreScorePlugin(t *testing.T) {
22042204
t.Errorf("Expected a scheduling error, but got: %v", err)
22052205
}
22062206
} else {
2207-
if err = testutils.WaitForPodToSchedule(testCtx.ClientSet, pod); err != nil {
2207+
if err = testutils.WaitForPodToSchedule(testCtx.Ctx, testCtx.ClientSet, pod); err != nil {
22082208
t.Errorf("Expected the pod to be scheduled. error: %v", err)
22092209
}
22102210
}
@@ -2258,7 +2258,7 @@ func TestPreEnqueuePlugin(t *testing.T) {
22582258
}
22592259

22602260
if tt.admitEnqueue {
2261-
if err := testutils.WaitForPodToScheduleWithTimeout(testCtx.ClientSet, pod, 10*time.Second); err != nil {
2261+
if err := testutils.WaitForPodToScheduleWithTimeout(testCtx.Ctx, testCtx.ClientSet, pod, 10*time.Second); err != nil {
22622262
t.Errorf("Expected the pod to be schedulable, but got: %v", err)
22632263
}
22642264
// Also verify enqueuePlugin is called.
@@ -2396,7 +2396,7 @@ func TestPreemptWithPermitPlugin(t *testing.T) {
23962396
t.Fatalf("Error while creating the running pod: %v", err)
23972397
}
23982398
// Wait until the pod to be scheduled.
2399-
if err = testutils.WaitForPodToSchedule(testCtx.ClientSet, r); err != nil {
2399+
if err = testutils.WaitForPodToSchedule(testCtx.Ctx, testCtx.ClientSet, r); err != nil {
24002400
t.Fatalf("The running pod is expected to be scheduled: %v", err)
24012401
}
24022402
}
@@ -2425,7 +2425,7 @@ func TestPreemptWithPermitPlugin(t *testing.T) {
24252425
t.Fatalf("Error while deleting the waiting pod: %v", err)
24262426
}
24272427
}
2428-
if err = testutils.WaitForPodToSchedule(testCtx.ClientSet, p); err != nil {
2428+
if err = testutils.WaitForPodToSchedule(testCtx.Ctx, testCtx.ClientSet, p); err != nil {
24292429
t.Fatalf("Expected the preemptor pod to be scheduled. error: %v", err)
24302430
}
24312431
}
@@ -2592,7 +2592,7 @@ func TestActivatePods(t *testing.T) {
25922592

25932593
// Verify all pods to be scheduled.
25942594
for _, pod := range pods {
2595-
if err := testutils.WaitForPodToScheduleWithTimeout(cs, pod, wait.ForeverTestTimeout); err != nil {
2595+
if err := testutils.WaitForPodToScheduleWithTimeout(testCtx.Ctx, cs, pod, wait.ForeverTestTimeout); err != nil {
25962596
t.Fatalf("Failed to wait for Pod %v to be schedulable: %v", pod.Name, err)
25972597
}
25982598
}
@@ -2768,7 +2768,7 @@ func TestPreEnqueuePluginEventsToRegister(t *testing.T) {
27682768
}
27692769

27702770
// Wait for the pod schedulabled.
2771-
if err := testutils.WaitForPodToScheduleWithTimeout(testCtx.ClientSet, pausePod, 10*time.Second); err != nil {
2771+
if err := testutils.WaitForPodToScheduleWithTimeout(testCtx.Ctx, testCtx.ClientSet, pausePod, 10*time.Second); err != nil {
27722772
t.Errorf("Expected the pod to be schedulable, but got: %v", err)
27732773
return
27742774
}
@@ -2810,7 +2810,7 @@ func TestPreEnqueuePluginEventsToRegister(t *testing.T) {
28102810
}
28112811

28122812
if expectedScheduled {
2813-
if err := testutils.WaitForPodToScheduleWithTimeout(testCtx.ClientSet, gatedPod, 10*time.Second); err != nil {
2813+
if err := testutils.WaitForPodToScheduleWithTimeout(testCtx.Ctx, testCtx.ClientSet, gatedPod, 10*time.Second); err != nil {
28142814
t.Errorf("Expected the pod to be schedulable, but got: %v", err)
28152815
}
28162816
return

0 commit comments

Comments
 (0)