(t *testing.T)
| 491 | } |
| 492 | |
| 493 | func TestLimiter_AssertMaxSeriesPerLabelSet(t *testing.T) { |
| 494 | |
| 495 | tests := map[string]struct { |
| 496 | limits validation.Limits |
| 497 | expected error |
| 498 | ringReplicationFactor int |
| 499 | ringIngesterCount int |
| 500 | shardByAllLabels bool |
| 501 | series int |
| 502 | }{ |
| 503 | "both local and global limit are disabled": { |
| 504 | ringReplicationFactor: 3, |
| 505 | ringIngesterCount: 10, |
| 506 | series: 200, |
| 507 | shardByAllLabels: true, |
| 508 | limits: validation.Limits{ |
| 509 | LimitsPerLabelSet: []validation.LimitsPerLabelSet{ |
| 510 | { |
| 511 | LabelSet: labels.FromMap(map[string]string{"foo": "bar"}), |
| 512 | Limits: validation.LimitsPerLabelSetEntry{ |
| 513 | MaxSeries: 0, |
| 514 | }, |
| 515 | }, |
| 516 | }, |
| 517 | }, |
| 518 | }, |
| 519 | "current number of series is above the limit": { |
| 520 | ringReplicationFactor: 3, |
| 521 | ringIngesterCount: 10, |
| 522 | series: 200, |
| 523 | shardByAllLabels: true, |
| 524 | expected: errMaxSeriesPerLabelSetLimitExceeded{globalLimit: 10, actualLocalLimit: 3}, |
| 525 | limits: validation.Limits{ |
| 526 | LimitsPerLabelSet: []validation.LimitsPerLabelSet{ |
| 527 | { |
| 528 | LabelSet: labels.FromMap(map[string]string{"foo": "bar"}), |
| 529 | Limits: validation.LimitsPerLabelSetEntry{ |
| 530 | MaxSeries: 10, |
| 531 | }, |
| 532 | }, |
| 533 | }, |
| 534 | }, |
| 535 | }, |
| 536 | "current number of series is below the limit and shard by all labels": { |
| 537 | ringReplicationFactor: 3, |
| 538 | ringIngesterCount: 10, |
| 539 | series: 2, |
| 540 | shardByAllLabels: true, |
| 541 | limits: validation.Limits{ |
| 542 | LimitsPerLabelSet: []validation.LimitsPerLabelSet{ |
| 543 | { |
| 544 | LabelSet: labels.FromMap(map[string]string{"foo": "bar"}), |
| 545 | Limits: validation.LimitsPerLabelSetEntry{ |
| 546 | MaxSeries: 10, |
| 547 | }, |
| 548 | }, |
| 549 | }, |
| 550 | }, |
nothing calls this directly
no test coverage detected