4
4
"context"
5
5
"fmt"
6
6
"io"
7
+ "net/http"
7
8
"sort"
8
9
"strings"
9
10
"testing"
@@ -31,6 +32,7 @@ import (
31
32
"github.com/thanos-io/thanos/pkg/store/hintspb"
32
33
"github.com/thanos-io/thanos/pkg/store/labelpb"
33
34
"github.com/thanos-io/thanos/pkg/store/storepb"
35
+ "github.com/weaveworks/common/httpgrpc"
34
36
"github.com/weaveworks/common/user"
35
37
"google.golang.org/grpc"
36
38
"google.golang.org/grpc/codes"
@@ -44,7 +46,6 @@ import (
44
46
"github.com/cortexproject/cortex/pkg/util"
45
47
"github.com/cortexproject/cortex/pkg/util/limiter"
46
48
util_log "github.com/cortexproject/cortex/pkg/util/log"
47
- "github.com/cortexproject/cortex/pkg/util/resource"
48
49
"github.com/cortexproject/cortex/pkg/util/services"
49
50
"github.com/cortexproject/cortex/pkg/util/validation"
50
51
)
@@ -1527,7 +1528,7 @@ func TestBlocksStoreQuerier_Select(t *testing.T) {
1527
1528
map [BlocksStoreClient ][]ulid.ULID {
1528
1529
& storeGatewayClientMock {
1529
1530
remoteAddr : "1.1.1.1" ,
1530
- mockedSeriesErr : & limiter.ResourceLimitReachedError {} ,
1531
+ mockedSeriesErr : limiter .ErrResourceLimitReached ,
1531
1532
}: {block1 },
1532
1533
},
1533
1534
map [BlocksStoreClient ][]ulid.ULID {
@@ -2499,20 +2500,18 @@ func TestBlocksStoreQuerier_PromQLExecution(t *testing.T) {
2499
2500
}
2500
2501
}
2501
2502
2502
- func TestBlocksStoreQuerier_ShouldRetryResourceBasedThrottlingError (t * testing.T ) {
2503
- limits := map [resource.Type ]float64 {
2504
- resource .CPU : 0.5 ,
2505
- resource .Heap : 0.5 ,
2506
- }
2507
-
2508
- resourceBasedLimiter , err := limiter .NewResourceBasedLimiter (& limiter.MockMonitor {
2509
- CpuUtilization : 0.7 ,
2510
- HeapUtilization : 0.7 ,
2511
- }, limits , prometheus .DefaultRegisterer , "ingester" )
2512
- require .NoError (t , err )
2513
-
2514
- err = resourceBasedLimiter .AcceptNewRequest ()
2515
- require .True (t , isRetryableError (err ))
2503
+ func TestBlocksStoreQuerier_isRetryableError (t * testing.T ) {
2504
+ require .True (t , isRetryableError (status .Error (codes .Unavailable , "" )))
2505
+ require .True (t , isRetryableError (storegateway .ErrTooManyInflightRequests ))
2506
+ require .True (t , isRetryableError (limiter .ErrResourceLimitReached ))
2507
+ require .True (t , isRetryableError (status .Error (codes .Canceled , "grpc: the client connection is closing" )))
2508
+ require .True (t , isRetryableError (errors .New ("pool exhausted" )))
2509
+
2510
+ require .False (t , isRetryableError (status .Error (codes .ResourceExhausted , "some other error" )))
2511
+ require .False (t , isRetryableError (status .Error (codes .Canceled , "some other error" )))
2512
+ require .False (t , isRetryableError (errors .New ("some other error" )))
2513
+ require .False (t , isRetryableError (fmt .Errorf ("some other error" )))
2514
+ require .False (t , isRetryableError (httpgrpc .Errorf (http .StatusServiceUnavailable , "some other error" )))
2516
2515
}
2517
2516
2518
2517
type blocksStoreSetMock struct {
0 commit comments