(t *testing.T)
| 636 | } |
| 637 | |
| 638 | func TestPollTolerateConsecutiveErrors(t *testing.T) { |
| 639 | var ( |
| 640 | c = newMockCompactor(PerTenantCompacted{}, false) |
| 641 | w = &backend.MockWriter{} |
| 642 | s = &mockJobSharder{owns: true} |
| 643 | b = newBlocklist(PerTenant{}, PerTenantCompacted{}) |
| 644 | ) |
| 645 | |
| 646 | testCases := []struct { |
| 647 | name string |
| 648 | tolerate int |
| 649 | tollerateTenantFailures int |
| 650 | tenantErrors map[string][]error |
| 651 | expectedError error |
| 652 | }{ |
| 653 | { |
| 654 | name: "no errors", |
| 655 | tolerate: 0, |
| 656 | tenantErrors: map[string][]error{"one": {}}, |
| 657 | expectedError: nil, |
| 658 | }, |
| 659 | { |
| 660 | name: "untolerated single error", |
| 661 | tolerate: 0, |
| 662 | tollerateTenantFailures: 0, |
| 663 | tenantErrors: map[string][]error{"one": {errors.New("tenant one error")}}, |
| 664 | expectedError: errors.New("too many tenant failures; abandoning polling cycle"), |
| 665 | }, |
| 666 | { |
| 667 | name: "tolerated errors", |
| 668 | tolerate: 2, |
| 669 | tollerateTenantFailures: 1, |
| 670 | tenantErrors: map[string][]error{ |
| 671 | "one": { |
| 672 | errors.New("tenant one error"), |
| 673 | errors.New("tenant one error"), |
| 674 | nil, |
| 675 | }, |
| 676 | "two": { |
| 677 | errors.New("tenant two error"), |
| 678 | errors.New("tenant two error"), |
| 679 | nil, |
| 680 | }, |
| 681 | }, |
| 682 | expectedError: nil, |
| 683 | }, |
| 684 | { |
| 685 | name: "too many errors", |
| 686 | tolerate: 2, |
| 687 | tollerateTenantFailures: 1, |
| 688 | tenantErrors: map[string][]error{ |
| 689 | "one": { |
| 690 | errors.New("tenant one error"), |
| 691 | errors.New("tenant one error"), |
| 692 | nil, |
| 693 | }, |
| 694 | "two": { |
| 695 | errors.New("tenant two error"), |
nothing calls this directly
no test coverage detected