6
6
7
7
"github.com/go-kit/log"
8
8
"github.com/grafana/dskit/flagext"
9
+ "github.com/pkg/errors"
9
10
"github.com/prometheus/client_golang/prometheus"
10
11
"github.com/prometheus/common/model"
11
12
"github.com/stretchr/testify/require"
@@ -16,16 +17,24 @@ import (
16
17
"github.com/grafana/loki/v3/pkg/storage/stores/shipper/bloomshipper"
17
18
)
18
19
20
+ type errorMockPool struct {
21
+ * JumpHashClientPool
22
+ }
23
+
24
+ func (p * errorMockPool ) Addr (_ string ) (string , error ) {
25
+ return "" , errors .New ("no server found" )
26
+ }
27
+
19
28
func TestBloomGatewayClient (t * testing.T ) {
20
29
logger := log .NewNopLogger ()
21
- reg := prometheus .NewRegistry ()
22
30
23
31
limits := newLimits ()
24
32
25
33
cfg := ClientConfig {}
26
34
flagext .DefaultValues (& cfg )
27
35
28
36
t .Run ("FilterChunks returns response" , func (t * testing.T ) {
37
+ reg := prometheus .NewRegistry ()
29
38
c , err := NewClient (cfg , limits , reg , logger , nil , false )
30
39
require .NoError (t , err )
31
40
expr , err := syntax .ParseExpr (`{foo="bar"}` )
@@ -34,6 +43,33 @@ func TestBloomGatewayClient(t *testing.T) {
34
43
require .NoError (t , err )
35
44
require .Equal (t , 0 , len (res ))
36
45
})
46
+
47
+ t .Run ("pool error is suppressed and returns full list of chunks" , func (t * testing.T ) {
48
+ reg := prometheus .NewRegistry ()
49
+ c , err := NewClient (cfg , limits , reg , logger , nil , false )
50
+ require .NoError (t , err )
51
+ c .pool = & errorMockPool {}
52
+
53
+ expected := []* logproto.GroupedChunkRefs {
54
+ {Fingerprint : 0x00 , Refs : []* logproto.ShortRef {shortRef (0 , 1 , 1 )}},
55
+ {Fingerprint : 0x9f , Refs : []* logproto.ShortRef {shortRef (0 , 1 , 2 )}},
56
+ {Fingerprint : 0xa0 , Refs : []* logproto.ShortRef {shortRef (0 , 1 , 3 )}},
57
+ {Fingerprint : 0xff , Refs : []* logproto.ShortRef {shortRef (0 , 1 , 4 )}},
58
+ }
59
+
60
+ blocks := []blockWithSeries {
61
+ {block : mkBlockRef (0x00 , 0x9f ), series : expected [0 :2 ]},
62
+ {block : mkBlockRef (0xa0 , 0xff ), series : expected [2 :4 ]},
63
+ }
64
+ expr , err := syntax .ParseExpr (`{foo="bar"}` )
65
+ require .NoError (t , err )
66
+
67
+ res , err := c .FilterChunks (context .Background (), "tenant" , bloomshipper .NewInterval (0 , 0 ), blocks , plan.QueryPlan {AST : expr })
68
+ require .NoError (t , err )
69
+ require .Equal (t , 4 , len (res ))
70
+
71
+ require .Equal (t , expected , res )
72
+ })
37
73
}
38
74
39
75
func shortRef (f , t model.Time , c uint32 ) * logproto.ShortRef {
@@ -94,3 +130,6 @@ func TestGatewayClient_MergeChunkSets(t *testing.T) {
94
130
result := mergeChunkSets (inp1 , inp2 )
95
131
require .Equal (t , expected , result )
96
132
}
133
+
134
+ func TestGatewayClient_FilterChunks (t * testing.T ) {
135
+ }
0 commit comments