From c9314dde593b0b845fa5345e58230e620ad41195 Mon Sep 17 00:00:00 2001 From: Aldo Culquicondor Date: Fri, 20 Mar 2020 16:18:44 -0400 Subject: [PATCH] Add support for multiple label values in test cases They are assigned in a round robin fashion Signed-off-by: Aldo Culquicondor --- .../config/performance-config.yaml | 2 +- test/utils/runners.go | 17 +++++++++++------ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/test/integration/scheduler_perf/config/performance-config.yaml b/test/integration/scheduler_perf/config/performance-config.yaml index 4ea03b9959a..34ac6dc4b16 100644 --- a/test/integration/scheduler_perf/config/performance-config.yaml +++ b/test/integration/scheduler_perf/config/performance-config.yaml @@ -162,7 +162,7 @@ nodeTemplatePath: config/node-default.yaml labelNodePrepareStrategy: labelKey: "failure-domain.beta.kubernetes.io/zone" - labelValue: "zone1" + labelValues: ["zone1"] initPods: - podTemplatePath: config/pod-with-node-affinity.yaml podsToSchedule: diff --git a/test/utils/runners.go b/test/utils/runners.go index aaac8bd37d5..fde5a703071 100644 --- a/test/utils/runners.go +++ b/test/utils/runners.go @@ -980,22 +980,27 @@ func (*TrivialNodePrepareStrategy) CleanupDependentObjects(nodeName string, clie } type LabelNodePrepareStrategy struct { - LabelKey string - LabelValue string + LabelKey string + LabelValues []string + roundRobinIdx int } var _ PrepareNodeStrategy = &LabelNodePrepareStrategy{} -func NewLabelNodePrepareStrategy(labelKey string, labelValue string) *LabelNodePrepareStrategy { +func NewLabelNodePrepareStrategy(labelKey string, labelValues ...string) *LabelNodePrepareStrategy { return &LabelNodePrepareStrategy{ - LabelKey: labelKey, - LabelValue: labelValue, + LabelKey: labelKey, + LabelValues: labelValues, } } func (s *LabelNodePrepareStrategy) PreparePatch(*v1.Node) []byte { - labelString := fmt.Sprintf("{\"%v\":\"%v\"}", s.LabelKey, s.LabelValue) + labelString := fmt.Sprintf("{\"%v\":\"%v\"}", s.LabelKey, s.LabelValues[s.roundRobinIdx]) patch := fmt.Sprintf(`{"metadata":{"labels":%v}}`, labelString) + s.roundRobinIdx++ + if s.roundRobinIdx == len(s.LabelValues) { + s.roundRobinIdx = 0 + } return []byte(patch) }