By testing limits, we are ensuring queries with multiple selects share the query limiter
(t *testing.T)
| 385 | |
| 386 | // By testing limits, we are ensuring queries with multiple selects share the query limiter |
| 387 | func 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) |
nothing calls this directly
no test coverage detected