Skip to content

Commit 7cdac86

Browse files
Merge branch 'master' into chore/worker_with_buildchanges
2 parents 380d579 + 931cf22 commit 7cdac86

File tree

574 files changed

+15355
-6871
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

574 files changed

+15355
-6871
lines changed

.ci/end2end.groovy

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
#!/usr/bin/env groovy
2+
3+
library identifier: 'apm@current',
4+
retriever: modernSCM(
5+
[$class: 'GitSCMSource',
6+
credentialsId: 'f94e9298-83ae-417e-ba91-85c279771570',
7+
id: '37cf2c00-2cc7-482e-8c62-7bbffef475e2',
8+
remote: 'git@github.com:elastic/apm-pipeline-library.git'])
9+
10+
pipeline {
11+
agent { label 'linux && immutable' }
12+
environment {
13+
BASE_DIR = 'src/github.com/elastic/kibana'
14+
HOME = "${env.WORKSPACE}"
15+
APM_ITS = 'apm-integration-testing'
16+
CYPRESS_DIR = 'x-pack/legacy/plugins/apm/cypress'
17+
PIPELINE_LOG_LEVEL = 'DEBUG'
18+
}
19+
options {
20+
timeout(time: 1, unit: 'HOURS')
21+
buildDiscarder(logRotator(numToKeepStr: '40', artifactNumToKeepStr: '20', daysToKeepStr: '30'))
22+
timestamps()
23+
ansiColor('xterm')
24+
disableResume()
25+
durabilityHint('PERFORMANCE_OPTIMIZED')
26+
}
27+
triggers {
28+
issueCommentTrigger('(?i).*jenkins\\W+run\\W+(?:the\\W+)?e2e(?:\\W+please)?.*')
29+
}
30+
parameters {
31+
booleanParam(name: 'FORCE', defaultValue: false, description: 'Whether to force the run.')
32+
}
33+
stages {
34+
stage('Checkout') {
35+
options { skipDefaultCheckout() }
36+
steps {
37+
deleteDir()
38+
gitCheckout(basedir: "${BASE_DIR}", githubNotifyFirstTimeContributor: false,
39+
shallow: false, reference: "/var/lib/jenkins/.git-references/kibana.git")
40+
script {
41+
dir("${BASE_DIR}"){
42+
def regexps =[ "^x-pack/legacy/plugins/apm/.*" ]
43+
env.APM_UPDATED = isGitRegionMatch(patterns: regexps)
44+
}
45+
}
46+
dir("${APM_ITS}"){
47+
git changelog: false,
48+
credentialsId: 'f6c7695a-671e-4f4f-a331-acdce44ff9ba',
49+
poll: false,
50+
url: "git@github.com:elastic/${APM_ITS}.git"
51+
}
52+
}
53+
}
54+
stage('Start services') {
55+
options { skipDefaultCheckout() }
56+
when {
57+
anyOf {
58+
expression { return params.FORCE }
59+
expression { return env.APM_UPDATED != "false" }
60+
}
61+
}
62+
steps {
63+
dir("${APM_ITS}"){
64+
sh './scripts/compose.py start master --no-kibana --no-xpack-secure'
65+
}
66+
}
67+
}
68+
stage('Prepare Kibana') {
69+
options { skipDefaultCheckout() }
70+
when {
71+
anyOf {
72+
expression { return params.FORCE }
73+
expression { return env.APM_UPDATED != "false" }
74+
}
75+
}
76+
environment {
77+
JENKINS_NODE_COOKIE = 'dontKillMe'
78+
}
79+
steps {
80+
dir("${BASE_DIR}"){
81+
sh script: "${CYPRESS_DIR}/ci/prepare-kibana.sh"
82+
}
83+
}
84+
}
85+
stage('Smoke Tests'){
86+
options { skipDefaultCheckout() }
87+
when {
88+
anyOf {
89+
expression { return params.FORCE }
90+
expression { return env.APM_UPDATED != "false" }
91+
}
92+
}
93+
steps{
94+
dir("${BASE_DIR}"){
95+
sh '''
96+
jobs -l
97+
docker build --tag cypress ${CYPRESS_DIR}/ci
98+
docker run --rm -t --user "$(id -u):$(id -g)" \
99+
-v `pwd`:/app --network="host" \
100+
--name cypress cypress'''
101+
}
102+
}
103+
post {
104+
always {
105+
dir("${BASE_DIR}"){
106+
archiveArtifacts(allowEmptyArchive: false, artifacts: "${CYPRESS_DIR}/screenshots/**,${CYPRESS_DIR}/videos/**,${CYPRESS_DIR}/*e2e-tests.xml")
107+
junit(allowEmptyResults: true, testResults: "${CYPRESS_DIR}/*e2e-tests.xml")
108+
}
109+
dir("${APM_ITS}"){
110+
sh 'docker-compose logs > apm-its.log || true'
111+
sh 'docker-compose down -v || true'
112+
archiveArtifacts(allowEmptyArchive: false, artifacts: 'apm-its.log')
113+
}
114+
}
115+
}
116+
}
117+
}
118+
post {
119+
always {
120+
dir("${BASE_DIR}"){
121+
archiveArtifacts(allowEmptyArchive: true, artifacts: "${CYPRESS_DIR}/ingest-data.log,kibana.log")
122+
}
123+
}
124+
}
125+
}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ disabledPlugins
2929
webpackstats.json
3030
/config/*
3131
!/config/kibana.yml
32+
!/config/apm.js
3233
coverage
3334
selenium
3435
.babel_register_cache.json

CONTRIBUTING.md

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ A high level overview of our contributing guidelines.
2424
- [Internationalization](#internationalization)
2525
- [Testing and Building](#testing-and-building)
2626
- [Debugging server code](#debugging-server-code)
27+
- [Instrumenting with Elastic APM](#instrumenting-with-elastic-apm)
2728
- [Debugging Unit Tests](#debugging-unit-tests)
2829
- [Unit Testing Plugins](#unit-testing-plugins)
2930
- [Cross-browser compatibility](#cross-browser-compatibility)
@@ -374,6 +375,29 @@ macOS users on a machine with a discrete graphics card may see significant speed
374375
### Debugging Server Code
375376
`yarn debug` will start the server with Node's inspect flag. Kibana's development mode will start three processes on ports `9229`, `9230`, and `9231`. Chrome's developer tools need to be configured to connect to all three connections. Add `localhost:<port>` for each Kibana process in Chrome's developer tools connection tab.
376377

378+
### Instrumenting with Elastic APM
379+
Kibana ships with the [Elastic APM Node.js Agent](https://github.com/elastic/apm-agent-nodejs) built-in for debugging purposes.
380+
381+
Its default configuration is meant to be used by core Kibana developers only, but it can easily be re-configured to your needs.
382+
In its default configuration it's disabled and will, once enabled, send APM data to a centrally managed Elasticsearch cluster accessible only to Elastic employees.
383+
384+
To change the location where data is sent, use the [`serverUrl`](https://www.elastic.co/guide/en/apm/agent/nodejs/current/configuration.html#server-url) APM config option.
385+
To activate the APM agent, use the [`active`](https://www.elastic.co/guide/en/apm/agent/nodejs/current/configuration.html#active) APM config option.
386+
387+
All config options can be set either via environment variables, or by creating an appropriate config file under `config/apm.dev.js`.
388+
For more information about configuring the APM agent, please refer to [the documentation](https://www.elastic.co/guide/en/apm/agent/nodejs/current/configuring-the-agent.html).
389+
390+
Example `config/apm.dev.js` file:
391+
392+
```js
393+
module.exports = {
394+
active: true,
395+
};
396+
```
397+
398+
Once the agent is active, it will trace all incoming HTTP requests to Kibana, monitor for errors, and collect process-level metrics.
399+
The collected data will be sent to the APM Server and is viewable in the APM UI in Kibana.
400+
377401
### Unit testing frameworks
378402
Kibana is migrating unit testing from Mocha to Jest. Legacy unit tests still
379403
exist in Mocha but all new unit tests should be written in Jest. Mocha tests
@@ -389,7 +413,7 @@ The following table outlines possible test file locations and how to invoke them
389413
| Jest | `src/**/*.test.js`<br>`src/**/*.test.ts` | `node scripts/jest -t regexp [test path]` |
390414
| Jest (integration) | `**/integration_tests/**/*.test.js` | `node scripts/jest_integration -t regexp [test path]` |
391415
| Mocha | `src/**/__tests__/**/*.js`<br>`!src/**/public/__tests__/*.js`<br>`packages/kbn-datemath/test/**/*.js`<br>`packages/kbn-dev-utils/src/**/__tests__/**/*.js`<br>`tasks/**/__tests__/**/*.js` | `node scripts/mocha --grep=regexp [test path]` |
392-
| Functional | `test/*integration/**/config.js`<br>`test/*functional/**/config.js` | `node scripts/functional_tests_server --config test/[directory]/config.js`<br>`node scripts/functional_test_runner --config test/[directory]/config.js --grep=regexp` |
416+
| Functional | `test/*integration/**/config.js`<br>`test/*functional/**/config.js`<br>`test/accessibility/config.js` | `node scripts/functional_tests_server --config test/[directory]/config.js`<br>`node scripts/functional_test_runner --config test/[directory]/config.js --grep=regexp` |
393417
| Karma | `src/**/public/__tests__/*.js` | `npm run test:dev` |
394418

395419
For X-Pack tests located in `x-pack/` see [X-Pack Testing](x-pack/README.md#testing)

Jenkinsfile

Lines changed: 39 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -7,43 +7,45 @@ stage("Kibana Pipeline") { // This stage is just here to help the BlueOcean UI a
77
timeout(time: 120, unit: 'MINUTES') {
88
timestamps {
99
ansiColor('xterm') {
10-
catchError {
11-
parallel([
12-
'kibana-intake-agent': kibanaPipeline.legacyJobRunner('kibana-intake'),
13-
'x-pack-intake-agent': kibanaPipeline.legacyJobRunner('x-pack-intake'),
14-
'kibana-oss-agent': kibanaPipeline.withWorkers('kibana-oss-tests', { kibanaPipeline.buildOss() }, [
15-
'oss-firefoxSmoke': kibanaPipeline.getPostBuildWorker('firefoxSmoke', { runbld('./test/scripts/jenkins_firefox_smoke.sh', 'Execute kibana-firefoxSmoke') }),
16-
'oss-ciGroup1': kibanaPipeline.getOssCiGroupWorker(1),
17-
'oss-ciGroup2': kibanaPipeline.getOssCiGroupWorker(2),
18-
'oss-ciGroup3': kibanaPipeline.getOssCiGroupWorker(3),
19-
'oss-ciGroup4': kibanaPipeline.getOssCiGroupWorker(4),
20-
'oss-ciGroup5': kibanaPipeline.getOssCiGroupWorker(5),
21-
'oss-ciGroup6': kibanaPipeline.getOssCiGroupWorker(6),
22-
'oss-ciGroup7': kibanaPipeline.getOssCiGroupWorker(7),
23-
'oss-ciGroup8': kibanaPipeline.getOssCiGroupWorker(8),
24-
'oss-ciGroup9': kibanaPipeline.getOssCiGroupWorker(9),
25-
'oss-ciGroup10': kibanaPipeline.getOssCiGroupWorker(10),
26-
'oss-ciGroup11': kibanaPipeline.getOssCiGroupWorker(11),
27-
'oss-ciGroup12': kibanaPipeline.getOssCiGroupWorker(12),
28-
'oss-accessibility': kibanaPipeline.getPostBuildWorker('accessibility', { runbld('./test/scripts/jenkins_accessibility.sh', 'Execute kibana-accessibility') }),
29-
// 'oss-visualRegression': kibanaPipeline.getPostBuildWorker('visualRegression', { runbld('./test/scripts/jenkins_visual_regression.sh', 'Execute kibana-visualRegression') }),
30-
]),
31-
'kibana-xpack-agent': kibanaPipeline.withWorkers('kibana-xpack-tests', { kibanaPipeline.buildXpack() }, [
32-
'xpack-firefoxSmoke': kibanaPipeline.getPostBuildWorker('xpack-firefoxSmoke', { runbld('./test/scripts/jenkins_xpack_firefox_smoke.sh', 'Execute xpack-firefoxSmoke') }),
33-
'xpack-ciGroup1': kibanaPipeline.getXpackCiGroupWorker(1),
34-
'xpack-ciGroup2': kibanaPipeline.getXpackCiGroupWorker(2),
35-
'xpack-ciGroup3': kibanaPipeline.getXpackCiGroupWorker(3),
36-
'xpack-ciGroup4': kibanaPipeline.getXpackCiGroupWorker(4),
37-
'xpack-ciGroup5': kibanaPipeline.getXpackCiGroupWorker(5),
38-
'xpack-ciGroup6': kibanaPipeline.getXpackCiGroupWorker(6),
39-
'xpack-ciGroup7': kibanaPipeline.getXpackCiGroupWorker(7),
40-
'xpack-ciGroup8': kibanaPipeline.getXpackCiGroupWorker(8),
41-
'xpack-ciGroup9': kibanaPipeline.getXpackCiGroupWorker(9),
42-
'xpack-ciGroup10': kibanaPipeline.getXpackCiGroupWorker(10),
43-
'xpack-accessibility': kibanaPipeline.getPostBuildWorker('xpack-accessibility', { runbld('./test/scripts/jenkins_xpack_accessibility.sh', 'Execute xpack-accessibility') }),
44-
// 'xpack-visualRegression': kibanaPipeline.getPostBuildWorker('xpack-visualRegression', { runbld('./test/scripts/jenkins_xpack_visual_regression.sh', 'Execute xpack-visualRegression') }),
45-
]),
46-
])
10+
githubPr.withDefaultPrComments {
11+
catchError {
12+
parallel([
13+
'kibana-intake-agent': kibanaPipeline.legacyJobRunner('kibana-intake'),
14+
'x-pack-intake-agent': kibanaPipeline.legacyJobRunner('x-pack-intake'),
15+
'kibana-oss-agent': kibanaPipeline.withWorkers('kibana-oss-tests', { kibanaPipeline.buildOss() }, [
16+
'oss-firefoxSmoke': kibanaPipeline.getPostBuildWorker('firefoxSmoke', { runbld('./test/scripts/jenkins_firefox_smoke.sh', 'Execute kibana-firefoxSmoke') }),
17+
'oss-ciGroup1': kibanaPipeline.getOssCiGroupWorker(1),
18+
'oss-ciGroup2': kibanaPipeline.getOssCiGroupWorker(2),
19+
'oss-ciGroup3': kibanaPipeline.getOssCiGroupWorker(3),
20+
'oss-ciGroup4': kibanaPipeline.getOssCiGroupWorker(4),
21+
'oss-ciGroup5': kibanaPipeline.getOssCiGroupWorker(5),
22+
'oss-ciGroup6': kibanaPipeline.getOssCiGroupWorker(6),
23+
'oss-ciGroup7': kibanaPipeline.getOssCiGroupWorker(7),
24+
'oss-ciGroup8': kibanaPipeline.getOssCiGroupWorker(8),
25+
'oss-ciGroup9': kibanaPipeline.getOssCiGroupWorker(9),
26+
'oss-ciGroup10': kibanaPipeline.getOssCiGroupWorker(10),
27+
'oss-ciGroup11': kibanaPipeline.getOssCiGroupWorker(11),
28+
'oss-ciGroup12': kibanaPipeline.getOssCiGroupWorker(12),
29+
'oss-accessibility': kibanaPipeline.getPostBuildWorker('accessibility', { runbld('./test/scripts/jenkins_accessibility.sh', 'Execute kibana-accessibility') }),
30+
// 'oss-visualRegression': kibanaPipeline.getPostBuildWorker('visualRegression', { runbld('./test/scripts/jenkins_visual_regression.sh', 'Execute kibana-visualRegression') }),
31+
]),
32+
'kibana-xpack-agent': kibanaPipeline.withWorkers('kibana-xpack-tests', { kibanaPipeline.buildXpack() }, [
33+
'xpack-firefoxSmoke': kibanaPipeline.getPostBuildWorker('xpack-firefoxSmoke', { runbld('./test/scripts/jenkins_xpack_firefox_smoke.sh', 'Execute xpack-firefoxSmoke') }),
34+
'xpack-ciGroup1': kibanaPipeline.getXpackCiGroupWorker(1),
35+
'xpack-ciGroup2': kibanaPipeline.getXpackCiGroupWorker(2),
36+
'xpack-ciGroup3': kibanaPipeline.getXpackCiGroupWorker(3),
37+
'xpack-ciGroup4': kibanaPipeline.getXpackCiGroupWorker(4),
38+
'xpack-ciGroup5': kibanaPipeline.getXpackCiGroupWorker(5),
39+
'xpack-ciGroup6': kibanaPipeline.getXpackCiGroupWorker(6),
40+
'xpack-ciGroup7': kibanaPipeline.getXpackCiGroupWorker(7),
41+
'xpack-ciGroup8': kibanaPipeline.getXpackCiGroupWorker(8),
42+
'xpack-ciGroup9': kibanaPipeline.getXpackCiGroupWorker(9),
43+
'xpack-ciGroup10': kibanaPipeline.getXpackCiGroupWorker(10),
44+
'xpack-accessibility': kibanaPipeline.getPostBuildWorker('xpack-accessibility', { runbld('./test/scripts/jenkins_xpack_accessibility.sh', 'Execute xpack-accessibility') }),
45+
// 'xpack-visualRegression': kibanaPipeline.getPostBuildWorker('xpack-visualRegression', { runbld('./test/scripts/jenkins_xpack_visual_regression.sh', 'Execute xpack-visualRegression') }),
46+
]),
47+
])
48+
}
4749
}
4850
kibanaPipeline.sendMail()
4951
}

config/apm.js

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
/*
2+
* Licensed to Elasticsearch B.V. under one or more contributor
3+
* license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright
5+
* ownership. Elasticsearch B.V. licenses this file to you under
6+
* the Apache License, Version 2.0 (the "License"); you may
7+
* not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
/**
21+
* DO NOT EDIT THIS FILE!
22+
*
23+
* This file contains the configuration for the Elastic APM instrumentaion of
24+
* Kibana itself and is only intented to be used during development of Kibana.
25+
*
26+
* Instrumentation is turned off by default. Once activated it will send APM
27+
* data to an Elasticsearch cluster accessible by Elastic employees.
28+
*
29+
* To modify the configuration, either use environment variables, or create a
30+
* file named `config/apm.dev.js`, which exports a config object as described
31+
* in the docs.
32+
*
33+
* For an overview over the available configuration files, see:
34+
* https://www.elastic.co/guide/en/apm/agent/nodejs/current/configuration.html
35+
*
36+
* For general information about Elastic APM, see:
37+
* https://www.elastic.co/guide/en/apm/get-started/current/index.html
38+
*/
39+
40+
const { readFileSync } = require('fs');
41+
const { join } = require('path');
42+
const { execSync } = require('child_process');
43+
const merge = require('lodash.merge');
44+
45+
module.exports = merge({
46+
active: false,
47+
serverUrl: 'https://f1542b814f674090afd914960583265f.apm.us-central1.gcp.cloud.es.io:443',
48+
// The secretToken below is intended to be hardcoded in this file even though
49+
// it makes it public. This is not a security/privacy issue. Normally we'd
50+
// instead disable the need for a secretToken in the APM Server config where
51+
// the data is transmitted to, but due to how it's being hosted, it's easier,
52+
// for now, to simply leave it in.
53+
secretToken: 'R0Gjg46pE9K9wGestd',
54+
globalLabels: {},
55+
centralConfig: false,
56+
logUncaughtExceptions: true
57+
}, devConfig());
58+
59+
const rev = gitRev();
60+
if (rev !== null) module.exports.globalLabels.git_rev = rev;
61+
62+
try {
63+
const filename = join(__dirname, '..', 'data', 'uuid');
64+
module.exports.globalLabels.kibana_uuid = readFileSync(filename, 'utf-8');
65+
} catch (e) {} // eslint-disable-line no-empty
66+
67+
function gitRev() {
68+
try {
69+
return execSync('git rev-parse --short HEAD', { encoding: 'utf-8' }).trim();
70+
} catch (e) {
71+
return null;
72+
}
73+
}
74+
75+
function devConfig() {
76+
try {
77+
return require('./apm.dev'); // eslint-disable-line import/no-unresolved
78+
} catch (e) {
79+
return {};
80+
}
81+
}

