mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-06 02:34:03 +00:00
Allow to specify feature gates on workload level in scheduler_perf
This commit is contained in:
parent
7dd03c1ee5
commit
e676d0e76a
@ -24,6 +24,7 @@ import (
|
|||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
"maps"
|
||||||
"math"
|
"math"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
@ -287,6 +288,10 @@ type workload struct {
|
|||||||
// If DefaultThresholdMetricSelector is nil, the metric is set to "SchedulingThroughput".
|
// If DefaultThresholdMetricSelector is nil, the metric is set to "SchedulingThroughput".
|
||||||
// Optional
|
// Optional
|
||||||
ThresholdMetricSelector *thresholdMetricSelector
|
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 {
|
func (w *workload) isValid(mcc *metricsCollectorConfig) error {
|
||||||
@ -968,7 +973,7 @@ func initTestOutput(tb testing.TB) io.Writer {
|
|||||||
|
|
||||||
var specialFilenameChars = regexp.MustCompile(`[^a-zA-Z0-9-_]`)
|
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))
|
tCtx := ktesting.Init(t, initoption.PerTestOutput(*useTestingLog))
|
||||||
artifacts, doArtifacts := os.LookupEnv("ARTIFACTS")
|
artifacts, doArtifacts := os.LookupEnv("ARTIFACTS")
|
||||||
if !*useTestingLog && doArtifacts {
|
if !*useTestingLog && doArtifacts {
|
||||||
@ -1036,7 +1041,7 @@ func setupTestCase(t testing.TB, tc *testCase, output io.Writer, outOfTreePlugin
|
|||||||
// a brand new etcd.
|
// a brand new etcd.
|
||||||
framework.StartEtcd(t, output, true)
|
framework.StartEtcd(t, output, true)
|
||||||
|
|
||||||
for feature, flag := range tc.FeatureGates {
|
for feature, flag := range featureGates {
|
||||||
featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, feature, flag)
|
featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, feature, flag)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1044,7 +1049,15 @@ func setupTestCase(t testing.TB, tc *testCase, output io.Writer, outOfTreePlugin
|
|||||||
timeout := 30 * time.Minute
|
timeout := 30 * time.Minute
|
||||||
tCtx = ktesting.WithTimeout(tCtx, timeout, fmt.Sprintf("timed out after the %s per-test timeout", timeout))
|
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.
|
// RunBenchmarkPerfScheduling runs the scheduler performance tests.
|
||||||
@ -1081,7 +1094,8 @@ func RunBenchmarkPerfScheduling(b *testing.B, outOfTreePluginRegistry frameworkr
|
|||||||
b.Skipf("disabled by label filter %v", testcaseLabelSelectors)
|
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)
|
results := runWorkload(tCtx, tc, w, informerFactory)
|
||||||
dataItems.DataItems = append(dataItems.DataItems, results...)
|
dataItems.DataItems = append(dataItems.DataItems, results...)
|
||||||
@ -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.
|
// In any case, we should make sure InFlightEvents is empty after running the scenario.
|
||||||
if err = checkEmptyInFlightEvents(); err != nil {
|
if err = checkEmptyInFlightEvents(); err != nil {
|
||||||
tCtx.Errorf("%s: %s", w.Name, err)
|
tCtx.Errorf("%s: %s", w.Name, err)
|
||||||
|
@ -47,11 +47,12 @@ func TestScheduling(t *testing.T) {
|
|||||||
if !enabled(strings.Split(*testSchedulingLabelFilter, ","), append(tc.Labels, w.Labels...)...) {
|
if !enabled(strings.Split(*testSchedulingLabelFilter, ","), append(tc.Labels, w.Labels...)...) {
|
||||||
t.Skipf("disabled by label filter %q", *testSchedulingLabelFilter)
|
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)
|
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.
|
// In any case, we should make sure InFlightEvents is empty after running the scenario.
|
||||||
if err = checkEmptyInFlightEvents(); err != nil {
|
if err = checkEmptyInFlightEvents(); err != nil {
|
||||||
tCtx.Errorf("%s: %s", w.Name, err)
|
tCtx.Errorf("%s: %s", w.Name, err)
|
||||||
|
Loading…
Reference in New Issue
Block a user