@@ -451,8 +451,26 @@ func TestBlocksStoreQuerier_Select(t *testing.T) {
451
451
},
452
452
},
453
453
limits : & blocksStoreLimitsMock {maxChunksPerQuery : 1 },
454
+ queryLimiter : noOpQueryLimiter ,
455
+ expectedErr : validation .LimitError (fmt .Sprintf (errMaxChunksPerQueryLimit , fmt .Sprintf ("{__name__=%q}" , metricName ), 1 )),
456
+ },
457
+ "max chunks per query limit hit while fetching chunks at first attempt - global limit" : {
458
+ finderResult : bucketindex.Blocks {
459
+ {ID : block1 },
460
+ {ID : block2 },
461
+ },
462
+ storeSetResponses : []interface {}{
463
+ map [BlocksStoreClient ][]ulid.ULID {
464
+ & storeGatewayClientMock {remoteAddr : "1.1.1.1" , mockedSeriesResponses : []* storepb.SeriesResponse {
465
+ mockSeriesResponse (labels.Labels {metricNameLabel , series1Label }, minT , 1 ),
466
+ mockSeriesResponse (labels.Labels {metricNameLabel , series1Label }, minT + 1 , 2 ),
467
+ mockHintsResponse (block1 , block2 ),
468
+ }}: {block1 , block2 },
469
+ },
470
+ },
471
+ limits : & blocksStoreLimitsMock {},
454
472
queryLimiter : limiter .NewQueryLimiter (0 , 0 , 1 ),
455
- expectedErr : validation .LimitError (fmt .Sprintf (limiter .ErrMaxChunksPerQueryLimit , fmt . Sprintf ( "{__name__=%q}" , metricName ), 1 )),
473
+ expectedErr : validation .LimitError (fmt .Sprintf (limiter .ErrMaxChunksPerQueryLimit , 1 )),
456
474
},
457
475
"max chunks per query limit hit while fetching chunks during subsequent attempts" : {
458
476
finderResult : bucketindex.Blocks {
@@ -489,8 +507,46 @@ func TestBlocksStoreQuerier_Select(t *testing.T) {
489
507
},
490
508
},
491
509
limits : & blocksStoreLimitsMock {maxChunksPerQuery : 3 },
510
+ queryLimiter : noOpQueryLimiter ,
511
+ expectedErr : validation .LimitError (fmt .Sprintf (errMaxChunksPerQueryLimit , fmt .Sprintf ("{__name__=%q}" , metricName ), 3 )),
512
+ },
513
+ "max chunks per query limit hit while fetching chunks during subsequent attempts - global" : {
514
+ finderResult : bucketindex.Blocks {
515
+ {ID : block1 },
516
+ {ID : block2 },
517
+ {ID : block3 },
518
+ {ID : block4 },
519
+ },
520
+ storeSetResponses : []interface {}{
521
+ // First attempt returns a client whose response does not include all expected blocks.
522
+ map [BlocksStoreClient ][]ulid.ULID {
523
+ & storeGatewayClientMock {remoteAddr : "1.1.1.1" , mockedSeriesResponses : []* storepb.SeriesResponse {
524
+ mockSeriesResponse (labels.Labels {metricNameLabel , series1Label }, minT , 1 ),
525
+ mockHintsResponse (block1 ),
526
+ }}: {block1 , block3 },
527
+ & storeGatewayClientMock {remoteAddr : "2.2.2.2" , mockedSeriesResponses : []* storepb.SeriesResponse {
528
+ mockSeriesResponse (labels.Labels {metricNameLabel , series2Label }, minT , 2 ),
529
+ mockHintsResponse (block2 ),
530
+ }}: {block2 , block4 },
531
+ },
532
+ // Second attempt returns 1 missing block.
533
+ map [BlocksStoreClient ][]ulid.ULID {
534
+ & storeGatewayClientMock {remoteAddr : "3.3.3.3" , mockedSeriesResponses : []* storepb.SeriesResponse {
535
+ mockSeriesResponse (labels.Labels {metricNameLabel , series1Label }, minT + 1 , 2 ),
536
+ mockHintsResponse (block3 ),
537
+ }}: {block3 , block4 },
538
+ },
539
+ // Third attempt returns the last missing block.
540
+ map [BlocksStoreClient ][]ulid.ULID {
541
+ & storeGatewayClientMock {remoteAddr : "4.4.4.4" , mockedSeriesResponses : []* storepb.SeriesResponse {
542
+ mockSeriesResponse (labels.Labels {metricNameLabel , series2Label }, minT + 1 , 3 ),
543
+ mockHintsResponse (block4 ),
544
+ }}: {block4 },
545
+ },
546
+ },
547
+ limits : & blocksStoreLimitsMock {},
492
548
queryLimiter : limiter .NewQueryLimiter (0 , 0 , 3 ),
493
- expectedErr : validation .LimitError (fmt .Sprintf (limiter .ErrMaxChunksPerQueryLimit , fmt . Sprintf ( "{__name__=%q}" , metricName ), 3 )),
549
+ expectedErr : validation .LimitError (fmt .Sprintf (limiter .ErrMaxChunksPerQueryLimit , 3 )),
494
550
},
495
551
"max series per query limit hit while fetching chunks" : {
496
552
finderResult : bucketindex.Blocks {
0 commit comments