From 338b06fb6903b65ec21705e4e1f7835f5a9a2cc8 Mon Sep 17 00:00:00 2001 From: Nicolas Mitchell Date: Sun, 4 Apr 2021 14:18:39 -0400 Subject: [PATCH 1/2] validate test/workload names in validateTestCases --- .../scheduler_perf/scheduler_perf_test.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/test/integration/scheduler_perf/scheduler_perf_test.go b/test/integration/scheduler_perf/scheduler_perf_test.go index 338f948294d..887ab11c685 100644 --- a/test/integration/scheduler_perf/scheduler_perf_test.go +++ b/test/integration/scheduler_perf/scheduler_perf_test.go @@ -111,6 +111,17 @@ func (tc *testCase) collectsMetrics() bool { return false } +func (tc *testCase) workloadNamesUnique() bool { + workloadUniqueNames := map[string]bool{} + for _, w := range tc.Workloads { + if workloadUniqueNames[w.Name] { + return false + } + workloadUniqueNames[w.Name] = true + } + return true +} + // workload is a subtest under a testCase that tests the scheduler performance // for a certain ordering of ops. The set of nodes created and pods scheduled // in a workload may be heterogeneous. @@ -766,10 +777,18 @@ func validateTestCases(testCases []*testCase) error { if len(testCases) == 0 { return fmt.Errorf("no test cases defined") } + testCaseUniqueNames := map[string]bool{} for _, tc := range testCases { + if testCaseUniqueNames[tc.Name] { + return fmt.Errorf("%s: name is not unique", tc.Name) + } + testCaseUniqueNames[tc.Name] = true if len(tc.Workloads) == 0 { return fmt.Errorf("%s: no workloads defined", tc.Name) } + if !tc.workloadNamesUnique() { + return fmt.Errorf("%s: workload names are not unique", tc.Name) + } if len(tc.WorkloadTemplate) == 0 { return fmt.Errorf("%s: no ops defined", tc.Name) } From 0e994e9481a36b692a62cfc7803fdd7eadc96afe Mon Sep 17 00:00:00 2001 From: Nicolas Mitchell Date: Tue, 6 Apr 2021 10:24:04 -0400 Subject: [PATCH 2/2] return error with non-unique workload name in scheduler_perf_test --- test/integration/scheduler_perf/scheduler_perf_test.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/integration/scheduler_perf/scheduler_perf_test.go b/test/integration/scheduler_perf/scheduler_perf_test.go index 887ab11c685..df5884087f5 100644 --- a/test/integration/scheduler_perf/scheduler_perf_test.go +++ b/test/integration/scheduler_perf/scheduler_perf_test.go @@ -111,15 +111,15 @@ func (tc *testCase) collectsMetrics() bool { return false } -func (tc *testCase) workloadNamesUnique() bool { +func (tc *testCase) workloadNamesUnique() error { workloadUniqueNames := map[string]bool{} for _, w := range tc.Workloads { if workloadUniqueNames[w.Name] { - return false + return fmt.Errorf("%s: workload name %s is not unique", tc.Name, w.Name) } workloadUniqueNames[w.Name] = true } - return true + return nil } // workload is a subtest under a testCase that tests the scheduler performance @@ -786,8 +786,8 @@ func validateTestCases(testCases []*testCase) error { if len(tc.Workloads) == 0 { return fmt.Errorf("%s: no workloads defined", tc.Name) } - if !tc.workloadNamesUnique() { - return fmt.Errorf("%s: workload names are not unique", tc.Name) + if err := tc.workloadNamesUnique(); err != nil { + return err } if len(tc.WorkloadTemplate) == 0 { return fmt.Errorf("%s: no ops defined", tc.Name)