@@ -28,7 +28,6 @@ import (
28
28
v1 "k8s.io/api/core/v1"
29
29
"k8s.io/apimachinery/pkg/api/resource"
30
30
apiruntime "k8s.io/apimachinery/pkg/runtime"
31
- "k8s.io/apimachinery/pkg/util/wait"
32
31
"k8s.io/client-go/informers"
33
32
clientsetfake "k8s.io/client-go/kubernetes/fake"
34
33
"k8s.io/client-go/tools/events"
@@ -141,6 +140,9 @@ func TestPreFilter(t *testing.T) {
141
140
}
142
141
for _ , tt := range tests {
143
142
t .Run (tt .name , func (t * testing.T ) {
143
+ ctx , cancel := context .WithCancel (context .Background ())
144
+ defer cancel ()
145
+
144
146
var registerPlugins []st.RegisterPluginFunc
145
147
registeredPlugins := append (
146
148
registerPlugins ,
@@ -149,7 +151,7 @@ func TestPreFilter(t *testing.T) {
149
151
)
150
152
151
153
fwk , err := st .NewFramework (
152
- registeredPlugins , "" , wait . NeverStop ,
154
+ ctx , registeredPlugins , "" ,
153
155
frameworkruntime .WithPodNominator (testutil .NewPodNominator (nil )),
154
156
frameworkruntime .WithSnapshotSharedLister (testutil .NewFakeSharedLister (make ([]* v1.Pod , 0 ), make ([]* v1.Node , 0 ))),
155
157
)
@@ -316,9 +318,9 @@ func TestPostFilter(t *testing.T) {
316
318
defer cancel ()
317
319
318
320
fwk , err := st .NewFramework (
321
+ ctx ,
319
322
registeredPlugins ,
320
323
"default-scheduler" ,
321
- ctx .Done (),
322
324
frameworkruntime .WithClientSet (cs ),
323
325
frameworkruntime .WithEventRecorder (& events.FakeRecorder {}),
324
326
frameworkruntime .WithInformerFactory (informerFactory ),
@@ -439,6 +441,9 @@ func TestReserve(t *testing.T) {
439
441
}
440
442
for _ , tt := range tests {
441
443
t .Run (tt .name , func (t * testing.T ) {
444
+ ctx , cancel := context .WithCancel (context .Background ())
445
+ defer cancel ()
446
+
442
447
var registerPlugins []st.RegisterPluginFunc
443
448
registeredPlugins := append (
444
449
registerPlugins ,
@@ -447,7 +452,7 @@ func TestReserve(t *testing.T) {
447
452
)
448
453
449
454
fwk , err := st .NewFramework (
450
- registeredPlugins , "" , wait . NeverStop ,
455
+ ctx , registeredPlugins , "" ,
451
456
frameworkruntime .WithPodNominator (testutil .NewPodNominator (nil )),
452
457
frameworkruntime .WithSnapshotSharedLister (testutil .NewFakeSharedLister (make ([]* v1.Pod , 0 ), make ([]* v1.Node , 0 ))),
453
458
)
@@ -558,6 +563,9 @@ func TestUnreserve(t *testing.T) {
558
563
}
559
564
for _ , tt := range tests {
560
565
t .Run (tt .name , func (t * testing.T ) {
566
+ ctx , cancel := context .WithCancel (context .Background ())
567
+ defer cancel ()
568
+
561
569
var registerPlugins []st.RegisterPluginFunc
562
570
registeredPlugins := append (
563
571
registerPlugins ,
@@ -566,7 +574,7 @@ func TestUnreserve(t *testing.T) {
566
574
)
567
575
568
576
fwk , err := st .NewFramework (
569
- registeredPlugins , "" , wait . NeverStop ,
577
+ ctx , registeredPlugins , "" ,
570
578
frameworkruntime .WithPodNominator (testutil .NewPodNominator (nil )),
571
579
frameworkruntime .WithSnapshotSharedLister (testutil .NewFakeSharedLister (make ([]* v1.Pod , 0 ), make ([]* v1.Node , 0 ))),
572
580
)
@@ -713,11 +721,12 @@ func TestDryRunPreemption(t *testing.T) {
713
721
registeredPlugins := makeRegisteredPlugin ()
714
722
715
723
cs := clientsetfake .NewSimpleClientset ()
716
- ctx := context .Background ()
724
+ ctx , cancel := context .WithCancel (context .Background ())
725
+ defer cancel ()
717
726
fwk , err := st .NewFramework (
727
+ ctx ,
718
728
registeredPlugins ,
719
729
"default-scheduler" ,
720
- ctx .Done (),
721
730
frameworkruntime .WithClientSet (cs ),
722
731
frameworkruntime .WithEventRecorder (& events.FakeRecorder {}),
723
732
frameworkruntime .WithPodNominator (testutil .NewPodNominator (nil )),
@@ -960,12 +969,13 @@ func TestPodEligibleToPreemptOthers(t *testing.T) {
960
969
t .Run (tt .name , func (t * testing.T ) {
961
970
registeredPlugins := makeRegisteredPlugin ()
962
971
cs := clientsetfake .NewSimpleClientset ()
963
- ctx := context .Background ()
972
+ ctx , cancel := context .WithCancel (context .Background ())
973
+ defer cancel ()
964
974
965
975
fwk , err := st .NewFramework (
976
+ ctx ,
966
977
registeredPlugins ,
967
978
"default-scheduler" ,
968
- ctx .Done (),
969
979
frameworkruntime .WithClientSet (cs ),
970
980
frameworkruntime .WithEventRecorder (& events.FakeRecorder {}),
971
981
frameworkruntime .WithPodNominator (testutil .NewPodNominator (nil )),
@@ -1116,6 +1126,9 @@ func TestAddElasticQuota(t *testing.T) {
1116
1126
}
1117
1127
for _ , tt := range tests {
1118
1128
t .Run (tt .name , func (t * testing.T ) {
1129
+ ctx , cancel := context .WithCancel (context .Background ())
1130
+ defer cancel ()
1131
+
1119
1132
var registerPlugins []st.RegisterPluginFunc
1120
1133
registeredPlugins := append (
1121
1134
registerPlugins ,
@@ -1124,7 +1137,7 @@ func TestAddElasticQuota(t *testing.T) {
1124
1137
)
1125
1138
1126
1139
fwk , err := st .NewFramework (
1127
- registeredPlugins , "" , wait . NeverStop ,
1140
+ ctx , registeredPlugins , "" ,
1128
1141
frameworkruntime .WithPodNominator (testutil .NewPodNominator (nil )),
1129
1142
frameworkruntime .WithSnapshotSharedLister (testutil .NewFakeSharedLister (make ([]* v1.Pod , 0 ), make ([]* v1.Node , 0 ))),
1130
1143
)
@@ -1186,6 +1199,9 @@ func TestUpdateElasticQuota(t *testing.T) {
1186
1199
}
1187
1200
for _ , tt := range tests {
1188
1201
t .Run (tt .name , func (t * testing.T ) {
1202
+ ctx , cancel := context .WithCancel (context .Background ())
1203
+ defer cancel ()
1204
+
1189
1205
var registerPlugins []st.RegisterPluginFunc
1190
1206
registeredPlugins := append (
1191
1207
registerPlugins ,
@@ -1194,7 +1210,7 @@ func TestUpdateElasticQuota(t *testing.T) {
1194
1210
)
1195
1211
1196
1212
fwk , err := st .NewFramework (
1197
- registeredPlugins , "" , wait . NeverStop ,
1213
+ ctx , registeredPlugins , "" ,
1198
1214
frameworkruntime .WithPodNominator (testutil .NewPodNominator (nil )),
1199
1215
frameworkruntime .WithSnapshotSharedLister (testutil .NewFakeSharedLister (make ([]* v1.Pod , 0 ), make ([]* v1.Node , 0 ))),
1200
1216
)
@@ -1235,6 +1251,9 @@ func TestDeleteElasticQuota(t *testing.T) {
1235
1251
}
1236
1252
for _ , tt := range tests {
1237
1253
t .Run (tt .name , func (t * testing.T ) {
1254
+ ctx , cancel := context .WithCancel (context .Background ())
1255
+ defer cancel ()
1256
+
1238
1257
var registerPlugins []st.RegisterPluginFunc
1239
1258
registeredPlugins := append (
1240
1259
registerPlugins ,
@@ -1243,7 +1262,7 @@ func TestDeleteElasticQuota(t *testing.T) {
1243
1262
)
1244
1263
1245
1264
fwk , err := st .NewFramework (
1246
- registeredPlugins , "" , wait . NeverStop ,
1265
+ ctx , registeredPlugins , "" ,
1247
1266
frameworkruntime .WithPodNominator (testutil .NewPodNominator (nil )),
1248
1267
frameworkruntime .WithSnapshotSharedLister (testutil .NewFakeSharedLister (make ([]* v1.Pod , 0 ), make ([]* v1.Node , 0 ))),
1249
1268
)
@@ -1310,6 +1329,9 @@ func TestAddPod(t *testing.T) {
1310
1329
}
1311
1330
for _ , tt := range tests {
1312
1331
t .Run (tt .name , func (t * testing.T ) {
1332
+ ctx , cancel := context .WithCancel (context .Background ())
1333
+ defer cancel ()
1334
+
1313
1335
var registerPlugins []st.RegisterPluginFunc
1314
1336
registeredPlugins := append (
1315
1337
registerPlugins ,
@@ -1318,7 +1340,7 @@ func TestAddPod(t *testing.T) {
1318
1340
)
1319
1341
1320
1342
fwk , err := st .NewFramework (
1321
- registeredPlugins , "" , wait . NeverStop ,
1343
+ ctx , registeredPlugins , "" ,
1322
1344
frameworkruntime .WithPodNominator (testutil .NewPodNominator (nil )),
1323
1345
frameworkruntime .WithSnapshotSharedLister (testutil .NewFakeSharedLister (make ([]* v1.Pod , 0 ), make ([]* v1.Node , 0 ))),
1324
1346
)
@@ -1419,6 +1441,9 @@ func TestUpdatePod(t *testing.T) {
1419
1441
}
1420
1442
for _ , tt := range tests {
1421
1443
t .Run (tt .name , func (t * testing.T ) {
1444
+ ctx , cancel := context .WithCancel (context .Background ())
1445
+ defer cancel ()
1446
+
1422
1447
var registerPlugins []st.RegisterPluginFunc
1423
1448
registeredPlugins := append (
1424
1449
registerPlugins ,
@@ -1427,7 +1452,7 @@ func TestUpdatePod(t *testing.T) {
1427
1452
)
1428
1453
1429
1454
fwk , err := st .NewFramework (
1430
- registeredPlugins , "" , wait . NeverStop ,
1455
+ ctx , registeredPlugins , "" ,
1431
1456
frameworkruntime .WithPodNominator (testutil .NewPodNominator (nil )),
1432
1457
frameworkruntime .WithSnapshotSharedLister (testutil .NewFakeSharedLister (make ([]* v1.Pod , 0 ), make ([]* v1.Node , 0 ))),
1433
1458
)
@@ -1533,6 +1558,9 @@ func TestDeletePod(t *testing.T) {
1533
1558
}
1534
1559
for _ , tt := range tests {
1535
1560
t .Run (tt .name , func (t * testing.T ) {
1561
+ ctx , cancel := context .WithCancel (context .Background ())
1562
+ defer cancel ()
1563
+
1536
1564
var registerPlugins []st.RegisterPluginFunc
1537
1565
registeredPlugins := append (
1538
1566
registerPlugins ,
@@ -1541,7 +1569,7 @@ func TestDeletePod(t *testing.T) {
1541
1569
)
1542
1570
1543
1571
fwk , err := st .NewFramework (
1544
- registeredPlugins , "" , wait . NeverStop ,
1572
+ ctx , registeredPlugins , "" ,
1545
1573
frameworkruntime .WithPodNominator (testutil .NewPodNominator (nil )),
1546
1574
frameworkruntime .WithSnapshotSharedLister (testutil .NewFakeSharedLister (make ([]* v1.Pod , 0 ), make ([]* v1.Node , 0 ))),
1547
1575
)
0 commit comments