From 5362e46287c72fd680e61f11a8f9e7c4ec4232af Mon Sep 17 00:00:00 2001 From: Ying Mao Date: Tue, 4 Oct 2022 14:32:53 -0400 Subject: [PATCH 1/4] Unskipping test --- .../spaces_only/tests/alerting/run_soon.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/run_soon.ts b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/run_soon.ts index f32665a5a1fac..050c220ab1b0f 100644 --- a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/run_soon.ts +++ b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/run_soon.ts @@ -18,8 +18,7 @@ export default function createRunSoonTests({ getService }: FtrProviderContext) { const es = getService('es'); const esArchiver = getService('esArchiver'); - // Failing: See https://github.com/elastic/kibana/issues/142564 - describe.skip('runSoon', () => { + describe('runSoon', () => { const objectRemover = new ObjectRemover(supertest); before(async () => { From fc8197e4dcc6139e4ec6999bcf3a87cb8e451afc Mon Sep 17 00:00:00 2001 From: Ying Mao Date: Tue, 4 Oct 2022 15:11:01 -0400 Subject: [PATCH 2/4] Unskipping test --- .../spaces_only/tests/alerting/disable.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/disable.ts b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/disable.ts index 495e423e43194..feec6431ee3cf 100644 --- a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/disable.ts +++ b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/disable.ts @@ -26,8 +26,7 @@ export default function createDisableRuleTests({ getService }: FtrProviderContex const retry = getService('retry'); const supertest = getService('supertest'); - // Failing: See https://github.com/elastic/kibana/issues/141864 - describe.skip('disable', () => { + describe('disable', () => { const objectRemover = new ObjectRemover(supertestWithoutAuth); const ruleUtils = new RuleUtils({ space: Spaces.space1, supertestWithoutAuth }); From e486a2491221fa9cad1ed91f6fc4c7142ab95584 Mon Sep 17 00:00:00 2001 From: Ying Mao Date: Tue, 4 Oct 2022 15:12:59 -0400 Subject: [PATCH 3/4] Adding retries --- .../spaces_only/tests/alerting/disable.ts | 36 ++++++++++--------- .../spaces_only/tests/alerting/run_soon.ts | 13 ++++--- 2 files changed, 28 insertions(+), 21 deletions(-) diff --git a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/disable.ts b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/disable.ts index feec6431ee3cf..d4149c9cf2fb8 100644 --- a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/disable.ts +++ b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/disable.ts @@ -51,15 +51,17 @@ export default function createDisableRuleTests({ getService }: FtrProviderContex await ruleUtils.disable(createdRule.id); // task doc should still exist but be disabled - const taskRecord = await getScheduledTask(createdRule.scheduled_task_id); - expect(taskRecord.type).to.eql('task'); - expect(taskRecord.task.taskType).to.eql('alerting:test.noop'); - expect(JSON.parse(taskRecord.task.params)).to.eql({ - alertId: createdRule.id, - spaceId: Spaces.space1.id, - consumer: 'alertsFixture', + await retry.try(async () => { + const taskRecord = await getScheduledTask(createdRule.scheduled_task_id); + expect(taskRecord.type).to.eql('task'); + expect(taskRecord.task.taskType).to.eql('alerting:test.noop'); + expect(JSON.parse(taskRecord.task.params)).to.eql({ + alertId: createdRule.id, + spaceId: Spaces.space1.id, + consumer: 'alertsFixture', + }); + expect(taskRecord.task.enabled).to.eql(false); }); - expect(taskRecord.task.enabled).to.eql(false); // Ensure AAD isn't broken await checkAAD({ @@ -195,15 +197,17 @@ export default function createDisableRuleTests({ getService }: FtrProviderContex .expect(204); // task doc should still exist but be disabled - const taskRecord = await getScheduledTask(createdRule.scheduled_task_id); - expect(taskRecord.type).to.eql('task'); - expect(taskRecord.task.taskType).to.eql('alerting:test.noop'); - expect(JSON.parse(taskRecord.task.params)).to.eql({ - alertId: createdRule.id, - spaceId: Spaces.space1.id, - consumer: 'alertsFixture', + await retry.try(async () => { + const taskRecord = await getScheduledTask(createdRule.scheduled_task_id); + expect(taskRecord.type).to.eql('task'); + expect(taskRecord.task.taskType).to.eql('alerting:test.noop'); + expect(JSON.parse(taskRecord.task.params)).to.eql({ + alertId: createdRule.id, + spaceId: Spaces.space1.id, + consumer: 'alertsFixture', + }); + expect(taskRecord.task.enabled).to.eql(false); }); - expect(taskRecord.task.enabled).to.eql(false); // Ensure AAD isn't broken await checkAAD({ diff --git a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/run_soon.ts b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/run_soon.ts index 050c220ab1b0f..bba958d47d241 100644 --- a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/run_soon.ts +++ b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/run_soon.ts @@ -35,7 +35,7 @@ export default function createRunSoonTests({ getService }: FtrProviderContext) { it('should successfully run rule where scheduled task id is different than rule id', async () => { await retry.try(async () => { - // Sometimes the rule may already be running. Try until it isn't + // Sometimes the rule may already be running, which returns a 200. Try until it isn't const response = await supertest .post(`${getUrlPrefix(``)}/internal/alerting/rule/${LOADED_RULE_ID}/_run_soon`) .set('kbn-xsrf', 'foo'); @@ -52,10 +52,13 @@ export default function createRunSoonTests({ getService }: FtrProviderContext) { expect(response.status).to.eql(200); objectRemover.add('default', response.body.id, 'rule', 'alerting'); - const runSoonResponse = await supertest - .post(`${getUrlPrefix(``)}/internal/alerting/rule/${response.body.id}/_run_soon`) - .set('kbn-xsrf', 'foo'); - expect(runSoonResponse.status).to.eql(204); + await retry.try(async () => { + // Sometimes the rule may already be running, which returns a 200. Try until it isn't + const runSoonResponse = await supertest + .post(`${getUrlPrefix(``)}/internal/alerting/rule/${response.body.id}/_run_soon`) + .set('kbn-xsrf', 'foo'); + expect(runSoonResponse.status).to.eql(204); + }); }); it('should return message when task does not exist for rule', async () => { From 3b237c7e166b7ff3967f0c48b33d085157f3044d Mon Sep 17 00:00:00 2001 From: Ying Mao Date: Tue, 4 Oct 2022 19:48:51 -0400 Subject: [PATCH 4/4] Cleanup --- .../spaces_only/tests/alerting/disable.ts | 39 +++++++++---------- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/disable.ts b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/disable.ts index d4149c9cf2fb8..495e423e43194 100644 --- a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/disable.ts +++ b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/disable.ts @@ -26,7 +26,8 @@ export default function createDisableRuleTests({ getService }: FtrProviderContex const retry = getService('retry'); const supertest = getService('supertest'); - describe('disable', () => { + // Failing: See https://github.com/elastic/kibana/issues/141864 + describe.skip('disable', () => { const objectRemover = new ObjectRemover(supertestWithoutAuth); const ruleUtils = new RuleUtils({ space: Spaces.space1, supertestWithoutAuth }); @@ -51,17 +52,15 @@ export default function createDisableRuleTests({ getService }: FtrProviderContex await ruleUtils.disable(createdRule.id); // task doc should still exist but be disabled - await retry.try(async () => { - const taskRecord = await getScheduledTask(createdRule.scheduled_task_id); - expect(taskRecord.type).to.eql('task'); - expect(taskRecord.task.taskType).to.eql('alerting:test.noop'); - expect(JSON.parse(taskRecord.task.params)).to.eql({ - alertId: createdRule.id, - spaceId: Spaces.space1.id, - consumer: 'alertsFixture', - }); - expect(taskRecord.task.enabled).to.eql(false); + const taskRecord = await getScheduledTask(createdRule.scheduled_task_id); + expect(taskRecord.type).to.eql('task'); + expect(taskRecord.task.taskType).to.eql('alerting:test.noop'); + expect(JSON.parse(taskRecord.task.params)).to.eql({ + alertId: createdRule.id, + spaceId: Spaces.space1.id, + consumer: 'alertsFixture', }); + expect(taskRecord.task.enabled).to.eql(false); // Ensure AAD isn't broken await checkAAD({ @@ -197,17 +196,15 @@ export default function createDisableRuleTests({ getService }: FtrProviderContex .expect(204); // task doc should still exist but be disabled - await retry.try(async () => { - const taskRecord = await getScheduledTask(createdRule.scheduled_task_id); - expect(taskRecord.type).to.eql('task'); - expect(taskRecord.task.taskType).to.eql('alerting:test.noop'); - expect(JSON.parse(taskRecord.task.params)).to.eql({ - alertId: createdRule.id, - spaceId: Spaces.space1.id, - consumer: 'alertsFixture', - }); - expect(taskRecord.task.enabled).to.eql(false); + const taskRecord = await getScheduledTask(createdRule.scheduled_task_id); + expect(taskRecord.type).to.eql('task'); + expect(taskRecord.task.taskType).to.eql('alerting:test.noop'); + expect(JSON.parse(taskRecord.task.params)).to.eql({ + alertId: createdRule.id, + spaceId: Spaces.space1.id, + consumer: 'alertsFixture', }); + expect(taskRecord.task.enabled).to.eql(false); // Ensure AAD isn't broken await checkAAD({