Skip to content

Commit 7fa8264

Browse files
committed
Fix unit tests
1 parent 2b56361 commit 7fa8264

File tree

5 files changed

+25
-19
lines changed

5 files changed

+25
-19
lines changed

pkg/store/bucket.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1624,9 +1624,10 @@ func (s *BucketStore) Series(req *storepb.SeriesRequest, seriesSrv storepb.Store
16241624
nil,
16251625
)
16261626
} else {
1627-
if s.lazyRetrievalMaxBufferedResponses < 1 {
1628-
// Unit tests hit this path. Using 1 to test corner cases.
1629-
s.lazyRetrievalMaxBufferedResponses = 1
1627+
lazyRetrievalMaxBufferedResponses := s.lazyRetrievalMaxBufferedResponses
1628+
if lazyRetrievalMaxBufferedResponses < 1 {
1629+
// Some unit and e2e tests hit this path.
1630+
lazyRetrievalMaxBufferedResponses = 1
16301631
}
16311632
resp = newLazyRespSet(
16321633
span,
@@ -1638,7 +1639,7 @@ func (s *BucketStore) Series(req *storepb.SeriesRequest, seriesSrv storepb.Store
16381639
shardMatcher,
16391640
false,
16401641
s.metrics.emptyPostingCount.WithLabelValues(tenant),
1641-
s.lazyRetrievalMaxBufferedResponses,
1642+
lazyRetrievalMaxBufferedResponses,
16421643
)
16431644
}
16441645

pkg/store/bucket_test.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1780,12 +1780,13 @@ func TestBucketSeries_OneBlock_InMemIndexCacheSegfault(t *testing.T) {
17801780
b1.meta.ULID: b1,
17811781
b2.meta.ULID: b2,
17821782
},
1783-
queryGate: gate.NewNoop(),
1784-
chunksLimiterFactory: NewChunksLimiterFactory(0),
1785-
seriesLimiterFactory: NewSeriesLimiterFactory(0),
1786-
bytesLimiterFactory: NewBytesLimiterFactory(0),
1787-
seriesBatchSize: SeriesBatchSize,
1788-
requestLoggerFunc: NoopRequestLoggerFunc,
1783+
queryGate: gate.NewNoop(),
1784+
chunksLimiterFactory: NewChunksLimiterFactory(0),
1785+
seriesLimiterFactory: NewSeriesLimiterFactory(0),
1786+
bytesLimiterFactory: NewBytesLimiterFactory(0),
1787+
seriesBatchSize: SeriesBatchSize,
1788+
requestLoggerFunc: NoopRequestLoggerFunc,
1789+
lazyRetrievalMaxBufferedResponses: 1,
17891790
}
17901791

17911792
t.Run("invoke series for one block. Fill the cache on the way.", func(t *testing.T) {

pkg/store/proxy.go

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -392,16 +392,10 @@ func (s *ProxyStore) Series(originalRequest *storepb.SeriesRequest, srv storepb.
392392
}
393393
}
394394
defer logGroupReplicaErrors()
395-
lazyRetrievalMaxBufferedResponses := s.lazyRetrievalMaxBufferedResponses
396-
if lazyRetrievalMaxBufferedResponses <= 0 {
397-
// Use 1 as default value for lazy retrieval buffer size.
398-
// Unit tests hit this path so that corner cases can be tested with buffer size 1.
399-
lazyRetrievalMaxBufferedResponses = 1
400-
}
401395
for _, st := range stores {
402396
st := st
403397

404-
respSet, err := newAsyncRespSet(ctx, st, r, s.responseTimeout, s.retrievalStrategy, &s.buffers, r.ShardInfo, reqLogger, s.metrics.emptyStreamResponses, lazyRetrievalMaxBufferedResponses)
398+
respSet, err := newAsyncRespSet(ctx, st, r, s.responseTimeout, s.retrievalStrategy, &s.buffers, r.ShardInfo, reqLogger, s.metrics.emptyStreamResponses, s.lazyRetrievalMaxBufferedResponses)
405399
if err != nil {
406400
level.Warn(s.logger).Log("msg", "Store failure", "group", st.GroupKey(), "replica", st.ReplicaKey(), "err", err)
407401
s.metrics.storeFailureCount.WithLabelValues(st.GroupKey(), st.ReplicaKey()).Inc()

pkg/store/proxy_merge.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,7 @@ func newAsyncRespSet(
515515
shardInfo *storepb.ShardInfo,
516516
logger log.Logger,
517517
emptyStreamResponses prometheus.Counter,
518-
fixedBufferSizeForLazyRetrieval int,
518+
lazyRetrievalMaxBufferedResponses int,
519519
) (respSet, error) {
520520

521521
var (
@@ -567,6 +567,11 @@ func newAsyncRespSet(
567567
switch retrievalStrategy {
568568
case LazyRetrieval:
569569
span.SetTag("retrival_strategy", LazyRetrieval)
570+
if lazyRetrievalMaxBufferedResponses < 1 {
571+
// Some unit and e2e tests hit this path.
572+
lazyRetrievalMaxBufferedResponses = 1
573+
}
574+
570575
return newLazyRespSet(
571576
span,
572577
frameTimeout,
@@ -577,7 +582,7 @@ func newAsyncRespSet(
577582
shardMatcher,
578583
applySharding,
579584
emptyStreamResponses,
580-
fixedBufferSizeForLazyRetrieval,
585+
lazyRetrievalMaxBufferedResponses,
581586
), nil
582587
case EagerRetrieval:
583588
span.SetTag("retrival_strategy", EagerRetrieval)

pkg/store/proxy_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1587,6 +1587,10 @@ func TestProxyStore_SeriesSlowStores(t *testing.T) {
15871587
expectedWarningsLen: 2,
15881588
},
15891589
} {
1590+
1591+
options := []ProxyStoreOption{
1592+
WithLazyRetrievalMaxBufferedResponsesForProxy(1),
1593+
}
15901594
if ok := t.Run(tc.title, func(t *testing.T) {
15911595
for _, strategy := range []RetrievalStrategy{EagerRetrieval, LazyRetrieval} {
15921596
if ok := t.Run(string(strategy), func(t *testing.T) {
@@ -1596,6 +1600,7 @@ func TestProxyStore_SeriesSlowStores(t *testing.T) {
15961600
component.Query,
15971601
tc.selectorLabels,
15981602
4*time.Second, strategy,
1603+
options...,
15991604
)
16001605

16011606
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)

0 commit comments

Comments
 (0)