Skip to content

Commit 15cc776

Browse files
committed
chore: use testCtx instead of context.TODO()
1 parent 8d0ee91 commit 15cc776

File tree

3 files changed

+7
-8
lines changed

3 files changed

+7
-8
lines changed

test/integration/scheduler/plugins/plugins_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1691,7 +1691,7 @@ func TestBindPlugin(t *testing.T) {
16911691
if err = testutils.WaitForPodToSchedule(testCtx.ClientSet, pod); err != nil {
16921692
t.Fatalf("Expected the pod to be scheduled. error: %v", err)
16931693
}
1694-
pod, err = testCtx.ClientSet.CoreV1().Pods(pod.Namespace).Get(context.TODO(), pod.Name, metav1.GetOptions{})
1694+
pod, err = testCtx.ClientSet.CoreV1().Pods(pod.Namespace).Get(testCtx.Ctx, pod.Name, metav1.GetOptions{})
16951695
if err != nil {
16961696
t.Errorf("can't get pod: %v", err)
16971697
}
@@ -2571,7 +2571,7 @@ func TestActivatePods(t *testing.T) {
25712571
name := fmt.Sprintf("executor-%v", i)
25722572
executor := st.MakePod().Name(name).Namespace(ns).Label("executor", "").Container(pause).Obj()
25732573
pods = append(pods, executor)
2574-
if _, err := cs.CoreV1().Pods(executor.Namespace).Create(context.TODO(), executor, metav1.CreateOptions{}); err != nil {
2574+
if _, err := cs.CoreV1().Pods(executor.Namespace).Create(testCtx.Ctx, executor, metav1.CreateOptions{}); err != nil {
25752575
t.Fatalf("Failed to create pod %v: %v", executor.Name, err)
25762576
}
25772577
}
@@ -2586,7 +2586,7 @@ func TestActivatePods(t *testing.T) {
25862586
// Create a driver pod.
25872587
driver := st.MakePod().Name("driver").Namespace(ns).Label("driver", "").Container(pause).Obj()
25882588
pods = append(pods, driver)
2589-
if _, err := cs.CoreV1().Pods(driver.Namespace).Create(context.TODO(), driver, metav1.CreateOptions{}); err != nil {
2589+
if _, err := cs.CoreV1().Pods(driver.Namespace).Create(testCtx.Ctx, driver, metav1.CreateOptions{}); err != nil {
25902590
t.Fatalf("Failed to create pod %v: %v", driver.Name, err)
25912591
}
25922592

test/integration/scheduler/preemption/preemption_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1201,7 +1201,7 @@ func TestNominatedNodeCleanUp(t *testing.T) {
12011201

12021202
// Delete the node if necessary.
12031203
if tt.deleteNode {
1204-
if err := cs.CoreV1().Nodes().Delete(context.TODO(), nodeName, *metav1.NewDeleteOptions(0)); err != nil {
1204+
if err := cs.CoreV1().Nodes().Delete(testCtx.Ctx, nodeName, *metav1.NewDeleteOptions(0)); err != nil {
12051205
t.Fatalf("Node %v cannot be deleted: %v", nodeName, err)
12061206
}
12071207
}
@@ -1457,7 +1457,7 @@ func TestPDBInPreemption(t *testing.T) {
14571457
}
14581458
// Add pod condition ready so that PDB is updated.
14591459
addPodConditionReady(p)
1460-
if _, err := testCtx.ClientSet.CoreV1().Pods(testCtx.NS.Name).UpdateStatus(context.TODO(), p, metav1.UpdateOptions{}); err != nil {
1460+
if _, err := testCtx.ClientSet.CoreV1().Pods(testCtx.NS.Name).UpdateStatus(testCtx.Ctx, p, metav1.UpdateOptions{}); err != nil {
14611461
t.Fatal(err)
14621462
}
14631463
}
@@ -1468,7 +1468,7 @@ func TestPDBInPreemption(t *testing.T) {
14681468

14691469
// Create PDBs.
14701470
for _, pdb := range test.pdbs {
1471-
_, err := testCtx.ClientSet.PolicyV1().PodDisruptionBudgets(testCtx.NS.Name).Create(context.TODO(), pdb, metav1.CreateOptions{})
1471+
_, err := testCtx.ClientSet.PolicyV1().PodDisruptionBudgets(testCtx.NS.Name).Create(testCtx.Ctx, pdb, metav1.CreateOptions{})
14721472
if err != nil {
14731473
t.Fatalf("Failed to create PDB: %v", err)
14741474
}

test/integration/scheduler/scheduler_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -561,7 +561,6 @@ func TestNodeEvents(t *testing.T) {
561561
// 4. Remove the taint from node2; pod2 should now schedule on node2
562562

563563
testCtx := testutils.InitTestSchedulerWithNS(t, "node-events")
564-
defer testCtx.ClientSet.CoreV1().Nodes().DeleteCollection(context.TODO(), metav1.DeleteOptions{}, metav1.ListOptions{})
565564

566565
// 1.1 create pod1
567566
pod1, err := testutils.CreatePausePodWithResource(testCtx.ClientSet, "pod1", testCtx.NS.Name, &v1.ResourceList{
@@ -620,7 +619,7 @@ func TestNodeEvents(t *testing.T) {
620619
Req(map[v1.ResourceName]string{v1.ResourceCPU: "40m"}).
621620
NodeAffinityIn("affinity-key", []string{"affinity-value"}).
622621
Toleration("taint-key").Obj()
623-
plugPod, err = testCtx.ClientSet.CoreV1().Pods(plugPod.Namespace).Create(context.TODO(), plugPod, metav1.CreateOptions{})
622+
plugPod, err = testCtx.ClientSet.CoreV1().Pods(plugPod.Namespace).Create(testCtx.Ctx, plugPod, metav1.CreateOptions{})
624623
if err != nil {
625624
t.Fatalf("Failed to create pod %v: %v", plugPod.Name, err)
626625
}

0 commit comments

Comments
 (0)