docs/developer/core/development-functional-tests.asciidoc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ When run without any arguments the `FunctionalTestRunner` automatically loads th
9898
* `--config test/functional/config.js` starts Elasticsearch and Kibana servers with the WebDriver tests configured to run in Chrome.
9999
* `--config test/functional/config.firefox.js` starts Elasticsearch and Kibana servers with the WebDriver tests configured to run in Firefox.
100100
* `--config test/api_integration/config.js` starts Elasticsearch and Kibana servers with the api integration tests configuration.
101+
* `--config test/accessibility/config.ts` starts Elasticsearch and Kibana servers with the WebDriver tests configured to run an accessibility audit using https://www.deque.com/axe/[axe].
101102

102103
There are also command line flags for `--bail` and `--grep`, which behave just like their mocha counterparts. For instance, use `--grep=foo` to run only tests that match a regular expression.
103104

@@ -362,7 +363,7 @@ Full list of services that are used in functional tests can be found here: {blob
362363
** Source: {blob}test/functional/services/remote/remote.ts[test/functional/services/remote/remote.ts]
363364
** Instance of https://seleniumhq.github.io/selenium/docs/api/javascript/module/selenium-webdriver/index_exports_WebDriver.html[WebDriver] class
364365
** Responsible for all communication with the browser
365-
** To perform browser actions, use `remote` service
366+
** To perform browser actions, use `remote` service
366367
** For searching and manipulating with DOM elements, use `testSubjects` and `find` services
367368
** See the https://seleniumhq.github.io/selenium/docs/api/javascript/[selenium-webdriver docs] for the full API.
368369

0 commit comments

Comments
 (0)