From c43b65eb298d0dc6585f81c829bb2727f18c632e Mon Sep 17 00:00:00 2001 From: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Date: Tue, 7 Jan 2025 22:43:21 +1100 Subject: [PATCH] [8.x] [APM] Attempt to fix flaky test in service_group_count.spec.ts (#204543) (#205691) # Backport This will backport the following commits from `main` to `8.x`: - [[APM] Attempt to fix flaky test in service_group_count.spec.ts (#204543)](https://github.com/elastic/kibana/pull/204543) ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) Co-authored-by: Irene Blanco --- .../service_group_count.spec.ts | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/x-pack/test/api_integration/deployment_agnostic/apis/observability/apm/service_groups/service_group_count/service_group_count.spec.ts b/x-pack/test/api_integration/deployment_agnostic/apis/observability/apm/service_groups/service_group_count/service_group_count.spec.ts index 08816f01d0f2b..d70d6ba0aedca 100644 --- a/x-pack/test/api_integration/deployment_agnostic/apis/observability/apm/service_groups/service_group_count/service_group_count.spec.ts +++ b/x-pack/test/api_integration/deployment_agnostic/apis/observability/apm/service_groups/service_group_count/service_group_count.spec.ts @@ -27,6 +27,16 @@ export default function ApiTest({ getService }: DeploymentAgnosticFtrProviderCon const start = Date.now() - 24 * 60 * 60 * 1000; const end = Date.now(); + const cleanUpAlerts = ({ roleAuthc, ruleId }: { roleAuthc: RoleCredentials; ruleId: string }) => { + return alertingApi.cleanUpAlerts({ + roleAuthc, + ruleId, + alertIndexName: APM_ALERTS_INDEX, + connectorIndexName: APM_ACTION_VARIABLE_INDEX, + consumer: 'apm', + }); + }; + describe('Service group counts', () => { let synthbeansServiceGroupId: string; let opbeansServiceGroupId: string; @@ -73,6 +83,7 @@ export default function ApiTest({ getService }: DeploymentAgnosticFtrProviderCon before(async () => { roleAuthc = await samlAuth.createM2mApiKeyWithRoleScope('admin'); + await cleanUpAlerts({ roleAuthc, ruleId }); const createdRule = await alertingApi.createRule({ name: 'Latency threshold | synth-go', params: { @@ -94,13 +105,7 @@ export default function ApiTest({ getService }: DeploymentAgnosticFtrProviderCon }); after(async () => { - await alertingApi.cleanUpAlerts({ - roleAuthc, - ruleId, - alertIndexName: APM_ALERTS_INDEX, - connectorIndexName: APM_ACTION_VARIABLE_INDEX, - consumer: 'apm', - }); + await cleanUpAlerts({ roleAuthc, ruleId }); await samlAuth.invalidateM2mApiKeyWithRoleScope(roleAuthc); });