[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>
This commit is contained in:
Gloria Hornero 2021-07-08 10:55:42 +02:00 committed by GitHub
parent b589fe5bd2
commit 646f1d4076
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 80 additions and 0 deletions

View file

@ -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');
});
});

View file

@ -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"
}

View file

@ -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,
});
});
}

View file

@ -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,
};
}