Fix nondeterministic test (#18828)

This commit is contained in:
Chris S. Kim 2023-09-15 15:23:49 -04:00 committed by GitHub
parent 1fda2965e8
commit edf56ee970
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 4 deletions

View File

@ -11,9 +11,11 @@ import (
"strings"
"text/tabwriter"
"github.com/mitchellh/cli"
"golang.org/x/exp/maps"
"github.com/hashicorp/consul/api"
"github.com/hashicorp/consul/command/flags"
"github.com/mitchellh/cli"
)
func New(ui cli.Ui) *cmd {
@ -135,9 +137,11 @@ func formatNodesCounts(usageStats map[string]api.ServiceUsage) (string, error) {
fmt.Fprint(tw, "\t\n")
for dc, usage := range usageStats {
nodesTotal += usage.Nodes
fmt.Fprintf(tw, "%s\t%d\n", dc, usage.Nodes)
nodes := maps.Keys(usageStats)
sort.Strings(nodes)
for _, dc := range nodes {
nodesTotal += usageStats[dc].Nodes
fmt.Fprintf(tw, "%s\t%d\n", dc, usageStats[dc].Nodes)
}
fmt.Fprint(tw, "\t\n")