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

Function TestQueryLookbackDelta

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

Source from the content-addressed store, hash-verified

3949}
3950
3951func TestQueryLookbackDelta(t *testing.T) {
3952 var (
3953 load = `load 5m
3954metric 0 1 2
3955`
3956 query = "metric"
3957 lastDatapointTs = time.Unix(600, 0)
3958 )
3959
3960 cases := []struct {
3961 name string
3962 ts time.Time
3963 engineLookback, queryLookback time.Duration
3964 expectSamples bool
3965 }{
3966 {
3967 name: "default lookback delta",
3968 ts: lastDatapointTs.Add(defaultLookbackDelta - time.Millisecond),
3969 expectSamples: true,
3970 },
3971 {
3972 name: "outside default lookback delta",
3973 ts: lastDatapointTs.Add(defaultLookbackDelta),
3974 expectSamples: false,
3975 },
3976 {
3977 name: "custom engine lookback delta",
3978 ts: lastDatapointTs.Add(10*time.Minute - time.Millisecond),
3979 engineLookback: 10 * time.Minute,
3980 expectSamples: true,
3981 },
3982 {
3983 name: "outside custom engine lookback delta",
3984 ts: lastDatapointTs.Add(10 * time.Minute),
3985 engineLookback: 10 * time.Minute,
3986 expectSamples: false,
3987 },
3988 {
3989 name: "custom query lookback delta",
3990 ts: lastDatapointTs.Add(20*time.Minute - time.Millisecond),
3991 engineLookback: 10 * time.Minute,
3992 queryLookback: 20 * time.Minute,
3993 expectSamples: true,
3994 },
3995 {
3996 name: "outside custom query lookback delta",
3997 ts: lastDatapointTs.Add(20 * time.Minute),
3998 engineLookback: 10 * time.Minute,
3999 queryLookback: 20 * time.Minute,
4000 expectSamples: false,
4001 },
4002 {
4003 name: "negative custom query lookback delta",
4004 ts: lastDatapointTs.Add(20*time.Minute - time.Millisecond),
4005 engineLookback: -10 * time.Minute,
4006 queryLookback: 20 * time.Minute,
4007 expectSamples: true,
4008 },

Callers

nothing calls this directly

Calls 7

NewTestEngineFunction · 0.92
LoadedStorageFunction · 0.92
NewPrometheusQueryOptsFunction · 0.92
AddMethod · 0.65
RunMethod · 0.65
NewInstantQueryMethod · 0.65
ExecMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…