Skip to content

Commit 369a18a

Browse files
committed
scheduler_perf: simplify flags, fix output
The "disabled by label filter" message for benchmarks printed the pointer to the filter string, not the filter string itself. This mistake gets avoided and the code becomes simpler when not using pointers.
1 parent cf480a3 commit 369a18a

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

test/integration/scheduler_perf/scheduler_perf.go

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -207,9 +207,9 @@ var (
207207
}
208208
)
209209

210-
var UseTestingLog *bool
211-
var PerfSchedulingLabelFilter *string
212-
var TestSchedulingLabelFilter *string
210+
var UseTestingLog bool
211+
var PerfSchedulingLabelFilter string
212+
var TestSchedulingLabelFilter string
213213

214214
// InitTests should be called in a TestMain in each config subdirectory.
215215
func InitTests() error {
@@ -235,9 +235,9 @@ func InitTests() error {
235235
"A set of key=value pairs that describe feature gates for alpha/experimental features. "+
236236
"Options are:\n"+strings.Join(LoggingFeatureGate.KnownFeatures(), "\n"))
237237

238-
UseTestingLog = flag.Bool("use-testing-log", false, "Write log entries with testing.TB.Log. This is more suitable for unit testing and debugging, but less realistic in real benchmarks.")
239-
PerfSchedulingLabelFilter = flag.String("perf-scheduling-label-filter", "performance", "comma-separated list of labels which a testcase must have (no prefix or +) or must not have (-), used by BenchmarkPerfScheduling")
240-
TestSchedulingLabelFilter = flag.String("test-scheduling-label-filter", "integration-test,-performance", "comma-separated list of labels which a testcase must have (no prefix or +) or must not have (-), used by TestScheduling")
238+
flag.BoolVar(&UseTestingLog, "use-testing-log", false, "Write log entries with testing.TB.Log. This is more suitable for unit testing and debugging, but less realistic in real benchmarks.")
239+
flag.StringVar(&PerfSchedulingLabelFilter, "perf-scheduling-label-filter", "performance", "comma-separated list of labels which a testcase must have (no prefix or +) or must not have (-), used by BenchmarkPerfScheduling")
240+
flag.StringVar(&TestSchedulingLabelFilter, "test-scheduling-label-filter", "integration-test,-performance", "comma-separated list of labels which a testcase must have (no prefix or +) or must not have (-), used by TestScheduling")
241241

242242
// This would fail if we hadn't removed the logging flags above.
243243
logsapi.AddGoFlags(LoggingConfig, flag.CommandLine)
@@ -988,7 +988,7 @@ func (scm stopCollectingMetricsOp) patchParams(_ *workload) (realOp, error) {
988988

989989
func initTestOutput(tb testing.TB) io.Writer {
990990
var output io.Writer
991-
if *UseTestingLog {
991+
if UseTestingLog {
992992
output = framework.NewTBWriter(tb)
993993
} else {
994994
tmpDir := tb.TempDir()
@@ -1020,9 +1020,9 @@ func initTestOutput(tb testing.TB) io.Writer {
10201020
var specialFilenameChars = regexp.MustCompile(`[^a-zA-Z0-9-_]`)
10211021

10221022
func setupTestCase(t testing.TB, tc *testCase, featureGates map[featuregate.Feature]bool, output io.Writer, outOfTreePluginRegistry frameworkruntime.Registry) (informers.SharedInformerFactory, ktesting.TContext) {
1023-
tCtx := ktesting.Init(t, initoption.PerTestOutput(*UseTestingLog))
1023+
tCtx := ktesting.Init(t, initoption.PerTestOutput(UseTestingLog))
10241024
artifacts, doArtifacts := os.LookupEnv("ARTIFACTS")
1025-
if !*UseTestingLog && doArtifacts {
1025+
if !UseTestingLog && doArtifacts {
10261026
// Reconfigure logging so that it goes to a separate file per
10271027
// test instead of stderr. If the test passes, the file gets
10281028
// deleted. The overall output can be very large (> 200 MB for
@@ -1130,9 +1130,9 @@ func RunBenchmarkPerfScheduling(b *testing.B, configFile string, topicName strin
11301130
}
11311131

11321132
if testing.Short() {
1133-
*PerfSchedulingLabelFilter += ",+short"
1133+
PerfSchedulingLabelFilter += ",+short"
11341134
}
1135-
testcaseLabelSelectors := strings.Split(*PerfSchedulingLabelFilter, ",")
1135+
testcaseLabelSelectors := strings.Split(PerfSchedulingLabelFilter, ",")
11361136

11371137
output := initTestOutput(b)
11381138

@@ -1150,7 +1150,7 @@ func RunBenchmarkPerfScheduling(b *testing.B, configFile string, topicName strin
11501150
for _, w := range tc.Workloads {
11511151
b.Run(w.Name, func(b *testing.B) {
11521152
if !enabled(testcaseLabelSelectors, append(tc.Labels, w.Labels...)...) {
1153-
b.Skipf("disabled by label filter %v", PerfSchedulingLabelFilter)
1153+
b.Skipf("disabled by label filter %q", PerfSchedulingLabelFilter)
11541154
}
11551155

11561156
featureGates := featureGatesMerge(tc.FeatureGates, w.FeatureGates)
@@ -1244,16 +1244,16 @@ func RunIntegrationPerfScheduling(t *testing.T, configFile string) {
12441244
}
12451245

12461246
if testing.Short() {
1247-
*TestSchedulingLabelFilter += ",+short"
1247+
TestSchedulingLabelFilter += ",+short"
12481248
}
1249-
testcaseLabelSelectors := strings.Split(*TestSchedulingLabelFilter, ",")
1249+
testcaseLabelSelectors := strings.Split(TestSchedulingLabelFilter, ",")
12501250

12511251
for _, tc := range testCases {
12521252
t.Run(tc.Name, func(t *testing.T) {
12531253
for _, w := range tc.Workloads {
12541254
t.Run(w.Name, func(t *testing.T) {
12551255
if !enabled(testcaseLabelSelectors, append(tc.Labels, w.Labels...)...) {
1256-
t.Skipf("disabled by label filter %q", *TestSchedulingLabelFilter)
1256+
t.Skipf("disabled by label filter %q", TestSchedulingLabelFilter)
12571257
}
12581258
featureGates := featureGatesMerge(tc.FeatureGates, w.FeatureGates)
12591259
informerFactory, tCtx := setupTestCase(t, tc, featureGates, nil, nil)

0 commit comments

Comments
 (0)