mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
[APM] Attempt to fix flaky test in service_group_count.spec.ts (#204543)
## Summary Fixes https://github.com/elastic/kibana/issues/201267 Before migrating the API tests to be deployment-agnostic, we had already seen some flaky results for this test (https://github.com/elastic/kibana/issues/197912). After completing the migration, the error occurred again. This PR aims to fix the potential issue by ensuring that all existing alerts are cleared before creating the alerts used in the test case. Co-authored-by: jennypavlova <dzheni.pavlova@elastic.co>
This commit is contained in:
parent
175916ef23
commit
128739dc46
1 changed files with 12 additions and 7 deletions
|
@ -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);
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue