Skip to content

Commit

Permalink
[Entity Analytics] Adding changes in the Integration test to wait for…
Browse files Browse the repository at this point in the history
… everything to be deleted before checking final status (#194447)

## Summary

Includes a wait to check for deleted resources before verifying the risk
engine status


### Checklist

Delete any items that are not applicable to this PR.

- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
- [x] [Flaky Test
Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was
used on any tests changed



### For maintainers

- [ ] This was checked for breaking API changes and was [labeled
appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)
  • Loading branch information
abhishekbhatia1710 authored Oct 17, 2024
1 parent 3c3b7c8 commit abc8f68
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ import {
riskEngineRouteHelpersFactory,
waitForRiskScoresToBePresent,
createAndSyncRuleAndAlertsFactory,
waitForRiskEngineTaskToBeGone,
waitForSavedObjectToBeGone,
waitForRiskScoresToBeGone,
} from '../../utils';
import { dataGeneratorFactory } from '../../../detections_response/utils';

Expand All @@ -22,6 +25,7 @@ export default ({ getService }: FtrProviderContext) => {
const es = getService('es');
const log = getService('log');
const esArchiver = getService('esArchiver');
const kibanaServer = getService('kibanaServer');

describe('@ess @ serverless @serverless QA risk_engine_cleanup_api', () => {
const createAndSyncRuleAndAlerts = createAndSyncRuleAndAlertsFactory({ supertest, log });
Expand Down Expand Up @@ -59,6 +63,10 @@ export default ({ getService }: FtrProviderContext) => {
cleanup_successful: true,
});

await waitForRiskEngineTaskToBeGone({ es, log });
await waitForSavedObjectToBeGone({ log, kibanaServer });
await waitForRiskScoresToBeGone({ es, log });

const status3 = await riskEngineRoutes.getStatus();
expect(status3.body.risk_engine_status).to.be('NOT_INSTALLED');
expect(status3.body.legacy_risk_engine_status).to.be('NOT_INSTALLED');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,40 @@ export const waitForRiskEngineTaskToBeGone = async ({
);
};

export const waitForSavedObjectToBeGone = async ({
log,
kibanaServer,
}: {
log: ToolingLog;
kibanaServer: KbnClient;
}): Promise<void> => {
await waitFor(
async () => {
const savedObject = await getRiskEngineConfigSO({ kibanaServer });
return savedObject == null;
},
'waitForSavedObjectToBeGone',
log
);
};

export const waitForRiskScoresToBeGone = async ({
es,
log,
}: {
es: Client;
log: ToolingLog;
}): Promise<void> => {
await waitFor(
async () => {
const riskScoreIndicesEmpty = await areRiskScoreIndicesEmpty({ es, log });
return riskScoreIndicesEmpty;
},
'waitForRiskScoreIndicesToBeEmpty',
log
);
};

export const getRiskEngineConfigSO = async ({ kibanaServer }: { kibanaServer: KbnClient }) => {
const soResponse = await kibanaServer.savedObjects.find({
type: riskEngineConfigurationTypeName,
Expand Down

0 comments on commit abc8f68

Please sign in to comment.