Skip to content

Commit

Permalink
Merge pull request kubernetes#127952 from macsko/allow_to_specify_fea…
Browse files Browse the repository at this point in the history
…ture_gates_on_workload_level_scheduler_perf

Allow to set feature gates on workload level in scheduler_perf
  • Loading branch information
k8s-ci-robot authored Oct 11, 2024
2 parents 8cbb115 + e676d0e commit 1b6c993
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
24 changes: 19 additions & 5 deletions test/integration/scheduler_perf/scheduler_perf.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"flag"
"fmt"
"io"
"maps"
"math"
"os"
"path"
Expand Down Expand Up @@ -287,6 +288,10 @@ type workload struct {
// If DefaultThresholdMetricSelector is nil, the metric is set to "SchedulingThroughput".
// Optional
ThresholdMetricSelector *thresholdMetricSelector
// Feature gates to set before running the workload.
// Explicitly setting a feature in this map overrides the test case settings.
// Optional
FeatureGates map[featuregate.Feature]bool
}

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

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

func setupTestCase(t testing.TB, tc *testCase, output io.Writer, outOfTreePluginRegistry frameworkruntime.Registry) (informers.SharedInformerFactory, ktesting.TContext) {
func setupTestCase(t testing.TB, tc *testCase, featureGates map[featuregate.Feature]bool, output io.Writer, outOfTreePluginRegistry frameworkruntime.Registry) (informers.SharedInformerFactory, ktesting.TContext) {
tCtx := ktesting.Init(t, initoption.PerTestOutput(*useTestingLog))
artifacts, doArtifacts := os.LookupEnv("ARTIFACTS")
if !*useTestingLog && doArtifacts {
Expand Down Expand Up @@ -1036,15 +1041,23 @@ func setupTestCase(t testing.TB, tc *testCase, output io.Writer, outOfTreePlugin
// a brand new etcd.
framework.StartEtcd(t, output, true)

for feature, flag := range tc.FeatureGates {
for feature, flag := range featureGates {
featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, feature, flag)
}

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

return setupClusterForWorkload(tCtx, tc.SchedulerConfigPath, tc.FeatureGates, outOfTreePluginRegistry)
return setupClusterForWorkload(tCtx, tc.SchedulerConfigPath, featureGates, outOfTreePluginRegistry)
}

func featureGatesMerge(src map[featuregate.Feature]bool, overrides map[featuregate.Feature]bool) map[featuregate.Feature]bool {
result := maps.Clone(src)
for feature, enabled := range overrides {
result[feature] = enabled
}
return result
}

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

informerFactory, tCtx := setupTestCase(b, tc, output, outOfTreePluginRegistry)
featureGates := featureGatesMerge(tc.FeatureGates, w.FeatureGates)
informerFactory, tCtx := setupTestCase(b, tc, featureGates, output, outOfTreePluginRegistry)

results := runWorkload(tCtx, tc, w, informerFactory)
dataItems.DataItems = append(dataItems.DataItems, results...)
Expand Down Expand Up @@ -1109,7 +1123,7 @@ func RunBenchmarkPerfScheduling(b *testing.B, outOfTreePluginRegistry frameworkr
}
}

if tc.FeatureGates[features.SchedulerQueueingHints] {
if featureGates[features.SchedulerQueueingHints] {
// In any case, we should make sure InFlightEvents is empty after running the scenario.
if err = checkEmptyInFlightEvents(); err != nil {
tCtx.Errorf("%s: %s", w.Name, err)
Expand Down
5 changes: 3 additions & 2 deletions test/integration/scheduler_perf/scheduler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,12 @@ func TestScheduling(t *testing.T) {
if !enabled(strings.Split(*testSchedulingLabelFilter, ","), append(tc.Labels, w.Labels...)...) {
t.Skipf("disabled by label filter %q", *testSchedulingLabelFilter)
}
informerFactory, tCtx := setupTestCase(t, tc, nil, nil)
featureGates := featureGatesMerge(tc.FeatureGates, w.FeatureGates)
informerFactory, tCtx := setupTestCase(t, tc, featureGates, nil, nil)

runWorkload(tCtx, tc, w, informerFactory)

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

0 comments on commit 1b6c993

Please sign in to comment.