Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SIEM] Adds 'open as ci' capability in Cypress tests #59880

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion x-pack/legacy/plugins/siem/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"build-graphql-types": "node scripts/generate_types_from_graphql.js",
"cypress:open": "../../../node_modules/.bin/cypress open",
"cypress:run": "../../../node_modules/.bin/cypress run --spec ./cypress/integration/**/*.spec.ts --reporter ../../../node_modules/cypress-multi-reporters --reporter-options configFile=./reporter_config.json; status=$?; ../../../node_modules/.bin/mochawesome-merge --reportDir ../../../../target/kibana-siem/cypress/results > ../../../../target/kibana-siem/cypress/results/output.json; ../../../../node_modules/.bin/marge ../../../../target/kibana-siem/cypress/results/output.json --reportDir ../../../../target/kibana-siem/cypress/results; mkdir -p ../../../../target/junit && cp ../../../../target/kibana-siem/cypress/results/*.xml ../../../../target/junit/ && exit $status;",
"cypress:run-as-ci": "node ../../../../scripts/functional_tests --config ../../../test/siem_cypress/config.ts"
"cypress:run-as-ci": "node ../../../../scripts/functional_tests --config ../../../test/siem_cypress/config.ts",
"cypress:open-as-ci": "node ../../../../scripts/functional_tests --config ../../../test/siem_cypress/config_open.ts"
},
"devDependencies": {
"@types/lodash": "^4.14.110",
Expand Down
52 changes: 52 additions & 0 deletions x-pack/test/siem_cypress/config_open.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import { resolve } from 'path';

import { FtrConfigProviderContext } from '@kbn/test/types/ftr';

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

import { SiemVisualCypressTestRunner } from './runner';

export default async function({ readConfigFile }: FtrConfigProviderContext) {
const kibanaCommonTestsConfig = await readConfigFile(
require.resolve('../../../test/common/config.js')
);
const xpackFunctionalTestsConfig = await readConfigFile(
require.resolve('../functional/config.js')
);

return {
...kibanaCommonTestsConfig.getAll(),

testRunner: SiemVisualCypressTestRunner,

esArchiver: {
directory: resolve(__dirname, 'es_archives'),
},

esTestCluster: {
...xpackFunctionalTestsConfig.get('esTestCluster'),
serverArgs: [
...xpackFunctionalTestsConfig.get('esTestCluster.serverArgs'),
// define custom es server here
'xpack.security.authc.api_key.enabled=true',
'xpack.security.enabled=true',
],
},

kbnTestServer: {
...xpackFunctionalTestsConfig.get('kbnTestServer'),
serverArgs: [
...xpackFunctionalTestsConfig.get('kbnTestServer.serverArgs'),
'--csp.strict=false',
// define custom kibana server args here
`--elasticsearch.ssl.certificateAuthorities=${CA_CERT_PATH}`,
],
},
};
}
26 changes: 26 additions & 0 deletions x-pack/test/siem_cypress/runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,29 @@ export async function SiemCypressTestRunner({ getService }: FtrProviderContext)
});
});
}

export async function SiemVisualCypressTestRunner({ getService }: FtrProviderContext) {
const log = getService('log');
const config = getService('config');
const esArchiver = getService('esArchiver');

await esArchiver.load('empty_kibana');
await esArchiver.load('auditbeat');

await withProcRunner(log, async procs => {
await procs.run('cypress', {
cmd: 'yarn',
args: ['cypress:open'],
cwd: resolve(__dirname, '../../legacy/plugins/siem'),
env: {
FORCE_COLOR: '1',
CYPRESS_baseUrl: Url.format(config.get('servers.kibana')),
CYPRESS_ELASTICSEARCH_URL: Url.format(config.get('servers.elasticsearch')),
CYPRESS_ELASTICSEARCH_USERNAME: config.get('servers.elasticsearch.username'),
CYPRESS_ELASTICSEARCH_PASSWORD: config.get('servers.elasticsearch.password'),
...process.env,
},
wait: true,
});
});
}