From 7a0db35131f383d9bd919843fb005e1c60b1b9e0 Mon Sep 17 00:00:00 2001 From: Tim Gross Date: Tue, 21 Dec 2021 08:44:25 -0500 Subject: [PATCH] Apply suggestions from code review Co-authored-by: Michael Schurter --- scheduler/spread_test.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/scheduler/spread_test.go b/scheduler/spread_test.go index dc07645b29dc..c33ed17f7193 100644 --- a/scheduler/spread_test.go +++ b/scheduler/spread_test.go @@ -636,7 +636,8 @@ func TestSpreadOnLargeCluster(t *testing.T) { }, } - for _, tc := range cases { + for i := range cases { + tc := cases[i] t.Run(tc.name, func(t *testing.T) { t.Parallel() h := NewHarness(t) @@ -765,6 +766,7 @@ func validateEqualSpread(h *Harness) error { } i := 0 nodesToRacks := map[string]string{} + racksToAllocCount := map[string]int{} for { raw := iter.Next() if raw == nil { @@ -774,6 +776,7 @@ func validateEqualSpread(h *Harness) error { rack, ok := node.Meta["rack"] if ok { nodesToRacks[node.ID] = rack + racksToAllocCount[rack] = 0 } i++ } @@ -781,7 +784,6 @@ func validateEqualSpread(h *Harness) error { // Collapse the count of allocations per node into a list of // counts. The results should be a single count or, if more than // one count, they should be no more than one apart. - racksToAllocCount := map[string]int{} for nodeID, nodeAllocs := range h.Plans[0].NodeAllocation { racksToAllocCount[nodesToRacks[nodeID]] += len(nodeAllocs) }