diff --git a/x-pack/test/security_solution_api_integration/test_suites/entity_analytics/risk_engine/trial_license_complete_tier/risk_engine_cleanup_api.ts b/x-pack/test/security_solution_api_integration/test_suites/entity_analytics/risk_engine/trial_license_complete_tier/risk_engine_cleanup_api.ts index ee6c5a3414fcc..968b234509d34 100644 --- a/x-pack/test/security_solution_api_integration/test_suites/entity_analytics/risk_engine/trial_license_complete_tier/risk_engine_cleanup_api.ts +++ b/x-pack/test/security_solution_api_integration/test_suites/entity_analytics/risk_engine/trial_license_complete_tier/risk_engine_cleanup_api.ts @@ -13,6 +13,9 @@ import { riskEngineRouteHelpersFactory, waitForRiskScoresToBePresent, createAndSyncRuleAndAlertsFactory, + waitForRiskEngineTaskToBeGone, + waitForSavedObjectToBeGone, + waitForRiskScoresToBeGone, } from '../../utils'; import { dataGeneratorFactory } from '../../../detections_response/utils'; @@ -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 }); @@ -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'); diff --git a/x-pack/test/security_solution_api_integration/test_suites/entity_analytics/utils/risk_engine.ts b/x-pack/test/security_solution_api_integration/test_suites/entity_analytics/utils/risk_engine.ts index 23a6c11b0b5cc..0a88e9fbe2518 100644 --- a/x-pack/test/security_solution_api_integration/test_suites/entity_analytics/utils/risk_engine.ts +++ b/x-pack/test/security_solution_api_integration/test_suites/entity_analytics/utils/risk_engine.ts @@ -331,6 +331,40 @@ export const waitForRiskEngineTaskToBeGone = async ({ ); }; +export const waitForSavedObjectToBeGone = async ({ + log, + kibanaServer, +}: { + log: ToolingLog; + kibanaServer: KbnClient; +}): Promise => { + await waitFor( + async () => { + const savedObject = await getRiskEngineConfigSO({ kibanaServer }); + return savedObject == null; + }, + 'waitForSavedObjectToBeGone', + log + ); +}; + +export const waitForRiskScoresToBeGone = async ({ + es, + log, +}: { + es: Client; + log: ToolingLog; +}): Promise => { + 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,