Skip to content

Commit

Permalink
[8.x] [APM] Attempt to fix flaky test in service_group_count.spec.ts (#…
Browse files Browse the repository at this point in the history
…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)](#204543)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Irene
Blanco","email":"[email protected]"},"sourceCommit":{"committedDate":"2025-01-07T09:54:39Z","message":"[APM]
Attempt to fix flaky test in service_group_count.spec.ts (#204543)\n\n##
Summary\r\n\r\nFixes
https://github.com/elastic/kibana/issues/201267\r\n\r\nBefore migrating
the API tests to be deployment-agnostic, we had already\r\nseen some
flaky results for this
test\r\n(#197912). After
completing the\r\nmigration, the error occurred again.\r\n\r\nThis PR
aims to fix the potential issue by ensuring that all existing\r\nalerts
are cleared before creating the alerts used in the test
case.\r\n\r\nCo-authored-by: jennypavlova
<[email protected]>","sha":"128739dc46f79457fb1848b4ef63c318cd1bb3f1","branchLabelMapping":{"^v9.0.0$":"main","^v8.18.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","v9.0.0","backport:prev-minor","Team:obs-ux-infra_services","v8.18.0"],"title":"[APM]
Attempt to fix flaky test in
service_group_count.spec.ts","number":204543,"url":"https://github.com/elastic/kibana/pull/204543","mergeCommit":{"message":"[APM]
Attempt to fix flaky test in service_group_count.spec.ts (#204543)\n\n##
Summary\r\n\r\nFixes
https://github.com/elastic/kibana/issues/201267\r\n\r\nBefore migrating
the API tests to be deployment-agnostic, we had already\r\nseen some
flaky results for this
test\r\n(#197912). After
completing the\r\nmigration, the error occurred again.\r\n\r\nThis PR
aims to fix the potential issue by ensuring that all existing\r\nalerts
are cleared before creating the alerts used in the test
case.\r\n\r\nCo-authored-by: jennypavlova
<[email protected]>","sha":"128739dc46f79457fb1848b4ef63c318cd1bb3f1"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/204543","number":204543,"mergeCommit":{"message":"[APM]
Attempt to fix flaky test in service_group_count.spec.ts (#204543)\n\n##
Summary\r\n\r\nFixes
https://github.com/elastic/kibana/issues/201267\r\n\r\nBefore migrating
the API tests to be deployment-agnostic, we had already\r\nseen some
flaky results for this
test\r\n(#197912). After
completing the\r\nmigration, the error occurred again.\r\n\r\nThis PR
aims to fix the potential issue by ensuring that all existing\r\nalerts
are cleared before creating the alerts used in the test
case.\r\n\r\nCo-authored-by: jennypavlova
<[email protected]>","sha":"128739dc46f79457fb1848b4ef63c318cd1bb3f1"}},{"branch":"8.x","label":"v8.18.0","branchLabelMappingKey":"^v8.18.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Irene Blanco <[email protected]>
  • Loading branch information
kibanamachine and iblancof authored Jan 7, 2025
1 parent def21fa commit c43b65e
Showing 1 changed file with 12 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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: {
Expand All @@ -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);
});

Expand Down

0 comments on commit c43b65e

Please sign in to comment.