@@ -18,6 +18,7 @@ package scheduling
1818
1919import (
2020 "context"
21+ "sync"
2122 "testing"
2223
2324 "github.com/google/go-cmp/cmp"
@@ -72,6 +73,7 @@ func TestSchedule(t *testing.T) {
7273 },
7374 },
7475 },
76+ Lock : sync.RWMutex {},
7577 },
7678 {
7779 Pod : & backend.Pod {NamespacedName : k8stypes.NamespacedName {Name : "pod2" }},
@@ -143,6 +145,7 @@ func TestSchedule(t *testing.T) {
143145 },
144146 },
145147 },
148+ Lock : sync.RWMutex {},
146149 },
147150 {
148151 Pod : & backend.Pod {NamespacedName : k8stypes.NamespacedName {Name : "pod2" }},
@@ -215,6 +218,7 @@ func TestSchedule(t *testing.T) {
215218 },
216219 },
217220 },
221+ Lock : sync.RWMutex {},
218222 },
219223 {
220224 Pod : & backend.Pod {NamespacedName : k8stypes.NamespacedName {Name : "pod2" }},
@@ -307,9 +311,9 @@ func TestSchedulePlugins(t *testing.T) {
307311 postSchedulePlugins : []plugins.PostSchedule {tp1 , tp2 },
308312 },
309313 input : []* podinfo.FakePodInfo {
310- {Pod : & backend.Pod {NamespacedName : k8stypes.NamespacedName {Name : "pod1" }}},
311- {Pod : & backend.Pod {NamespacedName : k8stypes.NamespacedName {Name : "pod2" }}},
312- {Pod : & backend.Pod {NamespacedName : k8stypes.NamespacedName {Name : "pod3" }}},
314+ {Pod : & backend.Pod {NamespacedName : k8stypes.NamespacedName {Name : "pod1" }}, Lock : sync. RWMutex {} },
315+ {Pod : & backend.Pod {NamespacedName : k8stypes.NamespacedName {Name : "pod2" }}, Lock : sync. RWMutex {} },
316+ {Pod : & backend.Pod {NamespacedName : k8stypes.NamespacedName {Name : "pod3" }}, Lock : sync. RWMutex {} },
313317 },
314318 wantTargetPod : k8stypes.NamespacedName {Name : "pod1" },
315319 targetPodScore : 1.1 ,
@@ -329,9 +333,9 @@ func TestSchedulePlugins(t *testing.T) {
329333 postSchedulePlugins : []plugins.PostSchedule {tp1 , tp2 },
330334 },
331335 input : []* podinfo.FakePodInfo {
332- {Pod : & backend.Pod {NamespacedName : k8stypes.NamespacedName {Name : "pod1" }}},
333- {Pod : & backend.Pod {NamespacedName : k8stypes.NamespacedName {Name : "pod2" }}},
334- {Pod : & backend.Pod {NamespacedName : k8stypes.NamespacedName {Name : "pod3" }}},
336+ {Pod : & backend.Pod {NamespacedName : k8stypes.NamespacedName {Name : "pod1" }}, Lock : sync. RWMutex {} },
337+ {Pod : & backend.Pod {NamespacedName : k8stypes.NamespacedName {Name : "pod2" }}, Lock : sync. RWMutex {} },
338+ {Pod : & backend.Pod {NamespacedName : k8stypes.NamespacedName {Name : "pod3" }}, Lock : sync. RWMutex {} },
335339 },
336340 wantTargetPod : k8stypes.NamespacedName {Name : "pod1" },
337341 targetPodScore : 50 ,
@@ -351,9 +355,9 @@ func TestSchedulePlugins(t *testing.T) {
351355 postSchedulePlugins : []plugins.PostSchedule {tp1 , tp2 },
352356 },
353357 input : []* podinfo.FakePodInfo {
354- {Pod : & backend.Pod {NamespacedName : k8stypes.NamespacedName {Name : "pod1" }}},
355- {Pod : & backend.Pod {NamespacedName : k8stypes.NamespacedName {Name : "pod2" }}},
356- {Pod : & backend.Pod {NamespacedName : k8stypes.NamespacedName {Name : "pod3" }}},
358+ {Pod : & backend.Pod {NamespacedName : k8stypes.NamespacedName {Name : "pod1" }}, Lock : sync. RWMutex {} },
359+ {Pod : & backend.Pod {NamespacedName : k8stypes.NamespacedName {Name : "pod2" }}, Lock : sync. RWMutex {} },
360+ {Pod : & backend.Pod {NamespacedName : k8stypes.NamespacedName {Name : "pod3" }}, Lock : sync. RWMutex {} },
357361 },
358362 numPodsToScore : 0 ,
359363 err : true , // no available pods to server after filter all
0 commit comments