mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-11-03 19:58:17 +00:00 
			
		
		
		
	validate test/workload names in validateTestCases
This commit is contained in:
		@@ -111,6 +111,17 @@ func (tc *testCase) collectsMetrics() bool {
 | 
				
			|||||||
	return false
 | 
						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
 | 
					// 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
 | 
					// for a certain ordering of ops. The set of nodes created and pods scheduled
 | 
				
			||||||
// in a workload may be heterogeneous.
 | 
					// in a workload may be heterogeneous.
 | 
				
			||||||
@@ -766,10 +777,18 @@ func validateTestCases(testCases []*testCase) error {
 | 
				
			|||||||
	if len(testCases) == 0 {
 | 
						if len(testCases) == 0 {
 | 
				
			||||||
		return fmt.Errorf("no test cases defined")
 | 
							return fmt.Errorf("no test cases defined")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
						testCaseUniqueNames := map[string]bool{}
 | 
				
			||||||
	for _, tc := range testCases {
 | 
						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 {
 | 
							if len(tc.Workloads) == 0 {
 | 
				
			||||||
			return fmt.Errorf("%s: no workloads defined", tc.Name)
 | 
								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 {
 | 
							if len(tc.WorkloadTemplate) == 0 {
 | 
				
			||||||
			return fmt.Errorf("%s: no ops defined", tc.Name)
 | 
								return fmt.Errorf("%s: no ops defined", tc.Name)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user