@@ -24,6 +24,7 @@ import (
24
24
"flag"
25
25
"fmt"
26
26
"io"
27
+ "maps"
27
28
"math"
28
29
"os"
29
30
"path"
@@ -287,6 +288,10 @@ type workload struct {
287
288
// If DefaultThresholdMetricSelector is nil, the metric is set to "SchedulingThroughput".
288
289
// Optional
289
290
ThresholdMetricSelector * thresholdMetricSelector
291
+ // Feature gates to set before running the workload.
292
+ // Explicitly setting a feature in this map overrides the test case settings.
293
+ // Optional
294
+ FeatureGates map [featuregate.Feature ]bool
290
295
}
291
296
292
297
func (w * workload ) isValid (mcc * metricsCollectorConfig ) error {
@@ -968,7 +973,7 @@ func initTestOutput(tb testing.TB) io.Writer {
968
973
969
974
var specialFilenameChars = regexp .MustCompile (`[^a-zA-Z0-9-_]` )
970
975
971
- func setupTestCase (t testing.TB , tc * testCase , output io.Writer , outOfTreePluginRegistry frameworkruntime.Registry ) (informers.SharedInformerFactory , ktesting.TContext ) {
976
+ func setupTestCase (t testing.TB , tc * testCase , featureGates map [featuregate. Feature ] bool , output io.Writer , outOfTreePluginRegistry frameworkruntime.Registry ) (informers.SharedInformerFactory , ktesting.TContext ) {
972
977
tCtx := ktesting .Init (t , initoption .PerTestOutput (* useTestingLog ))
973
978
artifacts , doArtifacts := os .LookupEnv ("ARTIFACTS" )
974
979
if ! * useTestingLog && doArtifacts {
@@ -1036,15 +1041,23 @@ func setupTestCase(t testing.TB, tc *testCase, output io.Writer, outOfTreePlugin
1036
1041
// a brand new etcd.
1037
1042
framework .StartEtcd (t , output , true )
1038
1043
1039
- for feature , flag := range tc . FeatureGates {
1044
+ for feature , flag := range featureGates {
1040
1045
featuregatetesting .SetFeatureGateDuringTest (t , utilfeature .DefaultFeatureGate , feature , flag )
1041
1046
}
1042
1047
1043
1048
// 30 minutes should be plenty enough even for the 5000-node tests.
1044
1049
timeout := 30 * time .Minute
1045
1050
tCtx = ktesting .WithTimeout (tCtx , timeout , fmt .Sprintf ("timed out after the %s per-test timeout" , timeout ))
1046
1051
1047
- return setupClusterForWorkload (tCtx , tc .SchedulerConfigPath , tc .FeatureGates , outOfTreePluginRegistry )
1052
+ return setupClusterForWorkload (tCtx , tc .SchedulerConfigPath , featureGates , outOfTreePluginRegistry )
1053
+ }
1054
+
1055
+ func featureGatesMerge (src map [featuregate.Feature ]bool , overrides map [featuregate.Feature ]bool ) map [featuregate.Feature ]bool {
1056
+ result := maps .Clone (src )
1057
+ for feature , enabled := range overrides {
1058
+ result [feature ] = enabled
1059
+ }
1060
+ return result
1048
1061
}
1049
1062
1050
1063
// RunBenchmarkPerfScheduling runs the scheduler performance tests.
@@ -1081,7 +1094,8 @@ func RunBenchmarkPerfScheduling(b *testing.B, outOfTreePluginRegistry frameworkr
1081
1094
b .Skipf ("disabled by label filter %v" , testcaseLabelSelectors )
1082
1095
}
1083
1096
1084
- informerFactory , tCtx := setupTestCase (b , tc , output , outOfTreePluginRegistry )
1097
+ featureGates := featureGatesMerge (tc .FeatureGates , w .FeatureGates )
1098
+ informerFactory , tCtx := setupTestCase (b , tc , featureGates , output , outOfTreePluginRegistry )
1085
1099
1086
1100
results := runWorkload (tCtx , tc , w , informerFactory )
1087
1101
dataItems .DataItems = append (dataItems .DataItems , results ... )
@@ -1109,7 +1123,7 @@ func RunBenchmarkPerfScheduling(b *testing.B, outOfTreePluginRegistry frameworkr
1109
1123
}
1110
1124
}
1111
1125
1112
- if tc . FeatureGates [features .SchedulerQueueingHints ] {
1126
+ if featureGates [features .SchedulerQueueingHints ] {
1113
1127
// In any case, we should make sure InFlightEvents is empty after running the scenario.
1114
1128
if err = checkEmptyInFlightEvents (); err != nil {
1115
1129
tCtx .Errorf ("%s: %s" , w .Name , err )
0 commit comments