mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-11-03 19:58:17 +00:00 
			
		
		
		
	Merge pull request #67230 from tanshanshan/schedulertest810
add ns for pod in scheduler integration test
This commit is contained in:
		@@ -52,7 +52,7 @@ func waitForNominatedNodeNameWithTimeout(cs clientset.Interface, pod *v1.Pod, ti
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
		return false, err
 | 
							return false, err
 | 
				
			||||||
	}); err != nil {
 | 
						}); err != nil {
 | 
				
			||||||
		return fmt.Errorf("Pod %v annotation did not get set: %v", pod.Name, err)
 | 
							return fmt.Errorf("Pod %v/%v annotation did not get set: %v", pod.Namespace, pod.Name, err)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	return nil
 | 
						return nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@@ -268,7 +268,7 @@ func TestPreemption(t *testing.T) {
 | 
				
			|||||||
		for i, p := range pods {
 | 
							for i, p := range pods {
 | 
				
			||||||
			if _, found := test.preemptedPodIndexes[i]; found {
 | 
								if _, found := test.preemptedPodIndexes[i]; found {
 | 
				
			||||||
				if err = wait.Poll(time.Second, wait.ForeverTestTimeout, podIsGettingEvicted(cs, p.Namespace, p.Name)); err != nil {
 | 
									if err = wait.Poll(time.Second, wait.ForeverTestTimeout, podIsGettingEvicted(cs, p.Namespace, p.Name)); err != nil {
 | 
				
			||||||
					t.Errorf("Test [%v]: Pod %v is not getting evicted.", test.description, p.Name)
 | 
										t.Errorf("Test [%v]: Pod %v/%v is not getting evicted.", test.description, p.Namespace, p.Name)
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
			} else {
 | 
								} else {
 | 
				
			||||||
				if p.DeletionTimestamp != nil {
 | 
									if p.DeletionTimestamp != nil {
 | 
				
			||||||
@@ -450,7 +450,7 @@ func TestPreemptionStarvation(t *testing.T) {
 | 
				
			|||||||
		// make sure that runningPods are all scheduled.
 | 
							// make sure that runningPods are all scheduled.
 | 
				
			||||||
		for _, p := range runningPods {
 | 
							for _, p := range runningPods {
 | 
				
			||||||
			if err := waitForPodToSchedule(cs, p); err != nil {
 | 
								if err := waitForPodToSchedule(cs, p); err != nil {
 | 
				
			||||||
				t.Fatalf("Pod %v didn't get scheduled: %v", p.Name, err)
 | 
									t.Fatalf("Pod %v/%v didn't get scheduled: %v", p.Namespace, p.Name, err)
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		// Create pending pods.
 | 
							// Create pending pods.
 | 
				
			||||||
@@ -464,7 +464,7 @@ func TestPreemptionStarvation(t *testing.T) {
 | 
				
			|||||||
		for _, p := range pendingPods {
 | 
							for _, p := range pendingPods {
 | 
				
			||||||
			if err := wait.Poll(100*time.Millisecond, wait.ForeverTestTimeout,
 | 
								if err := wait.Poll(100*time.Millisecond, wait.ForeverTestTimeout,
 | 
				
			||||||
				podUnschedulable(cs, p.Namespace, p.Name)); err != nil {
 | 
									podUnschedulable(cs, p.Namespace, p.Name)); err != nil {
 | 
				
			||||||
				t.Errorf("Pod %v didn't get marked unschedulable: %v", p.Name, err)
 | 
									t.Errorf("Pod %v/%v didn't get marked unschedulable: %v", p.Namespace, p.Name, err)
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		// Create the preemptor.
 | 
							// Create the preemptor.
 | 
				
			||||||
@@ -474,7 +474,7 @@ func TestPreemptionStarvation(t *testing.T) {
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
		// Check that the preemptor pod gets the annotation for nominated node name.
 | 
							// Check that the preemptor pod gets the annotation for nominated node name.
 | 
				
			||||||
		if err := waitForNominatedNodeName(cs, preemptor); err != nil {
 | 
							if err := waitForNominatedNodeName(cs, preemptor); err != nil {
 | 
				
			||||||
			t.Errorf("Test [%v]: NominatedNodeName annotation was not set for pod %v: %v", test.description, preemptor.Name, err)
 | 
								t.Errorf("Test [%v]: NominatedNodeName annotation was not set for pod %v/%v: %v", test.description, preemptor.Namespace, preemptor.Name, err)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		// Make sure that preemptor is scheduled after preemptions.
 | 
							// Make sure that preemptor is scheduled after preemptions.
 | 
				
			||||||
		if err := waitForPodToScheduleWithTimeout(cs, preemptor, 60*time.Second); err != nil {
 | 
							if err := waitForPodToScheduleWithTimeout(cs, preemptor, 60*time.Second); err != nil {
 | 
				
			||||||
@@ -532,7 +532,7 @@ func TestNominatedNodeCleanUp(t *testing.T) {
 | 
				
			|||||||
	// make sure that the pods are all scheduled.
 | 
						// make sure that the pods are all scheduled.
 | 
				
			||||||
	for _, p := range lowPriPods {
 | 
						for _, p := range lowPriPods {
 | 
				
			||||||
		if err := waitForPodToSchedule(cs, p); err != nil {
 | 
							if err := waitForPodToSchedule(cs, p); err != nil {
 | 
				
			||||||
			t.Fatalf("Pod %v didn't get scheduled: %v", p.Name, err)
 | 
								t.Fatalf("Pod %v/%v didn't get scheduled: %v", p.Namespace, p.Name, err)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	// Step 2. Create a medium priority pod.
 | 
						// Step 2. Create a medium priority pod.
 | 
				
			||||||
@@ -551,7 +551,7 @@ func TestNominatedNodeCleanUp(t *testing.T) {
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
	// Step 3. Check that nominated node name of the medium priority pod is set.
 | 
						// Step 3. Check that nominated node name of the medium priority pod is set.
 | 
				
			||||||
	if err := waitForNominatedNodeName(cs, medPriPod); err != nil {
 | 
						if err := waitForNominatedNodeName(cs, medPriPod); err != nil {
 | 
				
			||||||
		t.Errorf("NominatedNodeName annotation was not set for pod %v: %v", medPriPod.Name, err)
 | 
							t.Errorf("NominatedNodeName annotation was not set for pod %v/%v: %v", medPriPod.Namespace, medPriPod.Name, err)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	// Step 4. Create a high priority pod.
 | 
						// Step 4. Create a high priority pod.
 | 
				
			||||||
	podConf = initPausePod(cs, &pausePodConfig{
 | 
						podConf = initPausePod(cs, &pausePodConfig{
 | 
				
			||||||
@@ -569,7 +569,7 @@ func TestNominatedNodeCleanUp(t *testing.T) {
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
	// Step 5. Check that nominated node name of the high priority pod is set.
 | 
						// Step 5. Check that nominated node name of the high priority pod is set.
 | 
				
			||||||
	if err := waitForNominatedNodeName(cs, highPriPod); err != nil {
 | 
						if err := waitForNominatedNodeName(cs, highPriPod); err != nil {
 | 
				
			||||||
		t.Errorf("NominatedNodeName annotation was not set for pod %v: %v", medPriPod.Name, err)
 | 
							t.Errorf("NominatedNodeName annotation was not set for pod %v/%v: %v", medPriPod.Namespace, medPriPod.Name, err)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	// And the nominated node name of the medium priority pod is cleared.
 | 
						// And the nominated node name of the medium priority pod is cleared.
 | 
				
			||||||
	if err := wait.Poll(100*time.Millisecond, wait.ForeverTestTimeout, func() (bool, error) {
 | 
						if err := wait.Poll(100*time.Millisecond, wait.ForeverTestTimeout, func() (bool, error) {
 | 
				
			||||||
@@ -856,18 +856,18 @@ func TestPDBInPreemption(t *testing.T) {
 | 
				
			|||||||
		for i, p := range pods {
 | 
							for i, p := range pods {
 | 
				
			||||||
			if _, found := test.preemptedPodIndexes[i]; found {
 | 
								if _, found := test.preemptedPodIndexes[i]; found {
 | 
				
			||||||
				if err = wait.Poll(time.Second, wait.ForeverTestTimeout, podIsGettingEvicted(cs, p.Namespace, p.Name)); err != nil {
 | 
									if err = wait.Poll(time.Second, wait.ForeverTestTimeout, podIsGettingEvicted(cs, p.Namespace, p.Name)); err != nil {
 | 
				
			||||||
					t.Errorf("Test [%v]: Pod %v is not getting evicted.", test.description, p.Name)
 | 
										t.Errorf("Test [%v]: Pod %v/%v is not getting evicted.", test.description, p.Namespace, p.Name)
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
			} else {
 | 
								} else {
 | 
				
			||||||
				if p.DeletionTimestamp != nil {
 | 
									if p.DeletionTimestamp != nil {
 | 
				
			||||||
					t.Errorf("Test [%v]: Didn't expect pod %v to get preempted.", test.description, p.Name)
 | 
										t.Errorf("Test [%v]: Didn't expect pod %v/%v to get preempted.", test.description, p.Namespace, p.Name)
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		// Also check that the preemptor pod gets the annotation for nominated node name.
 | 
							// Also check that the preemptor pod gets the annotation for nominated node name.
 | 
				
			||||||
		if len(test.preemptedPodIndexes) > 0 {
 | 
							if len(test.preemptedPodIndexes) > 0 {
 | 
				
			||||||
			if err := waitForNominatedNodeName(cs, preemptor); err != nil {
 | 
								if err := waitForNominatedNodeName(cs, preemptor); err != nil {
 | 
				
			||||||
				t.Errorf("Test [%v]: NominatedNodeName annotation was not set for pod %v: %v", test.description, preemptor.Name, err)
 | 
									t.Errorf("Test [%v]: NominatedNodeName annotation was not set for pod %v/%v: %v", test.description, preemptor.Namespace, preemptor.Name, err)
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -498,10 +498,10 @@ func runPausePod(cs clientset.Interface, pod *v1.Pod) (*v1.Pod, error) {
 | 
				
			|||||||
		return nil, fmt.Errorf("Error creating pause pod: %v", err)
 | 
							return nil, fmt.Errorf("Error creating pause pod: %v", err)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if err = waitForPodToSchedule(cs, pod); err != nil {
 | 
						if err = waitForPodToSchedule(cs, pod); err != nil {
 | 
				
			||||||
		return pod, fmt.Errorf("Pod %v didn't schedule successfully. Error: %v", pod.Name, err)
 | 
							return pod, fmt.Errorf("Pod %v/%v didn't schedule successfully. Error: %v", pod.Namespace, pod.Name, err)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if pod, err = cs.CoreV1().Pods(pod.Namespace).Get(pod.Name, metav1.GetOptions{}); err != nil {
 | 
						if pod, err = cs.CoreV1().Pods(pod.Namespace).Get(pod.Name, metav1.GetOptions{}); err != nil {
 | 
				
			||||||
		return pod, fmt.Errorf("Error getting pod %v info: %v", pod.Name, err)
 | 
							return pod, fmt.Errorf("Error getting pod %v/%v info: %v", pod.Namespace, pod.Name, err)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	return pod, nil
 | 
						return pod, nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user