Skip to content

Commit

Permalink
added test for muted alert
Browse files Browse the repository at this point in the history
  • Loading branch information
YulNaumenko committed Nov 12, 2020
1 parent 676d8f1 commit f781dcb
Showing 1 changed file with 61 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,67 @@ instanceStateValue: true
});
});

it('should not fire actions when an alert instance is resolved, but alert is muted', async () => {
const reference = alertUtils.generateReference();

const { body: createdAction } = await supertestWithoutAuth
.post(`${getUrlPrefix(space.id)}/api/actions/action`)
.set('kbn-xsrf', 'foo')
.send({
name: 'MY action',
actionTypeId: 'test.noop',
config: {},
secrets: {},
})
.expect(200);

// pattern of when the alert should fire.
const pattern = {
instance: [false, true, true],
};

const createdAlert = await supertestWithoutAuth
.post(`${getUrlPrefix(space.id)}/api/alerts/alert`)
.set('kbn-xsrf', 'foo')
.send(
getTestAlertData({
alertTypeId: 'test.patternFiring',
schedule: { interval: '1s' },
throttle: null,
params: {
pattern,
},
actions: [
{
id: createdAction.id,
group: 'default',
params: {},
},
{
group: ResolvedActionGroup.id,
id: indexRecordActionId,
params: {
index: ES_TEST_INDEX_NAME,
reference,
message: 'Resolved message',
},
},
],
})
);

await alertUtils.muteAll(createdAlert.id);

expect(createdAlert.status).to.eql(200);
const alertId = createdAlert.body.id;
objectRemover.add(space.id, alertId, 'alert', 'alerts');

const actionTestRecord = (
await esTestIndexTool.waitForDocs('action:test.index-record', reference, 0)
)[0];
expect(actionTestRecord).to.eql(0);
});

it('should reschedule failing alerts using the Task Manager retry logic with alert schedule interval', async () => {
/*
Alerts should set the Task Manager schedule interval with initial value.
Expand Down

0 comments on commit f781dcb

Please sign in to comment.