From aebe7302a2dff12af67cb972cadec38320648c2a Mon Sep 17 00:00:00 2001 From: Ryland Herrick Date: Fri, 13 Oct 2023 11:47:31 -0500 Subject: [PATCH] [8.11] Risk score test unskip and clear transform (#168469) (#168867) # Backport This will backport the following commits from `main` to `8.11`: - [Risk score test unskip and clear transform (#168469)](https://github.com/elastic/kibana/pull/168469) ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) Co-authored-by: Khristinin Nikita --- .../group10/risk_engine/init_and_status_apis.ts | 17 +++++++++++++++-- .../risk_engine/risk_scoring_task_execution.ts | 9 +++++---- .../group10/risk_engine/telemetry_usage.ts | 5 ++++- 3 files changed, 24 insertions(+), 7 deletions(-) diff --git a/x-pack/test/detection_engine_api_integration/security_and_spaces/group10/risk_engine/init_and_status_apis.ts b/x-pack/test/detection_engine_api_integration/security_and_spaces/group10/risk_engine/init_and_status_apis.ts index 5693c0a37c5f5..708e7d03f537b 100644 --- a/x-pack/test/detection_engine_api_integration/security_and_spaces/group10/risk_engine/init_and_status_apis.ts +++ b/x-pack/test/detection_engine_api_integration/security_and_spaces/group10/risk_engine/init_and_status_apis.ts @@ -18,6 +18,8 @@ import { installLegacyRiskScore, getLegacyRiskScoreDashboards, clearLegacyDashboards, + deleteRiskEngineTask, + deleteAllRiskScores, } from './utils'; // eslint-disable-next-line import/no-default-export @@ -29,6 +31,16 @@ export default ({ getService }: FtrProviderContext) => { const log = getService('log'); describe('Risk Engine', () => { + beforeEach(async () => { + await cleanRiskEngineConfig({ kibanaServer }); + await deleteRiskEngineTask({ es, log }); + await deleteAllRiskScores(log, es); + await clearTransforms({ + es, + log, + }); + }); + afterEach(async () => { await cleanRiskEngineConfig({ kibanaServer, @@ -45,10 +57,11 @@ export default ({ getService }: FtrProviderContext) => { supertest, log, }); + await deleteRiskEngineTask({ es, log }); }); // FLAKY: https://github.com/elastic/kibana/issues/168376 - describe.skip('init api', () => { + describe('init api', () => { it('should return response with success status', async () => { const response = await riskEngineRoutes.init(); expect(response.body).to.eql({ @@ -374,7 +387,7 @@ export default ({ getService }: FtrProviderContext) => { }); // FLAKY: https://github.com/elastic/kibana/issues/168355 - describe.skip('status api', () => { + describe('status api', () => { it('should disable / enable risk engine', async () => { const status1 = await riskEngineRoutes.getStatus(); diff --git a/x-pack/test/detection_engine_api_integration/security_and_spaces/group10/risk_engine/risk_scoring_task_execution.ts b/x-pack/test/detection_engine_api_integration/security_and_spaces/group10/risk_engine/risk_scoring_task_execution.ts index 9de57ceb970b4..6a95d236a9d0a 100644 --- a/x-pack/test/detection_engine_api_integration/security_and_spaces/group10/risk_engine/risk_scoring_task_execution.ts +++ b/x-pack/test/detection_engine_api_integration/security_and_spaces/group10/risk_engine/risk_scoring_task_execution.ts @@ -24,6 +24,7 @@ import { cleanRiskEngineConfig, waitForRiskEngineTaskToBeGone, deleteRiskScoreIndices, + clearTransforms, } from './utils'; // eslint-disable-next-line import/no-default-export @@ -37,8 +38,7 @@ export default ({ getService }: FtrProviderContext): void => { const createAndSyncRuleAndAlerts = createAndSyncRuleAndAlertsFactory({ supertest, log }); const riskEngineRoutes = riskEngineRouteHelpersFactory(supertest); - // Failing: See https://github.com/elastic/kibana/issues/168424 - describe.skip('Risk Engine - Risk Scoring Task', () => { + describe('Risk Engine - Risk Scoring Task', () => { context('with auditbeat data', () => { const { indexListOfDocuments } = dataGeneratorFactory({ es, @@ -62,6 +62,7 @@ export default ({ getService }: FtrProviderContext): void => { await deleteAllRiskScores(log, es); await deleteAllAlerts(supertest, log, es); await deleteAllRules(supertest, log); + await clearTransforms({ es, log }); }); afterEach(async () => { @@ -70,6 +71,7 @@ export default ({ getService }: FtrProviderContext): void => { await deleteAllRiskScores(log, es); await deleteAllAlerts(supertest, log, es); await deleteAllRules(supertest, log); + await clearTransforms({ es, log }); }); describe('with some alerts containing hosts', () => { @@ -94,8 +96,7 @@ export default ({ getService }: FtrProviderContext): void => { }); }); - // FLAKY: https://github.com/elastic/kibana/issues/168415 - describe.skip('initializing the risk engine', () => { + describe('initializing the risk engine', () => { beforeEach(async () => { await riskEngineRoutes.init(); }); diff --git a/x-pack/test/detection_engine_api_integration/security_and_spaces/group10/risk_engine/telemetry_usage.ts b/x-pack/test/detection_engine_api_integration/security_and_spaces/group10/risk_engine/telemetry_usage.ts index 5306937a97ab5..2e7888fe00591 100644 --- a/x-pack/test/detection_engine_api_integration/security_and_spaces/group10/risk_engine/telemetry_usage.ts +++ b/x-pack/test/detection_engine_api_integration/security_and_spaces/group10/risk_engine/telemetry_usage.ts @@ -17,6 +17,7 @@ import { waitForRiskScoresToBePresent, riskEngineRouteHelpersFactory, cleanRiskEngineConfig, + clearTransforms, } from './utils'; import { dataGeneratorFactory } from '../../../utils/data_generator'; @@ -53,6 +54,7 @@ export default ({ getService }: FtrProviderContext) => { await deleteRiskScoreIndices({ log, es }); await deleteAllAlerts(supertest, log, es); await deleteAllRules(supertest, log); + await clearTransforms({ es, log }); }); describe('Risk engine not enabled', () => { @@ -66,7 +68,7 @@ export default ({ getService }: FtrProviderContext) => { }); // FLAKY: https://github.com/elastic/kibana/issues/168429 - describe.skip('Risk engine enabled', () => { + describe('Risk engine enabled', () => { let hostId: string; let userId: string; @@ -108,6 +110,7 @@ export default ({ getService }: FtrProviderContext) => { await deleteRiskScoreIndices({ log, es }); await deleteAllAlerts(supertest, log, es); await deleteAllRules(supertest, log); + await clearTransforms({ es, log }); }); it('should return riskEngineMetrics with expected values', async () => {