mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 19:56:01 +00:00
Merge pull request #91874 from gaurav1086/TestSchedulingQueue_Close_fix_race_condition
TestSchedulingQueue: Remove the unnecessary slice and for loop
This commit is contained in:
commit
b8f24173da
@ -710,35 +710,22 @@ func TestUnschedulablePodsMap(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestSchedulingQueue_Close(t *testing.T) {
|
func TestSchedulingQueue_Close(t *testing.T) {
|
||||||
tests := []struct {
|
q := NewPriorityQueue(newDefaultQueueSort())
|
||||||
name string
|
wantErr := fmt.Errorf(queueClosed)
|
||||||
q SchedulingQueue
|
wg := sync.WaitGroup{}
|
||||||
expectedErr error
|
wg.Add(1)
|
||||||
}{
|
go func() {
|
||||||
{
|
defer wg.Done()
|
||||||
name: "PriorityQueue close",
|
pod, err := q.Pop()
|
||||||
q: NewPriorityQueue(newDefaultQueueSort()),
|
if err.Error() != wantErr.Error() {
|
||||||
expectedErr: fmt.Errorf(queueClosed),
|
t.Errorf("Expected err %q from Pop() if queue is closed, but got %q", wantErr.Error(), err.Error())
|
||||||
},
|
}
|
||||||
}
|
if pod != nil {
|
||||||
for _, test := range tests {
|
t.Errorf("Expected pod nil from Pop() if queue is closed, but got: %v", pod)
|
||||||
t.Run(test.name, func(t *testing.T) {
|
}
|
||||||
wg := sync.WaitGroup{}
|
}()
|
||||||
wg.Add(1)
|
q.Close()
|
||||||
go func() {
|
wg.Wait()
|
||||||
defer wg.Done()
|
|
||||||
pod, err := test.q.Pop()
|
|
||||||
if err.Error() != test.expectedErr.Error() {
|
|
||||||
t.Errorf("Expected err %q from Pop() if queue is closed, but got %q", test.expectedErr.Error(), err.Error())
|
|
||||||
}
|
|
||||||
if pod != nil {
|
|
||||||
t.Errorf("Expected pod nil from Pop() if queue is closed, but got: %v", pod)
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
test.q.Close()
|
|
||||||
wg.Wait()
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TestRecentlyTriedPodsGoBack tests that pods which are recently tried and are
|
// TestRecentlyTriedPodsGoBack tests that pods which are recently tried and are
|
||||||
|
Loading…
Reference in New Issue
Block a user