mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
[Security Solution][Serverless] Integrating Cypress with the parallel script (#162160)
This commit is contained in:
parent
1a300e31bb
commit
621401ed6a
13 changed files with 87 additions and 59 deletions
|
@ -43,8 +43,7 @@ disabled:
|
|||
- x-pack/test/threat_intelligence_cypress/config.ts
|
||||
- x-pack/test/functional_enterprise_search/visual_config.ts
|
||||
- x-pack/test/functional_enterprise_search/cli_config.ts
|
||||
- x-pack/test_serverless/functional/test_suites/security/cypress/config_headless.ts
|
||||
- x-pack/test_serverless/functional/test_suites/security/cypress/config_visual.ts
|
||||
- x-pack/test_serverless/functional/test_suites/security/cypress/security_config.ts
|
||||
- x-pack/plugins/apm/ftr_e2e/ftr_config_open.ts
|
||||
- x-pack/plugins/apm/ftr_e2e/ftr_config_run.ts
|
||||
- x-pack/plugins/apm/ftr_e2e/ftr_config.ts
|
||||
|
|
|
@ -95,6 +95,24 @@ steps:
|
|||
- exit_status: '-1'
|
||||
limit: 3
|
||||
|
||||
- command: .buildkite/scripts/steps/functional/security_serverless.sh
|
||||
label: 'Serverless Security Cypress Tests'
|
||||
agents:
|
||||
queue: n2-4-spot
|
||||
depends_on: build
|
||||
timeout_in_minutes: 40
|
||||
soft_fail:
|
||||
- exit_status: 10
|
||||
retry:
|
||||
automatic:
|
||||
- exit_status: '-1'
|
||||
limit: 3
|
||||
- exit_status: '*'
|
||||
limit: 1
|
||||
artifact_paths:
|
||||
- "target/kibana-security-serverless/**/*"
|
||||
|
||||
|
||||
- command: .buildkite/scripts/steps/lint.sh
|
||||
label: 'Linting'
|
||||
agents:
|
||||
|
|
|
@ -59,3 +59,18 @@ steps:
|
|||
limit: 3
|
||||
- exit_status: '*'
|
||||
limit: 1
|
||||
|
||||
- command: .buildkite/scripts/steps/functional/security_serverless.sh
|
||||
label: 'Serverless Security Cypress Tests'
|
||||
agents:
|
||||
queue: n2-4-spot
|
||||
depends_on: build
|
||||
timeout_in_minutes: 40
|
||||
retry:
|
||||
automatic:
|
||||
- exit_status: '-1'
|
||||
limit: 3
|
||||
- exit_status: '*'
|
||||
limit: 1
|
||||
artifact_paths:
|
||||
- "target/kibana-security-serverless/**/*"
|
13
.buildkite/scripts/steps/functional/security_serverless.sh
Normal file
13
.buildkite/scripts/steps/functional/security_serverless.sh
Normal file
|
@ -0,0 +1,13 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
source .buildkite/scripts/steps/functional/common.sh
|
||||
source .buildkite/scripts/steps/functional/common_cypress.sh
|
||||
|
||||
export JOB=kibana-serverless-security-cypress
|
||||
export KIBANA_INSTALL_DIR=${KIBANA_BUILD_LOCATION}
|
||||
|
||||
echo "--- Security Serverless Cypress"
|
||||
|
||||
yarn --cwd x-pack/test_serverless/functional/test_suites/security/cypress cypress:run
|
|
@ -21,7 +21,6 @@ elif [[ "$SERVERLESS_ENVIRONMENT" == "security" ]]; then
|
|||
SERVERLESS_CONFIGS=(
|
||||
"x-pack/test_serverless/api_integration/test_suites/security/config.ts"
|
||||
"x-pack/test_serverless/functional/test_suites/security/config.ts"
|
||||
"x-pack/test_serverless/functional/test_suites/security/cypress/config_headless.ts"
|
||||
)
|
||||
fi
|
||||
|
||||
|
|
|
@ -71,6 +71,7 @@ export const cli = () => {
|
|||
const { argv } = yargs(process.argv.slice(2));
|
||||
|
||||
const isOpen = argv._[0] === 'open';
|
||||
const cypressConfigFilePath = require.resolve(`../../${argv.configFile}`) as string;
|
||||
const cypressConfigFile = await import(require.resolve(`../../${argv.configFile}`));
|
||||
const spec: string | undefined = argv?.spec as string;
|
||||
const files = retrieveIntegrations(spec ? [spec] : cypressConfigFile?.e2e?.specPattern);
|
||||
|
@ -285,7 +286,7 @@ export const cli = () => {
|
|||
|
||||
if (isOpen) {
|
||||
await cypress.open({
|
||||
configFile: require.resolve(`../../${argv.configFile}`),
|
||||
configFile: cypressConfigFilePath,
|
||||
config: {
|
||||
e2e: {
|
||||
baseUrl: `http://localhost:${kibanaPort}`,
|
||||
|
@ -298,7 +299,7 @@ export const cli = () => {
|
|||
result = await cypress.run({
|
||||
browser: 'chrome',
|
||||
spec: filePath,
|
||||
configFile: argv.configFile as string,
|
||||
configFile: cypressConfigFilePath,
|
||||
reporter: argv.reporter as string,
|
||||
reporterOptions: argv.reporterOptions,
|
||||
config: {
|
||||
|
|
|
@ -1,19 +0,0 @@
|
|||
/*
|
||||
* 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 { SecuritySolutionServerlessVisualTestRunner } from './runner';
|
||||
|
||||
export default async function ({ readConfigFile }: FtrConfigProviderContext) {
|
||||
const svlSecConfig = await readConfigFile(require.resolve('./security_config.base.ts'));
|
||||
|
||||
return {
|
||||
...svlSecConfig.getAll(),
|
||||
testRunner: SecuritySolutionServerlessVisualTestRunner,
|
||||
};
|
||||
}
|
|
@ -19,7 +19,6 @@ export default defineCypressConfig({
|
|||
viewportWidth: 1680,
|
||||
numTestsKeptInMemory: 10,
|
||||
e2e: {
|
||||
baseUrl: 'http://localhost:5620/app/security/get_started',
|
||||
experimentalRunAllSpecs: true,
|
||||
experimentalMemoryManagement: true,
|
||||
supportFile: './support/e2e.js',
|
||||
|
|
|
@ -5,9 +5,8 @@
|
|||
"private": true,
|
||||
"license": "Elastic License 2.0",
|
||||
"scripts": {
|
||||
"cypress:open": "../../../../../../node_modules/.bin/cypress open --config-file ./cypress.config.ts",
|
||||
"cypress:run": "../../../../../../node_modules/.bin/cypress run --browser chrome --config-file ./cypress.config.ts",
|
||||
"cypress:serverless:open": "node ../../../../../../scripts/functional_tests --config ./config_visual.ts",
|
||||
"cypress:serverless:run": "node ../../../../../../scripts/functional_tests --config ./config_headless.ts"
|
||||
"cypress:open": "node ../../../../../plugins/security_solution/scripts/start_cypress_parallel open --config-file ../../../x-pack/test_serverless/functional/test_suites/security/cypress/cypress.config.ts --ftr-config-file ../../../../../../x-pack/test_serverless/functional/test_suites/security/cypress/security_config",
|
||||
"cypress:run": "node ../../../../../plugins/security_solution/scripts/start_cypress_parallel run --browser chrome --config-file ../../../x-pack/test_serverless/functional/test_suites/security/cypress/cypress.config.ts --ftr-config-file ../../../../../../x-pack/test_serverless/functional/test_suites/security/cypress/security_config --reporter ../../../../../../node_modules/cypress-multi-reporters --reporter-options configFile=./reporter_config.json; status=$?; yarn junit:merge && exit $status",
|
||||
"junit:merge": "../../../../../../node_modules/.bin/mochawesome-merge ../../../../../../target/kibana-security-serverless/cypress/results/mochawesome*.json > ../../../../../../target/kibana-security-serverless/cypress/results/output.json && ../../../../../../node_modules/.bin/marge ../../../../../../target/kibana-security-serverless/cypress/results/output.json --reportDir ../../../../../../target/kibana-security-serverless/cypress/results && mkdir -p ../../../../../../target/junit && cp ../../../../../../target/kibana-security-serverless/cypress/results/*.xml ../../../../../../target/junit/"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
{
|
||||
"reporterEnabled": "mochawesome, mocha-junit-reporter",
|
||||
"reporterOptions": {
|
||||
"html": false,
|
||||
"json": true,
|
||||
"mochaFile": "../../../../../../target/kibana-security-serverless/cypress/results/TEST-security-solution-cypress-[hash].xml",
|
||||
"overwrite": false,
|
||||
"reportDir": "../../../../../../target/kibana-security-serverless/cypress/results"
|
||||
}
|
||||
}
|
|
@ -5,36 +5,23 @@
|
|||
* 2.0.
|
||||
*/
|
||||
|
||||
import { resolve } from 'path';
|
||||
import { withProcRunner } from '@kbn/dev-proc-runner';
|
||||
|
||||
import { FtrProviderContext } from '../../../ftr_provider_context';
|
||||
|
||||
export type { FtrProviderContext } from '../../../ftr_provider_context';
|
||||
|
||||
export async function SecuritySolutionCypressTestRunner(
|
||||
{ getService }: FtrProviderContext,
|
||||
command: string
|
||||
envVars?: Record<string, string>
|
||||
) {
|
||||
const log = getService('log');
|
||||
const config = getService('config');
|
||||
const esArchiver = getService('esArchiver');
|
||||
|
||||
await withProcRunner(log, async (procs) => {
|
||||
await procs.run('cypress', {
|
||||
cmd: 'yarn',
|
||||
args: [command],
|
||||
cwd: resolve(__dirname),
|
||||
env: {
|
||||
...process.env,
|
||||
},
|
||||
wait: true,
|
||||
});
|
||||
});
|
||||
}
|
||||
await esArchiver.load('x-pack/test/security_solution_cypress/es_archives/auditbeat');
|
||||
|
||||
export async function SecuritySolutionServerlessVisualTestRunner(context: FtrProviderContext) {
|
||||
return SecuritySolutionCypressTestRunner(context, 'cypress:open');
|
||||
}
|
||||
|
||||
export async function SecuritySolutionServerlessHeadlessTestRunner(context: FtrProviderContext) {
|
||||
return SecuritySolutionCypressTestRunner(context, 'cypress:run');
|
||||
return {
|
||||
FORCE_COLOR: '1',
|
||||
ELASTICSEARCH_USERNAME: config.get('servers.elasticsearch.username'),
|
||||
ELASTICSEARCH_PASSWORD: config.get('servers.elasticsearch.password'),
|
||||
...envVars,
|
||||
};
|
||||
}
|
||||
|
|
|
@ -7,13 +7,17 @@
|
|||
|
||||
import { FtrConfigProviderContext } from '@kbn/test';
|
||||
|
||||
import { SecuritySolutionServerlessHeadlessTestRunner } from './runner';
|
||||
import type { FtrProviderContext } from './runner';
|
||||
import { SecuritySolutionCypressTestRunner } from './runner';
|
||||
|
||||
export default async function ({ readConfigFile }: FtrConfigProviderContext) {
|
||||
const svlSecConfig = await readConfigFile(require.resolve('./security_config.base.ts'));
|
||||
const securitySolutionCypressConfig = await readConfigFile(
|
||||
require.resolve('./security_config.base.ts')
|
||||
);
|
||||
|
||||
return {
|
||||
...svlSecConfig.getAll(),
|
||||
testRunner: SecuritySolutionServerlessHeadlessTestRunner,
|
||||
...securitySolutionCypressConfig.getAll(),
|
||||
|
||||
testRunner: (context: FtrProviderContext) => SecuritySolutionCypressTestRunner(context),
|
||||
};
|
||||
}
|
|
@ -5,11 +5,14 @@
|
|||
* 2.0.
|
||||
*/
|
||||
|
||||
const ELASTICSEARCH_USERNAME = Cypress.env('ELASTICSEARCH_USERNAME');
|
||||
const ELASTICSEARCH_PASSWORD = Cypress.env('ELASTICSEARCH_PASSWORD');
|
||||
|
||||
export const navigatesToLandingPage = () => {
|
||||
cy.visit('/', {
|
||||
cy.visit('/app/security/get_started', {
|
||||
auth: {
|
||||
username: 'elastic',
|
||||
password: 'changeme',
|
||||
username: ELASTICSEARCH_USERNAME,
|
||||
password: ELASTICSEARCH_PASSWORD,
|
||||
},
|
||||
});
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue