runQueryFuzzTestCases executes the fuzz test for the specified number of runs for both instant and range queries.
(t *testing.T, ps *promqlsmith.PromQLSmith, c1, c2 *e2ecortex.Client, queryTime, start, end time.Time, step time.Duration, run int, skipStdAggregations bool)
| 1737 | |
| 1738 | // runQueryFuzzTestCases executes the fuzz test for the specified number of runs for both instant and range queries. |
| 1739 | func runQueryFuzzTestCases(t *testing.T, ps *promqlsmith.PromQLSmith, c1, c2 *e2ecortex.Client, queryTime, start, end time.Time, step time.Duration, run int, skipStdAggregations bool) { |
| 1740 | type testCase struct { |
| 1741 | query string |
| 1742 | res1, res2 model.Value |
| 1743 | err1, err2 error |
| 1744 | instantQuery bool |
| 1745 | } |
| 1746 | |
| 1747 | cases := make([]*testCase, 0, 2*run) |
| 1748 | var ( |
| 1749 | expr parser.Expr |
| 1750 | query string |
| 1751 | ) |
| 1752 | for i := 0; i < run; i++ { |
| 1753 | for { |
| 1754 | expr = ps.WalkInstantQuery() |
| 1755 | if isValidQuery(expr, skipStdAggregations) { |
| 1756 | query = expr.Pretty(0) |
| 1757 | break |
| 1758 | } |
| 1759 | } |
| 1760 | |
| 1761 | res1, err1 := c1.Query(query, queryTime) |
| 1762 | res2, err2 := c2.Query(query, queryTime) |
| 1763 | cases = append(cases, &testCase{ |
| 1764 | query: query, |
| 1765 | res1: res1, |
| 1766 | res2: res2, |
| 1767 | err1: err1, |
| 1768 | err2: err2, |
| 1769 | instantQuery: true, |
| 1770 | }) |
| 1771 | } |
| 1772 | |
| 1773 | for i := 0; i < run; i++ { |
| 1774 | for { |
| 1775 | expr = ps.WalkRangeQuery() |
| 1776 | if isValidQuery(expr, skipStdAggregations) { |
| 1777 | query = expr.Pretty(0) |
| 1778 | break |
| 1779 | } |
| 1780 | } |
| 1781 | |
| 1782 | res1, err1 := c1.QueryRange(query, start, end, step) |
| 1783 | res2, err2 := c2.QueryRange(query, start, end, step) |
| 1784 | cases = append(cases, &testCase{ |
| 1785 | query: query, |
| 1786 | res1: res1, |
| 1787 | res2: res2, |
| 1788 | err1: err1, |
| 1789 | err2: err2, |
| 1790 | instantQuery: false, |
| 1791 | }) |
| 1792 | } |
| 1793 | |
| 1794 | failures := 0 |
| 1795 | for i, tc := range cases { |
| 1796 | qt := "instant query" |
no test coverage detected