app/vmalert: fix tests after a216fe6728

a216fe6728
Signed-off-by: hagen1778 <roman@victoriametrics.com>
(cherry picked from commit eed0c3c6b0)
This commit is contained in:
hagen1778 2023-10-25 16:25:26 +02:00 committed by Aliaksandr Valialkin
parent 855c25b6c4
commit cf541c757a
No known key found for this signature in database
GPG key ID: A72BEC6CD3D0DED1

View file

@ -641,7 +641,7 @@ func TestGetPrometheusReqTimestamp(t *testing.T) {
Interval: time.Hour, Interval: time.Hour,
}, },
"2023-08-28T11:11:00+00:00", "2023-08-28T11:11:00+00:00",
"2023-08-28T10:59:30+00:00", "2023-08-28T11:00:00+00:00",
}, },
{ {
"without query align + default evalDelay", "without query align + default evalDelay",
@ -671,13 +671,22 @@ func TestGetPrometheusReqTimestamp(t *testing.T) {
"2023-08-28T11:30:00+00:00", "2023-08-28T11:30:00+00:00",
}, },
{ {
"with eval_delay", "1h interval with eval_delay",
&Group{ &Group{
EvalDelay: &evalDelay, EvalDelay: &evalDelay,
Interval: time.Hour, Interval: time.Hour,
}, },
"2023-08-28T11:41:00+00:00", "2023-08-28T11:41:00+00:00",
"2023-08-28T10:59:00+00:00", "2023-08-28T11:00:00+00:00",
},
{
"1m interval with eval_delay",
&Group{
EvalDelay: &evalDelay,
Interval: time.Minute,
},
"2023-08-28T11:41:13+00:00",
"2023-08-28T11:40:00+00:00",
}, },
{ {
"disable alignment with eval_delay", "disable alignment with eval_delay",
@ -687,16 +696,18 @@ func TestGetPrometheusReqTimestamp(t *testing.T) {
evalAlignment: &disableAlign, evalAlignment: &disableAlign,
}, },
"2023-08-28T11:41:00+00:00", "2023-08-28T11:41:00+00:00",
"2023-08-28T11:40:00+00:00", "2023-08-28T11:40:00+00:02",
}, },
} }
for _, tc := range testCases { for _, tc := range testCases {
originT, _ := time.Parse(time.RFC3339, tc.originTS) t.Run(tc.name, func(t *testing.T) {
expT, _ := time.Parse(time.RFC3339, tc.expTS) originT, _ := time.Parse(time.RFC3339, tc.originTS)
gotTS := tc.g.adjustReqTimestamp(originT) expT, _ := time.Parse(time.RFC3339, tc.expTS)
if !gotTS.Equal(expT) { gotTS := tc.g.adjustReqTimestamp(originT)
t.Fatalf("get wrong prometheus request timestamp, expect %s, got %s", expT, gotTS) if !gotTS.Equal(expT) {
} t.Fatalf("get wrong prometheus request timestamp, expect %s, got %s", expT, gotTS)
}
})
} }
} }