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

Function TestFindNonOverlapQueryLength

pkg/util/promql/promql_test.go:12–88  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

10)
11
12func TestFindNonOverlapQueryLength(t *testing.T) {
13 for _, tc := range []struct {
14 name string
15 query string
16 expectedLength time.Duration
17 }{
18 {
19 name: "number literal, no select",
20 query: `1`,
21 },
22 {
23 name: "string literal, no select",
24 query: `"test"`,
25 },
26 {
27 name: "function, no select",
28 query: `"time()"`,
29 },
30 {
31 name: "single vector selector",
32 query: `up`,
33 expectedLength: time.Minute * 5,
34 },
35 {
36 name: "single matrix selector",
37 query: `up[1h]`,
38 expectedLength: time.Hour,
39 },
40 {
41 name: "sum rate",
42 query: `sum(rate(up[1h]))`,
43 expectedLength: time.Hour,
44 },
45 {
46 name: "single vector selector with offset",
47 query: `up offset 7d`,
48 expectedLength: time.Minute * 5,
49 },
50 {
51 name: "single matrix selector with offset",
52 query: `up[1h] offset 7d`,
53 expectedLength: time.Hour,
54 },
55 {
56 name: "multiple vector selectors, dedup time range",
57 query: `sum(up) + sum(up) + sum(up)`,
58 expectedLength: time.Minute * 5,
59 },
60 {
61 name: "multiple matrix selectors, dedup time range",
62 query: `sum_over_time(up[1h]) + sum_over_time(up[1h]) + sum_over_time(up[1h])`,
63 expectedLength: time.Hour,
64 },
65 {
66 name: "multiple vector selectors with offsets",
67 query: `sum(up) + sum(up offset 1h) + sum(up offset 2h)`,
68 expectedLength: time.Minute * 15,
69 },

Callers

nothing calls this directly

Calls 3

RunMethod · 0.65
EqualMethod · 0.65

Tested by

no test coverage detected