Skip to content

Commit 2e55c08

Browse files
Merge branch '7.11' into backport/7.11/pr-88321
2 parents 27df27a + d24dcf6 commit 2e55c08

106 files changed

Lines changed: 1345 additions & 1166 deletions

File tree

Some content is hidden

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

.ci/Jenkinsfile_flaky

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,10 @@ kibanaLibrary.load()
55

66
def CI_GROUP_PARAM = params.CI_GROUP
77

8-
// Looks like 'oss:ciGroup:1', 'oss:firefoxSmoke', or 'all:serverMocha'
8+
// Looks like 'oss:ciGroup:1', 'oss:firefoxSmoke'
99
def JOB_PARTS = CI_GROUP_PARAM.split(':')
1010
def IS_XPACK = JOB_PARTS[0] == 'xpack'
1111
def JOB = JOB_PARTS[1]
12-
def NEED_BUILD = JOB != 'serverMocha'
1312
def CI_GROUP = JOB_PARTS.size() > 2 ? JOB_PARTS[2] : ''
1413
def EXECUTIONS = params.NUMBER_EXECUTIONS.toInteger()
1514
def AGENT_COUNT = getAgentCount(EXECUTIONS)
@@ -31,15 +30,13 @@ kibanaPipeline(timeoutMinutes: 180) {
3130
print "Agent ${agentNumberInside} - ${agentExecutions} executions"
3231

3332
workers.functional('flaky-test-runner', {
34-
if (NEED_BUILD) {
35-
if (!IS_XPACK) {
36-
kibanaPipeline.buildOss()
37-
if (CI_GROUP == '1') {
38-
runbld("./test/scripts/jenkins_build_kbn_sample_panel_action.sh", "Build kbn tp sample panel action for ciGroup1")
39-
}
40-
} else {
41-
kibanaPipeline.buildXpack()
33+
if (!IS_XPACK) {
34+
kibanaPipeline.buildOss()
35+
if (CI_GROUP == '1') {
36+
runbld("./test/scripts/jenkins_build_kbn_sample_panel_action.sh", "Build kbn tp sample panel action for ciGroup1")
4237
}
38+
} else {
39+
kibanaPipeline.buildXpack()
4340
}
4441
}, getWorkerMap(agentNumberInside, agentExecutions, worker, workerFailures))()
4542
}
@@ -60,17 +57,7 @@ kibanaPipeline(timeoutMinutes: 180) {
6057

6158
def getWorkerFromParams(isXpack, job, ciGroup) {
6259
if (!isXpack) {
63-
if (job == 'serverMocha') {
64-
return kibanaPipeline.functionalTestProcess('serverMocha', {
65-
kibanaPipeline.bash(
66-
"""
67-
source src/dev/ci_setup/setup_env.sh
68-
node scripts/mocha
69-
""",
70-
"run `node scripts/mocha`"
71-
)
72-
})
73-
} else if (job == 'accessibility') {
60+
if (job == 'accessibility') {
7461
return kibanaPipeline.functionalTestProcess('kibana-accessibility', './test/scripts/jenkins_accessibility.sh')
7562
} else if (job == 'firefoxSmoke') {
7663
return kibanaPipeline.functionalTestProcess('firefoxSmoke', './test/scripts/jenkins_firefox_smoke.sh')

.ci/teamcity/tests/mocha.sh

Lines changed: 0 additions & 8 deletions
This file was deleted.

.eslintrc.js

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,6 @@ const SAFER_LODASH_SET_DEFINITELYTYPED_HEADER = `
7171
*/
7272
`;
7373

74-
const allMochaRulesOff = {};
75-
Object.keys(require('eslint-plugin-mocha').rules).forEach((k) => {
76-
allMochaRulesOff['mocha/' + k] = 'off';
77-
});
78-
7974
module.exports = {
8075
root: true,
8176

@@ -546,7 +541,6 @@ module.exports = {
546541
'packages/kbn-eslint-import-resolver-kibana/**/*.js',
547542
'packages/kbn-eslint-plugin-eslint/**/*',
548543
'x-pack/gulpfile.js',
549-
'x-pack/dev-tools/mocha/setup_mocha.js',
550544
'x-pack/scripts/*.js',
551545
],
552546
excludedFiles: ['**/integration_tests/**/*'],
@@ -578,7 +572,9 @@ module.exports = {
578572
*/
579573
{
580574
files: ['test/harden/*.js', 'packages/elastic-safer-lodash-set/test/*.js'],
581-
rules: allMochaRulesOff,
575+
rules: {
576+
'mocha/handle-done-callback': 'off',
577+
},
582578
},
583579
{
584580
files: ['**/*.{js,mjs,ts,tsx}'],
@@ -798,7 +794,6 @@ module.exports = {
798794
files: ['x-pack/plugins/security_solution/**/*.{js,mjs,ts,tsx}'],
799795
plugins: ['eslint-plugin-node', 'react'],
800796
env: {
801-
mocha: true,
802797
jest: true,
803798
},
804799
rules: {
@@ -934,7 +929,6 @@ module.exports = {
934929
files: ['x-pack/plugins/lists/**/*.{js,mjs,ts,tsx}'],
935930
plugins: ['eslint-plugin-node'],
936931
env: {
937-
mocha: true,
938932
jest: true,
939933
},
940934
rules: {

.teamcity/src/builds/test/QuickTests.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ object QuickTests : BuildType({
1414
val testScripts = mapOf(
1515
"Test Hardening" to ".ci/teamcity/checks/test_hardening.sh",
1616
"Test Projects" to ".ci/teamcity/tests/test_projects.sh",
17-
"Mocha Tests" to ".ci/teamcity/tests/mocha.sh"
1817
)
1918

2019
steps {

docs/developer/contributing/development-tests.asciidoc

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,6 @@ root)
1717
|Jest (integration) |`**/integration_tests/**/*.test.{js,mjs,ts,tsx}`
1818
|`yarn test:jest_integration [test path]`
1919

20-
|Mocha
21-
|`**/__tests__/**/*.js`
22-
|`node scripts/mocha --grep=regexp [test path]`
23-
2420
|Functional
2521
|`test/**/config.js` `x-pack/test/**/config.js`
2622
|`node scripts/functional_tests_server --config [directory]/config.js``node scripts/functional_test_runner_ --config [directory]/config.js --grep=regexp`
@@ -60,8 +56,6 @@ kibana/src/plugins/dashboard/server$ yarn test:jest --coverage
6056
yarn jest --coverage --verbose --config /home/tyler/elastic/kibana/src/plugins/dashboard/jest.config.js server
6157
----
6258

63-
NOTE: There are still a handful of legacy tests that use the Mocha test runner. For those tests, use `node scripts/mocha --grep=regexp [test path]`. Tests using Mocha are located within `__tests__` directories.
64-
6559

6660
[discrete]
6761
=== Running browser automation tests

docs/developer/contributing/development-unit-tests.asciidoc

Lines changed: 4 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,7 @@
11
[[development-unit-tests]]
22
== Unit testing frameworks
33

4-
{kib} is migrating unit testing from `Mocha` to `Jest`. Legacy unit tests
5-
still exist in Mocha but all new unit tests should be written in Jest.
6-
7-
[discrete]
8-
=== Mocha (legacy)
9-
10-
Mocha tests are contained in `__tests__` directories.
11-
12-
*Running Mocha Unit Tests*
13-
14-
["source","shell"]
15-
-----------
16-
yarn test:mocha
17-
-----------
4+
{kib} is doing unit testing using `Jest`.
185

196
[discrete]
207
== Jest
@@ -92,23 +79,10 @@ the `--debug-brk` flag. You’ll need to connect a remote debugger such
9279
as https://github.com/node-inspector/node-inspector[`node-inspector`]
9380
to proceed in this mode.
9481

95-
[source,bash]
96-
----
97-
node scripts/mocha --debug <file>
98-
----
99-
10082
[discrete]
10183
=== Unit Testing Plugins
10284

103-
This should work super if you’re using the
85+
Even when using
10486
https://github.com/elastic/kibana/tree/master/packages/kbn-plugin-generator[Kibana
105-
plugin generator]. If you’re not using the generator, well, you’re on
106-
your own. We suggest you look at how the generator works.
107-
108-
To run the tests for just your particular plugin run the following
109-
command from your plugin:
110-
111-
[source,bash]
112-
----
113-
yarn test:mocha
114-
----
87+
plugin generator] we do not enforce a way for unit testing your plugin. Please setup and you use
88+
the tools of your choice. If the plugin will live inside the Kibana repo `Jest` must be used.

docs/developer/contributing/interpreting-ci-failures.asciidoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ image::images/jenkins/job_view.png[]
2727
[discrete]
2828
=== Viewing ciGroup/test Logs
2929

30-
To view the logs for a failed specific ciGroup, jest, mocha, type checkers, linters, etc., click on the *Pipeline Steps* link in from the Job page.
30+
To view the logs for a failed specific ciGroup, jest, type checkers, linters, etc., click on the *Pipeline Steps* link in from the Job page.
3131

3232
image::images/jenkins/pipeline_steps_view.png[]
3333

docs/user/dashboard/vega-reference.asciidoc

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -216,24 +216,8 @@ on the currently picked range: `"interval": {"%autointerval%": 10}` will
216216
try to get about 10-15 data points (buckets).
217217

218218
[float]
219-
[[vega-esmfiles]]
220-
=== Access Elastic Map Service files
221-
222-
experimental[] Access the Elastic Map Service files via the same mechanism:
223-
224-
[source,yaml]
225-
----
226-
url: {
227-
// "type" defaults to "elasticsearch" otherwise
228-
type: emsfile
229-
// Name of the file, exactly as in the Region map visualization
230-
name: World Countries
231-
}
232-
// The result is a geojson file, get its features to use
233-
// this data source with the "shape" marks
234-
// https://vega.github.io/vega/docs/marks/shape/
235-
format: {property: "features"}
236-
----
219+
[[vega-with-a-map]]
220+
=== Vega with a Map
237221

238222
To enable Maps, the graph must specify `type=map` in the host
239223
configuration:
@@ -282,6 +266,22 @@ Additionally, you can use `latitude`, `longitude`, and `zoom` signals.
282266
These signals can be used in the graph, or can be updated to modify the
283267
position of the map.
284268

269+
experimental[] You can use Vega's https://vega.github.io/vega/docs/data/[data] element to access https://www.elastic.co/elastic-maps-service[Elastic Maps Service (EMS)] vector shapes of administrative boundaries in your Vega map by setting `url.data` to `emsFile`:
270+
271+
[source,yaml]
272+
----
273+
url: {
274+
// "type" defaults to "elasticsearch" otherwise
275+
type: emsfile
276+
// Name of the file, exactly as in the Region map visualization
277+
name: World Countries
278+
}
279+
// The result is a geojson file, get its features to use
280+
// this data source with the "shape" marks
281+
// https://vega.github.io/vega/docs/marks/shape/
282+
format: {property: "features"}
283+
----
284+
285285
[float]
286286
[[vega-tooltip]]
287287
==== Additional tooltip styling
@@ -308,22 +308,22 @@ a configuration option for changing the tooltip position and padding:
308308
[[vega-url-loading]]
309309
==== Advanced setting to enable URL loading from any domain
310310

311-
Vega can load data from any URL, but this is disabled by default in {kib}.
311+
Vega can load data from any URL, but this is disabled by default in {kib}.
312312
To change this, set `vis_type_vega.enableExternalUrls: true` in `kibana.yml`,
313313
then restart {kib}.
314314

315315
[float]
316316
[[vega-inspector]]
317317
==== Vega Inspector
318-
Use the contextual *Inspect* tool to gain insights into different elements.
318+
Use the contextual *Inspect* tool to gain insights into different elements.
319319
For Vega visualizations, there are two different views: *Request* and *Vega debug*.
320320

321321
[float]
322322
[[inspect-elasticsearch-requests]]
323323
===== Inspect {es} requests
324324

325-
Vega uses the {ref}/search-search.html[{es} search API] to get documents and aggregation
326-
results from {es}. To troubleshoot these requests, click *Inspect*, which shows the most recent requests.
325+
Vega uses the {ref}/search-search.html[{es} search API] to get documents and aggregation
326+
results from {es}. To troubleshoot these requests, click *Inspect*, which shows the most recent requests.
327327
In case your specification has more than one request, you can switch between the views using the *View* dropdown.
328328

329329
[role="screenshot"]
@@ -333,10 +333,10 @@ image::visualize/images/vega_tutorial_inspect_requests.png[]
333333
[[vega-debugging]]
334334
===== Vega debugging
335335

336-
With the *Vega debug* view, you can inspect the *Data sets* and *Signal Values* runtime data.
337-
338-
The runtime data is read from the
339-
https://vega.github.io/vega/docs/api/debugging/#scope[runtime scope].
336+
With the *Vega debug* view, you can inspect the *Data sets* and *Signal Values* runtime data.
337+
338+
The runtime data is read from the
339+
https://vega.github.io/vega/docs/api/debugging/#scope[runtime scope].
340340

341341
[role="screenshot"]
342342
image::visualize/images/vega_tutorial_inspect_data_sets.png[]
@@ -348,15 +348,15 @@ the <<vega-browser-debugging-console, Vega browser debugging process>>.
348348
[[asking-for-help-with-a-vega-spec]]
349349
===== Asking for help with a Vega spec
350350

351-
Because of the dynamic nature of the data in {es}, it is hard to help you with
351+
Because of the dynamic nature of the data in {es}, it is hard to help you with
352352
Vega specs unless you can share a dataset. To do this, click *Inspect*, select the *Vega debug* view,
353353
then select the *Spec* tab:
354354

355355
[role="screenshot"]
356356
image::visualize/images/vega_tutorial_getting_help.png[]
357357

358-
To copy the response, click *Copy to clipboard*. Paste the copied data to
359-
https://gist.github.com/[gist.github.com], possibly with a .json extension. Use the [raw] button,
358+
To copy the response, click *Copy to clipboard*. Paste the copied data to
359+
https://gist.github.com/[gist.github.com], possibly with a .json extension. Use the [raw] button,
360360
and share that when asking for help.
361361

362362
[float]

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@
4242
"es": "node scripts/es",
4343
"test:jest": "node scripts/jest",
4444
"test:jest_integration": "node scripts/jest_integration",
45-
"test:mocha": "node scripts/mocha",
4645
"test:ftr": "node scripts/functional_tests",
4746
"test:ftr:server": "node scripts/functional_tests_server",
4847
"test:ftr:runner": "node scripts/functional_test_runner",

packages/README.md

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -44,23 +44,17 @@ All new packages should use the `@kbn` namespace, and should be marked with
4444

4545
## Unit tests for a package
4646

47-
Currently there are two patterns used to test packages, one using Mocha and one using Jest. These patterns emerged out of convention and we'd like to make them more similar to each other in the near future.
47+
Currently there is only one tool being used in order to test packages which is Jest. Below we will explain how it should be done.
4848

49-
### 1. Mocha
50-
Today a package can follow the pattern of having a `__tests__` directory in each source code directory of a package which contains the tests for that module. These are usually run by Mocha.
51-
52-
If a package's tests should be run with Mocha, you'll have to opt-in to run them by appending the package's test file pattern(s) to Kibana's `src/dev/mocha/run_mocha_cli.js` file. These will then be run by the unit test runner.
53-
54-
* `yarn test` or `yarn grunt test` runs all unit tests.
55-
* `node scripts/mocha` runs all Mocha tests.
56-
57-
### 2. Jest
58-
A package can also follow the pattern of having `.test.js` files as siblings of the source code files, and these run by Jest.
49+
### Jest
50+
A package should follow the pattern of having `.test.js` files as siblings of the source code files, and these run by Jest.
5951

6052
A package using the `.test.js` naming convention will have those tests automatically picked up by Jest and run by the unit test runner, currently mapped to the Kibana `test` script in the root `package.json`.
6153

6254
* `yarn test` or `yarn grunt test` runs all unit tests.
6355
* `yarn jest` runs all Jest tests in Kibana.
6456

57+
In order for the plugin or package to use Jest, a jest.config.js file must be present in it's root. However, there are safeguards for this in CI should a test file be added without a corresponding config file.
58+
6559
----
6660
Each package can also specify its own `test` script in the package's `package.json`, for cases where you'd prefer to run the tests from the local package directory.

0 commit comments

Comments
 (0)