MCPcopy Index your code
hub / github.com/cortexproject/cortex / TestEngine_XFunctions

Function TestEngine_XFunctions

pkg/engine/engine_test.go:105–128  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

103}
104
105func TestEngine_XFunctions(t *testing.T) {
106 ctx := context.Background()
107 reg := prometheus.NewRegistry()
108
109 now := time.Now()
110 start := time.Now().Add(-time.Minute * 5)
111 step := time.Minute
112 queryable := promqltest.LoadedStorage(t, "")
113 opts := promql.EngineOpts{
114 Logger: utillog.GoKitLogToSlog(log.NewNopLogger()),
115 Reg: reg,
116 }
117 queryEngine := New(opts, ThanosEngineConfig{Enabled: true, EnableXFunctions: true}, reg)
118
119 for name := range parse.XFunctions {
120 t.Run(name, func(t *testing.T) {
121 _, err := queryEngine.NewInstantQuery(ctx, queryable, nil, fmt.Sprintf("%s(foo[1m])", name), now)
122 require.NoError(t, err)
123
124 _, err = queryEngine.NewRangeQuery(ctx, queryable, nil, fmt.Sprintf("%s(foo[1m])", name), start, now, step)
125 require.NoError(t, err)
126 })
127 }
128}
129
130func TestEngine_With_Logical_Plan(t *testing.T) {
131 ctx := context.Background()

Callers

nothing calls this directly

Calls 5

NewInstantQueryMethod · 0.80
NewRangeQueryMethod · 0.80
NewFunction · 0.70
RunMethod · 0.65
AddMethod · 0.45

Tested by

no test coverage detected