@@ -171,13 +171,13 @@ func TestIngesterStreaming(t *testing.T) {
171
171
},
172
172
},
173
173
}
174
- d .On ("QueryStream" , mock .Anything , mock .Anything , mock .Anything , mock .Anything ).Return (queryResponse , nil )
175
-
176
- ctx := user .InjectOrgID (context .Background (), "0" )
174
+ var partialDataErr error
177
175
if partialDataEnabled {
178
- d = & MockDistributor {}
179
- d .On ("QueryStream" , mock .Anything , mock .Anything , mock .Anything , mock .Anything ).Return (queryResponse , partialdata.Error {})
176
+ partialDataErr = partialdata.Error {}
180
177
}
178
+ d .On ("QueryStream" , mock .Anything , mock .Anything , mock .Anything , mock .Anything ).Return (queryResponse , partialDataErr )
179
+
180
+ ctx := user .InjectOrgID (context .Background (), "0" )
181
181
182
182
queryable := newDistributorQueryable (d , true , true , batch .NewChunkMergeIterator , 0 , func (string ) bool {
183
183
return partialDataEnabled
@@ -204,7 +204,7 @@ func TestIngesterStreaming(t *testing.T) {
204
204
require .NoError (t , seriesSet .Err ())
205
205
206
206
if partialDataEnabled {
207
- require .NotEmpty (t , seriesSet .Warnings ())
207
+ require .Contains (t , seriesSet .Warnings (), partialdata . ErrorMsg )
208
208
}
209
209
}
210
210
}
@@ -218,40 +218,52 @@ func TestDistributorQuerier_LabelNames(t *testing.T) {
218
218
219
219
for _ , labelNamesWithMatchers := range []bool {false , true } {
220
220
for _ , streamingEnabled := range []bool {false , true } {
221
- streamingEnabled := streamingEnabled
222
- labelNamesWithMatchers := labelNamesWithMatchers
223
- t .Run ("with matchers" , func (t * testing.T ) {
224
- t .Parallel ()
225
-
226
- metrics := []model.Metric {
227
- {"foo" : "bar" },
228
- {"job" : "baz" },
229
- {"job" : "baz" , "foo" : "boom" },
230
- }
231
- d := & MockDistributor {}
232
-
233
- if labelNamesWithMatchers {
234
- d .On ("LabelNames" , mock .Anything , model .Time (mint ), model .Time (maxt ), mock .Anything , someMatchers ).
235
- Return (labelNames , nil )
236
- d .On ("LabelNamesStream" , mock .Anything , model .Time (mint ), model .Time (maxt ), mock .Anything , someMatchers ).
237
- Return (labelNames , nil )
238
- } else {
239
- d .On ("MetricsForLabelMatchers" , mock .Anything , model .Time (mint ), model .Time (maxt ), mock .Anything , someMatchers ).
240
- Return (metrics , nil )
241
- d .On ("MetricsForLabelMatchersStream" , mock .Anything , model .Time (mint ), model .Time (maxt ), mock .Anything , someMatchers ).
242
- Return (metrics , nil )
243
- }
221
+ for _ , partialDataEnabled := range []bool {false , true } {
222
+ streamingEnabled := streamingEnabled
223
+ labelNamesWithMatchers := labelNamesWithMatchers
224
+ t .Run ("with matchers" , func (t * testing.T ) {
225
+ t .Parallel ()
226
+
227
+ metrics := []model.Metric {
228
+ {"foo" : "bar" },
229
+ {"job" : "baz" },
230
+ {"job" : "baz" , "foo" : "boom" },
231
+ }
232
+ d := & MockDistributor {}
244
233
245
- queryable := newDistributorQueryable (d , streamingEnabled , labelNamesWithMatchers , nil , 0 , nil )
246
- querier , err := queryable .Querier (mint , maxt )
247
- require .NoError (t , err )
234
+ var partialDataErr error
235
+ if partialDataEnabled {
236
+ partialDataErr = partialdata.Error {}
237
+ }
238
+ if labelNamesWithMatchers {
239
+ d .On ("LabelNames" , mock .Anything , model .Time (mint ), model .Time (maxt ), mock .Anything , someMatchers ).
240
+ Return (labelNames , partialDataErr )
241
+ d .On ("LabelNamesStream" , mock .Anything , model .Time (mint ), model .Time (maxt ), mock .Anything , someMatchers ).
242
+ Return (labelNames , partialDataErr )
243
+ } else {
244
+ d .On ("MetricsForLabelMatchers" , mock .Anything , model .Time (mint ), model .Time (maxt ), mock .Anything , someMatchers ).
245
+ Return (metrics , partialDataErr )
246
+ d .On ("MetricsForLabelMatchersStream" , mock .Anything , model .Time (mint ), model .Time (maxt ), mock .Anything , someMatchers ).
247
+ Return (metrics , partialDataErr )
248
+ }
248
249
249
- ctx := context .Background ()
250
- names , warnings , err := querier .LabelNames (ctx , nil , someMatchers ... )
251
- require .NoError (t , err )
252
- assert .Empty (t , warnings )
253
- assert .Equal (t , labelNames , names )
254
- })
250
+ queryable := newDistributorQueryable (d , streamingEnabled , labelNamesWithMatchers , nil , 0 , func (string ) bool {
251
+ return partialDataEnabled
252
+ })
253
+ querier , err := queryable .Querier (mint , maxt )
254
+ require .NoError (t , err )
255
+
256
+ ctx := context .Background ()
257
+ names , warnings , err := querier .LabelNames (ctx , nil , someMatchers ... )
258
+ require .NoError (t , err )
259
+ if partialDataEnabled {
260
+ assert .Contains (t , warnings , partialdata .ErrorMsg )
261
+ } else {
262
+ assert .Empty (t , warnings )
263
+ }
264
+ assert .Equal (t , labelNames , names )
265
+ })
266
+ }
255
267
}
256
268
}
257
269
}
0 commit comments