Skip to content

Commit

Permalink
Fix querier tests
Browse files Browse the repository at this point in the history
Signed-off-by: Filip Petkovski <[email protected]>
  • Loading branch information
fpetkovski committed Oct 20, 2022
1 parent b5c155c commit 419d323
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 12 deletions.
10 changes: 5 additions & 5 deletions pkg/query/querier_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,7 @@ func TestQuerier_Select(t *testing.T) {
} {
g := gate.New(2)

proxy := newProxyForStore(tcase.storeAPI)
proxy := newProxyForStore(false, tcase.storeAPI)
q := newQuerier(context.Background(), nil, tcase.mint, tcase.maxt, tcase.replicaLabels, nil, proxy, sc.dedup, 0, true, false, false, g, timeout, nil, NoopSeriesStatsReporter)

t.Cleanup(func() { testutil.Ok(t, q.Close()) })
Expand Down Expand Up @@ -685,13 +685,13 @@ func TestQuerier_Select(t *testing.T) {
}
}

func newProxyForStore(storeAPI ...storepb.StoreServer) *store.ProxyStore {
func newProxyForStore(storesWithSortedSeries bool, storeAPI ...storepb.StoreServer) *store.ProxyStore {
labelsFunc := func() []labelpb.ZLabelSet { return nil }
timeFunc := func() (int64, int64) { return math.MinInt64, math.MaxInt64 }
clientsFunc := func() []store.Client {
clients := make([]store.Client, 0, len(storeAPI))
for _, s := range storeAPI {
clients = append(clients, receive.NewLocalClient(storepb.ServerAsClient(s, 0), labelsFunc, timeFunc))
clients = append(clients, receive.NewLocalClient(storepb.ServerAsClient(s, 0), storesWithSortedSeries, labelsFunc, timeFunc))
}
return clients
}
Expand Down Expand Up @@ -886,7 +886,7 @@ func TestQuerierWithDedupUnderstoodByPromQL_Rate(t *testing.T) {
timeout := 100 * time.Second
g := gate.New(2)

proxy := newProxyForStore(s)
proxy := newProxyForStore(false, s)
q := newQuerier(context.Background(), logger, realSeriesWithStaleMarkerMint, realSeriesWithStaleMarkerMaxt, []string{"replica"}, nil, proxy, false, 0, true, false, false, g, timeout, nil, NoopSeriesStatsReporter)

t.Cleanup(func() {
Expand Down Expand Up @@ -959,7 +959,7 @@ func TestQuerierWithDedupUnderstoodByPromQL_Rate(t *testing.T) {
timeout := 5 * time.Second
g := gate.New(2)

proxy := newProxyForStore(s)
proxy := newProxyForStore(false, s)
q := newQuerier(context.Background(), logger, realSeriesWithStaleMarkerMint, realSeriesWithStaleMarkerMaxt, []string{"replica"}, nil, proxy, true, 0, true, false, false, g, timeout, nil, NoopSeriesStatsReporter)

t.Cleanup(func() {
Expand Down
2 changes: 1 addition & 1 deletion pkg/query/query_bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func benchQuerySelect(t testutil.TB, totalSamples, totalSeries int, dedup bool)
q := &querier{
ctx: context.Background(),
logger: logger,
proxy: newProxyForStore(stores...),
proxy: newProxyForStore(true, stores...),
replicaLabels: []string{"z_replica"},
replicaLabelSet: map[string]struct{}{"z_replica": {}},
deduplicate: dedup,
Expand Down
13 changes: 8 additions & 5 deletions pkg/receive/multitsdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,16 +93,18 @@ func NewMultiTSDB(
type localClient struct {
storepb.StoreClient

labelSetFunc func() []labelpb.ZLabelSet
timeRangeFunc func() (int64, int64)
sendsSortedSeries bool
labelSetFunc func() []labelpb.ZLabelSet
timeRangeFunc func() (int64, int64)
}

func NewLocalClient(
c storepb.StoreClient,
sendsSortedSeries bool,
labelSetFunc func() []labelpb.ZLabelSet,
timeRangeFunc func() (int64, int64),
) store.Client {
return &localClient{c, labelSetFunc, timeRangeFunc}
return &localClient{c, sendsSortedSeries, labelSetFunc, timeRangeFunc}
}

func (l *localClient) LabelSets() []labels.Labels {
Expand Down Expand Up @@ -130,7 +132,7 @@ func (l *localClient) SupportsSharding() bool {
}

func (l *localClient) SendsSortedSeries() bool {
return true
return l.sendsSortedSeries
}

type tenant struct {
Expand Down Expand Up @@ -165,7 +167,8 @@ func (t *tenant) client() store.Client {

store := t.store()
client := storepb.ServerAsClient(store, 0)
return NewLocalClient(client, store.LabelSet, store.TimeRange)

return NewLocalClient(client, true, store.LabelSet, store.TimeRange)
}

func (t *tenant) exemplars() *exemplars.TSDB {
Expand Down
3 changes: 2 additions & 1 deletion pkg/store/bucket.go
Original file line number Diff line number Diff line change
Expand Up @@ -1048,7 +1048,8 @@ func (s *BucketStore) Series(req *storepb.SeriesRequest, srv storepb.Store_Serie
}
}

// Label from individual series are already sorted by wrapping respones in sortedSeriesSet.
// Label from individual series are already sorted by wrapping responses in sortedSeriesSet.
// Because of that, we can set the sortLabels argument to false and save some CPU cycles.
sortedSeriesSrv := newSortedSeriesServer(srv, sortWithoutLabelSet, false, sortSeries)
for _, bs := range s.blockSets {
blockMatchers, ok := bs.labelMatchers(matchers...)
Expand Down

0 comments on commit 419d323

Please sign in to comment.