Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Entity Analytics] Adding changes in the Integration test to wait for everything to be deleted before checking final status #194447

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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