Skip to content

Commit

Permalink
Adding changes in the Integration test to wait for everything to be d…
Browse files Browse the repository at this point in the history
…eleted before checking final status
  • Loading branch information
abhishekbhatia1710 committed Sep 30, 2024
1 parent 4994e41 commit 171a6b8
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 @@ -354,6 +354,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 171a6b8

Please sign in to comment.