Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
Signed-off-by: Arve Knudsen <[email protected]>
  • Loading branch information
aknuds1 committed Sep 25, 2024
1 parent f11b57d commit b61cbbd
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions pkg/ingester/client/buffering_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,16 +265,24 @@ func (ms *mockServer) Push(_ context.Context, r *mimirpb.WriteRequest) (*mimirpb
ms.mu.Lock()
defer ms.mu.Unlock()

// Clear unmarshal data. We don't need it and it breaks equality check in test.
r.ClearTimeseriesUnmarshalData()
ms.reqs = append(ms.reqs, r)
d, err := r.Marshal()
if err != nil {
return nil, fmt.Errorf("marshal WriteRequest: %w", err)
}
var c mimirpb.WriteRequest
if err := c.Unmarshal(d); err != nil {
return nil, fmt.Errorf("unmarshal WriteRequest: %w", err)
}
// Clear unmarshal data, to ensure equality.
c.ClearTimeseriesUnmarshalData()
ms.reqs = append(ms.reqs, &c)

if ms.trackSamples {
if ms.samplesPerSeries == nil {
ms.samplesPerSeries = map[string][]mimirpb.Sample{}
}

for _, ts := range r.Timeseries {
for _, ts := range c.Timeseries {
ser := mimirpb.FromLabelAdaptersToLabels(ts.Labels).String()
ms.samplesPerSeries[ser] = append(ms.samplesPerSeries[ser], ts.Samples...)
}
Expand Down

0 comments on commit b61cbbd

Please sign in to comment.