mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
Fix enable API to schedule task after alert is updated (#55095)
This commit is contained in:
parent
5af378a2fb
commit
9c2d778d1c
3 changed files with 9 additions and 7 deletions
|
@ -883,7 +883,6 @@ describe('enable()', () => {
|
|||
schedule: { interval: '10s' },
|
||||
alertTypeId: '2',
|
||||
enabled: true,
|
||||
scheduledTaskId: 'task-123',
|
||||
updatedBy: 'elastic',
|
||||
apiKey: null,
|
||||
apiKeyOwner: null,
|
||||
|
@ -892,6 +891,9 @@ describe('enable()', () => {
|
|||
version: '123',
|
||||
}
|
||||
);
|
||||
expect(savedObjectsClient.update).toHaveBeenCalledWith('alert', '1', {
|
||||
scheduledTaskId: 'task-123',
|
||||
});
|
||||
expect(taskManager.schedule).toHaveBeenCalledWith({
|
||||
taskType: `alerting:2`,
|
||||
params: {
|
||||
|
@ -964,7 +966,6 @@ describe('enable()', () => {
|
|||
schedule: { interval: '10s' },
|
||||
alertTypeId: '2',
|
||||
enabled: true,
|
||||
scheduledTaskId: 'task-123',
|
||||
apiKey: Buffer.from('123:abc').toString('base64'),
|
||||
apiKeyOwner: 'elastic',
|
||||
updatedBy: 'elastic',
|
||||
|
@ -973,6 +974,9 @@ describe('enable()', () => {
|
|||
version: '123',
|
||||
}
|
||||
);
|
||||
expect(savedObjectsClient.update).toHaveBeenCalledWith('alert', '1', {
|
||||
scheduledTaskId: 'task-123',
|
||||
});
|
||||
expect(taskManager.schedule).toHaveBeenCalledWith({
|
||||
taskType: `alerting:2`,
|
||||
params: {
|
||||
|
|
|
@ -362,7 +362,6 @@ export class AlertsClient {
|
|||
});
|
||||
|
||||
if (attributes.enabled === false) {
|
||||
const scheduledTask = await this.scheduleAlert(id, attributes.alertTypeId);
|
||||
const username = await this.getUserName();
|
||||
await this.savedObjectsClient.update(
|
||||
'alert',
|
||||
|
@ -372,11 +371,11 @@ export class AlertsClient {
|
|||
enabled: true,
|
||||
...this.apiKeyAsAlertAttributes(await this.createAPIKey(), username),
|
||||
updatedBy: username,
|
||||
|
||||
scheduledTaskId: scheduledTask.id,
|
||||
},
|
||||
{ version }
|
||||
);
|
||||
const scheduledTask = await this.scheduleAlert(id, attributes.alertTypeId);
|
||||
await this.savedObjectsClient.update('alert', id, { scheduledTaskId: scheduledTask.id });
|
||||
await this.invalidateApiKey({ apiKey: attributes.apiKey });
|
||||
}
|
||||
}
|
||||
|
|
|
@ -761,8 +761,7 @@ export default function alertTests({ getService }: FtrProviderContext) {
|
|||
}
|
||||
});
|
||||
|
||||
// Flaky: https://github.com/elastic/kibana/issues/54125
|
||||
it.skip(`should unmute all instances when unmuting an alert`, async () => {
|
||||
it(`should unmute all instances when unmuting an alert`, async () => {
|
||||
const testStart = new Date();
|
||||
const reference = alertUtils.generateReference();
|
||||
const response = await alertUtils.createAlwaysFiringAction({
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue