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

[buildkite] Add uptime playwright tests to PR pipeline #115590

Merged
merged 11 commits into from
Oct 20, 2021
11 changes: 11 additions & 0 deletions .buildkite/pipelines/pull_request/uptime.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
steps:
- command: .buildkite/scripts/steps/functional/uptime.sh
label: 'Uptime @elastic/synthetics Tests'
agents:
queue: ci-group-6
depends_on: build
timeout_in_minutes: 120
retry:
automatic:
- exit_status: '*'
limit: 1
4 changes: 4 additions & 0 deletions .buildkite/scripts/pipelines/pull_request/pipeline.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ const uploadPipeline = (pipelineContent) => {
// 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'));
}

pipeline.push(getPipeline('.buildkite/pipelines/pull_request/post_build.yml'));

uploadPipeline(pipeline.join('\n'));
Expand Down
2 changes: 2 additions & 0 deletions .buildkite/scripts/steps/functional/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

set -euo pipefail

# Note, changes here might also need to be made in other scripts, e.g. uptime.sh

source .buildkite/scripts/common/util.sh

.buildkite/scripts/bootstrap.sh
Expand Down
17 changes: 17 additions & 0 deletions .buildkite/scripts/steps/functional/uptime.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env bash

set -euo pipefail

source .buildkite/scripts/common/util.sh

.buildkite/scripts/bootstrap.sh
.buildkite/scripts/download_build_artifacts.sh

export JOB=kibana-uptime-playwright

echo "--- Uptime @elastic/synthetics Tests"

cd "$XPACK_DIR"

checks-reporter-with-killswitch "Uptime @elastic/synthetics Tests" \
node plugins/uptime/scripts/e2e.js --kibana-install-dir "$KIBANA_BUILD_LOCATION"
2 changes: 1 addition & 1 deletion x-pack/plugins/uptime/e2e/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ async function config({ readConfigFile }: FtrConfigProviderContext) {
'--csp.warnLegacyBrowsers=false',
// define custom kibana server args here
`--elasticsearch.ssl.certificateAuthorities=${CA_CERT_PATH}`,
`--elasticsearch.ignoreVersionMismatch=true`,
`--elasticsearch.ignoreVersionMismatch=${process.env.CI ? 'false' : 'true'}`,
`--uiSettings.overrides.theme:darkMode=true`,
`--elasticsearch.username=kibana_system`,
`--elasticsearch.password=changeme`,
Expand Down
15 changes: 5 additions & 10 deletions x-pack/plugins/uptime/e2e/playwright_start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,10 @@ import './journeys';

export function playwrightRunTests() {
return async ({ getService }: any) => {
try {
const result = await playwrightStart(getService);

if (result && result.uptime.status !== 'succeeded') {
process.exit(1);
}
} catch (error) {
console.error('errors: ', error);
process.exit(1);
const result = await playwrightStart(getService);

if (result && result.uptime.status !== 'succeeded') {
throw new Error('Tests failed');
}
};
}
Expand All @@ -42,7 +37,7 @@ async function playwrightStart(getService: any) {

const res = await playwrightRun({
params: { kibanaUrl },
playwrightOptions: { chromiumSandbox: false, timeout: 60 * 1000 },
playwrightOptions: { headless: true, chromiumSandbox: false, timeout: 60 * 1000 },
});

console.log('Removing esArchiver...');
Expand Down
18 changes: 13 additions & 5 deletions x-pack/plugins/uptime/scripts/e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,14 @@ const { argv } = yargs(process.argv.slice(2))
type: 'boolean',
description: 'Opens the Playwright Test Runner',
})
.option('kibana-install-dir', {
default: '',
type: 'string',
description: 'Path to the Kibana install directory',
})
.help();

const { server, runner, open } = argv;
const { server, runner, open, kibanaInstallDir } = argv;

const e2eDir = path.join(__dirname, '../e2e');

Expand All @@ -44,9 +49,12 @@ if (server) {
const config = './playwright_run.ts';

function executeRunner() {
childProcess.execSync(`node ../../../scripts/${ftrScript} --config ${config}`, {
cwd: e2eDir,
stdio: 'inherit',
});
childProcess.execSync(
`node ../../../scripts/${ftrScript} --config ${config} --kibana-install-dir '${kibanaInstallDir}'`,
{
cwd: e2eDir,
stdio: 'inherit',
}
);
}
executeRunner();