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

Using @elastic/synthetics to run uptime e2e tests #90673

Closed
wants to merge 61 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
6c4222f
Added server and runner script
shahzad31 Mar 1, 2021
c26d77b
Added server and runner script
shahzad31 Mar 1, 2021
70ce302
revert
shahzad31 Mar 1, 2021
33c535e
revert
shahzad31 Mar 1, 2021
8054b8e
remove fixture
shahzad31 Mar 1, 2021
978b6d1
update tsconfig
shahzad31 Mar 1, 2021
7c03734
update json file
shahzad31 Mar 1, 2021
5bb1d08
Merge branch 'master' into playwright-ftr-e2e
kibanamachine Mar 1, 2021
bc83e06
Merge branch 'master' into playwright-ftr-e2e
shahzad31 Mar 1, 2021
2cf8be0
Merge branch 'playwright-ftr-e2e' of https://github.com/shahzad31/kib…
shahzad31 Mar 1, 2021
3ff35c5
update ts config
shahzad31 Mar 1, 2021
3988f1e
update unit test
shahzad31 Mar 1, 2021
75497cf
update ts
shahzad31 Mar 1, 2021
237ef3d
[CI] support uptime ui and apm-ui analysis
v1v Mar 1, 2021
9846b5e
Support uptime and apm e2e in parallel stages
v1v Mar 1, 2021
6681a73
Look for changes for the uptime sub-folder
v1v Mar 1, 2021
4cf0b08
Refactor
v1v Mar 1, 2021
3011e56
Support GitHub checks for the uptime e2e
v1v Mar 1, 2021
9a256c4
Merge branch 'master' into playwright-ftr-e2e
kibanamachine Mar 2, 2021
1adbaa0
fix signature
v1v Mar 2, 2021
dd35c42
Merge branch 'playwright-ftr-e2e' of github.com:shahzad31/kibana into…
v1v Mar 2, 2021
7b4916a
Initial attempt to support the uptime e2e in the CI
v1v Mar 2, 2021
98c4432
fix syntax
shahzad31 Mar 2, 2021
fb8ba17
Merge branch 'playwright-ftr-e2e' of https://github.com/shahzad31/kib…
shahzad31 Mar 2, 2021
e60c82b
Use the internal ES port for the healthcheck
v1v Mar 2, 2021
8932eba
Use the kibana port for the uptime e2e
v1v Mar 2, 2021
c1cd9bd
Checkout in the new stage
v1v Mar 2, 2021
dccb092
fix linting
v1v Mar 2, 2021
9497ebc
fix credentials, location and waitfor
v1v Mar 2, 2021
518df1c
added kibana wait in runner
shahzad31 Mar 2, 2021
818e0a8
Merge branch 'playwright-ftr-e2e' of https://github.com/shahzad31/kib…
shahzad31 Mar 2, 2021
108786b
delegate the wait for to the consumer
v1v Mar 2, 2021
82c3844
store docker context
v1v Mar 2, 2021
7c91ab0
fix the must be owned by the user identifier
v1v Mar 2, 2021
4f619dc
no watch
shahzad31 Mar 2, 2021
b75aede
headless mode
shahzad31 Mar 2, 2021
2d4da12
Merge branch 'master' into playwright-ftr-e2e
shahzad31 Mar 3, 2021
6dd9bd1
update journey
shahzad31 Mar 3, 2021
b44cc44
timeout
shahzad31 Mar 3, 2021
bcdd44a
ci: kill previous running builds
v1v Mar 3, 2021
8040fa2
test timeout
shahzad31 Mar 3, 2021
badb9eb
Merge branch 'playwright-ftr-e2e' of https://github.com/shahzad31/kib…
shahzad31 Mar 3, 2021
1dbcb04
Merge branch 'master' into playwright-ftr-e2e
shahzad31 Mar 4, 2021
984a3c9
update loading
shahzad31 Mar 4, 2021
282d943
update selector
shahzad31 Mar 4, 2021
92a8f85
sandbox false
shahzad31 Mar 4, 2021
30d4af5
Merge branch 'master' into playwright-ftr-e2e
shahzad31 Apr 13, 2021
2b87d01
update
shahzad31 Apr 13, 2021
ffae5f1
update
shahzad31 Apr 13, 2021
fd69e6e
update
shahzad31 Apr 13, 2021
0befc3d
revert
shahzad31 Apr 13, 2021
47a7dfb
Merge branch 'master' into playwright-ftr-e2e
shahzad31 Apr 25, 2021
ce0d72e
try different stuff
shahzad31 Apr 26, 2021
1ff39d5
ci: set env variable to run the build
v1v Apr 26, 2021
f4402ef
update
shahzad31 Apr 26, 2021
fa65022
Merge branch 'playwright-ftr-e2e' of https://github.com/shahzad31/kib…
shahzad31 Apr 26, 2021
57283c0
Merge branch 'master' into playwright-ftr-e2e
shahzad31 Apr 26, 2021
20ce6dc
Merge branch 'master' into playwright-ftr-e2e
shahzad31 Jul 7, 2021
38e5ad5
wip
shahzad31 Jul 7, 2021
c032b11
revert
shahzad31 Jul 7, 2021
92f3b41
Delete run_elasticsearch.js
shahzad31 Jul 7, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
244 changes: 175 additions & 69 deletions .ci/end2end.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,12 @@ pipeline {
BASE_DIR = 'src/github.com/elastic/kibana'
HOME = "${env.WORKSPACE}"
E2E_DIR = 'x-pack/plugins/apm/e2e'
UPTIME_E2E_DIR = 'x-pack/plugins/uptime/e2e'
PIPELINE_LOG_LEVEL = 'INFO'
KBN_OPTIMIZER_THEMES = 'v7light'
GITHUB_CHECK_APM_UI = 'end2end-for-apm-ui'
GITHUB_CHECK_UPTIME_UI = 'end2end-for-uptime-ui'
v1v marked this conversation as resolved.
Show resolved Hide resolved
GCS_UPLOAD_PREFIX = 'prefix' // forced to set the variable even though it's not required in this pipeline (https://github.com/elastic/kibana/pull/52449)
}
options {
timeout(time: 1, unit: 'HOURS')
Expand All @@ -37,93 +41,195 @@ pipeline {
deleteDir()
gitCheckout(basedir: "${BASE_DIR}", githubNotifyFirstTimeContributor: false,
shallow: false, reference: "/var/lib/jenkins/.git-references/kibana.git")

// Filter when to run based on the below reasons:
// - On a PRs when:
// - There are changes related to the APM UI project
// - only when the owners of those changes are members of the given GitHub teams
// - On merges to branches when:
// - There are changes related to the APM UI project
// - FORCE parameter is set to true.
script {
def apm_updated = false
dir("${BASE_DIR}"){
apm_updated = isGitRegionMatch(patterns: [ "^x-pack/plugins/apm/.*" ])
}
if (isPR()) {
def isMember = isMemberOf(user: env.CHANGE_AUTHOR, team: ['apm-ui', 'uptime'])
setEnvVar('RUN_APM_E2E', params.FORCE || (apm_updated && isMember))
} else {
setEnvVar('RUN_APM_E2E', params.FORCE || apm_updated)
}
}
setEnvVar('RUN_APM_E2E', (params.FORCE || analyseBuildReasonForApmUI()))
setEnvVar('RUN_UPTIME_E2E', (params.FORCE || analyseBuildReasonForUptimeUI()))
}
}
stage('Prepare Kibana') {
options { skipDefaultCheckout() }
when { expression { return env.RUN_APM_E2E != "false" } }
environment {
JENKINS_NODE_COOKIE = 'dontKillMe'
}
steps {
notifyStatus('Preparing kibana', 'PENDING')
dir("${BASE_DIR}"){
sh "${E2E_DIR}/ci/prepare-kibana.sh"
}
}
post {
unsuccessful {
notifyStatus('Kibana warm up failed', 'FAILURE')
stage('e2e') {
when {
anyOf {
expression { return env.RUN_APM_E2E != "false" }
expression { return env.RUN_UPTIME_E2E != "false" }
}
}
}
stage('Smoke Tests'){
options { skipDefaultCheckout() }
when { expression { return env.RUN_APM_E2E != "false" } }
steps{
notifyTestStatus('Running smoke tests', 'PENDING')
dir("${BASE_DIR}"){
sh "${E2E_DIR}/ci/run-e2e.sh"
}
}
post {
always {
dir("${BASE_DIR}/${E2E_DIR}"){
archiveArtifacts(allowEmptyArchive: false, artifacts: 'cypress/screenshots/**,cypress/videos/**,cypress/test-results/*e2e-tests.xml')
junit(allowEmptyResults: true, testResults: 'cypress/test-results/*e2e-tests.xml')
dir('tmp/apm-integration-testing'){
sh 'docker-compose logs > apm-its-docker.log || true'
sh 'docker-compose down -v || true'
archiveArtifacts(allowEmptyArchive: true, artifacts: 'apm-its-docker.log')
parallel {
stage('APM-UI') {
// This stage reuses the top-level agent
stages {
stage('Prepare build context') {
options { skipDefaultCheckout() }
steps {
pipelineManager([ cancelPreviousRunningBuilds: [ when: 'PR' ] ])
}
}
stage('Prepare Kibana') {
options { skipDefaultCheckout() }
when { expression { return env.RUN_APM_E2E != "false" } }
environment {
JENKINS_NODE_COOKIE = 'dontKillMe'
}
steps {
notifyStatus(env.GITHUB_CHECK_APM_UI, 'Preparing kibana', 'PENDING')
dir("${BASE_DIR}"){
sh "${E2E_DIR}/ci/prepare-kibana.sh"
}
}
post {
unsuccessful {
notifyStatus(env.GITHUB_CHECK_APM_UI, 'Kibana warm up failed', 'FAILURE')
}
}
}
stage('Smoke Tests'){
options { skipDefaultCheckout() }
when { expression { return env.RUN_APM_E2E != "false" } }
steps{
notifyTestStatus(env.GITHUB_CHECK_APM_UI, 'Running smoke tests', 'PENDING')
dir("${BASE_DIR}"){
sh "${E2E_DIR}/ci/run-e2e.sh"
}
}
post {
always {
dir("${BASE_DIR}/${E2E_DIR}"){
archiveArtifacts(allowEmptyArchive: false, artifacts: 'cypress/screenshots/**,cypress/videos/**,cypress/test-results/*e2e-tests.xml')
junit(allowEmptyResults: true, testResults: 'cypress/test-results/*e2e-tests.xml')
dir('tmp/apm-integration-testing'){
sh 'docker-compose logs > apm-its-docker.log || true'
sh 'docker-compose down -v || true'
archiveArtifacts(allowEmptyArchive: true, artifacts: 'apm-its-docker.log')
}
archiveArtifacts(allowEmptyArchive: true, artifacts: 'tmp/*.log')
}
}
unsuccessful {
notifyTestStatus(env.GITHUB_CHECK_APM_UI, 'Test failures', 'FAILURE')
}
success {
notifyTestStatus(env.GITHUB_CHECK_APM_UI, 'Tests passed', 'SUCCESS')
}
}
}
}
post {
always {
dir("${BASE_DIR}"){
archiveArtifacts(allowEmptyArchive: true, artifacts: "${E2E_DIR}/kibana.log")
}
}
archiveArtifacts(allowEmptyArchive: true, artifacts: 'tmp/*.log')
}
}
unsuccessful {
notifyTestStatus('Test failures', 'FAILURE')
}
success {
notifyTestStatus('Tests passed', 'SUCCESS')
stage('UPTIME-UI') {
// This stage requires a new agent
agent { label 'linux && immutable' }
options { skipDefaultCheckout() }
when { expression { return env.RUN_UPTIME_E2E != "false" } }
stages {
stage('Prepare build context') {
options { skipDefaultCheckout() }
steps {
pipelineManager([ cancelPreviousRunningBuilds: [ when: 'PR' ] ])
deleteDir()
gitCheckout(basedir: "${BASE_DIR}", githubNotifyFirstTimeContributor: false,
shallow: false, reference: "/var/lib/jenkins/.git-references/kibana.git")
}
}
stage('Prepare Kibana') {
options { skipDefaultCheckout() }
environment {
JENKINS_NODE_COOKIE = 'dontKillMe'
}
steps {
notifyStatus(env.GITHUB_CHECK_UPTIME_UI, 'Preparing kibana', 'PENDING')
dir("${BASE_DIR}"){
sh "${UPTIME_E2E_DIR}/ci/prepare_kibana.sh"
}
}
post {
unsuccessful {
notifyStatus(env.GITHUB_CHECK_UPTIME_UI, 'Kibana warm up failed', 'FAILURE')
}
}
}
stage('Smoke Tests'){
options { skipDefaultCheckout() }
steps{
notifyTestStatus(env.GITHUB_CHECK_UPTIME_UI, 'Running smoke tests', 'PENDING')
dir("${BASE_DIR}"){
sh "${UPTIME_E2E_DIR}/ci/run_e2e.sh"
}
}
post {
always {
dir("${UPTIME_E2E_DIR}"){
sh 'docker-compose logs > uptime-e2e-docker.log || true'
archiveArtifacts(allowEmptyArchive: true, artifacts: 'uptime-e2e-docker.log')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Once L159 produces the junit files, then you can add something like

Suggested change
archiveArtifacts(allowEmptyArchive: true, artifacts: 'uptime-e2e-docker.log')
archiveArtifacts(allowEmptyArchive: true, artifacts: 'uptime-e2e-docker.log')
junit(allowEmptyResults: true, testResults: '<RELATIVE_PATH_FROM_UPTIME_E2E_DIR>/<FILE_NAME>.xml')

But please replace '<RELATIVE_PATH_FROM_UPTIME_E2E_DIR>/<FILE_NAME>.xml'

}
echo 'TBD: archive test output when the smoke tests generate junit output'
}
unsuccessful {
notifyTestStatus(env.GITHUB_CHECK_UPTIME_UI, 'Test failures', 'FAILURE')
}
success {
notifyTestStatus(env.GITHUB_CHECK_UPTIME_UI, 'Tests passed', 'SUCCESS')
}
}
}
}
post {
always {
dir("${BASE_DIR}"){
archiveArtifacts(allowEmptyArchive: true, artifacts: "${UPTIME_E2E_DIR}/kibana.log")
}
}
}
}
}
}
}
post {
always {
dir("${BASE_DIR}"){
archiveArtifacts(allowEmptyArchive: true, artifacts: "${E2E_DIR}/kibana.log")
}
}
cleanup {
notifyBuildResult(prComment: false, analyzeFlakey: false, shouldNotify: false)
}
}
}

def notifyStatus(String description, String status) {
withGithubStatus.notify('end2end-for-apm-ui', description, status, getBlueoceanTabURL('pipeline'))
def notifyStatus(String check, String description, String status) {
withGithubStatus.notify(check, description, status, getBlueoceanTabURL('pipeline'))
}

def notifyTestStatus(String description, String status) {
withGithubStatus.notify('end2end-for-apm-ui', description, status, getBlueoceanTabURL('tests'))
def notifyTestStatus(String check, String description, String status) {
withGithubStatus.notify(check, description, status, getBlueoceanTabURL('tests'))
}

def analyseBuildReasonForApmUI() {
return shouldTriggerABuild(patterns: [ "^x-pack/plugins/apm/.*" ], team: ['apm-ui', 'uptime'])
}

def analyseBuildReasonForUptimeUI() {
return shouldTriggerABuild(patterns: [ "^x-pack/plugins/uptime/.*" ], team: ['uptime'])
}

/**
* Filter when to run based on the below reasons:
* - On a PRs when:
* - There are changes related to the given subfolder
* - only when the owners of those changes are members of the given GitHub teams
* - On merges to branches when:
* - There are changes related to the given subfolder
* - FORCE parameter is set to true.
*/
def shouldTriggerABuild(Map args = [:]) {
def patterns = args.patterns
def team = args.team
def updated = false
dir("${BASE_DIR}"){
updated = isGitRegionMatch(patterns: patterns)
}
if (isPR()) {
def isMember = isMemberOf(user: env.CHANGE_AUTHOR, team: team)
return (params.FORCE || (updated && isMember))
} else {
return (params.FORCE || apm_updated)
}
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,7 @@
"@elastic/eslint-plugin-eui": "0.0.2",
"@elastic/github-checks-reporter": "0.0.20b3",
"@elastic/makelogs": "^6.0.0",
"@elastic/synthetics": "^1.0.0-beta.8",
"@istanbuljs/schema": "^0.1.2",
"@jest/reporters": "^26.6.2",
"@kbn/babel-code-parser": "link:bazel-bin/packages/kbn-babel-code-parser",
Expand Down
5 changes: 5 additions & 0 deletions src/dev/typescript/projects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ export const PROJECTS = [
disableTypeCheck: true,
}),

new Project(resolve(REPO_ROOT, 'x-pack/plugins/uptime/e2e/tsconfig.json'), {
name: 'uptime/synthetics-e2e-tests',
disableTypeCheck: true,
}),

// NOTE: using glob.sync rather than glob-all or globby
// because it takes less than 10 ms, while the other modules
// both took closer to 1000ms.
Expand Down
2 changes: 1 addition & 1 deletion x-pack/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@
"engines": {
"yarn": "^1.21.1"
}
}
}
14 changes: 14 additions & 0 deletions x-pack/plugins/uptime/e2e/ci/prepare_kibana.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env bash
set -e

UPTIME_DIR=x-pack/plugins/uptime
echo "1/2 Install dependencies..."
# shellcheck disable=SC1091
source src/dev/ci_setup/setup_env.sh true
yarn kbn bootstrap

echo "2/2 Start Kibana..."
## Might help to avoid FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
export NODE_OPTIONS="--max-old-space-size=4096"
cd $UPTIME_DIR
nohup node ./scripts/start_e2e_server.js > e2e/kibana.log 2>&1 &
38 changes: 38 additions & 0 deletions x-pack/plugins/uptime/e2e/ci/run_e2e.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/usr/bin/env bash
##
## This is a wrapper to configure the environment with the right tools in the CI
## and run the e2e steps.
##

# shellcheck disable=SC1091
source src/dev/ci_setup/setup_env.sh true
set -e

# variables
KIBANA_PORT=5620

# formatting
bold=$(tput bold)
normal=$(tput sgr0)

# paths
E2E_DIR="${0%/*}/../.."

cd "${E2E_DIR}"

#
# Ask user to start Kibana
##################################################
echo "" # newline
echo "${bold}To start Kibana please run the following command:${normal}
node ./scripts/start_e2e_server.js"

echo "✅ Setup completed successfully. Running tests..."
node ./scripts/start_e2e_runner.js
e2e_status=$?

# Report the e2e status at the very end
if [ $e2e_status -ne 0 ]; then
echo "⚠️ Running tests failed."
exit 1
fi
Loading