@@ -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
f .RunPreFilterPlugins (ctx , state , nil )
1535
1549
f .RunPreFilterExtensionAddPod (ctx , state , nil , nil , nil )
@@ -1718,6 +1732,9 @@ func TestRunPreFilterPlugins(t *testing.T) {
1718
1732
if err != nil {
1719
1733
t .Fatalf ("Failed to create framework for testing: %v" , err )
1720
1734
}
1735
+ defer func () {
1736
+ _ = f .Close ()
1737
+ }()
1721
1738
1722
1739
state := framework .NewCycleState ()
1723
1740
result , status , _ := f .RunPreFilterPlugins (ctx , state , nil )
@@ -1808,6 +1825,9 @@ func TestRunPreFilterExtensionRemovePod(t *testing.T) {
1808
1825
if err != nil {
1809
1826
t .Fatalf ("Failed to create framework for testing: %v" , err )
1810
1827
}
1828
+ defer func () {
1829
+ _ = f .Close ()
1830
+ }()
1811
1831
1812
1832
state := framework .NewCycleState ()
1813
1833
state .SkipFilterPlugins = tt .skippedPluginNames
@@ -1892,6 +1912,9 @@ func TestRunPreFilterExtensionAddPod(t *testing.T) {
1892
1912
if err != nil {
1893
1913
t .Fatalf ("Failed to create framework for testing: %v" , err )
1894
1914
}
1915
+ defer func () {
1916
+ _ = f .Close ()
1917
+ }()
1895
1918
1896
1919
state := framework .NewCycleState ()
1897
1920
state .SkipFilterPlugins = tt .skippedPluginNames
@@ -2095,6 +2118,9 @@ func TestFilterPlugins(t *testing.T) {
2095
2118
if err != nil {
2096
2119
t .Fatalf ("fail to create framework: %s" , err )
2097
2120
}
2121
+ defer func () {
2122
+ _ = f .Close ()
2123
+ }()
2098
2124
state := framework .NewCycleState ()
2099
2125
state .SkipFilterPlugins = tt .skippedPlugins
2100
2126
gotStatus := f .RunFilterPlugins (ctx , state , pod , nil )
@@ -2219,6 +2245,9 @@ func TestPostFilterPlugins(t *testing.T) {
2219
2245
if err != nil {
2220
2246
t .Fatalf ("fail to create framework: %s" , err )
2221
2247
}
2248
+ defer func () {
2249
+ _ = f .Close ()
2250
+ }()
2222
2251
_ , gotStatus := f .RunPostFilterPlugins (ctx , nil , pod , nil )
2223
2252
if ! reflect .DeepEqual (gotStatus , tt .wantStatus ) {
2224
2253
t .Errorf ("Unexpected status. got: %v, want: %v" , gotStatus , tt .wantStatus )
@@ -2370,6 +2399,9 @@ func TestFilterPluginsWithNominatedPods(t *testing.T) {
2370
2399
if err != nil {
2371
2400
t .Fatalf ("fail to create framework: %s" , err )
2372
2401
}
2402
+ defer func () {
2403
+ _ = f .Close ()
2404
+ }()
2373
2405
tt .nodeInfo .SetNode (tt .node )
2374
2406
gotStatus := f .RunFilterPluginsWithNominatedPods (ctx , framework .NewCycleState (), tt .pod , tt .nodeInfo )
2375
2407
if diff := cmp .Diff (gotStatus , tt .wantStatus , cmpOpts ... ); diff != "" {
@@ -2527,6 +2559,9 @@ func TestPreBindPlugins(t *testing.T) {
2527
2559
if err != nil {
2528
2560
t .Fatalf ("fail to create framework: %s" , err )
2529
2561
}
2562
+ defer func () {
2563
+ _ = f .Close ()
2564
+ }()
2530
2565
2531
2566
status := f .RunPreBindPlugins (ctx , nil , pod , "" )
2532
2567
@@ -2682,6 +2717,9 @@ func TestReservePlugins(t *testing.T) {
2682
2717
ctx , cancel := context .WithCancel (context .Background ())
2683
2718
defer cancel ()
2684
2719
f , err := newFrameworkWithQueueSortAndBind (ctx , registry , profile )
2720
+ defer func () {
2721
+ _ = f .Close ()
2722
+ }()
2685
2723
if err != nil {
2686
2724
t .Fatalf ("fail to create framework: %s" , err )
2687
2725
}
@@ -2810,6 +2848,9 @@ func TestPermitPlugins(t *testing.T) {
2810
2848
f , err := newFrameworkWithQueueSortAndBind (ctx , registry , profile ,
2811
2849
WithWaitingPods (NewWaitingPodsMap ()),
2812
2850
)
2851
+ defer func () {
2852
+ _ = f .Close ()
2853
+ }()
2813
2854
if err != nil {
2814
2855
t .Fatalf ("fail to create framework: %s" , err )
2815
2856
}
@@ -2999,6 +3040,9 @@ func TestRecordingMetrics(t *testing.T) {
2999
3040
cancel ()
3000
3041
t .Fatalf ("Failed to create framework for testing: %v" , err )
3001
3042
}
3043
+ defer func () {
3044
+ _ = f .Close ()
3045
+ }()
3002
3046
3003
3047
tt .action (f )
3004
3048
@@ -3112,6 +3156,9 @@ func TestRunBindPlugins(t *testing.T) {
3112
3156
cancel ()
3113
3157
t .Fatal (err )
3114
3158
}
3159
+ defer func () {
3160
+ _ = fwk .Close ()
3161
+ }()
3115
3162
3116
3163
st := fwk .RunBindPlugins (context .Background (), state , pod , "" )
3117
3164
if st .Code () != tt .wantStatus {
@@ -3170,6 +3217,9 @@ func TestPermitWaitDurationMetric(t *testing.T) {
3170
3217
if err != nil {
3171
3218
t .Fatalf ("Failed to create framework for testing: %v" , err )
3172
3219
}
3220
+ defer func () {
3221
+ _ = f .Close ()
3222
+ }()
3173
3223
3174
3224
f .RunPermitPlugins (ctx , nil , pod , "" )
3175
3225
f .WaitOnPermit (ctx , pod )
@@ -3228,6 +3278,9 @@ func TestWaitOnPermit(t *testing.T) {
3228
3278
if err != nil {
3229
3279
t .Fatalf ("Failed to create framework for testing: %v" , err )
3230
3280
}
3281
+ defer func () {
3282
+ _ = f .Close ()
3283
+ }()
3231
3284
3232
3285
runPermitPluginsStatus := f .RunPermitPlugins (ctx , nil , pod , "" )
3233
3286
if runPermitPluginsStatus .Code () != framework .Wait {
@@ -3282,6 +3335,9 @@ func TestListPlugins(t *testing.T) {
3282
3335
if err != nil {
3283
3336
t .Fatalf ("Failed to create framework for testing: %v" , err )
3284
3337
}
3338
+ defer func () {
3339
+ _ = f .Close ()
3340
+ }()
3285
3341
got := f .ListPlugins ()
3286
3342
if diff := cmp .Diff (tt .want , got ); diff != "" {
3287
3343
t .Errorf ("unexpected plugins (-want,+got):\n %s" , diff )
0 commit comments