mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Alerting: Fix state age test failures (#22606)
- use output from relative time instead of static string to prevent clock issues
This commit is contained in:
parent
6af45bf4ac
commit
99daa4454b
@ -4,9 +4,9 @@ import { AlertRuleDTO, AlertRulesState } from 'app/types';
|
|||||||
import { reducerTester } from '../../../../test/core/redux/reducerTester';
|
import { reducerTester } from '../../../../test/core/redux/reducerTester';
|
||||||
|
|
||||||
describe('Alert rules', () => {
|
describe('Alert rules', () => {
|
||||||
const newStateDate = dateTime()
|
const newStateDate = dateTime().subtract(1, 'y');
|
||||||
.subtract(1, 'y')
|
const newStateDateFormatted = newStateDate.format('YYYY-MM-DD');
|
||||||
.format('YYYY-MM-DD');
|
const newStateDateAge = newStateDate.fromNow(true);
|
||||||
const payload: AlertRuleDTO[] = [
|
const payload: AlertRuleDTO[] = [
|
||||||
{
|
{
|
||||||
id: 2,
|
id: 2,
|
||||||
@ -16,7 +16,7 @@ describe('Alert rules', () => {
|
|||||||
panelId: 4,
|
panelId: 4,
|
||||||
name: 'TestData - Always Alerting',
|
name: 'TestData - Always Alerting',
|
||||||
state: 'alerting',
|
state: 'alerting',
|
||||||
newStateDate: `${newStateDate}T10:00:30+02:00`,
|
newStateDate: `${newStateDateFormatted}T10:00:30+02:00`,
|
||||||
evalDate: '0001-01-01T00:00:00Z',
|
evalDate: '0001-01-01T00:00:00Z',
|
||||||
evalData: { evalMatches: [{ metric: 'A-series', tags: null, value: 215 }] },
|
evalData: { evalMatches: [{ metric: 'A-series', tags: null, value: 215 }] },
|
||||||
executionError: '',
|
executionError: '',
|
||||||
@ -30,7 +30,7 @@ describe('Alert rules', () => {
|
|||||||
panelId: 3,
|
panelId: 3,
|
||||||
name: 'TestData - Always OK',
|
name: 'TestData - Always OK',
|
||||||
state: 'ok',
|
state: 'ok',
|
||||||
newStateDate: `${newStateDate}T10:01:01+02:00`,
|
newStateDate: `${newStateDateFormatted}T10:01:01+02:00`,
|
||||||
evalDate: '0001-01-01T00:00:00Z',
|
evalDate: '0001-01-01T00:00:00Z',
|
||||||
evalData: {},
|
evalData: {},
|
||||||
executionError: '',
|
executionError: '',
|
||||||
@ -44,7 +44,7 @@ describe('Alert rules', () => {
|
|||||||
panelId: 3,
|
panelId: 3,
|
||||||
name: 'TestData - ok',
|
name: 'TestData - ok',
|
||||||
state: 'ok',
|
state: 'ok',
|
||||||
newStateDate: `${newStateDate}T10:01:01+02:00`,
|
newStateDate: `${newStateDateFormatted}T10:01:01+02:00`,
|
||||||
evalDate: '0001-01-01T00:00:00Z',
|
evalDate: '0001-01-01T00:00:00Z',
|
||||||
evalData: {},
|
evalData: {},
|
||||||
executionError: 'error',
|
executionError: 'error',
|
||||||
@ -58,7 +58,7 @@ describe('Alert rules', () => {
|
|||||||
panelId: 3,
|
panelId: 3,
|
||||||
name: 'TestData - Paused',
|
name: 'TestData - Paused',
|
||||||
state: 'paused',
|
state: 'paused',
|
||||||
newStateDate: `${newStateDate}T10:01:01+02:00`,
|
newStateDate: `${newStateDateFormatted}T10:01:01+02:00`,
|
||||||
evalDate: '0001-01-01T00:00:00Z',
|
evalDate: '0001-01-01T00:00:00Z',
|
||||||
evalData: {},
|
evalData: {},
|
||||||
executionError: 'error',
|
executionError: 'error',
|
||||||
@ -72,7 +72,7 @@ describe('Alert rules', () => {
|
|||||||
panelId: 3,
|
panelId: 3,
|
||||||
name: 'TestData - Ok',
|
name: 'TestData - Ok',
|
||||||
state: 'ok',
|
state: 'ok',
|
||||||
newStateDate: `${newStateDate}T10:01:01+02:00`,
|
newStateDate: `${newStateDateFormatted}T10:01:01+02:00`,
|
||||||
evalDate: '0001-01-01T00:00:00Z',
|
evalDate: '0001-01-01T00:00:00Z',
|
||||||
evalData: {
|
evalData: {
|
||||||
noData: true,
|
noData: true,
|
||||||
@ -126,10 +126,10 @@ describe('Alert rules', () => {
|
|||||||
executionError: '',
|
executionError: '',
|
||||||
id: 2,
|
id: 2,
|
||||||
name: 'TestData - Always Alerting',
|
name: 'TestData - Always Alerting',
|
||||||
newStateDate: `${newStateDate}T10:00:30+02:00`,
|
newStateDate: `${newStateDateFormatted}T10:00:30+02:00`,
|
||||||
panelId: 4,
|
panelId: 4,
|
||||||
state: 'alerting',
|
state: 'alerting',
|
||||||
stateAge: 'a year',
|
stateAge: newStateDateAge,
|
||||||
stateClass: 'alert-state-critical',
|
stateClass: 'alert-state-critical',
|
||||||
stateIcon: 'icon-gf icon-gf-critical',
|
stateIcon: 'icon-gf icon-gf-critical',
|
||||||
stateText: 'ALERTING',
|
stateText: 'ALERTING',
|
||||||
@ -144,10 +144,10 @@ describe('Alert rules', () => {
|
|||||||
executionError: '',
|
executionError: '',
|
||||||
id: 1,
|
id: 1,
|
||||||
name: 'TestData - Always OK',
|
name: 'TestData - Always OK',
|
||||||
newStateDate: `${newStateDate}T10:01:01+02:00`,
|
newStateDate: `${newStateDateFormatted}T10:01:01+02:00`,
|
||||||
panelId: 3,
|
panelId: 3,
|
||||||
state: 'ok',
|
state: 'ok',
|
||||||
stateAge: 'a year',
|
stateAge: newStateDateAge,
|
||||||
stateClass: 'alert-state-ok',
|
stateClass: 'alert-state-ok',
|
||||||
stateIcon: 'icon-gf icon-gf-online',
|
stateIcon: 'icon-gf icon-gf-online',
|
||||||
stateText: 'OK',
|
stateText: 'OK',
|
||||||
@ -163,10 +163,10 @@ describe('Alert rules', () => {
|
|||||||
id: 3,
|
id: 3,
|
||||||
info: 'Execution Error: error',
|
info: 'Execution Error: error',
|
||||||
name: 'TestData - ok',
|
name: 'TestData - ok',
|
||||||
newStateDate: `${newStateDate}T10:01:01+02:00`,
|
newStateDate: `${newStateDateFormatted}T10:01:01+02:00`,
|
||||||
panelId: 3,
|
panelId: 3,
|
||||||
state: 'ok',
|
state: 'ok',
|
||||||
stateAge: 'a year',
|
stateAge: newStateDateAge,
|
||||||
stateClass: 'alert-state-ok',
|
stateClass: 'alert-state-ok',
|
||||||
stateIcon: 'icon-gf icon-gf-online',
|
stateIcon: 'icon-gf icon-gf-online',
|
||||||
stateText: 'OK',
|
stateText: 'OK',
|
||||||
@ -181,10 +181,10 @@ describe('Alert rules', () => {
|
|||||||
executionError: 'error',
|
executionError: 'error',
|
||||||
id: 4,
|
id: 4,
|
||||||
name: 'TestData - Paused',
|
name: 'TestData - Paused',
|
||||||
newStateDate: `${newStateDate}T10:01:01+02:00`,
|
newStateDate: `${newStateDateFormatted}T10:01:01+02:00`,
|
||||||
panelId: 3,
|
panelId: 3,
|
||||||
state: 'paused',
|
state: 'paused',
|
||||||
stateAge: 'a year',
|
stateAge: newStateDateAge,
|
||||||
stateClass: 'alert-state-paused',
|
stateClass: 'alert-state-paused',
|
||||||
stateIcon: 'fa fa-pause',
|
stateIcon: 'fa fa-pause',
|
||||||
stateText: 'PAUSED',
|
stateText: 'PAUSED',
|
||||||
@ -202,10 +202,10 @@ describe('Alert rules', () => {
|
|||||||
id: 5,
|
id: 5,
|
||||||
info: 'Query returned no data',
|
info: 'Query returned no data',
|
||||||
name: 'TestData - Ok',
|
name: 'TestData - Ok',
|
||||||
newStateDate: `${newStateDate}T10:01:01+02:00`,
|
newStateDate: `${newStateDateFormatted}T10:01:01+02:00`,
|
||||||
panelId: 3,
|
panelId: 3,
|
||||||
state: 'ok',
|
state: 'ok',
|
||||||
stateAge: 'a year',
|
stateAge: newStateDateAge,
|
||||||
stateClass: 'alert-state-ok',
|
stateClass: 'alert-state-ok',
|
||||||
stateIcon: 'icon-gf icon-gf-online',
|
stateIcon: 'icon-gf icon-gf-online',
|
||||||
stateText: 'OK',
|
stateText: 'OK',
|
||||||
|
Loading…
Reference in New Issue
Block a user