From a6a0c1292641fcc3d6222be28fcf7580d19d03bd Mon Sep 17 00:00:00 2001 From: Mark Hopkin Date: Tue, 20 Feb 2024 14:56:57 +0000 Subject: [PATCH] [Entity Analytics] Remove everything except `esarchiver` calls from `before` and `after` calls in cypress tests (#177175) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Summary A couple of small tweaks to our cypress tests to move any non-archiver code out of `before` and `after` hooks and into `beforeEach`. Flaky test run serverless and ess https://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/5219 ✅ ✅ See https://github.com/elastic/kibana/issues/174247 for context Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> --- .../dashboards/upgrade_risk_score.cy.ts | 3 +-- .../e2e/entity_analytics/entity_flyout.cy.ts | 15 ++++++--------- .../entity_analytics/host_details/risk_tab.cy.ts | 1 - .../hosts/hosts_risk_column.cy.ts | 2 -- 4 files changed, 7 insertions(+), 14 deletions(-) diff --git a/x-pack/test/security_solution_cypress/cypress/e2e/entity_analytics/dashboards/upgrade_risk_score.cy.ts b/x-pack/test/security_solution_cypress/cypress/e2e/entity_analytics/dashboards/upgrade_risk_score.cy.ts index 2f399416122d2..0da6597450126 100644 --- a/x-pack/test/security_solution_cypress/cypress/e2e/entity_analytics/dashboards/upgrade_risk_score.cy.ts +++ b/x-pack/test/security_solution_cypress/cypress/e2e/entity_analytics/dashboards/upgrade_risk_score.cy.ts @@ -36,7 +36,7 @@ import { deleteRiskEngineConfiguration } from '../../../tasks/api_calls/risk_eng const spaceId = 'default'; describe('Upgrade risk scores', { tags: ['@ess', '@serverless'] }, () => { - before(() => { + beforeEach(() => { login(); deleteRiskEngineConfiguration(); createRule(getNewRule({ rule_id: 'rule1' })); @@ -44,7 +44,6 @@ describe('Upgrade risk scores', { tags: ['@ess', '@serverless'] }, () => { describe('show upgrade risk button', () => { beforeEach(() => { - login(); deleteRiskScore({ riskScoreEntity: RiskScoreEntity.host, spaceId }); deleteRiskScore({ riskScoreEntity: RiskScoreEntity.user, spaceId }); installLegacyRiskScoreModule(RiskScoreEntity.host, spaceId); diff --git a/x-pack/test/security_solution_cypress/cypress/e2e/entity_analytics/entity_flyout.cy.ts b/x-pack/test/security_solution_cypress/cypress/e2e/entity_analytics/entity_flyout.cy.ts index b2d545773cb94..90eb208f7d710 100644 --- a/x-pack/test/security_solution_cypress/cypress/e2e/entity_analytics/entity_flyout.cy.ts +++ b/x-pack/test/security_solution_cypress/cypress/e2e/entity_analytics/entity_flyout.cy.ts @@ -62,14 +62,18 @@ describe( }, }, () => { - before(() => { + beforeEach(() => { cy.task('esArchiverLoad', { archiveName: 'risk_scores_new_complete_data' }); cy.task('esArchiverLoad', { archiveName: 'query_alert', useCreate: true, docsOnly: true }); cy.task('esArchiverLoad', { archiveName: 'user_managed_data' }); enableAssetCriticality(); + mockRiskEngineEnabled(); + login(); + visitWithTimeRange(ALERTS_URL); + waitForAlerts(); }); - after(() => { + afterEach(() => { cy.task('esArchiverUnload', 'risk_scores_new_complete_data'); cy.task('esArchiverUnload', 'user_managed_data'); deleteAlertsAndRules(); // esArchiverUnload doesn't work properly when using with `useCreate` and `docsOnly` flags @@ -77,13 +81,6 @@ describe( deleteCriticality({ idField: 'user.name', idValue: USER_NAME }); }); - beforeEach(() => { - mockRiskEngineEnabled(); - login(); - visitWithTimeRange(ALERTS_URL); - waitForAlerts(); - }); - describe('User details', () => { it('should display entity flyout and open risk input panel', () => { expandFirstAlertUserFlyout(); diff --git a/x-pack/test/security_solution_cypress/cypress/e2e/entity_analytics/host_details/risk_tab.cy.ts b/x-pack/test/security_solution_cypress/cypress/e2e/entity_analytics/host_details/risk_tab.cy.ts index fcb329da8b0d0..6b4f12a7619aa 100644 --- a/x-pack/test/security_solution_cypress/cypress/e2e/entity_analytics/host_details/risk_tab.cy.ts +++ b/x-pack/test/security_solution_cypress/cypress/e2e/entity_analytics/host_details/risk_tab.cy.ts @@ -22,7 +22,6 @@ describe('risk tab', { tags: ['@ess', '@serverless'] }, () => { // FLAKY: https://github.com/elastic/kibana/issues/169034 describe.skip('with legacy risk score', () => { before(() => { - // illegal_argument_exception: unknown setting [index.lifecycle.rollover_alias] cy.task('esArchiverLoad', { archiveName: 'risk_hosts' }); }); diff --git a/x-pack/test/security_solution_cypress/cypress/e2e/entity_analytics/hosts/hosts_risk_column.cy.ts b/x-pack/test/security_solution_cypress/cypress/e2e/entity_analytics/hosts/hosts_risk_column.cy.ts index 15e62f274145f..dfbb017efe0d2 100644 --- a/x-pack/test/security_solution_cypress/cypress/e2e/entity_analytics/hosts/hosts_risk_column.cy.ts +++ b/x-pack/test/security_solution_cypress/cypress/e2e/entity_analytics/hosts/hosts_risk_column.cy.ts @@ -16,7 +16,6 @@ import { mockRiskEngineEnabled } from '../../../tasks/entity_analytics'; describe('All hosts table', { tags: ['@ess', '@serverless'] }, () => { describe('with legacy risk score', () => { before(() => { - // illegal_argument_exception: unknown setting [index.lifecycle.name] cy.task('esArchiverLoad', { archiveName: 'risk_hosts' }); }); @@ -39,7 +38,6 @@ describe('All hosts table', { tags: ['@ess', '@serverless'] }, () => { describe('with new risk score', () => { before(() => { - // illegal_argument_exception: unknown setting [index.lifecycle.name] cy.task('esArchiverLoad', { archiveName: 'risk_scores_new' }); });