Skip to content

Commit

Permalink
Clean up alerts before executing test
Browse files Browse the repository at this point in the history
  • Loading branch information
iblancof committed Dec 16, 2024
1 parent 3a6d27a commit 11354af
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 11354af

Please sign in to comment.