mirror of
https://github.com/prometheus/prometheus.git
synced 2025-09-21 05:41:01 +02:00
Sort series by labels in requireEqual()
Tests that look at samples with StaleNaN values will fail because these samples are generated from map iteration and so the order can be unstable. Signed-off-by: Lukasz Mierzwa <l.mierzwa@gmail.com>
This commit is contained in:
parent
e2193f634f
commit
c75768739a
@ -36,6 +36,7 @@ import (
|
||||
|
||||
"github.com/gogo/protobuf/proto"
|
||||
"github.com/google/go-cmp/cmp"
|
||||
"github.com/google/go-cmp/cmp/cmpopts"
|
||||
"github.com/grafana/regexp"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
prom_testutil "github.com/prometheus/client_golang/prometheus/testutil"
|
||||
@ -1992,7 +1993,16 @@ func TestScrapeLoopAppend(t *testing.T) {
|
||||
func requireEqual(t *testing.T, expected, actual interface{}, msgAndArgs ...interface{}) {
|
||||
t.Helper()
|
||||
testutil.RequireEqualWithOptions(t, expected, actual,
|
||||
[]cmp.Option{cmp.Comparer(equalFloatSamples), cmp.AllowUnexported(histogramSample{})},
|
||||
[]cmp.Option{
|
||||
cmp.Comparer(equalFloatSamples),
|
||||
cmp.AllowUnexported(histogramSample{}),
|
||||
// StaleNaN samples are generated by iterating over a map, which means that the order
|
||||
// of samples might be different on every test run. Sort series by label to avoid
|
||||
// test failures because of that.
|
||||
cmpopts.SortSlices(func(a, b floatSample) int {
|
||||
return labels.Compare(a.metric, b.metric)
|
||||
}),
|
||||
},
|
||||
msgAndArgs...)
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user