From 39827e50579b1c2bd6d612d5820698e60264cc42 Mon Sep 17 00:00:00 2001 From: Ying Mao Date: Thu, 7 Nov 2024 07:49:36 -0500 Subject: [PATCH] Fixes flaky backfill tests. (#198592) Resolves https://github.com/elastic/kibana/issues/192144 Resolves https://github.com/elastic/kibana/issues/198168 Resolves https://github.com/elastic/kibana/issues/197239 ## Summary Minor fixes to the backfill functional tests to try to reduce flakiness. --- .../group1/tests/alerting/backfill/api_key.ts | 6 +++--- .../group1/tests/alerting/backfill/schedule.ts | 2 +- .../group1/tests/alerting/backfill/task_runner.ts | 5 ++--- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/x-pack/test/alerting_api_integration/security_and_spaces/group1/tests/alerting/backfill/api_key.ts b/x-pack/test/alerting_api_integration/security_and_spaces/group1/tests/alerting/backfill/api_key.ts index cf818de0e4fab..a36d7708bb99c 100644 --- a/x-pack/test/alerting_api_integration/security_and_spaces/group1/tests/alerting/backfill/api_key.ts +++ b/x-pack/test/alerting_api_integration/security_and_spaces/group1/tests/alerting/backfill/api_key.ts @@ -263,11 +263,11 @@ export default function apiKeyBackfillTests({ getService }: FtrProviderContext) } }); - // invoke the invalidate task - await runInvalidateTask(); - // pending API key should now be deleted because backfill is done await retry.try(async () => { + // invoke the invalidate task + await runInvalidateTask(); + const results = await getApiKeysPendingInvalidation(); expect(results.length).to.eql(0); return results; diff --git a/x-pack/test/alerting_api_integration/security_and_spaces/group1/tests/alerting/backfill/schedule.ts b/x-pack/test/alerting_api_integration/security_and_spaces/group1/tests/alerting/backfill/schedule.ts index 8f25a3e181c66..9d7b79d6cbce0 100644 --- a/x-pack/test/alerting_api_integration/security_and_spaces/group1/tests/alerting/backfill/schedule.ts +++ b/x-pack/test/alerting_api_integration/security_and_spaces/group1/tests/alerting/backfill/schedule.ts @@ -759,7 +759,7 @@ export default function scheduleBackfillTests({ getService }: FtrProviderContext }); it('should handle schedule request where some requests succeed and some requests fail appropriately', async () => { - const start = moment().utc().startOf('day').subtract(7, 'days').toISOString(); + const start = moment().utc().startOf('day').subtract(14, 'days').toISOString(); const end = moment().utc().startOf('day').subtract(5, 'days').toISOString(); // create 2 rules const rresponse1 = await supertest diff --git a/x-pack/test/alerting_api_integration/security_and_spaces/group1/tests/alerting/backfill/task_runner.ts b/x-pack/test/alerting_api_integration/security_and_spaces/group1/tests/alerting/backfill/task_runner.ts index e21b9e598556c..2083a79c0d0f5 100644 --- a/x-pack/test/alerting_api_integration/security_and_spaces/group1/tests/alerting/backfill/task_runner.ts +++ b/x-pack/test/alerting_api_integration/security_and_spaces/group1/tests/alerting/backfill/task_runner.ts @@ -87,8 +87,7 @@ export default function createBackfillTaskRunnerTests({ getService }: FtrProvide moment().utc().startOf('day').subtract(9, 'days').add(41, 'minutes').toISOString(), ]; - // FLAKY: https://github.com/elastic/kibana/issues/192144 - describe.skip('ad hoc backfill task', () => { + describe('ad hoc backfill task', () => { beforeEach(async () => { await esTestIndexTool.destroy(); await esTestIndexTool.setup(); @@ -167,7 +166,7 @@ export default function createBackfillTaskRunnerTests({ getService }: FtrProvide objectRemover.add(spaceId, ruleId, 'rule', 'alerting'); const start = moment(originalDocTimestamps[1]).utc().startOf('day').toISOString(); - const end = moment().utc().startOf('day').subtract(9, 'days').toISOString(); + const end = moment(originalDocTimestamps[11]).utc().startOf('day').toISOString(); // Schedule backfill for this rule const response2 = await supertestWithoutAuth