Skip to content

Commit

Permalink
Re-enable APM E2E tests and allow server to shut down cleanly on fail…
Browse files Browse the repository at this point in the history
…ure (#115450) (#116201)

* 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.

Co-authored-by: Nathan L Smith <nathan.smith@elastic.co>
  • Loading branch information
kibanamachine and smith authored Oct 25, 2021
1 parent 6d5f595 commit 41c39de
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 25 deletions.
12 changes: 6 additions & 6 deletions .buildkite/scripts/pipelines/pull_request/pipeline.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
Expand Down
8 changes: 6 additions & 2 deletions .buildkite/scripts/steps/functional/apm_cypress.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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"
14 changes: 7 additions & 7 deletions vars/tasks.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -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/',
Expand Down
11 changes: 3 additions & 8 deletions x-pack/plugins/apm/ftr_e2e/cypress_start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`);
}
};
}
Expand Down
9 changes: 7 additions & 2 deletions x-pack/plugins/apm/scripts/test/e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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');

Expand All @@ -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' }
);

0 comments on commit 41c39de

Please sign in to comment.