Merge pull request #125971 from googs1025/integration_test
chore: use testCtx instead of context.TODO() for scheduler integration
This commit is contained in:
		| @@ -1691,7 +1691,7 @@ func TestBindPlugin(t *testing.T) { | |||||||
| 				if err = testutils.WaitForPodToSchedule(testCtx.ClientSet, pod); err != nil { | 				if err = testutils.WaitForPodToSchedule(testCtx.ClientSet, pod); err != nil { | ||||||
| 					t.Fatalf("Expected the pod to be scheduled. error: %v", err) | 					t.Fatalf("Expected the pod to be scheduled. error: %v", err) | ||||||
| 				} | 				} | ||||||
| 				pod, err = testCtx.ClientSet.CoreV1().Pods(pod.Namespace).Get(context.TODO(), pod.Name, metav1.GetOptions{}) | 				pod, err = testCtx.ClientSet.CoreV1().Pods(pod.Namespace).Get(testCtx.Ctx, pod.Name, metav1.GetOptions{}) | ||||||
| 				if err != nil { | 				if err != nil { | ||||||
| 					t.Errorf("can't get pod: %v", err) | 					t.Errorf("can't get pod: %v", err) | ||||||
| 				} | 				} | ||||||
| @@ -2571,7 +2571,7 @@ func TestActivatePods(t *testing.T) { | |||||||
| 		name := fmt.Sprintf("executor-%v", i) | 		name := fmt.Sprintf("executor-%v", i) | ||||||
| 		executor := st.MakePod().Name(name).Namespace(ns).Label("executor", "").Container(pause).Obj() | 		executor := st.MakePod().Name(name).Namespace(ns).Label("executor", "").Container(pause).Obj() | ||||||
| 		pods = append(pods, executor) | 		pods = append(pods, executor) | ||||||
| 		if _, err := cs.CoreV1().Pods(executor.Namespace).Create(context.TODO(), executor, metav1.CreateOptions{}); err != nil { | 		if _, err := cs.CoreV1().Pods(executor.Namespace).Create(testCtx.Ctx, executor, metav1.CreateOptions{}); err != nil { | ||||||
| 			t.Fatalf("Failed to create pod %v: %v", executor.Name, err) | 			t.Fatalf("Failed to create pod %v: %v", executor.Name, err) | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| @@ -2586,7 +2586,7 @@ func TestActivatePods(t *testing.T) { | |||||||
| 	// Create a driver pod. | 	// Create a driver pod. | ||||||
| 	driver := st.MakePod().Name("driver").Namespace(ns).Label("driver", "").Container(pause).Obj() | 	driver := st.MakePod().Name("driver").Namespace(ns).Label("driver", "").Container(pause).Obj() | ||||||
| 	pods = append(pods, driver) | 	pods = append(pods, driver) | ||||||
| 	if _, err := cs.CoreV1().Pods(driver.Namespace).Create(context.TODO(), driver, metav1.CreateOptions{}); err != nil { | 	if _, err := cs.CoreV1().Pods(driver.Namespace).Create(testCtx.Ctx, driver, metav1.CreateOptions{}); err != nil { | ||||||
| 		t.Fatalf("Failed to create pod %v: %v", driver.Name, err) | 		t.Fatalf("Failed to create pod %v: %v", driver.Name, err) | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|   | |||||||
| @@ -1168,7 +1168,7 @@ func TestNominatedNodeCleanUp(t *testing.T) { | |||||||
|  |  | ||||||
| 			// Delete the node if necessary. | 			// Delete the node if necessary. | ||||||
| 			if tt.deleteNode { | 			if tt.deleteNode { | ||||||
| 				if err := cs.CoreV1().Nodes().Delete(context.TODO(), nodeName, *metav1.NewDeleteOptions(0)); err != nil { | 				if err := cs.CoreV1().Nodes().Delete(testCtx.Ctx, nodeName, *metav1.NewDeleteOptions(0)); err != nil { | ||||||
| 					t.Fatalf("Node %v cannot be deleted: %v", nodeName, err) | 					t.Fatalf("Node %v cannot be deleted: %v", nodeName, err) | ||||||
| 				} | 				} | ||||||
| 			} | 			} | ||||||
| @@ -1424,7 +1424,7 @@ func TestPDBInPreemption(t *testing.T) { | |||||||
| 				} | 				} | ||||||
| 				// Add pod condition ready so that PDB is updated. | 				// Add pod condition ready so that PDB is updated. | ||||||
| 				addPodConditionReady(p) | 				addPodConditionReady(p) | ||||||
| 				if _, err := testCtx.ClientSet.CoreV1().Pods(testCtx.NS.Name).UpdateStatus(context.TODO(), p, metav1.UpdateOptions{}); err != nil { | 				if _, err := testCtx.ClientSet.CoreV1().Pods(testCtx.NS.Name).UpdateStatus(testCtx.Ctx, p, metav1.UpdateOptions{}); err != nil { | ||||||
| 					t.Fatal(err) | 					t.Fatal(err) | ||||||
| 				} | 				} | ||||||
| 			} | 			} | ||||||
| @@ -1435,7 +1435,7 @@ func TestPDBInPreemption(t *testing.T) { | |||||||
|  |  | ||||||
| 			// Create PDBs. | 			// Create PDBs. | ||||||
| 			for _, pdb := range test.pdbs { | 			for _, pdb := range test.pdbs { | ||||||
| 				_, err := testCtx.ClientSet.PolicyV1().PodDisruptionBudgets(testCtx.NS.Name).Create(context.TODO(), pdb, metav1.CreateOptions{}) | 				_, err := testCtx.ClientSet.PolicyV1().PodDisruptionBudgets(testCtx.NS.Name).Create(testCtx.Ctx, pdb, metav1.CreateOptions{}) | ||||||
| 				if err != nil { | 				if err != nil { | ||||||
| 					t.Fatalf("Failed to create PDB: %v", err) | 					t.Fatalf("Failed to create PDB: %v", err) | ||||||
| 				} | 				} | ||||||
|   | |||||||
| @@ -561,7 +561,6 @@ func TestNodeEvents(t *testing.T) { | |||||||
| 	// 4. Remove the taint from node2; pod2 should now schedule on node2 | 	// 4. Remove the taint from node2; pod2 should now schedule on node2 | ||||||
|  |  | ||||||
| 	testCtx := testutils.InitTestSchedulerWithNS(t, "node-events") | 	testCtx := testutils.InitTestSchedulerWithNS(t, "node-events") | ||||||
| 	defer testCtx.ClientSet.CoreV1().Nodes().DeleteCollection(context.TODO(), metav1.DeleteOptions{}, metav1.ListOptions{}) |  | ||||||
|  |  | ||||||
| 	// 1.1 create pod1 | 	// 1.1 create pod1 | ||||||
| 	pod1, err := testutils.CreatePausePodWithResource(testCtx.ClientSet, "pod1", testCtx.NS.Name, &v1.ResourceList{ | 	pod1, err := testutils.CreatePausePodWithResource(testCtx.ClientSet, "pod1", testCtx.NS.Name, &v1.ResourceList{ | ||||||
| @@ -620,7 +619,7 @@ func TestNodeEvents(t *testing.T) { | |||||||
| 		Req(map[v1.ResourceName]string{v1.ResourceCPU: "40m"}). | 		Req(map[v1.ResourceName]string{v1.ResourceCPU: "40m"}). | ||||||
| 		NodeAffinityIn("affinity-key", []string{"affinity-value"}). | 		NodeAffinityIn("affinity-key", []string{"affinity-value"}). | ||||||
| 		Toleration("taint-key").Obj() | 		Toleration("taint-key").Obj() | ||||||
| 	plugPod, err = testCtx.ClientSet.CoreV1().Pods(plugPod.Namespace).Create(context.TODO(), plugPod, metav1.CreateOptions{}) | 	plugPod, err = testCtx.ClientSet.CoreV1().Pods(plugPod.Namespace).Create(testCtx.Ctx, plugPod, metav1.CreateOptions{}) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		t.Fatalf("Failed to create pod %v: %v", plugPod.Name, err) | 		t.Fatalf("Failed to create pod %v: %v", plugPod.Name, err) | ||||||
| 	} | 	} | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Kubernetes Prow Robot
					Kubernetes Prow Robot