mirror of
https://github.com/elastic/kibana.git
synced 2025-04-18 23:21:39 -04:00
[Profiling] Migrate Profiling Cypress tests to on_merge
from on_merge_unsupported_ftrs
(#206727)
## Summary Closes https://github.com/elastic/kibana/issues/206664 This PR moves Profiling Cypress tests to be run on the main pipeline instead of the unsupported one. --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
parent
d0c56b02fa
commit
3498d509ef
28 changed files with 142 additions and 287 deletions
|
@ -6,10 +6,7 @@ disabled:
|
|||
- x-pack/solutions/observability/plugins/observability_onboarding/e2e/ftr_config.ts
|
||||
- x-pack/solutions/observability/plugins/inventory/e2e/ftr_config_run.ts
|
||||
- x-pack/solutions/observability/plugins/inventory/e2e/ftr_config.ts
|
||||
- x-pack/solutions/observability/plugins/profiling/e2e/ftr_config_open.ts
|
||||
- x-pack/solutions/observability/plugins/profiling/e2e/ftr_config_runner.ts
|
||||
- x-pack/solutions/observability/plugins/profiling/e2e/ftr_config.ts
|
||||
|
||||
- x-pack/test/profiling_cypress/cli_config.ts
|
||||
#FTR configs
|
||||
- x-pack/solutions/observability/plugins/uptime/e2e/config.ts
|
||||
|
||||
|
|
|
@ -479,6 +479,22 @@ steps:
|
|||
- exit_status: '-1'
|
||||
limit: 1
|
||||
|
||||
- command: .buildkite/scripts/steps/functional/profiling_cypress.sh
|
||||
label: 'Profiling Cypress Tests'
|
||||
agents:
|
||||
image: family/kibana-ubuntu-2004
|
||||
imageProject: elastic-images-prod
|
||||
provider: gcp
|
||||
machineType: n2-standard-4
|
||||
preemptible: true
|
||||
depends_on: build
|
||||
timeout_in_minutes: 120
|
||||
parallelism: 3
|
||||
retry:
|
||||
automatic:
|
||||
- exit_status: '-1'
|
||||
limit: 1
|
||||
|
||||
- command: .buildkite/scripts/steps/functional/apm_cypress.sh
|
||||
label: 'APM Cypress Tests'
|
||||
agents:
|
||||
|
|
|
@ -28,25 +28,6 @@ steps:
|
|||
- exit_status: '-1'
|
||||
limit: 3
|
||||
|
||||
- command: .buildkite/scripts/steps/functional/profiling_cypress.sh
|
||||
label: 'Profiling Cypress Tests'
|
||||
agents:
|
||||
image: family/kibana-ubuntu-2004
|
||||
imageProject: elastic-images-prod
|
||||
provider: gcp
|
||||
machineType: n2-standard-4
|
||||
preemptible: true
|
||||
depends_on: build
|
||||
env:
|
||||
PING_SLACK_TEAM: "@obs-ux-infra_services-team"
|
||||
timeout_in_minutes: 120
|
||||
retry:
|
||||
automatic:
|
||||
- exit_status: '-1'
|
||||
limit: 3
|
||||
- exit_status: '*'
|
||||
limit: 1
|
||||
|
||||
- command: .buildkite/scripts/steps/functional/synthetics_plugin.sh
|
||||
label: 'Synthetics @elastic/synthetics Tests'
|
||||
agents:
|
||||
|
|
|
@ -13,7 +13,7 @@ steps:
|
|||
- check_types
|
||||
- check_oas_snapshot
|
||||
timeout_in_minutes: 120
|
||||
parallelism: 2
|
||||
parallelism: 3
|
||||
retry:
|
||||
automatic:
|
||||
- exit_status: '-1'
|
||||
|
|
|
@ -2,17 +2,15 @@
|
|||
|
||||
set -euo pipefail
|
||||
|
||||
source .buildkite/scripts/common/util.sh
|
||||
source .buildkite/scripts/steps/functional/common.sh
|
||||
|
||||
.buildkite/scripts/bootstrap.sh
|
||||
.buildkite/scripts/download_build_artifacts.sh
|
||||
.buildkite/scripts/copy_es_snapshot_cache.sh
|
||||
export KIBANA_INSTALL_DIR=${KIBANA_BUILD_LOCATION}
|
||||
|
||||
export JOB=kibana-profiling-cypress
|
||||
|
||||
echo "--- Profiling Cypress Tests"
|
||||
|
||||
cd "$XPACK_DIR"
|
||||
cd "$XPACK_DIR/solutions/observability/plugins/profiling/e2e"
|
||||
|
||||
NODE_OPTIONS=--openssl-legacy-provider node solutions/observability/plugins/profiling/scripts/test/e2e.js \
|
||||
--kibana-install-dir "$KIBANA_BUILD_LOCATION" \
|
||||
set +e
|
||||
yarn cypress:run; status=$?; yarn junit:merge || :; exit $status
|
||||
|
|
3
.github/CODEOWNERS
vendored
3
.github/CODEOWNERS
vendored
|
@ -2586,6 +2586,9 @@ x-pack/solutions/security/plugins/security_solution/server/lib/security_integrat
|
|||
# Changes to translation files should not ping code reviewers
|
||||
x-pack/platform/plugins/private/translations/translations
|
||||
|
||||
# Profiling cypress tests
|
||||
x-pack/test/profiling_cypress @elastic/obs-ux-infra_services-team
|
||||
|
||||
# Profiling api integration testing
|
||||
x-pack/test/profiling_api_integration @elastic/obs-ux-infra_services-team
|
||||
|
||||
|
|
|
@ -141,7 +141,7 @@ Tests run on buildkite PR pipeline are parallelized (8 parallel jobs) and are or
|
|||
```yml
|
||||
...
|
||||
depends_on: build
|
||||
parallelism: 8
|
||||
parallelism: 3
|
||||
...
|
||||
```
|
||||
|
||||
|
@ -150,7 +150,7 @@ Tests run on buildkite PR pipeline are parallelized (8 parallel jobs) and are or
|
|||
#### Start Cypress dashboard
|
||||
|
||||
```
|
||||
node x-pack/solutions/observability/plugins/apm/scripts/test/e2e --headed
|
||||
node x-pack/solutions/observability/plugins/apm/scripts/test/e2e --open
|
||||
```
|
||||
|
||||
#### Run tests
|
||||
|
@ -159,6 +159,12 @@ node x-pack/solutions/observability/plugins/apm/scripts/test/e2e --headed
|
|||
node x-pack/solutions/observability/plugins/apm/scripts/test/e2e
|
||||
```
|
||||
|
||||
#### Run tests in headed mode
|
||||
|
||||
```
|
||||
node x-pack/solutions/observability/plugins/apm/scripts/test/e2e --headed
|
||||
```
|
||||
|
||||
### A11y checks
|
||||
|
||||
Accessibility tests are added on the e2e with `checkA11y()`, they will run together with cypress.
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
"cypress": "NODE_OPTIONS=--openssl-legacy-provider node ../../../../security/plugins/security_solution/scripts/start_cypress_parallel --config-file ../observability/plugins/apm/ftr_e2e/cypress.config.ts --ftr-config-file ../../../../../test/apm_cypress/cli_config",
|
||||
"cypress:open": "yarn cypress open",
|
||||
"cypress:run": "yarn cypress run",
|
||||
"cypress:run:headed": "yarn cypress run --headed",
|
||||
"junit:merge": "../../../../../../node_modules/.bin/mochawesome-merge ../../../../../../target/kibana-apm/cypress/results/mochawesome*.json > ../../../../../../target/kibana-apm/cypress/results/output.json && ../../../../../../node_modules/.bin/marge ../../../../../../target/kibana-apm/cypress/results/output.json --reportDir ../../../../../../target/kibana-apm/cypress/results && yarn junit:transform && mkdir -p ../../../../../../target/junit && cp ../../../../../../target/kibana-apm/cypress/results/*.xml ../../../../../../target/junit/",
|
||||
"junit:transform": "node ../../../../security/plugins/security_solution/scripts/junit_transformer --pathPattern '../../../../../../target/kibana-apm/cypress/results/*.xml' --rootDirectory ../../../../../../ --reportName 'APM Cypress' --writeInPlace"
|
||||
}
|
||||
|
|
|
@ -17,15 +17,22 @@ const { argv } = yargs(process.argv.slice(2))
|
|||
type: 'boolean',
|
||||
description: 'Runs Cypress in headed mode',
|
||||
})
|
||||
.option('open', {
|
||||
default: false,
|
||||
type: 'boolean',
|
||||
description: 'Opens Cypress dashboard',
|
||||
})
|
||||
.help();
|
||||
|
||||
const e2eDir = path.join(__dirname, '../../ftr_e2e');
|
||||
|
||||
function runTests() {
|
||||
const mode = argv.headed ? 'open' : 'run';
|
||||
console.log(`Running e2e tests: "yarn cypress:${mode}"`);
|
||||
const mode = argv.open ? 'open' : 'run';
|
||||
const isHeaded = mode === 'run' && argv.headed ? ':headed' : '';
|
||||
|
||||
return childProcess.spawnSync('yarn', [`cypress:${mode}`], {
|
||||
console.log(`Running e2e tests: "yarn cypress:${mode}${isHeaded}"`);
|
||||
|
||||
return childProcess.spawnSync('yarn', [`cypress:${mode}${isHeaded}`], {
|
||||
cwd: e2eDir,
|
||||
encoding: 'utf8',
|
||||
stdio: 'inherit',
|
||||
|
|
|
@ -51,29 +51,24 @@ The E2E tests are located in [`x-pack/solutions/observability/plugins/profiling/
|
|||
|
||||
Universal Profiling uses [FTR](../../../../packages/kbn-test/README.mdx) (functional test runner) and [Cypress](https://www.cypress.io/) to run the e2e tests. The tests are located at `kibana/x-pack/solutions/observability/plugins/profiling/e2e/cypress/e2e`.
|
||||
|
||||
### Start test server
|
||||
|
||||
```
|
||||
node x-pack/solutions/observability/plugins/profiling/scripts/test/e2e --server
|
||||
```
|
||||
|
||||
### Open cypress dashboard
|
||||
### Start with Cypress Dashboard
|
||||
|
||||
```
|
||||
node x-pack/solutions/observability/plugins/profiling/scripts/test/e2e --open
|
||||
```
|
||||
|
||||
### Run tests in terminal
|
||||
|
||||
```
|
||||
node x-pack/solutions/observability/plugins/profiling/scripts/test/e2e --runner
|
||||
```
|
||||
|
||||
### Run like CI
|
||||
### Run tests
|
||||
Runs all tests in the terminal
|
||||
|
||||
```
|
||||
node x-pack/solutions/observability/plugins/profiling/scripts/test/e2e
|
||||
```
|
||||
|
||||
### Run tests in headed mode
|
||||
|
||||
```
|
||||
node x-pack/solutions/observability/plugins/profiling/scripts/test/e2e --headed
|
||||
```
|
||||
|
||||
## Other resources
|
||||
- [Official Profiling documentation](https://www.elastic.co/observability/universal-profiling)
|
||||
|
|
|
@ -11,41 +11,35 @@ Tests run on buildkite PR pipeline are parallelized (4 parallel jobs) and are or
|
|||
```yml
|
||||
...
|
||||
depends_on: build
|
||||
parallelism: 4
|
||||
parallelism: 3
|
||||
...
|
||||
```
|
||||
|
||||
## Running it locally
|
||||
|
||||
### Start test server
|
||||
### Start with Cypress Dashboard
|
||||
|
||||
```
|
||||
node x-pack/solutions/observability/plugins/profiling/scripts/test/e2e --server
|
||||
node x-pack/solutions/observability/plugins/profiling/scripts/test/e2e --open
|
||||
```
|
||||
|
||||
### Run tests
|
||||
Runs all tests in the terminal
|
||||
|
||||
```
|
||||
node x-pack/solutions/observability/plugins/profiling/scripts/test/e2e --runner
|
||||
node x-pack/solutions/observability/plugins/profiling/scripts/test/e2e
|
||||
```
|
||||
|
||||
### Open cypress dashboard
|
||||
Opens cypress dashboard, there it's possible to select what test you want to run.
|
||||
### Run tests in headed mode
|
||||
|
||||
```
|
||||
node x-pack/solutions/observability/plugins/profiling/scripts/test/e2e --open
|
||||
node x-pack/solutions/observability/plugins/profiling/scripts/test/e2e --headed
|
||||
```
|
||||
|
||||
### Arguments
|
||||
|
||||
| Option | Description |
|
||||
| ------------ | ----------------------------------------------- |
|
||||
| --server | Only start ES and Kibana |
|
||||
| --runner | Only run tests |
|
||||
| --spec | Specify the specs to run |
|
||||
| --times | Repeat the test n number of times |
|
||||
| --bail | stop tests after the first failure |
|
||||
| --open | Opens Cypress dashboard |
|
||||
| --headed | Runs tests in headed mode |
|
||||
|
||||
```
|
||||
node x-pack/solutions/observability/plugins/profiling/scripts/test/e2e.js --runner --spec cypress/e2e/profiling.cy.ts --times 2
|
||||
```
|
||||
|
|
|
@ -8,25 +8,27 @@
|
|||
import { defineCypressConfig } from '@kbn/cypress-config';
|
||||
|
||||
export default defineCypressConfig({
|
||||
reporter: '../../../../../../node_modules/cypress-multi-reporters',
|
||||
reporterOptions: {
|
||||
configFile: './reporter_config.json',
|
||||
},
|
||||
fileServerFolder: './cypress',
|
||||
fixturesFolder: './cypress/fixtures',
|
||||
screenshotsFolder: './cypress/screenshots',
|
||||
videosFolder: './cypress/videos',
|
||||
requestTimeout: 10000,
|
||||
responseTimeout: 40000,
|
||||
defaultCommandTimeout: 30000,
|
||||
defaultCommandTimeout: 60000,
|
||||
execTimeout: 120000,
|
||||
pageLoadTimeout: 120000,
|
||||
viewportHeight: 1800,
|
||||
viewportWidth: 1440,
|
||||
video: false,
|
||||
screenshotOnRunFailure: false,
|
||||
retries: {
|
||||
runMode: 1,
|
||||
},
|
||||
screenshotOnRunFailure: true,
|
||||
e2e: {
|
||||
baseUrl: 'http://localhost:5601',
|
||||
supportFile: './cypress/support/e2e.ts',
|
||||
specPattern: './cypress/e2e/**/*.cy.{js,jsx,ts,tsx}',
|
||||
specPattern: './cypress/e2e/**/*.cy.ts',
|
||||
experimentalMemoryManagement: true,
|
||||
numTestsKeptInMemory: 3,
|
||||
experimentalRunAllSpecs: true,
|
||||
},
|
||||
});
|
||||
|
|
3
x-pack/solutions/observability/plugins/profiling/e2e/cypress/.gitignore
vendored
Normal file
3
x-pack/solutions/observability/plugins/profiling/e2e/cypress/.gitignore
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
/videos/*
|
||||
/screenshots/*
|
||||
/downloads/*
|
|
@ -59,14 +59,13 @@ Cypress.Commands.add(
|
|||
'addKqlFilter',
|
||||
({ key, value, dataTestSubj = 'profilingUnifiedSearchBar', waitForSuggestion = true }) => {
|
||||
cy.getByTestSubj(dataTestSubj).type(key);
|
||||
cy.contains(key);
|
||||
cy.getByTestSubj(`autocompleteSuggestion-field-${key}-`).click();
|
||||
// Do not close quotes here as it will not display the suggestion box
|
||||
cy.getByTestSubj(dataTestSubj).type(`: "${value}`);
|
||||
|
||||
cy.getByTestSubj(`autocompleteSuggestion-field-${key}-`).should('be.visible');
|
||||
cy.getByTestSubj(dataTestSubj).type(` : ${value}`);
|
||||
if (waitForSuggestion) {
|
||||
cy.getByTestSubj(
|
||||
Cypress.$.escapeSelector(`autocompleteSuggestion-value-"${value}"-`)
|
||||
).click();
|
||||
cy.getByTestSubj(`autocompleteSuggestion-value-\\"${value}\\"-`)
|
||||
.should('be.visible')
|
||||
.click({ force: true });
|
||||
}
|
||||
cy.getByTestSubj(dataTestSubj).type('{enter}');
|
||||
}
|
||||
|
|
|
@ -10,4 +10,3 @@ Cypress.on('uncaught:exception', (err, runnable) => {
|
|||
});
|
||||
|
||||
import './commands';
|
||||
// import './output_command_timings';
|
||||
|
|
|
@ -1,26 +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 type { FtrConfigProviderContext } from '@kbn/test';
|
||||
import cypress from 'cypress';
|
||||
import type { FtrProviderContext } from './ftr_provider_context';
|
||||
import { cypressTestRunner } from './cypress_test_runner';
|
||||
|
||||
async function ftrConfigOpen({ readConfigFile }: FtrConfigProviderContext) {
|
||||
const kibanaConfig = await readConfigFile(require.resolve('./ftr_config.ts'));
|
||||
return {
|
||||
...kibanaConfig.getAll(),
|
||||
testRunner,
|
||||
};
|
||||
}
|
||||
|
||||
export async function testRunner(ftrProviderContext: FtrProviderContext) {
|
||||
await cypressTestRunner({ ftrProviderContext, cypressExecution: cypress.open });
|
||||
}
|
||||
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
export default ftrConfigOpen;
|
|
@ -1,35 +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 type { FtrConfigProviderContext } from '@kbn/test';
|
||||
import cypress from 'cypress';
|
||||
import { cypressTestRunner } from './cypress_test_runner';
|
||||
import type { FtrProviderContext } from './ftr_provider_context';
|
||||
|
||||
async function ftrConfigRun({ readConfigFile }: FtrConfigProviderContext) {
|
||||
const kibanaConfig = await readConfigFile(require.resolve('./ftr_config.ts'));
|
||||
|
||||
return {
|
||||
...kibanaConfig.getAll(),
|
||||
testRunner,
|
||||
};
|
||||
}
|
||||
|
||||
async function testRunner(ftrProviderContext: FtrProviderContext) {
|
||||
const result = await cypressTestRunner({ ftrProviderContext, cypressExecution: cypress.run });
|
||||
|
||||
if (
|
||||
result &&
|
||||
((result as CypressCommandLine.CypressFailedRunResult)?.status === 'failed' ||
|
||||
(result as CypressCommandLine.CypressRunResult)?.totalFailed)
|
||||
) {
|
||||
process.exitCode = 1;
|
||||
}
|
||||
}
|
||||
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
export default ftrConfigRun;
|
|
@ -1,10 +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 type { GenericFtrProviderContext } from '@kbn/test';
|
||||
|
||||
export type FtrProviderContext = GenericFtrProviderContext<{}, {}>;
|
|
@ -0,0 +1,15 @@
|
|||
{
|
||||
"author": "Elastic",
|
||||
"name": "@kbn/profiling-ftr-e2e",
|
||||
"version": "1.0.0",
|
||||
"private": true,
|
||||
"license": "Elastic License 2.0",
|
||||
"scripts": {
|
||||
"cypress": "NODE_OPTIONS=--openssl-legacy-provider node ../../../../security/plugins/security_solution/scripts/start_cypress_parallel --config-file ../observability/plugins/profiling/e2e/cypress.config.ts --ftr-config-file ../../../../../test/profiling_cypress/cli_config",
|
||||
"cypress:open": "yarn cypress open",
|
||||
"cypress:run": "yarn cypress run",
|
||||
"cypress:run:headed": "yarn cypress run --headed",
|
||||
"junit:merge": "../../../../../../node_modules/.bin/mochawesome-merge ../../../../../../target/kibana-profiling/cypress/results/mochawesome*.json > ../../../../../../target/kibana-profiling/cypress/results/output.json && ../../../../../../node_modules/.bin/marge ../../../../../../target/kibana-profiling/cypress/results/output.json --reportDir ../../../../../../target/kibana-profiling/cypress/results && yarn junit:transform && mkdir -p ../../../../../../target/junit && cp ../../../../../../target/kibana-profiling/cypress/results/*.xml ../../../../../../target/junit/",
|
||||
"junit:transform": "node ../../../../security/plugins/security_solution/scripts/junit_transformer --pathPattern '../../../../../../target/kibana-profiling/cypress/results/*.xml' --rootDirectory ../../../../../../ --reportName 'Profiling Cypress' --writeInPlace"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
{
|
||||
"reporterEnabled": "mochawesome, mocha-junit-reporter",
|
||||
"reporterOptions": {
|
||||
"html": false,
|
||||
"json": true,
|
||||
"mochaFile": "../../../../../../target/kibana-profiling/cypress/results/TEST-profiling-cypress-[hash].xml",
|
||||
"overwrite": false,
|
||||
"reportDir": "../../../../../../target/kibana-profiling/cypress/results"
|
||||
}
|
||||
}
|
|
@ -9,11 +9,7 @@
|
|||
},
|
||||
"kbn_references": [
|
||||
{ "path": "../../../../test/tsconfig.json" },
|
||||
"@kbn/test",
|
||||
"@kbn/dev-utils",
|
||||
"@kbn/cypress-config",
|
||||
"@kbn/observability-plugin",
|
||||
"@kbn/ftr-common-functional-services",
|
||||
"@kbn/ftr-common-functional-ui-services"
|
||||
]
|
||||
}
|
||||
|
|
|
@ -6,104 +6,42 @@
|
|||
*/
|
||||
|
||||
/* eslint-disable no-console */
|
||||
const { times } = require('lodash');
|
||||
const path = require('path');
|
||||
const yargs = require('yargs');
|
||||
const childProcess = require('child_process');
|
||||
const { REPO_ROOT } = require('@kbn/repo-info');
|
||||
|
||||
const { argv } = yargs(process.argv.slice(2))
|
||||
.parserConfiguration({ 'unknown-options-as-args': true })
|
||||
.option('kibana-install-dir', {
|
||||
default: '',
|
||||
type: 'string',
|
||||
description: 'Path to the Kibana install directory',
|
||||
})
|
||||
.option('server', {
|
||||
.option('headed', {
|
||||
default: false,
|
||||
type: 'boolean',
|
||||
description: 'Start Elasticsearch and Kibana',
|
||||
})
|
||||
.option('runner', {
|
||||
default: false,
|
||||
type: 'boolean',
|
||||
description:
|
||||
'Run all tests (an instance of Elasticsearch and kibana are needs to be available)',
|
||||
description: 'Runs Cypress in headed mode',
|
||||
})
|
||||
.option('open', {
|
||||
default: false,
|
||||
type: 'boolean',
|
||||
description:
|
||||
'Open cypress dashboard (an instance of Elasticsearch and kibana are needs to be available)',
|
||||
})
|
||||
.option('times', {
|
||||
type: 'number',
|
||||
description: 'Repeat the test n number of times',
|
||||
})
|
||||
.option('bail', {
|
||||
default: false,
|
||||
type: 'boolean',
|
||||
description: 'stop tests after the first failure',
|
||||
description: 'Opens Cypress dashboard',
|
||||
})
|
||||
.help();
|
||||
|
||||
const e2eDir = path.join(__dirname, '../../e2e');
|
||||
|
||||
let ftrScript = 'functional_tests.js';
|
||||
if (argv.server) {
|
||||
ftrScript = 'functional_tests_server.js';
|
||||
} else if (argv.runner || argv.open) {
|
||||
ftrScript = 'functional_test_runner.js';
|
||||
}
|
||||
|
||||
const cypressCliArgs = yargs(argv._).parserConfiguration({
|
||||
'boolean-negation': false,
|
||||
}).argv;
|
||||
|
||||
if (cypressCliArgs.grep) {
|
||||
throw new Error('--grep is not supported. Please use --spec instead');
|
||||
}
|
||||
|
||||
const ftrConfig = argv.open ? './ftr_config_open.ts' : './ftr_config_runner.ts';
|
||||
const spawnArgs = [
|
||||
`${REPO_ROOT}/scripts/${ftrScript}`,
|
||||
`--config=${ftrConfig}`,
|
||||
`--kibana-install-dir=${argv.kibanaInstallDir}`,
|
||||
...(argv.bail ? [`--bail`] : []),
|
||||
];
|
||||
|
||||
function runTests() {
|
||||
console.log(`Running e2e tests: "node ${spawnArgs.join(' ')}"`);
|
||||
const mode = argv.open ? 'open' : 'run';
|
||||
const isHeaded = mode === 'run' && argv.headed ? ':headed' : '';
|
||||
|
||||
return childProcess.spawnSync('node', spawnArgs, {
|
||||
console.log(`Running e2e tests: "yarn cypress:${mode}${isHeaded}"`);
|
||||
|
||||
return childProcess.spawnSync('yarn', [`cypress:${mode}${isHeaded}`], {
|
||||
cwd: e2eDir,
|
||||
env: {
|
||||
...process.env,
|
||||
CYPRESS_CLI_ARGS: JSON.stringify(cypressCliArgs),
|
||||
NODE_OPTIONS: '--openssl-legacy-provider',
|
||||
},
|
||||
encoding: 'utf8',
|
||||
stdio: 'inherit',
|
||||
});
|
||||
}
|
||||
|
||||
const runCounter = { succeeded: 0, failed: 0, remaining: argv.times };
|
||||
let exitStatus = 0;
|
||||
times(argv.times ?? 1, () => {
|
||||
const child = runTests();
|
||||
if (child.status === 0) {
|
||||
runCounter.succeeded++;
|
||||
} else {
|
||||
exitStatus = child.status;
|
||||
runCounter.failed++;
|
||||
}
|
||||
|
||||
runCounter.remaining--;
|
||||
|
||||
if (argv.times > 1) {
|
||||
console.log(runCounter);
|
||||
}
|
||||
});
|
||||
const child = runTests();
|
||||
exitStatus = child.status;
|
||||
|
||||
process.exitCode = exitStatus;
|
||||
console.log(`Quitting with exit code ${exitStatus}`);
|
||||
|
|
|
@ -7,9 +7,8 @@
|
|||
|
||||
import type { FtrConfigProviderContext } from '@kbn/test';
|
||||
import { CA_CERT_PATH } from '@kbn/dev-utils';
|
||||
import { commonFunctionalServices } from '@kbn/ftr-common-functional-services';
|
||||
import { commonFunctionalUIServices } from '@kbn/ftr-common-functional-ui-services';
|
||||
import path from 'path';
|
||||
import { cypressTestRunner } from './runner';
|
||||
|
||||
const kibanaYamlFilePath = path.join(__dirname, './ftr_kibana.yml');
|
||||
|
||||
|
@ -18,17 +17,12 @@ async function ftrConfig({ readConfigFile }: FtrConfigProviderContext) {
|
|||
require.resolve('@kbn/test-suites-src/common/config')
|
||||
);
|
||||
const xpackFunctionalTestsConfig = await readConfigFile(
|
||||
require.resolve('@kbn/test-suites-xpack/functional/config.base')
|
||||
require.resolve('../functional/config.base.js')
|
||||
);
|
||||
|
||||
return {
|
||||
...kibanaCommonTestsConfig.getAll(),
|
||||
|
||||
services: {
|
||||
...commonFunctionalServices,
|
||||
...commonFunctionalUIServices,
|
||||
},
|
||||
|
||||
esTestCluster: {
|
||||
...xpackFunctionalTestsConfig.get('esTestCluster'),
|
||||
serverArgs: [
|
||||
|
@ -51,8 +45,8 @@ async function ftrConfig({ readConfigFile }: FtrConfigProviderContext) {
|
|||
`--config=${kibanaYamlFilePath}`,
|
||||
],
|
||||
},
|
||||
testRunner: cypressTestRunner,
|
||||
};
|
||||
}
|
||||
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
export default ftrConfig;
|
|
@ -6,10 +6,8 @@
|
|||
*/
|
||||
|
||||
import axios from 'axios';
|
||||
import type cypress from 'cypress';
|
||||
import path from 'path';
|
||||
import Url from 'url';
|
||||
import type { FtrProviderContext } from './ftr_provider_context';
|
||||
import type { FtrProviderContext } from '../common/ftr_provider_context';
|
||||
import { loadProfilingData } from './load_profiling_data';
|
||||
import { setupProfilingResources } from './setup_profiling_resources';
|
||||
|
||||
|
@ -17,13 +15,8 @@ const DEFAULT_HEADERS = {
|
|||
'kbn-xsrf': true,
|
||||
'x-elastic-internal-origin': 'Kibana',
|
||||
};
|
||||
export async function cypressTestRunner({
|
||||
ftrProviderContext: { getService },
|
||||
cypressExecution,
|
||||
}: {
|
||||
ftrProviderContext: FtrProviderContext;
|
||||
cypressExecution: typeof cypress.run | typeof cypress.open;
|
||||
}) {
|
||||
|
||||
export async function cypressTestRunner({ getService }: FtrProviderContext) {
|
||||
const config = getService('config');
|
||||
|
||||
const username = config.get('servers.elasticsearch.username');
|
||||
|
@ -53,12 +46,12 @@ export async function cypressTestRunner({
|
|||
{ headers: DEFAULT_HEADERS }
|
||||
);
|
||||
|
||||
// Only runs the setup once. This is useful when runing the tests with --times args
|
||||
// Only runs the setup once. This is useful when running the tests with --times args
|
||||
if (!profilingResources.data.has_setup) {
|
||||
await setupProfilingResources({ kibanaUrlWithAuth });
|
||||
}
|
||||
|
||||
// Only loads profiling data once. This is useful when runing the tests with --times args
|
||||
// Only loads profiling data once. This is useful when running the tests with --times args
|
||||
if (!profilingResources.data.has_data) {
|
||||
await loadProfilingData({ esNode, esRequestTimeout });
|
||||
}
|
||||
|
@ -69,42 +62,21 @@ export async function cypressTestRunner({
|
|||
port: config.get('servers.kibana.port'),
|
||||
});
|
||||
|
||||
const cypressProjectPath = path.join(__dirname);
|
||||
const { open, ...cypressCliArgs } = getCypressCliArgs();
|
||||
|
||||
const res = await cypressExecution({
|
||||
...cypressCliArgs,
|
||||
project: cypressProjectPath,
|
||||
config: {
|
||||
e2e: {
|
||||
baseUrl: kibanaUrlWithoutAuth,
|
||||
},
|
||||
},
|
||||
env: {
|
||||
KIBANA_URL: kibanaUrlWithoutAuth,
|
||||
ES_NODE: esNode,
|
||||
ES_REQUEST_TIMEOUT: esRequestTimeout,
|
||||
TEST_CLOUD: process.env.TEST_CLOUD,
|
||||
},
|
||||
});
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
function getCypressCliArgs(): Record<string, unknown> {
|
||||
if (!process.env.CYPRESS_CLI_ARGS) {
|
||||
return {};
|
||||
}
|
||||
|
||||
const { $0, _, ...cypressCliArgs } = JSON.parse(process.env.CYPRESS_CLI_ARGS) as Record<
|
||||
string,
|
||||
unknown
|
||||
>;
|
||||
|
||||
const spec =
|
||||
typeof cypressCliArgs.spec === 'string' && !cypressCliArgs.spec.includes('**')
|
||||
? `**/${cypressCliArgs.spec}*`
|
||||
: cypressCliArgs.spec;
|
||||
|
||||
return { ...cypressCliArgs, spec };
|
||||
return {
|
||||
KIBANA_URL: kibanaUrlWithoutAuth,
|
||||
ES_NODE: esNode,
|
||||
ES_REQUEST_TIMEOUT: esRequestTimeout,
|
||||
TEST_CLOUD: process.env.TEST_CLOUD,
|
||||
baseUrl: Url.format({
|
||||
protocol: config.get('servers.kibana.protocol'),
|
||||
hostname: config.get('servers.kibana.hostname'),
|
||||
port: config.get('servers.kibana.port'),
|
||||
}),
|
||||
protocol: config.get('servers.kibana.protocol'),
|
||||
hostname: config.get('servers.kibana.hostname'),
|
||||
configport: config.get('servers.kibana.port'),
|
||||
ELASTICSEARCH_URL: Url.format(config.get('servers.elasticsearch')),
|
||||
ELASTICSEARCH_USERNAME: config.get('servers.kibana.username'),
|
||||
ELASTICSEARCH_PASSWORD: config.get('servers.kibana.password'),
|
||||
};
|
||||
}
|
Loading…
Add table
Reference in a new issue