Skip to content

Commit

Permalink
Fixed tests.
Browse files Browse the repository at this point in the history
Signed-off-by: bwplotka <[email protected]>
  • Loading branch information
bwplotka committed Dec 20, 2022
1 parent 1bc0814 commit 6f26748
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 7 deletions.
1 change: 1 addition & 0 deletions pkg/dedup/iter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"github.com/prometheus/prometheus/model/labels"
"github.com/prometheus/prometheus/storage"
"github.com/prometheus/prometheus/tsdb/chunkenc"
"github.com/thanos-io/thanos/pkg/store/storepb"

"github.com/efficientgo/core/testutil"
)
Expand Down
3 changes: 0 additions & 3 deletions pkg/query/querier.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ package query

import (
"context"
"fmt"
"strings"
"sync"
"time"
Expand Down Expand Up @@ -393,8 +392,6 @@ func (q *querier) selectFn(ctx context.Context, hints *storage.SelectHints, ms .
}
}

fmt.Println(resp.seriesSet)

if !q.isDedupEnabled() {
return &promSeriesSet{
mint: q.mint,
Expand Down
2 changes: 1 addition & 1 deletion pkg/query/querier_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,7 @@ func TestQuerier_Select(t *testing.T) {
{
lset: labels.FromStrings("a", "1", "x", "1"),
// We don't expect correctness here, it's just random non-replica data.
samples: []sample{{1, 1}, {2, 2}, {3, 3}, {4, 4}, {100, 1}, {300, 3}},
samples: []sample{{1, 1}, {2, 2}, {3, 3}, {100, 1}, {300, 3}},
},
{
lset: labels.FromStrings("a", "1", "x", "2"),
Expand Down
3 changes: 2 additions & 1 deletion pkg/store/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,8 @@ func (s *LocalStore) Series(r *storepb.SeriesRequest, srv storepb.Store_SeriesSe

chosen = chosen[:0]
resp := &storepb.Series{
Labels: series.Labels,
// Copy labels as in-process clients like proxy tend to work on same memory for labels.
Labels: labelpb.DeepCopy(series.Labels),
Chunks: make([]storepb.AggrChunk, 0, len(s.sortedChunks[si])),
}

Expand Down
6 changes: 4 additions & 2 deletions pkg/store/proxy_heap.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,10 @@ func chainSeriesAndRemIdenticalChunks(series []*storepb.SeriesResponse) *storepb
return finalChunks[i].Compare(finalChunks[j]) > 0
})

series[0].GetSeries().Chunks = finalChunks
return series[0]
return storepb.NewSeriesResponse(&storepb.Series{
Labels: series[0].GetSeries().Labels,
Chunks: finalChunks,
})
}

func (d *dedupResponseHeap) At() *storepb.SeriesResponse {
Expand Down
19 changes: 19 additions & 0 deletions pkg/store/proxy_heap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,25 @@ func TestSortWithoutLabels(t *testing.T) {
},
dedupLabels: map[string]struct{}{"b": {}},
},
// Longer series.
{
input: []*storepb.SeriesResponse{
storeSeriesResponse(t, labels.FromStrings(
"__name__", "gitlab_transaction_cache_read_hit_count_total", "action", "widget.json", "controller", "Projects::MergeRequests::ContentController", "env", "gprd", "environment",
"gprd", "fqdn", "web-08-sv-gprd.c.gitlab-production.internal", "instance", "web-08-sv-gprd.c.gitlab-production.internal:8083", "job", "gitlab-rails", "monitor", "app", "provider",
"gcp", "region", "us-east", "replica", "01", "shard", "default", "stage", "main", "tier", "sv", "type", "web",
)),
},
exp: []*storepb.SeriesResponse{
storeSeriesResponse(t, labels.FromStrings(
// No replica label anymore.
"__name__", "gitlab_transaction_cache_read_hit_count_total", "action", "widget.json", "controller", "Projects::MergeRequests::ContentController", "env", "gprd", "environment",
"gprd", "fqdn", "web-08-sv-gprd.c.gitlab-production.internal", "instance", "web-08-sv-gprd.c.gitlab-production.internal:8083", "job", "gitlab-rails", "monitor", "app", "provider",
"gcp", "region", "us-east", "shard", "default", "stage", "main", "tier", "sv", "type", "web",
)),
},
dedupLabels: map[string]struct{}{"replica": {}},
},
} {
t.Run("", func(t *testing.T) {
sortWithoutLabels(tcase.input, tcase.dedupLabels)
Expand Down

0 comments on commit 6f26748

Please sign in to comment.