@@ -904,6 +904,11 @@ func TestNewFrameworkMultiPointExpansion(t *testing.T) {
904
904
ctx , cancel := context .WithCancel (ctx )
905
905
defer cancel ()
906
906
fw , err := NewFramework (ctx , registry , & config.KubeSchedulerProfile {Plugins : tc .plugins })
907
+ defer func () {
908
+ if fw != nil {
909
+ _ = fw .Close ()
910
+ }
911
+ }()
907
912
if err != nil {
908
913
if tc .wantErr == "" || ! strings .Contains (err .Error (), tc .wantErr ) {
909
914
t .Fatalf ("Unexpected error, got %v, expect: %s" , err , tc .wantErr )
@@ -913,7 +918,6 @@ func TestNewFrameworkMultiPointExpansion(t *testing.T) {
913
918
t .Fatalf ("Unexpected error, got %v, expect: %s" , err , tc .wantErr )
914
919
}
915
920
}
916
-
917
921
if tc .wantErr == "" {
918
922
if diff := cmp .Diff (tc .wantPlugins , fw .ListPlugins ()); diff != "" {
919
923
t .Fatalf ("Unexpected eventToPlugin map (-want,+got):%s" , diff )
@@ -969,7 +973,9 @@ func TestPreEnqueuePlugins(t *testing.T) {
969
973
if err != nil {
970
974
t .Fatalf ("fail to create framework: %s" , err )
971
975
}
972
-
976
+ defer func () {
977
+ _ = f .Close ()
978
+ }()
973
979
got := f .PreEnqueuePlugins ()
974
980
if ! reflect .DeepEqual (got , tt .want ) {
975
981
t .Errorf ("PreEnqueuePlugins(): want %v, but got %v" , tt .want , got )
@@ -1092,7 +1098,9 @@ func TestRunPreScorePlugins(t *testing.T) {
1092
1098
if err != nil {
1093
1099
t .Fatalf ("Failed to create framework for testing: %v" , err )
1094
1100
}
1095
-
1101
+ defer func () {
1102
+ _ = f .Close ()
1103
+ }()
1096
1104
state := framework .NewCycleState ()
1097
1105
status := f .RunPreScorePlugins (ctx , state , nil , nil )
1098
1106
if status .Code () != tt .wantStatusCode {
@@ -1486,6 +1494,9 @@ func TestRunScorePlugins(t *testing.T) {
1486
1494
if err != nil {
1487
1495
t .Fatalf ("Failed to create framework for testing: %v" , err )
1488
1496
}
1497
+ defer func () {
1498
+ _ = f .Close ()
1499
+ }()
1489
1500
1490
1501
state := framework .NewCycleState ()
1491
1502
state .SkipScorePlugins = tt .skippedPlugins
@@ -1530,6 +1541,9 @@ func TestPreFilterPlugins(t *testing.T) {
1530
1541
if err != nil {
1531
1542
t .Fatalf ("Failed to create framework for testing: %v" , err )
1532
1543
}
1544
+ defer func () {
1545
+ _ = f .Close ()
1546
+ }()
1533
1547
state := framework .NewCycleState ()
1534
1548
1535
1549
f .RunPreFilterPlugins (ctx , state , nil )
@@ -1719,6 +1733,9 @@ func TestRunPreFilterPlugins(t *testing.T) {
1719
1733
if err != nil {
1720
1734
t .Fatalf ("Failed to create framework for testing: %v" , err )
1721
1735
}
1736
+ defer func () {
1737
+ _ = f .Close ()
1738
+ }()
1722
1739
1723
1740
state := framework .NewCycleState ()
1724
1741
result , status := f .RunPreFilterPlugins (ctx , state , nil )
@@ -1809,6 +1826,9 @@ func TestRunPreFilterExtensionRemovePod(t *testing.T) {
1809
1826
if err != nil {
1810
1827
t .Fatalf ("Failed to create framework for testing: %v" , err )
1811
1828
}
1829
+ defer func () {
1830
+ _ = f .Close ()
1831
+ }()
1812
1832
1813
1833
state := framework .NewCycleState ()
1814
1834
state .SkipFilterPlugins = tt .skippedPluginNames
@@ -1893,6 +1913,9 @@ func TestRunPreFilterExtensionAddPod(t *testing.T) {
1893
1913
if err != nil {
1894
1914
t .Fatalf ("Failed to create framework for testing: %v" , err )
1895
1915
}
1916
+ defer func () {
1917
+ _ = f .Close ()
1918
+ }()
1896
1919
1897
1920
state := framework .NewCycleState ()
1898
1921
state .SkipFilterPlugins = tt .skippedPluginNames
@@ -2096,6 +2119,9 @@ func TestFilterPlugins(t *testing.T) {
2096
2119
if err != nil {
2097
2120
t .Fatalf ("fail to create framework: %s" , err )
2098
2121
}
2122
+ defer func () {
2123
+ _ = f .Close ()
2124
+ }()
2099
2125
state := framework .NewCycleState ()
2100
2126
state .SkipFilterPlugins = tt .skippedPlugins
2101
2127
gotStatus := f .RunFilterPlugins (ctx , state , pod , nil )
@@ -2220,6 +2246,9 @@ func TestPostFilterPlugins(t *testing.T) {
2220
2246
if err != nil {
2221
2247
t .Fatalf ("fail to create framework: %s" , err )
2222
2248
}
2249
+ defer func () {
2250
+ _ = f .Close ()
2251
+ }()
2223
2252
_ , gotStatus := f .RunPostFilterPlugins (ctx , nil , pod , nil )
2224
2253
if ! reflect .DeepEqual (gotStatus , tt .wantStatus ) {
2225
2254
t .Errorf ("Unexpected status. got: %v, want: %v" , gotStatus , tt .wantStatus )
@@ -2371,6 +2400,9 @@ func TestFilterPluginsWithNominatedPods(t *testing.T) {
2371
2400
if err != nil {
2372
2401
t .Fatalf ("fail to create framework: %s" , err )
2373
2402
}
2403
+ defer func () {
2404
+ _ = f .Close ()
2405
+ }()
2374
2406
tt .nodeInfo .SetNode (tt .node )
2375
2407
gotStatus := f .RunFilterPluginsWithNominatedPods (ctx , framework .NewCycleState (), tt .pod , tt .nodeInfo )
2376
2408
if diff := cmp .Diff (gotStatus , tt .wantStatus , cmpOpts ... ); diff != "" {
@@ -2528,6 +2560,9 @@ func TestPreBindPlugins(t *testing.T) {
2528
2560
if err != nil {
2529
2561
t .Fatalf ("fail to create framework: %s" , err )
2530
2562
}
2563
+ defer func () {
2564
+ _ = f .Close ()
2565
+ }()
2531
2566
2532
2567
status := f .RunPreBindPlugins (ctx , nil , pod , "" )
2533
2568
@@ -2683,6 +2718,9 @@ func TestReservePlugins(t *testing.T) {
2683
2718
ctx , cancel := context .WithCancel (context .Background ())
2684
2719
defer cancel ()
2685
2720
f , err := newFrameworkWithQueueSortAndBind (ctx , registry , profile )
2721
+ defer func () {
2722
+ _ = f .Close ()
2723
+ }()
2686
2724
if err != nil {
2687
2725
t .Fatalf ("fail to create framework: %s" , err )
2688
2726
}
@@ -2811,6 +2849,9 @@ func TestPermitPlugins(t *testing.T) {
2811
2849
f , err := newFrameworkWithQueueSortAndBind (ctx , registry , profile ,
2812
2850
WithWaitingPods (NewWaitingPodsMap ()),
2813
2851
)
2852
+ defer func () {
2853
+ _ = f .Close ()
2854
+ }()
2814
2855
if err != nil {
2815
2856
t .Fatalf ("fail to create framework: %s" , err )
2816
2857
}
@@ -3000,6 +3041,9 @@ func TestRecordingMetrics(t *testing.T) {
3000
3041
cancel ()
3001
3042
t .Fatalf ("Failed to create framework for testing: %v" , err )
3002
3043
}
3044
+ defer func () {
3045
+ _ = f .Close ()
3046
+ }()
3003
3047
3004
3048
tt .action (f )
3005
3049
@@ -3113,6 +3157,9 @@ func TestRunBindPlugins(t *testing.T) {
3113
3157
cancel ()
3114
3158
t .Fatal (err )
3115
3159
}
3160
+ defer func () {
3161
+ _ = fwk .Close ()
3162
+ }()
3116
3163
3117
3164
st := fwk .RunBindPlugins (context .Background (), state , pod , "" )
3118
3165
if st .Code () != tt .wantStatus {
@@ -3171,6 +3218,9 @@ func TestPermitWaitDurationMetric(t *testing.T) {
3171
3218
if err != nil {
3172
3219
t .Fatalf ("Failed to create framework for testing: %v" , err )
3173
3220
}
3221
+ defer func () {
3222
+ _ = f .Close ()
3223
+ }()
3174
3224
3175
3225
f .RunPermitPlugins (ctx , nil , pod , "" )
3176
3226
f .WaitOnPermit (ctx , pod )
@@ -3229,6 +3279,9 @@ func TestWaitOnPermit(t *testing.T) {
3229
3279
if err != nil {
3230
3280
t .Fatalf ("Failed to create framework for testing: %v" , err )
3231
3281
}
3282
+ defer func () {
3283
+ _ = f .Close ()
3284
+ }()
3232
3285
3233
3286
runPermitPluginsStatus := f .RunPermitPlugins (ctx , nil , pod , "" )
3234
3287
if runPermitPluginsStatus .Code () != framework .Wait {
@@ -3283,6 +3336,9 @@ func TestListPlugins(t *testing.T) {
3283
3336
if err != nil {
3284
3337
t .Fatalf ("Failed to create framework for testing: %v" , err )
3285
3338
}
3339
+ defer func () {
3340
+ _ = f .Close ()
3341
+ }()
3286
3342
got := f .ListPlugins ()
3287
3343
if diff := cmp .Diff (tt .want , got ); diff != "" {
3288
3344
t .Errorf ("unexpected plugins (-want,+got):\n %s" , diff )
0 commit comments