Skip to content

Commit 1b6c993

Browse files
authored
Merge pull request kubernetes#127952 from macsko/allow_to_specify_feature_gates_on_workload_level_scheduler_perf
Allow to set feature gates on workload level in scheduler_perf
2 parents 8cbb115 + e676d0e commit 1b6c993

File tree

2 files changed

+22
-7
lines changed

2 files changed

+22
-7
lines changed

test/integration/scheduler_perf/scheduler_perf.go

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import (
2424
"flag"
2525
"fmt"
2626
"io"
27+
"maps"
2728
"math"
2829
"os"
2930
"path"
@@ -287,6 +288,10 @@ type workload struct {
287288
// If DefaultThresholdMetricSelector is nil, the metric is set to "SchedulingThroughput".
288289
// Optional
289290
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
290295
}
291296

292297
func (w *workload) isValid(mcc *metricsCollectorConfig) error {
@@ -968,7 +973,7 @@ func initTestOutput(tb testing.TB) io.Writer {
968973

969974
var specialFilenameChars = regexp.MustCompile(`[^a-zA-Z0-9-_]`)
970975

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) {
972977
tCtx := ktesting.Init(t, initoption.PerTestOutput(*useTestingLog))
973978
artifacts, doArtifacts := os.LookupEnv("ARTIFACTS")
974979
if !*useTestingLog && doArtifacts {
@@ -1036,15 +1041,23 @@ func setupTestCase(t testing.TB, tc *testCase, output io.Writer, outOfTreePlugin
10361041
// a brand new etcd.
10371042
framework.StartEtcd(t, output, true)
10381043

1039-
for feature, flag := range tc.FeatureGates {
1044+
for feature, flag := range featureGates {
10401045
featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, feature, flag)
10411046
}
10421047

10431048
// 30 minutes should be plenty enough even for the 5000-node tests.
10441049
timeout := 30 * time.Minute
10451050
tCtx = ktesting.WithTimeout(tCtx, timeout, fmt.Sprintf("timed out after the %s per-test timeout", timeout))
10461051

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
10481061
}
10491062

10501063
// RunBenchmarkPerfScheduling runs the scheduler performance tests.
@@ -1081,7 +1094,8 @@ func RunBenchmarkPerfScheduling(b *testing.B, outOfTreePluginRegistry frameworkr
10811094
b.Skipf("disabled by label filter %v", testcaseLabelSelectors)
10821095
}
10831096

1084-
informerFactory, tCtx := setupTestCase(b, tc, output, outOfTreePluginRegistry)
1097+
featureGates := featureGatesMerge(tc.FeatureGates, w.FeatureGates)
1098+
informerFactory, tCtx := setupTestCase(b, tc, featureGates, output, outOfTreePluginRegistry)
10851099

10861100
results := runWorkload(tCtx, tc, w, informerFactory)
10871101
dataItems.DataItems = append(dataItems.DataItems, results...)
@@ -1109,7 +1123,7 @@ func RunBenchmarkPerfScheduling(b *testing.B, outOfTreePluginRegistry frameworkr
11091123
}
11101124
}
11111125

1112-
if tc.FeatureGates[features.SchedulerQueueingHints] {
1126+
if featureGates[features.SchedulerQueueingHints] {
11131127
// In any case, we should make sure InFlightEvents is empty after running the scenario.
11141128
if err = checkEmptyInFlightEvents(); err != nil {
11151129
tCtx.Errorf("%s: %s", w.Name, err)

test/integration/scheduler_perf/scheduler_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,12 @@ func TestScheduling(t *testing.T) {
4747
if !enabled(strings.Split(*testSchedulingLabelFilter, ","), append(tc.Labels, w.Labels...)...) {
4848
t.Skipf("disabled by label filter %q", *testSchedulingLabelFilter)
4949
}
50-
informerFactory, tCtx := setupTestCase(t, tc, nil, nil)
50+
featureGates := featureGatesMerge(tc.FeatureGates, w.FeatureGates)
51+
informerFactory, tCtx := setupTestCase(t, tc, featureGates, nil, nil)
5152

5253
runWorkload(tCtx, tc, w, informerFactory)
5354

54-
if tc.FeatureGates[features.SchedulerQueueingHints] {
55+
if featureGates[features.SchedulerQueueingHints] {
5556
// In any case, we should make sure InFlightEvents is empty after running the scenario.
5657
if err = checkEmptyInFlightEvents(); err != nil {
5758
tCtx.Errorf("%s: %s", w.Name, err)

0 commit comments

Comments
 (0)