Re-enable APM E2E tests and allow server to shut down cleanly on failure (#115450)

* Re-enable APM E2E tests and allow server to shut down cleanly on failure

Calling `process.exit` in the test script made it so the FTR runner would not properly shut down the server, and cause other tests to fail because Kibana was left running on a port. Remove that and just throw
instead.

No changes were made to the tests, as I was unable to reproduce any failures locally. I'll try in CI and see if we can get anything to fail.

Fixes #115280.
This commit is contained in:
Nathan L Smith 2021-10-25 14:05:15 -05:00 committed by GitHub
parent 3a18a8226f
commit 81264f73e9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 29 additions and 25 deletions

View file

@ -66,12 +66,12 @@ const uploadPipeline = (pipelineContent) => {
pipeline.push(getPipeline('.buildkite/pipelines/pull_request/security_solution.yml'));
}
// if (
// (await doAnyChangesMatch([/^x-pack\/plugins\/apm/])) ||
// process.env.GITHUB_PR_LABELS.includes('ci:all-cypress-suites')
// ) {
// pipeline.push(getPipeline('.buildkite/pipelines/pull_request/apm_cypress.yml'));
// }
if (
(await doAnyChangesMatch([/^x-pack\/plugins\/apm/])) ||
process.env.GITHUB_PR_LABELS.includes('ci:all-cypress-suites')
) {
pipeline.push(getPipeline('.buildkite/pipelines/pull_request/apm_cypress.yml'));
}
if (await doAnyChangesMatch([/^x-pack\/plugins\/uptime/])) {
pipeline.push(getPipeline('.buildkite/pipelines/pull_request/uptime.yml'));

View file

@ -2,7 +2,10 @@
set -euo pipefail
source .buildkite/scripts/steps/functional/common.sh
source .buildkite/scripts/common/util.sh
.buildkite/scripts/bootstrap.sh
.buildkite/scripts/download_build_artifacts.sh
export JOB=kibana-apm-cypress
@ -11,4 +14,5 @@ echo "--- APM Cypress Tests"
cd "$XPACK_DIR"
checks-reporter-with-killswitch "APM Cypress Tests" \
node plugins/apm/scripts/test/e2e.js
node plugins/apm/scripts/test/e2e.js \
--kibana-install-dir "$KIBANA_BUILD_LOCATION"

View file

@ -146,13 +146,13 @@ def functionalXpack(Map params = [:]) {
}
}
// whenChanged([
// 'x-pack/plugins/apm/',
// ]) {
// if (githubPr.isPr()) {
// task(kibanaPipeline.functionalTestProcess('xpack-APMCypress', './test/scripts/jenkins_apm_cypress.sh'))
// }
// }
whenChanged([
'x-pack/plugins/apm/',
]) {
if (githubPr.isPr()) {
task(kibanaPipeline.functionalTestProcess('xpack-APMCypress', './test/scripts/jenkins_apm_cypress.sh'))
}
}
whenChanged([
'x-pack/plugins/uptime/',

View file

@ -16,15 +16,10 @@ import { esArchiverLoad, esArchiverUnload } from './cypress/tasks/es_archiver';
export function cypressRunTests(spec?: string) {
return async ({ getService }: FtrProviderContext) => {
try {
const result = await cypressStart(getService, cypress.run, spec);
const result = await cypressStart(getService, cypress.run, spec);
if (result && (result.status === 'failed' || result.totalFailed > 0)) {
process.exit(1);
}
} catch (error) {
console.error('errors: ', error);
process.exit(1);
if (result && (result.status === 'failed' || result.totalFailed > 0)) {
throw new Error(`APM Cypress tests failed`);
}
};
}

View file

@ -12,6 +12,11 @@ const yargs = require('yargs');
const childProcess = require('child_process');
const { argv } = yargs(process.argv.slice(2))
.option('kibana-install-dir', {
default: '',
type: 'string',
description: 'Path to the Kibana install directory',
})
.option('server', {
default: false,
type: 'boolean',
@ -30,7 +35,7 @@ const { argv } = yargs(process.argv.slice(2))
})
.help();
const { server, runner, open } = argv;
const { server, runner, open, kibanaInstallDir } = argv;
const e2eDir = path.join(__dirname, '../../ftr_e2e');
@ -44,6 +49,6 @@ if (server) {
const config = open ? './cypress_open.ts' : './cypress_run.ts';
childProcess.execSync(
`node ../../../../scripts/${ftrScript} --config ${config}`,
`node ../../../../scripts/${ftrScript} --config ${config} --kibana-install-dir '${kibanaInstallDir}'`,
{ cwd: e2eDir, stdio: 'inherit' }
);