Skip to content

Commit

Permalink
Fully verify exemplars
Browse files Browse the repository at this point in the history
Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
  • Loading branch information
aknuds1 committed May 31, 2024
1 parent 3328b82 commit 4144fc9
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions pkg/distributor/distributor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1465,8 +1465,16 @@ func TestDistributor_Push_ExemplarValidation(t *testing.T) {

for testName, tc := range tests {
t.Run(testName, func(t *testing.T) {
expSamples := tc.req.Timeseries[0].Samples
expExemplars := tc.req.Timeseries[0].Exemplars
expectedSamples := tc.req.Timeseries[0].Samples
// During the call to Push, the labels of tc.req's exemplars are cleared, probably during request cleanup
// (in order to avoid retaining references to unmarshaled input bytes).
// Therefore, make a deep copy.
expectedExemplars := make([]mimirpb.Exemplar, len(tc.req.Timeseries[0].Exemplars))
copy(expectedExemplars, tc.req.Timeseries[0].Exemplars)
for i, e := range expectedExemplars {
expectedExemplars[i].Labels = make([]mimirpb.LabelAdapter, len(e.Labels))
copy(expectedExemplars[i].Labels, e.Labels)
}
limits := prepareDefaultLimits()
limits.MaxGlobalExemplarsPerUser = 10
ds, ingesters, _, _ := prepare(t, prepConfig{
Expand All @@ -1490,10 +1498,9 @@ func TestDistributor_Push_ExemplarValidation(t *testing.T) {
ss := i.series()
require.Len(t, ss, 1)
for _, s := range ss {
require.Equal(t, expSamples, s.Samples)
require.Equal(t, expectedSamples, s.Samples)
if !tc.expectedDrop {
// Not sure why, but during the push, the request's exemplar labels become empty
require.Len(t, s.Exemplars, len(expExemplars))
require.Equal(t, s.Exemplars, expectedExemplars)
} else {
require.Empty(t, s.Exemplars)
}
Expand Down

0 comments on commit 4144fc9

Please sign in to comment.