Skip to content

Commit f781dcb

Browse files
committed
added test for muted alert
1 parent 676d8f1 commit f781dcb

1 file changed

Lines changed: 61 additions & 0 deletions

File tree

  • x-pack/test/alerting_api_integration/spaces_only/tests/alerting

x-pack/test/alerting_api_integration/spaces_only/tests/alerting/alerts_base.ts

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,67 @@ instanceStateValue: true
210210
});
211211
});
212212

213+
it('should not fire actions when an alert instance is resolved, but alert is muted', async () => {
214+
const reference = alertUtils.generateReference();
215+
216+
const { body: createdAction } = await supertestWithoutAuth
217+
.post(`${getUrlPrefix(space.id)}/api/actions/action`)
218+
.set('kbn-xsrf', 'foo')
219+
.send({
220+
name: 'MY action',
221+
actionTypeId: 'test.noop',
222+
config: {},
223+
secrets: {},
224+
})
225+
.expect(200);
226+
227+
// pattern of when the alert should fire.
228+
const pattern = {
229+
instance: [false, true, true],
230+
};
231+
232+
const createdAlert = await supertestWithoutAuth
233+
.post(`${getUrlPrefix(space.id)}/api/alerts/alert`)
234+
.set('kbn-xsrf', 'foo')
235+
.send(
236+
getTestAlertData({
237+
alertTypeId: 'test.patternFiring',
238+
schedule: { interval: '1s' },
239+
throttle: null,
240+
params: {
241+
pattern,
242+
},
243+
actions: [
244+
{
245+
id: createdAction.id,
246+
group: 'default',
247+
params: {},
248+
},
249+
{
250+
group: ResolvedActionGroup.id,
251+
id: indexRecordActionId,
252+
params: {
253+
index: ES_TEST_INDEX_NAME,
254+
reference,
255+
message: 'Resolved message',
256+
},
257+
},
258+
],
259+
})
260+
);
261+
262+
await alertUtils.muteAll(createdAlert.id);
263+
264+
expect(createdAlert.status).to.eql(200);
265+
const alertId = createdAlert.body.id;
266+
objectRemover.add(space.id, alertId, 'alert', 'alerts');
267+
268+
const actionTestRecord = (
269+
await esTestIndexTool.waitForDocs('action:test.index-record', reference, 0)
270+
)[0];
271+
expect(actionTestRecord).to.eql(0);
272+
});
273+
213274
it('should reschedule failing alerts using the Task Manager retry logic with alert schedule interval', async () => {
214275
/*
215276
Alerts should set the Task Manager schedule interval with initial value.

0 commit comments

Comments
 (0)