From 646f1d4076fd1ab2589c429f09966d4659be7b71 Mon Sep 17 00:00:00 2001 From: Gloria Hornero Date: Thu, 8 Jul 2021 10:55:42 +0200 Subject: [PATCH] [Security Solution] Test automation for upgrade, phase 2 and 3 (#104424) * adds upgrade cypress test * adds new configuration and runner * fixes typos * fixes typecheck issue * fixes typo * fixes command * fixes typo * fixes consistency Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> --- .../custom_query_rule.spec.ts | 29 +++++++++++++++++ x-pack/plugins/security_solution/package.json | 1 + .../test/security_solution_cypress/runner.ts | 31 +++++++++++++++++++ .../upgrade_config.ts | 19 ++++++++++++ 4 files changed, 80 insertions(+) create mode 100644 x-pack/plugins/security_solution/cypress/upgrade_integration/custom_query_rule.spec.ts create mode 100644 x-pack/test/security_solution_cypress/upgrade_config.ts diff --git a/x-pack/plugins/security_solution/cypress/upgrade_integration/custom_query_rule.spec.ts b/x-pack/plugins/security_solution/cypress/upgrade_integration/custom_query_rule.spec.ts new file mode 100644 index 0000000000000..2718c0735a671 --- /dev/null +++ b/x-pack/plugins/security_solution/cypress/upgrade_integration/custom_query_rule.spec.ts @@ -0,0 +1,29 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import { RULE_NAME } from '../screens/alerts_detection_rules'; + +import { + goToManageAlertsDetectionRules, + waitForAlertsIndexToBeCreated, + waitForAlertsPanelToBeLoaded, +} from '../tasks/alerts'; +import { waitForRulesTableToBeLoaded } from '../tasks/alerts_detection_rules'; +import { loginAndWaitForPageWithoutDateRange } from '../tasks/login'; + +import { ALERTS_URL } from '../urls/navigation'; + +describe('After an upgrade, the cusom query rule', () => { + it('Displays the rule', function () { + loginAndWaitForPageWithoutDateRange(ALERTS_URL); + waitForAlertsPanelToBeLoaded(); + waitForAlertsIndexToBeCreated(); + goToManageAlertsDetectionRules(); + waitForRulesTableToBeLoaded(); + cy.get(RULE_NAME).should('have.text', 'Custom query rule for upgrade'); + }); +}); diff --git a/x-pack/plugins/security_solution/package.json b/x-pack/plugins/security_solution/package.json index 5362454d3b46b..3a0eb1a5458a8 100644 --- a/x-pack/plugins/security_solution/package.json +++ b/x-pack/plugins/security_solution/package.json @@ -17,6 +17,7 @@ "cypress:run:ccs": "yarn cypress:run:reporter --browser chrome --headless --config integrationFolder=./cypress/ccs_integration", "cypress:run-as-ci": "node --max-old-space-size=2048 ../../../scripts/functional_tests --config ../../test/security_solution_cypress/cli_config.ts", "cypress:run-as-ci:firefox": "node --max-old-space-size=2048 ../../../scripts/functional_tests --config ../../test/security_solution_cypress/config.firefox.ts", + "cypress:run:upgrade": "yarn cypress:run:reporter --browser chrome --headless --config integrationFolder=./cypress/upgrade_integration", "junit:merge": "../../../node_modules/.bin/mochawesome-merge ../../../target/kibana-security-solution/cypress/results/mochawesome*.json > ../../../target/kibana-security-solution/cypress/results/output.json && ../../../node_modules/.bin/marge ../../../target/kibana-security-solution/cypress/results/output.json --reportDir ../../../target/kibana-security-solution/cypress/results && mkdir -p ../../../target/junit && cp ../../../target/kibana-security-solution/cypress/results/*.xml ../../../target/junit/", "test:generate": "node scripts/endpoint/resolver_generator" } diff --git a/x-pack/test/security_solution_cypress/runner.ts b/x-pack/test/security_solution_cypress/runner.ts index 0ac671f143d03..10a754d9bc53f 100644 --- a/x-pack/test/security_solution_cypress/runner.ts +++ b/x-pack/test/security_solution_cypress/runner.ts @@ -149,3 +149,34 @@ export async function SecuritySolutionCypressVisualTestRunner({ getService }: Ft }); }); } + +export async function SecuritySolutionCypressUpgradeCliTestRunner({ + getService, +}: FtrProviderContext) { + const log = getService('log'); + + await withProcRunner(log, async (procs) => { + await procs.run('cypress', { + cmd: 'yarn', + args: ['cypress:run:upgrade'], + cwd: resolve(__dirname, '../../plugins/security_solution'), + env: { + FORCE_COLOR: '1', + // eslint-disable-next-line @typescript-eslint/naming-convention + CYPRESS_baseUrl: process.env.TEST_KIBANA_URL, + // eslint-disable-next-line @typescript-eslint/naming-convention + CYPRESS_protocol: process.env.TEST_KIBANA_PROTOCOL, + // eslint-disable-next-line @typescript-eslint/naming-convention + CYPRESS_hostname: process.env.TEST_KIBANA_HOSTNAME, + // eslint-disable-next-line @typescript-eslint/naming-convention + CYPRESS_configport: process.env.TEST_KIBANA_PORT, + CYPRESS_ELASTICSEARCH_URL: process.env.TEST_ES_URL, + CYPRESS_ELASTICSEARCH_USERNAME: process.env.TEST_ES_USER, + CYPRESS_ELASTICSEARCH_PASSWORD: process.env.TEST_ES_PASS, + CYPRESS_KIBANA_URL: process.env.TEST_KIBANA_URL, + ...process.env, + }, + wait: true, + }); + }); +} diff --git a/x-pack/test/security_solution_cypress/upgrade_config.ts b/x-pack/test/security_solution_cypress/upgrade_config.ts new file mode 100644 index 0000000000000..a17d0ef00397c --- /dev/null +++ b/x-pack/test/security_solution_cypress/upgrade_config.ts @@ -0,0 +1,19 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import { FtrConfigProviderContext } from '@kbn/test'; + +import { SecuritySolutionCypressUpgradeCliTestRunner } from './runner'; + +export default async function ({ readConfigFile }: FtrConfigProviderContext) { + const securitySolutionCypressConfig = await readConfigFile(require.resolve('./config.ts')); + return { + ...securitySolutionCypressConfig.getAll(), + + testRunner: SecuritySolutionCypressUpgradeCliTestRunner, + }; +}