Skip to content

Commit bddddc9

Browse files
[SECURITY SOLUTION] Adds 'cypress:open-as-ci' command (#76125) (#76869)
* adds 'cypress:open-as-ci' command * fixes typecheck error Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com> # Conflicts: # x-pack/plugins/security_solution/package.json
1 parent 99dc8bd commit bddddc9

File tree

6 files changed

+69
-9
lines changed

6 files changed

+69
-9
lines changed

test/scripts/jenkins_security_solution_cypress.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ source test/scripts/jenkins_test_setup_xpack.sh
55
echo " -> Running security solution cypress tests"
66
cd "$XPACK_DIR"
77

8-
checks-reporter-with-killswitch "Security solution Cypress Tests" \
8+
checks-reporter-with-killswitch "Security Solution Cypress Tests" \
99
node scripts/functional_tests \
1010
--debug --bail \
1111
--kibana-install-dir "$KIBANA_INSTALL_DIR" \
12-
--config test/security_solution_cypress/config.ts
12+
--config test/security_solution_cypress/cli_config.ts
1313

1414
echo ""
1515
echo ""

x-pack/plugins/security_solution/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@
88
"extract-mitre-attacks": "node scripts/extract_tactics_techniques_mitre.js && node ../../../scripts/eslint ./public/pages/detection_engine/mitre/mitre_tactics_techniques.ts --fix",
99
"build-graphql-types": "node scripts/generate_types_from_graphql.js",
1010
"cypress:open": "cypress open --config-file ./cypress/cypress.json",
11+
"cypress:open-as-ci": "node ../../../scripts/functional_tests --config ../../test/security_solution_cypress/visual_config.ts",
1112
"cypress:run": "cypress run --browser chrome --headless --spec ./cypress/integration/**/*.spec.ts --config-file ./cypress/cypress.json --reporter ../../node_modules/cypress-multi-reporters --reporter-options configFile=./cypress/reporter_config.json; status=$?; ../../node_modules/.bin/mochawesome-merge --reportDir ../../../target/kibana-security-solution/cypress/results > ../../../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/ && exit $status;",
12-
"cypress:run-as-ci": "node ../../../scripts/functional_tests --config ../../test/security_solution_cypress/config.ts",
13-
"test:generate": "ts-node --project scripts/endpoint/cli_tsconfig.json scripts/endpoint/resolver_generator.ts"
13+
"cypress:run-as-ci": "node ../../../scripts/functional_tests --config ../../test/security_solution_cypress/cli_config.ts",
14+
"test:generate": "node scripts/endpoint/resolver_generator"
1415
},
1516
"devDependencies": {
1617
"@types/md5": "^2.2.0",
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License;
4+
* you may not use this file except in compliance with the Elastic License.
5+
*/
6+
7+
import { FtrConfigProviderContext } from '@kbn/test/types/ftr';
8+
9+
import { SecuritySolutionCypressCliTestRunner } from './runner';
10+
11+
export default async function ({ readConfigFile }: FtrConfigProviderContext) {
12+
const securitySolutionCypressConfig = await readConfigFile(require.resolve('./config.ts'));
13+
return {
14+
...securitySolutionCypressConfig.getAll(),
15+
16+
testRunner: SecuritySolutionCypressCliTestRunner,
17+
};
18+
}

x-pack/test/security_solution_cypress/config.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ import { FtrConfigProviderContext } from '@kbn/test/types/ftr';
1010

1111
import { CA_CERT_PATH } from '@kbn/dev-utils';
1212

13-
import { SiemCypressTestRunner } from './runner';
14-
1513
export default async function ({ readConfigFile }: FtrConfigProviderContext) {
1614
const kibanaCommonTestsConfig = await readConfigFile(
1715
require.resolve('../../../test/common/config.js')
@@ -23,8 +21,6 @@ export default async function ({ readConfigFile }: FtrConfigProviderContext) {
2321
return {
2422
...kibanaCommonTestsConfig.getAll(),
2523

26-
testRunner: SiemCypressTestRunner,
27-
2824
esArchiver: {
2925
directory: resolve(__dirname, 'es_archives'),
3026
},

x-pack/test/security_solution_cypress/runner.ts

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { withProcRunner } from '@kbn/dev-utils';
1111

1212
import { FtrProviderContext } from './ftr_provider_context';
1313

14-
export async function SiemCypressTestRunner({ getService }: FtrProviderContext) {
14+
export async function SecuritySolutionCypressCliTestRunner({ getService }: FtrProviderContext) {
1515
const log = getService('log');
1616
const config = getService('config');
1717
const esArchiver = getService('esArchiver');
@@ -37,3 +37,30 @@ export async function SiemCypressTestRunner({ getService }: FtrProviderContext)
3737
});
3838
});
3939
}
40+
41+
export async function SecuritySolutionCypressVisualTestRunner({ getService }: FtrProviderContext) {
42+
const log = getService('log');
43+
const config = getService('config');
44+
const esArchiver = getService('esArchiver');
45+
46+
await esArchiver.load('empty_kibana');
47+
await esArchiver.load('auditbeat');
48+
49+
await withProcRunner(log, async (procs) => {
50+
await procs.run('cypress', {
51+
cmd: 'yarn',
52+
args: ['cypress:open'],
53+
cwd: resolve(__dirname, '../../plugins/security_solution'),
54+
env: {
55+
FORCE_COLOR: '1',
56+
// eslint-disable-next-line @typescript-eslint/naming-convention
57+
CYPRESS_baseUrl: Url.format(config.get('servers.kibana')),
58+
CYPRESS_ELASTICSEARCH_URL: Url.format(config.get('servers.elasticsearch')),
59+
CYPRESS_ELASTICSEARCH_USERNAME: config.get('servers.elasticsearch.username'),
60+
CYPRESS_ELASTICSEARCH_PASSWORD: config.get('servers.elasticsearch.password'),
61+
...process.env,
62+
},
63+
wait: true,
64+
});
65+
});
66+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License;
4+
* you may not use this file except in compliance with the Elastic License.
5+
*/
6+
7+
import { FtrConfigProviderContext } from '@kbn/test/types/ftr';
8+
9+
import { SecuritySolutionCypressVisualTestRunner } from './runner';
10+
11+
export default async function ({ readConfigFile }: FtrConfigProviderContext) {
12+
const securitySolutionCypressConfig = await readConfigFile(require.resolve('./config.ts'));
13+
return {
14+
...securitySolutionCypressConfig.getAll(),
15+
16+
testRunner: SecuritySolutionCypressVisualTestRunner,
17+
};
18+
}

0 commit comments

Comments
 (0)