MCPcopy Create free account
hub / github.com/cortexproject/cortex / TestLimits

Function TestLimits

pkg/querier/querier_test.go:387–540  ·  view source on GitHub ↗

By testing limits, we are ensuring queries with multiple selects share the query limiter

(t *testing.T)

Source from the content-addressed store, hash-verified

385
386// By testing limits, we are ensuring queries with multiple selects share the query limiter
387func TestLimits(t *testing.T) {
388 t.Parallel()
389 start := time.Now().Add(-2 * time.Hour)
390 end := time.Now()
391 ctx := user.InjectOrgID(context.Background(), "0")
392 var cfg Config
393 flagext.DefaultValues(&cfg)
394 const chunks = 1
395
396 for _, enc := range encodings {
397 chks, _ := makeMockChunks(t, chunks, enc, model.TimeFromUnix(start.Unix()))
398 clientChks, err := chunkcompat.ToChunks(chks)
399 require.NoError(t, err)
400 streamResponse := client.QueryStreamResponse{
401 Chunkseries: []client.TimeSeriesChunk{
402 {
403 Labels: []cortexpb.LabelAdapter{
404 {Name: model.MetricNameLabel, Value: "foo"},
405 {Name: "order", Value: "2"},
406 },
407 Chunks: clientChks,
408 },
409 {
410 Labels: []cortexpb.LabelAdapter{
411 {Name: model.MetricNameLabel, Value: "foo"},
412 {Name: "order", Value: "1"},
413 },
414 Chunks: clientChks,
415 },
416 {
417 Labels: []cortexpb.LabelAdapter{
418 {Name: model.MetricNameLabel, Value: "foo"},
419 {Name: "orders", Value: "3"},
420 },
421 Chunks: clientChks,
422 },
423 {
424 Labels: []cortexpb.LabelAdapter{
425 {Name: model.MetricNameLabel, Value: "bar"},
426 {Name: "orders", Value: "2"},
427 },
428 Chunks: clientChks,
429 },
430 {
431 Labels: []cortexpb.LabelAdapter{
432 {Name: model.MetricNameLabel, Value: "bar"},
433 {Name: "orders", Value: "1"},
434 },
435 Chunks: clientChks,
436 },
437 },
438 }
439
440 distributor := &MockLimitingDistributor{
441 response: &streamResponse,
442 }
443
444 distributorQueryableStreaming := newDistributorQueryable(distributor, cfg.IngesterMetadataStreaming, cfg.IngesterLabelNamesWithMatchers, batch.NewChunkMergeIterator, cfg.QueryIngestersWithin, nil, 1)

Callers

nothing calls this directly

Calls 14

NewRangeQueryMethod · 0.95
DefaultValuesFunction · 0.92
ToChunksFunction · 0.92
NewOverridesFunction · 0.92
makeMockChunksFunction · 0.85
newDistributorQueryableFunction · 0.85
UseAlwaysQueryableFunction · 0.85
DefaultLimitsConfigFunction · 0.85
NewQueryableFunction · 0.70
RunMethod · 0.65
StringMethod · 0.65
ExecMethod · 0.65

Tested by

no test coverage detected