44 "context"
55 "fmt"
66 "io"
7+ "net/http"
78 "sort"
89 "strings"
910 "testing"
@@ -31,6 +32,7 @@ import (
3132 "github.com/thanos-io/thanos/pkg/store/hintspb"
3233 "github.com/thanos-io/thanos/pkg/store/labelpb"
3334 "github.com/thanos-io/thanos/pkg/store/storepb"
35+ "github.com/weaveworks/common/httpgrpc"
3436 "github.com/weaveworks/common/user"
3537 "google.golang.org/grpc"
3638 "google.golang.org/grpc/codes"
@@ -44,7 +46,6 @@ import (
4446 "github.com/cortexproject/cortex/pkg/util"
4547 "github.com/cortexproject/cortex/pkg/util/limiter"
4648 util_log "github.com/cortexproject/cortex/pkg/util/log"
47- "github.com/cortexproject/cortex/pkg/util/resource"
4849 "github.com/cortexproject/cortex/pkg/util/services"
4950 "github.com/cortexproject/cortex/pkg/util/validation"
5051)
@@ -1527,7 +1528,7 @@ func TestBlocksStoreQuerier_Select(t *testing.T) {
15271528 map [BlocksStoreClient ][]ulid.ULID {
15281529 & storeGatewayClientMock {
15291530 remoteAddr : "1.1.1.1" ,
1530- mockedSeriesErr : & limiter.ResourceLimitReachedError {} ,
1531+ mockedSeriesErr : limiter .ErrResourceLimitReached ,
15311532 }: {block1 },
15321533 },
15331534 map [BlocksStoreClient ][]ulid.ULID {
@@ -2499,20 +2500,18 @@ func TestBlocksStoreQuerier_PromQLExecution(t *testing.T) {
24992500 }
25002501}
25012502
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" )))
25162515}
25172516
25182517type blocksStoreSetMock struct {
0 commit comments