Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Michael Schurter <mschurter@hashicorp.com>
  • Loading branch information
tgross and schmichael committed Dec 21, 2021
1 parent e3f6c3b commit 7a0db35
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions scheduler/spread_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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 {
Expand All @@ -774,14 +776,14 @@ func validateEqualSpread(h *Harness) error {
rack, ok := node.Meta["rack"]
if ok {
nodesToRacks[node.ID] = rack
racksToAllocCount[rack] = 0
}
i++
}

// 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)
}
Expand Down

0 comments on commit 7a0db35

Please sign in to comment.