MCPcopy Index your code
hub / github.com/prometheus/prometheus / TestQueryError

Function TestQueryError

promql/engine_test.go:249–276  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

247func (errSeriesSet) Warnings() annotations.Annotations { return nil }
248
249func TestQueryError(t *testing.T) {
250 opts := promql.EngineOpts{
251 Logger: nil,
252 Reg: nil,
253 MaxSamples: 10,
254 Timeout: 10 * time.Second,
255 }
256 engine := promqltest.NewTestEngineWithOpts(t, opts)
257 errStorage := promql.ErrStorage{errors.New("storage error")}
258 queryable := storage.QueryableFunc(func(_, _ int64) (storage.Querier, error) {
259 return &errQuerier{err: errStorage}, nil
260 })
261 ctx := t.Context()
262
263 vectorQuery, err := engine.NewInstantQuery(ctx, queryable, nil, "foo", time.Unix(1, 0))
264 require.NoError(t, err)
265
266 res := vectorQuery.Exec(ctx)
267 require.Error(t, res.Err, "expected error on failed select but got none")
268 require.ErrorIs(t, res.Err, errStorage, "expected error doesn't match")
269
270 matrixQuery, err := engine.NewInstantQuery(ctx, queryable, nil, "foo[1m]", time.Unix(1, 0))
271 require.NoError(t, err)
272
273 res = matrixQuery.Exec(ctx)
274 require.Error(t, res.Err, "expected error on failed select but got none")
275 require.ErrorIs(t, res.Err, errStorage, "expected error doesn't match")
276}
277
278type noopHintRecordingQueryable struct {
279 hints []*storage.SelectHints

Callers

nothing calls this directly

Calls 6

NewTestEngineWithOptsFunction · 0.92
QueryableFuncFuncType · 0.92
NewInstantQueryMethod · 0.65
ExecMethod · 0.65
ErrorMethod · 0.65
ContextMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…