Skip to content

Commit

Permalink
update test
Browse files Browse the repository at this point in the history
  • Loading branch information
shahzad31 committed Jul 18, 2024
1 parent d7abefd commit 7c19f87
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ describe('Alert Actions factory', () => {
dedupKey: expect.any(String),
eventAction: 'resolve',
summary:
'The alert for "{{context.monitorName}}" from {{context.locationName}} is no longer active: {{context.recoveryReason}}. - Elastic Synthetics\n\nDetails:\n\n- Monitor name: {{context.monitorName}} \n- {{context.monitorUrlLabel}}: {{{context.monitorUrl}}} \n- Monitor type: {{context.monitorType}} \n- From: {{context.locationName}} \n- Last error received: {{{context.lastErrorMessage}}} \n{{{context.linkMessage}}}',
'The alert for monitor "{{context.monitorName}}" from {{context.locationName}} is no longer active: {{context.recoveryReason}}. - Elastic Synthetics\n\nDetails:\n\n- Monitor name: {{context.monitorName}} \n- {{context.monitorUrlLabel}}: {{{context.monitorUrl}}} \n- Monitor type: {{context.monitorType}} \n- From: {{context.locationName}} \n- Last error received: {{{context.lastErrorMessage}}} \n{{{context.linkMessage}}}',
},
},
{
Expand Down Expand Up @@ -193,7 +193,7 @@ describe('Alert Actions factory', () => {
dedupKey: expect.any(String),
eventAction: 'resolve',
summary:
'The alert for "{{context.monitorName}}" from {{context.locationName}} is no longer active: {{context.recoveryReason}}. - Elastic Synthetics\n\nDetails:\n\n- Monitor name: {{context.monitorName}} \n- {{context.monitorUrlLabel}}: {{{context.monitorUrl}}} \n- Monitor type: {{context.monitorType}} \n- From: {{context.locationName}} \n- Last error received: {{{context.lastErrorMessage}}} \n{{{context.linkMessage}}}',
'The alert for monitor "{{context.monitorName}}" from {{context.locationName}} is no longer active: {{context.recoveryReason}}. - Elastic Synthetics\n\nDetails:\n\n- Monitor name: {{context.monitorName}} \n- {{context.monitorUrlLabel}}: {{{context.monitorUrl}}} \n- Monitor type: {{context.monitorType}} \n- From: {{context.locationName}} \n- Last error received: {{{context.lastErrorMessage}}} \n{{{context.linkMessage}}}',
},
},
{
Expand Down Expand Up @@ -230,8 +230,7 @@ describe('Alert Actions factory', () => {
dedupKey: 'always-downxpack.uptime.alerts.actionGroups.monitorStatus',
eventAction: 'trigger',
severity: 'error',
summary:
'The alert for "{{context.monitorName}}" from {{context.locationName}} is no longer active: {{context.recoveryReason}}.\n\nDetails:\n\nMonitor name: {{context.monitorName}}\n{{context.monitorUrlLabel}}: {{{context.monitorUrl}}}\nMonitor type: {{context.monitorType}}\nFrom: {{context.locationName}}\nLatest error received: {{{context.lastErrorMessage}}}\n{{{context.linkMessage}}}',
summary: SyntheticsMonitorStatusTranslations.defaultRecoveryMessage,
},
id: 'f2a3b195-ed76-499a-805d-82d24d4eeba9',
},
Expand Down Expand Up @@ -263,11 +262,9 @@ describe('Alert Actions factory', () => {
path: '',
text: '',
},
message:
'The alert for "{{context.monitorName}}" from {{context.locationName}} is no longer active: {{context.recoveryReason}}. - Elastic Synthetics\n\nDetails:\n\n- Monitor name: {{context.monitorName}} \n- {{context.monitorUrlLabel}}: {{{context.monitorUrl}}} \n- Monitor type: {{context.monitorType}} \n- From: {{context.locationName}} \n- Last error received: {{{context.lastErrorMessage}}} \n{{{context.linkMessage}}}',
message: SyntheticsMonitorStatusTranslations.defaultRecoveryMessage,
messageHTML: null,
subject:
'"{{context.monitorName}}" ({{context.locationName}}) {{context.recoveryStatus}} - Elastic Synthetics',
subject: SyntheticsMonitorStatusTranslations.defaultRecoverySubjectMessage,
to: ['[email protected]'],
},
},
Expand All @@ -286,11 +283,9 @@ describe('Alert Actions factory', () => {
path: '',
text: '',
},
message:
'"{{context.monitorName}}" is {{{context.status}}} from {{context.locationName}}. - Elastic Synthetics\n\nDetails:\n\n- Monitor name: {{context.monitorName}} \n- {{context.monitorUrlLabel}}: {{{context.monitorUrl}}} \n- Monitor type: {{context.monitorType}} \n- Checked at: {{context.checkedAt}} \n- From: {{context.locationName}} \n- Error received: {{{context.lastErrorMessage}}} \n{{{context.linkMessage}}}',
message: SyntheticsMonitorStatusTranslations.defaultActionMessage,
messageHTML: null,
subject:
'"{{context.monitorName}}" ({{context.locationName}}) is down - Elastic Synthetics',
subject: SyntheticsMonitorStatusTranslations.defaultSubjectMessage,
to: ['[email protected]'],
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,37 +281,6 @@ describe('StatusRuleExecutor', () => {
});
});

it('tests getLastRunForPendingMonitors filters out recently created', async () => {
jest.spyOn(monitorUtils, 'getAllMonitors').mockResolvedValue([
{
...testMonitors[0],
attributes: {
...testMonitors[0].attributes,
locations: [
{
geo: { lon: -95.86, lat: 41.25 },
isServiceManaged: true,
id: 'us_central_qa',
},
],
},
created_at: moment().subtract(5, 'minutes').toISOString(),
},
]);

await statusRule.getDownChecks();
const { pendingConfigs } = await statusRule.getLastRunForPendingMonitors({
id1: {
locationId: 'us-east-1',
configId: 'id1',
status: 'down',
timestamp: '2021-06-01T00:00:00.000Z',
monitorQueryId: 'test',
},
});
expect(pendingConfigs).toEqual({});
});

it('tests findEarliestMonitorCreatedAt', async () => {
const fiveMinutesAgo = moment().subtract(5, 'minutes').toISOString();
const tenMinutesAgo = moment().subtract(10, 'minutes').toISOString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -593,25 +593,25 @@ describe('current status route', () => {
pendingConfigs: {
'id3-Asia/Pacific - Japan': {
configId: 'id3',
location: 'Asia/Pacific - Japan',
locationId: 'Asia/Pacific - Japan',
monitorQueryId: 'project-monitor-id',
status: 'unknown',
},
'id3-Europe - Germany': {
configId: 'id3',
location: 'Europe - Germany',
locationId: 'Europe - Germany',
monitorQueryId: 'project-monitor-id',
status: 'unknown',
},
'id4-Asia/Pacific - Japan': {
configId: 'id4',
location: 'Asia/Pacific - Japan',
locationId: 'Asia/Pacific - Japan',
monitorQueryId: 'id4',
status: 'unknown',
},
'id4-Europe - Germany': {
configId: 'id4',
location: 'Europe - Germany',
locationId: 'Europe - Germany',
monitorQueryId: 'id4',
status: 'unknown',
},
Expand Down

0 comments on commit 7c19f87

Please sign in to comment.