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 15 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
181 changes: 116 additions & 65 deletions .ci/end2end.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -37,83 +37,90 @@ 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)
}
}
}
}
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')
}
analyseBuildReasonForApmUI()
analyseBuildReasonForUptimeUI()
}
}
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"
stage('e2e') {
when {
anyOf {
expression { return env.RUN_APM_E2E != "false" }
expression { return env.RUN_UPTIME_E2E != "false" }
}
}
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 {
// One or more stages need to be included within the parallel block.
stage('APM-UI') {
stages {
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('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')
}
archiveArtifacts(allowEmptyArchive: true, artifacts: 'tmp/*.log')
}
}
unsuccessful {
notifyTestStatus('Test failures', 'FAILURE')
}
success {
notifyTestStatus('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') {
agent { label 'linux && immutable' }
options { skipDefaultCheckout() }
when { expression { return env.RUN_UPTIME_E2E != "false" } }
steps {
echo 'TBC'
}
Copy link
Member

Choose a reason for hiding this comment

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

This is the new section after restructuring the CI pipeline to support two parallel stages, one for the existing e2e for the APM-UI and a new stage (this one) for the Uptime e2e.

}
}
}
}
post {
always {
dir("${BASE_DIR}"){
archiveArtifacts(allowEmptyArchive: true, artifacts: "${E2E_DIR}/kibana.log")
}
}
cleanup {
notifyBuildResult(prComment: false, analyzeFlakey: false, shouldNotify: false)
}
Expand All @@ -127,3 +134,47 @@ def notifyStatus(String description, String status) {
def notifyTestStatus(String description, String status) {
withGithubStatus.notify('end2end-for-apm-ui', description, status, getBlueoceanTabURL('tests'))
}

/**
* 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.
*/
def analyseBuildReasonForApmUI() {
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)
}
}

/**
* Filter when to run based on the below reasons:
* - On a PRs when:
* - There are changes related to the Uptime 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 Uptime UI project
* - FORCE parameter is set to true.
*/
def analyseBuildReasonForUptimeUI() {
def uptime_updated = false
dir("${BASE_DIR}"){
uptime_updated = isGitRegionMatch(patterns: [ "^x-pack/plugins/apm/.*" ])
}
if (isPR()) {
def isMember = isMemberOf(user: env.CHANGE_AUTHOR, team: ['uptime'])
setEnvVar('RUN_UPTIME_E2E', params.FORCE || (uptime_updated && isMember))
} else {
setEnvVar('RUN_UPTIME_E2E', params.FORCE || uptime_updated)
}
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,7 @@
"@elastic/github-checks-reporter": "0.0.20b3",
"@elastic/makelogs": "^6.0.0",
"@elastic/maki": "6.3.0",
"@elastic/synthetics": "0.0.1-alpha.9",
"@elastic/ui-ace": "0.2.3",
"@istanbuljs/schema": "^0.1.2",
"@jest/reporters": "^26.5.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ export const schema = Joi.object()
serverEnvVars: Joi.object(),
dataArchive: Joi.string(),
ssl: Joi.boolean().default(false),
skipEsCluster: Joi.boolean(),
})
.default(),

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,16 @@ import { setupUsers, DEFAULT_SUPERUSER_PASS } from './auth';

export async function runElasticsearch({ config, options }) {
const { log, esFrom } = options;

const ssl = config.get('esTestCluster.ssl');
const license = config.get('esTestCluster.license');
const esArgs = config.get('esTestCluster.serverArgs');
const esEnvVars = config.get('esTestCluster.serverEnvVars');
const isSecurityEnabled = esArgs.includes('xpack.security.enabled=true');

if (config.get('esTestCluster.skipEsCluster')) {
return;
}
const cluster = createLegacyEsTestCluster({
port: config.get('servers.elasticsearch.port'),
password: isSecurityEnabled
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 @@ -32,6 +32,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
50 changes: 50 additions & 0 deletions x-pack/plugins/uptime/e2e/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* 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 { FtrConfigProviderContext } from '@kbn/test/types/ftr';

import { CA_CERT_PATH } from '@kbn/dev-utils';
async function config({ readConfigFile }: FtrConfigProviderContext) {
const kibanaCommonTestsConfig = await readConfigFile(
require.resolve('../../../../test/common/config.js')
);
const xpackFunctionalTestsConfig = await readConfigFile(
require.resolve('../../../test/functional/config.js')
);

return {
...kibanaCommonTestsConfig.getAll(),

esTestCluster: {
skipEsCluster: true,
...xpackFunctionalTestsConfig.get('esTestCluster'),
serverArgs: [
...xpackFunctionalTestsConfig.get('esTestCluster.serverArgs'),
// define custom es server here
// API Keys is enabled at the top level
'xpack.security.enabled=true',
],
},

kbnTestServer: {
...xpackFunctionalTestsConfig.get('kbnTestServer'),
serverArgs: [
...xpackFunctionalTestsConfig.get('kbnTestServer.serverArgs'),
'--csp.strict=false',
// define custom kibana server args here
`--elasticsearch.ssl.certificateAuthorities=${CA_CERT_PATH}`,
`--elasticsearch.ignoreVersionMismatch=true`,
`--uiSettings.overrides.theme:darkMode=true`,
`--elasticsearch.username=kibana_system`,
`--elasticsearch.password=changeme`,
],
},
};
}

// eslint-disable-next-line import/no-default-export
export default config;
48 changes: 48 additions & 0 deletions x-pack/plugins/uptime/e2e/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# 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.

version: '3.7'
services:
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:${STACK_VERSION}
container_name: uptime-e2e-es
healthcheck:
test:
['CMD-SHELL', 'curl -s http://localhost:9220/_cluster/health | grep -vq ''"status":"red"''']
retries: 10
interval: 20s
environment:
- node.name=elasticsearch
- cluster.name=es-docker-cluster
- cluster.initial_master_nodes=elasticsearch
- bootstrap.memory_lock=true
- 'ES_JAVA_OPTS=-Xms512m -Xmx512m'
- ELASTICSEARCH_PORT=9220
- xpack.security.enabled=true
- ELASTIC_PASSWORD=changeme
ulimits:
memlock:
soft: -1
hard: -1
ports:
- '9220:9200'
- '9320:9300'
expose:
- '9220'
networks:
- elastic
heartbeat:
image: docker.elastic.co/beats/heartbeat:${STACK_VERSION}
container_name: uptime-e2e-heartbeat
depends_on:
- elasticsearch
volumes:
- ./heartbeat.docker.yml:/usr/share/heartbeat/heartbeat.yml:ro
networks:
- elastic

networks:
elastic:
driver: bridge
12 changes: 12 additions & 0 deletions x-pack/plugins/uptime/e2e/ftr_provider_context.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*
* 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 { GenericFtrProviderContext } from '@kbn/test/types/ftr';

import { services } from './services';

export type FtrProviderContext = GenericFtrProviderContext<typeof services, {}>;
Loading