diff --git a/test/e2e/density.go b/test/e2e/density.go index bf2fae0b424..2df18619237 100644 --- a/test/e2e/density.go +++ b/test/e2e/density.go @@ -463,7 +463,7 @@ var _ = framework.KubeDescribe("Density", func() { It(name, func() { nodePreparer := framework.NewE2ETestNodePreparer( f.ClientSet, - map[int]testutils.PrepareNodeStrategy{nodeCount: &testutils.TrivialNodePrepareStrategy{}}, + []testutils.CountToStrategy{{Count: nodeCount, Strategy: &testutils.TrivialNodePrepareStrategy{}}}, ) framework.ExpectNoError(nodePreparer.PrepareNodes()) defer nodePreparer.CleanupNodes() diff --git a/test/e2e/framework/util.go b/test/e2e/framework/util.go index 83473a4a306..5a962a308b9 100644 --- a/test/e2e/framework/util.go +++ b/test/e2e/framework/util.go @@ -4522,11 +4522,11 @@ type E2ETestNodePreparer struct { // Specifies how many nodes should be modified using the given strategy. // Only one strategy can be applied to a single Node, so there needs to // be at least Nodes in the cluster. - countToStrategy map[int]testutils.PrepareNodeStrategy + countToStrategy []testutils.CountToStrategy nodeToAppliedStrategy map[string]testutils.PrepareNodeStrategy } -func NewE2ETestNodePreparer(client clientset.Interface, countToStrategy map[int]testutils.PrepareNodeStrategy) testutils.TestNodePreparer { +func NewE2ETestNodePreparer(client clientset.Interface, countToStrategy []testutils.CountToStrategy) testutils.TestNodePreparer { return &E2ETestNodePreparer{ client: client, countToStrategy: countToStrategy, @@ -4545,14 +4545,14 @@ func (p *E2ETestNodePreparer) PrepareNodes() error { } index := 0 sum := 0 - for k, strategy := range p.countToStrategy { - sum += k + for _, v := range p.countToStrategy { + sum += v.Count for ; index < sum; index++ { - if err := testutils.DoPrepareNode(p.client, &nodes.Items[index], strategy); err != nil { + if err := testutils.DoPrepareNode(p.client, &nodes.Items[index], v.Strategy); err != nil { glog.Errorf("Aborting node preparation: %v", err) return err } - p.nodeToAppliedStrategy[nodes.Items[index].Name] = strategy + p.nodeToAppliedStrategy[nodes.Items[index].Name] = v.Strategy } } return nil diff --git a/test/integration/framework/perf_utils.go b/test/integration/framework/perf_utils.go index 37a40bdaec7..e633c212ccb 100644 --- a/test/integration/framework/perf_utils.go +++ b/test/integration/framework/perf_utils.go @@ -32,11 +32,11 @@ const ( type IntegrationTestNodePreparer struct { client clientset.Interface - countToStrategy map[int]testutils.PrepareNodeStrategy + countToStrategy []testutils.CountToStrategy nodeNamePrefix string } -func NewIntegrationTestNodePreparer(client clientset.Interface, countToStrategy map[int]testutils.PrepareNodeStrategy, nodeNamePrefix string) testutils.TestNodePreparer { +func NewIntegrationTestNodePreparer(client clientset.Interface, countToStrategy []testutils.CountToStrategy, nodeNamePrefix string) testutils.TestNodePreparer { return &IntegrationTestNodePreparer{ client: client, countToStrategy: countToStrategy, @@ -46,8 +46,8 @@ func NewIntegrationTestNodePreparer(client clientset.Interface, countToStrategy func (p *IntegrationTestNodePreparer) PrepareNodes() error { numNodes := 0 - for k := range p.countToStrategy { - numNodes += k + for _, v := range p.countToStrategy { + numNodes += v.Count } glog.Infof("Making %d nodes", numNodes) @@ -80,10 +80,10 @@ func (p *IntegrationTestNodePreparer) PrepareNodes() error { nodes := e2eframework.GetReadySchedulableNodesOrDie(p.client) index := 0 sum := 0 - for k, strategy := range p.countToStrategy { - sum += k + for _, v := range p.countToStrategy { + sum += v.Count for ; index < sum; index++ { - if err := testutils.DoPrepareNode(p.client, &nodes.Items[index], strategy); err != nil { + if err := testutils.DoPrepareNode(p.client, &nodes.Items[index], v.Strategy); err != nil { glog.Errorf("Aborting node preparation: %v", err) return err } diff --git a/test/integration/scheduler_perf/scheduler_bench_test.go b/test/integration/scheduler_perf/scheduler_bench_test.go index 2cd4bcb7dc5..62690d443a5 100644 --- a/test/integration/scheduler_perf/scheduler_bench_test.go +++ b/test/integration/scheduler_perf/scheduler_bench_test.go @@ -60,7 +60,7 @@ func benchmarkScheduling(numNodes, numScheduledPods int, b *testing.B) { nodePreparer := framework.NewIntegrationTestNodePreparer( c, - map[int]testutils.PrepareNodeStrategy{numNodes: &testutils.TrivialNodePrepareStrategy{}}, + []testutils.CountToStrategy{{Count: numNodes, Strategy: &testutils.TrivialNodePrepareStrategy{}}}, "scheduler-perf-", ) if err := nodePreparer.PrepareNodes(); err != nil { diff --git a/test/integration/scheduler_perf/scheduler_test.go b/test/integration/scheduler_perf/scheduler_test.go index 1a9d1780c12..9c8fcfe1fd0 100644 --- a/test/integration/scheduler_perf/scheduler_test.go +++ b/test/integration/scheduler_perf/scheduler_test.go @@ -83,7 +83,7 @@ func schedulePods(numNodes, numPods int) int32 { nodePreparer := framework.NewIntegrationTestNodePreparer( c, - map[int]testutils.PrepareNodeStrategy{numNodes: &testutils.TrivialNodePrepareStrategy{}}, + []testutils.CountToStrategy{{Count: numNodes, Strategy: &testutils.TrivialNodePrepareStrategy{}}}, "scheduler-perf-", ) if err := nodePreparer.PrepareNodes(); err != nil { diff --git a/test/utils/runners.go b/test/utils/runners.go index a7bf2c30c74..b23fac15080 100644 --- a/test/utils/runners.go +++ b/test/utils/runners.go @@ -608,6 +608,11 @@ waitLoop: return nil } +type CountToStrategy struct { + Count int + Strategy PrepareNodeStrategy +} + type TestNodePreparer interface { PrepareNodes() error CleanupNodes() error