mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 19:56:01 +00:00
Merge pull request #73943 from bsalamat/fix_race
Fix races in scheduling queue tests
This commit is contained in:
commit
ace0bde081
@ -443,18 +443,26 @@ func TestPriorityQueue_NominatedPodsForNode(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestPriorityQueue_PendingPods(t *testing.T) {
|
func TestPriorityQueue_PendingPods(t *testing.T) {
|
||||||
|
makeSet := func(pods []*v1.Pod) map[*v1.Pod]struct{} {
|
||||||
|
pendingSet := map[*v1.Pod]struct{}{}
|
||||||
|
for _, p := range pods {
|
||||||
|
pendingSet[p] = struct{}{}
|
||||||
|
}
|
||||||
|
return pendingSet
|
||||||
|
}
|
||||||
|
|
||||||
q := NewPriorityQueue(nil)
|
q := NewPriorityQueue(nil)
|
||||||
q.Add(&medPriorityPod)
|
q.Add(&medPriorityPod)
|
||||||
addOrUpdateUnschedulablePod(q, &unschedulablePod)
|
addOrUpdateUnschedulablePod(q, &unschedulablePod)
|
||||||
addOrUpdateUnschedulablePod(q, &highPriorityPod)
|
addOrUpdateUnschedulablePod(q, &highPriorityPod)
|
||||||
expectedList := []*v1.Pod{&medPriorityPod, &unschedulablePod, &highPriorityPod}
|
expectedSet := makeSet([]*v1.Pod{&medPriorityPod, &unschedulablePod, &highPriorityPod})
|
||||||
if !reflect.DeepEqual(expectedList, q.PendingPods()) {
|
if !reflect.DeepEqual(expectedSet, makeSet(q.PendingPods())) {
|
||||||
t.Error("Unexpected list of pending Pods for node.")
|
t.Error("Unexpected list of pending Pods.")
|
||||||
}
|
}
|
||||||
// Move all to active queue. We should still see the same set of pods.
|
// Move all to active queue. We should still see the same set of pods.
|
||||||
q.MoveAllToActiveQueue()
|
q.MoveAllToActiveQueue()
|
||||||
if !reflect.DeepEqual(expectedList, q.PendingPods()) {
|
if !reflect.DeepEqual(expectedSet, makeSet(q.PendingPods())) {
|
||||||
t.Error("Unexpected list of pending Pods for node.")
|
t.Error("Unexpected list of pending Pods...")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -954,8 +962,8 @@ func TestHighProirotyFlushUnschedulableQLeftover(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
q.unschedulableQ.addOrUpdate(&highPod)
|
addOrUpdateUnschedulablePod(q, &highPod)
|
||||||
q.unschedulableQ.addOrUpdate(&midPod)
|
addOrUpdateUnschedulablePod(q, &midPod)
|
||||||
|
|
||||||
// Update pod condition to highPod.
|
// Update pod condition to highPod.
|
||||||
podutil.UpdatePodCondition(&highPod.Status, &v1.PodCondition{
|
podutil.UpdatePodCondition(&highPod.Status, &v1.PodCondition{
|
||||||
|
Loading…
Reference in New Issue
Block a user