Skip to content

Commit cdd6734

Browse files
committed
Fix flaky label evaluation by sorting both sides
Signed-off-by: Danny Kopping <danny@coder.com>
1 parent c11dc61 commit cdd6734

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

coderd/prometheusmetrics/aggregator_test.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,9 +206,11 @@ func verifyCollectedMetrics(t *testing.T, expected []*agentproto.Stats_Metric, a
206206

207207
dtoLabels := asMetricAgentLabels(d.GetLabel())
208208
// dto labels are sorted in alphabetical order.
209-
sort.Slice(e.Labels, func(i, j int) bool {
209+
sortFn := func(i, j int) bool {
210210
return e.Labels[i].Name < e.Labels[j].Name
211-
})
211+
}
212+
sort.Slice(e.Labels, sortFn)
213+
sort.Slice(dtoLabels, sortFn)
212214
require.Equal(t, e.Labels, dtoLabels, d.String())
213215
}
214216
return true

0 commit comments

Comments
 (0)