@@ -217,7 +217,7 @@ func TestSelectHost(t *testing.T) {
217
217
}
218
218
219
219
func TestGenericScheduler (t * testing.T ) {
220
- algorithmpredicates .SetPredicatesOrdering (order )
220
+ defer algorithmpredicates .SetPredicatesOrderingDuringTest (order )( )
221
221
tests := []struct {
222
222
name string
223
223
predicates map [string ]algorithmpredicates.FitPredicate
@@ -479,7 +479,6 @@ func TestGenericScheduler(t *testing.T) {
479
479
480
480
// makeScheduler makes a simple genericScheduler for testing.
481
481
func makeScheduler (predicates map [string ]algorithmpredicates.FitPredicate , nodes []* v1.Node ) * genericScheduler {
482
- algorithmpredicates .SetPredicatesOrdering (order )
483
482
cache := internalcache .New (time .Duration (0 ), wait .NeverStop )
484
483
fwk , _ := framework .NewFramework (EmptyPluginRegistry , nil )
485
484
for _ , n := range nodes {
@@ -503,6 +502,7 @@ func makeScheduler(predicates map[string]algorithmpredicates.FitPredicate, nodes
503
502
}
504
503
505
504
func TestFindFitAllError (t * testing.T ) {
505
+ defer algorithmpredicates .SetPredicatesOrderingDuringTest (order )()
506
506
predicates := map [string ]algorithmpredicates.FitPredicate {"true" : truePredicate , "matches" : matchesPredicate }
507
507
nodes := makeNodeList ([]string {"3" , "2" , "1" })
508
508
scheduler := makeScheduler (predicates , nodes )
@@ -531,6 +531,7 @@ func TestFindFitAllError(t *testing.T) {
531
531
}
532
532
533
533
func TestFindFitSomeError (t * testing.T ) {
534
+ defer algorithmpredicates .SetPredicatesOrderingDuringTest (order )()
534
535
predicates := map [string ]algorithmpredicates.FitPredicate {"true" : truePredicate , "matches" : matchesPredicate }
535
536
nodes := makeNodeList ([]string {"3" , "2" , "1" })
536
537
scheduler := makeScheduler (predicates , nodes )
@@ -846,7 +847,7 @@ var startTime20190107 = metav1.Date(2019, 1, 7, 1, 1, 1, 0, time.UTC)
846
847
// TestSelectNodesForPreemption tests selectNodesForPreemption. This test assumes
847
848
// that podsFitsOnNode works correctly and is tested separately.
848
849
func TestSelectNodesForPreemption (t * testing.T ) {
849
- algorithmpredicates .SetPredicatesOrdering (order )
850
+ defer algorithmpredicates .SetPredicatesOrderingDuringTest (order )( )
850
851
tests := []struct {
851
852
name string
852
853
predicates map [string ]algorithmpredicates.FitPredicate
@@ -1005,7 +1006,7 @@ func TestSelectNodesForPreemption(t *testing.T) {
1005
1006
1006
1007
// TestPickOneNodeForPreemption tests pickOneNodeForPreemption.
1007
1008
func TestPickOneNodeForPreemption (t * testing.T ) {
1008
- algorithmpredicates .SetPredicatesOrdering (order )
1009
+ defer algorithmpredicates .SetPredicatesOrderingDuringTest (order )( )
1009
1010
tests := []struct {
1010
1011
name string
1011
1012
predicates map [string ]algorithmpredicates.FitPredicate
@@ -1321,6 +1322,7 @@ func TestNodesWherePreemptionMightHelp(t *testing.T) {
1321
1322
}
1322
1323
1323
1324
func TestPreempt (t * testing.T ) {
1325
+ defer algorithmpredicates .SetPredicatesOrderingDuringTest (order )()
1324
1326
failedPredMap := FailedPredicateMap {
1325
1327
"machine1" : []algorithmpredicates.PredicateFailureReason {algorithmpredicates .NewInsufficientResourceError (v1 .ResourceMemory , 1000 , 500 , 300 )},
1326
1328
"machine2" : []algorithmpredicates.PredicateFailureReason {algorithmpredicates .ErrDiskConflict },
0 commit comments