Skip to content

Commit 9aecd89

Browse files
sort samples from different series before checking for expected samples (#2893)
Signed-off-by: Sandeep Sukhani <[email protected]>
1 parent bb5181a commit 9aecd89

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

pkg/testexporter/correctness/simple.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"flag"
66
"fmt"
77
"math"
8+
"sort"
89
"time"
910

1011
"github.com/go-kit/kit/log/level"
@@ -118,6 +119,18 @@ func (tc *simpleTestCase) Query(ctx context.Context, client v1.API, selectors st
118119
return nil, fmt.Errorf("didn't get matrix from Prom")
119120
}
120121

122+
// sort samples belonging to different series by first timestamp of the batch
123+
sort.Slice(ms, func(i, j int) bool {
124+
if len(ms[i].Values) == 0 {
125+
return true
126+
}
127+
if len(ms[j].Values) == 0 {
128+
return true
129+
}
130+
131+
return ms[i].Values[0].Timestamp.Before(ms[j].Values[0].Timestamp)
132+
})
133+
121134
var result []model.SamplePair
122135
for _, stream := range ms {
123136
result = append(result, stream.Values...)

0 commit comments

Comments
 (0)