From 729da476a57d3fc0a7bc505ea545955b27855632 Mon Sep 17 00:00:00 2001 From: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Date: Wed, 5 Oct 2022 07:17:10 -0600 Subject: [PATCH] Fixing flaky `runSoon` test (#142652) (#142733) * Unskipping test * Unskipping test * Adding retries * Cleanup (cherry picked from commit f644fde9a5f53a9c838c4392bbd0ef7ded30f122) Co-authored-by: Ying Mao --- .../spaces_only/tests/alerting/run_soon.ts | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 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..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 @@ -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 () => { @@ -36,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'); @@ -53,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 () => {