-
Notifications
You must be signed in to change notification settings - Fork 8.6k
[Functional Tests] Use @kbn/test on Kibana CI #18967
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
Merged
Merged
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
b05c2d3
Replace test:api with @kbn/test runTests
b6181ff
Improve CLI help menu :sos:
0374e6c
Use --es-from
b0221bc
Replace jenkins:selenium with kbn-test
9e26b1e
Validate cli args, fixing test in the process
70bc0fb
Clean up some stuff
1adc41f
Code review fixes
abb0c5e
Explanation for collectCliArgs
12e037e
Remove exit codes, they're useless anyway.
7c44f5e
Make markdown vis test pass with dev_mode setting
bd193d9
Tests
16e7485
Remove unneeded export
45ea76b
Code review: move console logging up to cli.js
f830ffb
Code review: refactor startServers and runTests to take single option…
904efa0
Code review: Remove all things I am sure we do not use
f2afcca
Merge branch 'master' into archanid-18593
365db67
Merge branch 'master' into archanid-18593
archanid a33f81e
Improve tests
e16024e
Code review fixes
f12aa46
Pass created log to runFtr, runElasticsearch, runKibanaServer
47dcc07
Update --es-from option to --esFrom
c888b65
Merge branch 'master' into archanid-18593
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
137 changes: 137 additions & 0 deletions
137
packages/kbn-test/src/functional_tests/cli/run_tests/__snapshots__/args.test.js.snap
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,137 @@ | ||
| // Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
|
||
| exports[`display help for run tests CLI displays as expected 1`] = ` | ||
| "Run Functional Tests | ||
|
|
||
| Usage: | ||
| node scripts/functional_tests --help | ||
| node scripts/functional_tests [--config <file1> [--config <file2> ...]] | ||
| node scripts/functional_tests [options] [-- --<other args>] | ||
|
|
||
| Options: | ||
| --help Display this menu and exit. | ||
| --config <file> Pass in a config. Can pass in multiple configs. | ||
| --esFrom <snapshot|source> Build Elasticsearch from source or run from snapshot. Default: snapshot | ||
| --kibana-install-dir <dir> Run Kibana from existing install directory instead of from source. | ||
| --bail Stop the test run at the first failure. | ||
| --grep <pattern> Pattern to select which tests to run. | ||
| --updateBaselines Replace baseline screenshots with whatever is generated from the test. | ||
| --verbose Log everything. | ||
| --debug Run in debug mode. | ||
| --quiet Only log errors. | ||
| --silent Log nothing." | ||
| `; | ||
|
|
||
| exports[`process options for run tests CLI accepts boolean value for updateBaselines 1`] = ` | ||
| Object { | ||
| "configs": Array [ | ||
| "foo", | ||
| ], | ||
| "createLogger": [Function], | ||
| "extraKbnOpts": undefined, | ||
| "updateBaselines": true, | ||
| } | ||
| `; | ||
|
|
||
| exports[`process options for run tests CLI accepts debug option 1`] = ` | ||
| Object { | ||
| "configs": Array [ | ||
| "foo", | ||
| ], | ||
| "createLogger": [Function], | ||
| "debug": true, | ||
| "extraKbnOpts": undefined, | ||
| } | ||
| `; | ||
|
|
||
| exports[`process options for run tests CLI accepts empty config value if default passed 1`] = ` | ||
| Object { | ||
| "config": "", | ||
| "configs": Array [ | ||
| "foo", | ||
| ], | ||
| "createLogger": [Function], | ||
| "extraKbnOpts": undefined, | ||
| } | ||
| `; | ||
|
|
||
| exports[`process options for run tests CLI accepts extra server options 1`] = ` | ||
| Object { | ||
| "_": Object { | ||
| "server.foo": "bar", | ||
| }, | ||
| "configs": Array [ | ||
| "foo", | ||
| ], | ||
| "createLogger": [Function], | ||
| "extraKbnOpts": Object { | ||
| "server.foo": "bar", | ||
| }, | ||
| } | ||
| `; | ||
|
|
||
| exports[`process options for run tests CLI accepts quiet option 1`] = ` | ||
| Object { | ||
| "configs": Array [ | ||
| "foo", | ||
| ], | ||
| "createLogger": [Function], | ||
| "extraKbnOpts": undefined, | ||
| "quiet": true, | ||
| } | ||
| `; | ||
|
|
||
| exports[`process options for run tests CLI accepts silent option 1`] = ` | ||
| Object { | ||
| "configs": Array [ | ||
| "foo", | ||
| ], | ||
| "createLogger": [Function], | ||
| "extraKbnOpts": undefined, | ||
| "silent": true, | ||
| } | ||
| `; | ||
|
|
||
| exports[`process options for run tests CLI accepts source value for esFrom 1`] = ` | ||
| Object { | ||
| "configs": Array [ | ||
| "foo", | ||
| ], | ||
| "createLogger": [Function], | ||
| "esFrom": "source", | ||
| "extraKbnOpts": undefined, | ||
| } | ||
| `; | ||
|
|
||
| exports[`process options for run tests CLI accepts string value for kibana-install-dir 1`] = ` | ||
| Object { | ||
| "configs": Array [ | ||
| "foo", | ||
| ], | ||
| "createLogger": [Function], | ||
| "extraKbnOpts": undefined, | ||
| "kibana-install-dir": "foo", | ||
| } | ||
| `; | ||
|
|
||
| exports[`process options for run tests CLI accepts value for grep 1`] = ` | ||
| Object { | ||
| "configs": Array [ | ||
| "foo", | ||
| ], | ||
| "createLogger": [Function], | ||
| "extraKbnOpts": undefined, | ||
| "grep": "management", | ||
| } | ||
| `; | ||
|
|
||
| exports[`process options for run tests CLI accepts verbose option 1`] = ` | ||
| Object { | ||
| "configs": Array [ | ||
| "foo", | ||
| ], | ||
| "createLogger": [Function], | ||
| "extraKbnOpts": undefined, | ||
| "verbose": true, | ||
| } | ||
| `; | ||
75 changes: 75 additions & 0 deletions
75
packages/kbn-test/src/functional_tests/cli/run_tests/__snapshots__/cli.test.js.snap
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| // Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
|
||
| exports[`run tests CLI options accepts help option even if invalid options passed 1`] = ` | ||
| Array [ | ||
| Array [ | ||
| "Run Functional Tests | ||
|
|
||
| Usage: | ||
| node scripts/functional_tests --help | ||
| node scripts/functional_tests [--config <file1> [--config <file2> ...]] | ||
| node scripts/functional_tests [options] [-- --<other args>] | ||
|
|
||
| Options: | ||
| --help Display this menu and exit. | ||
| --config <file> Pass in a config. Can pass in multiple configs. | ||
| --esFrom <snapshot|source> Build Elasticsearch from source or run from snapshot. Default: snapshot | ||
| --kibana-install-dir <dir> Run Kibana from existing install directory instead of from source. | ||
| --bail Stop the test run at the first failure. | ||
| --grep <pattern> Pattern to select which tests to run. | ||
| --updateBaselines Replace baseline screenshots with whatever is generated from the test. | ||
| --verbose Log everything. | ||
| --debug Run in debug mode. | ||
| --quiet Only log errors. | ||
| --silent Log nothing.", | ||
| ], | ||
| ] | ||
| `; | ||
|
|
||
| exports[`run tests CLI options rejects boolean config value 1`] = ` | ||
| Array [ | ||
| Array [ | ||
| "[31mError: functional_tests: invalid argument [true] to option [config][39m", | ||
| ], | ||
| ] | ||
| `; | ||
|
|
||
| exports[`run tests CLI options rejects boolean value for kibana-install-dir 1`] = ` | ||
| Array [ | ||
| Array [ | ||
| "[31mError: functional_tests: invalid argument [true] to option [kibana-install-dir][39m", | ||
| ], | ||
| ] | ||
| `; | ||
|
|
||
| exports[`run tests CLI options rejects empty config value if no default passed 1`] = ` | ||
| Array [ | ||
| Array [ | ||
| "[31mError: functional_tests: config is required[39m", | ||
| ], | ||
| ] | ||
| `; | ||
|
|
||
| exports[`run tests CLI options rejects invalid options even if valid options exist 1`] = ` | ||
| Array [ | ||
| Array [ | ||
| "[31mError: functional_tests: invalid option [aintnothang][39m", | ||
| ], | ||
| ] | ||
| `; | ||
|
|
||
| exports[`run tests CLI options rejects non-boolean value for bail 1`] = ` | ||
| Array [ | ||
| Array [ | ||
| "[31mError: functional_tests: invalid argument [peanut] to option [bail][39m", | ||
| ], | ||
| ] | ||
| `; | ||
|
|
||
| exports[`run tests CLI options rejects non-enum value for esFrom 1`] = ` | ||
| Array [ | ||
| Array [ | ||
| "[31mError: functional_tests: invalid argument [butter] to option [esFrom][39m", | ||
| ], | ||
| ] | ||
| `; |
133 changes: 133 additions & 0 deletions
133
packages/kbn-test/src/functional_tests/cli/run_tests/args.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,133 @@ | ||
| /* | ||
| * Licensed to Elasticsearch B.V. under one or more contributor | ||
| * license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright | ||
| * ownership. Elasticsearch B.V. licenses this file to you under | ||
| * the Apache License, Version 2.0 (the "License"); you may | ||
| * not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, | ||
| * software distributed under the License is distributed on an | ||
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| * KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations | ||
| * under the License. | ||
| */ | ||
|
|
||
| import dedent from 'dedent'; | ||
| import { createToolingLog, pickLevelFromFlags } from '@kbn/dev-utils'; | ||
|
|
||
| const options = { | ||
| help: { desc: 'Display this menu and exit.' }, | ||
| config: { | ||
| arg: '<file>', | ||
| desc: 'Pass in a config. Can pass in multiple configs.', | ||
| }, | ||
| esFrom: { | ||
| arg: '<snapshot|source>', | ||
| choices: ['snapshot', 'source'], | ||
| desc: 'Build Elasticsearch from source or run from snapshot.', | ||
| default: 'snapshot', | ||
| }, | ||
| 'kibana-install-dir': { | ||
| arg: '<dir>', | ||
| desc: 'Run Kibana from existing install directory instead of from source.', | ||
| }, | ||
| bail: { desc: 'Stop the test run at the first failure.' }, | ||
| grep: { | ||
| arg: '<pattern>', | ||
| desc: 'Pattern to select which tests to run.', | ||
| }, | ||
| updateBaselines: { | ||
| desc: | ||
| 'Replace baseline screenshots with whatever is generated from the test.', | ||
| }, | ||
| verbose: { desc: 'Log everything.' }, | ||
| debug: { desc: 'Run in debug mode.' }, | ||
| quiet: { desc: 'Only log errors.' }, | ||
| silent: { desc: 'Log nothing.' }, | ||
| }; | ||
|
|
||
| export function displayHelp() { | ||
| const helpOptions = Object.keys(options) | ||
| .filter(name => name !== '_') | ||
| .map(name => { | ||
| const option = options[name]; | ||
| return { | ||
| ...option, | ||
| usage: `${name} ${option.arg || ''}`, | ||
| default: option.default ? `Default: ${option.default}` : '', | ||
| }; | ||
| }) | ||
| .map(option => { | ||
| return `--${option.usage.padEnd(28)} ${option.desc} ${option.default}`; | ||
| }) | ||
| .join(`\n `); | ||
|
|
||
| return dedent(` | ||
| Run Functional Tests | ||
|
|
||
| Usage: | ||
| node scripts/functional_tests --help | ||
| node scripts/functional_tests [--config <file1> [--config <file2> ...]] | ||
| node scripts/functional_tests [options] [-- --<other args>] | ||
|
|
||
| Options: | ||
| ${helpOptions} | ||
| `); | ||
| } | ||
|
|
||
| export function processOptions(userOptions, defaultConfigPaths) { | ||
| validateOptions(userOptions); | ||
|
|
||
| let configs; | ||
| if (userOptions.config) { | ||
| configs = [].concat(userOptions.config); | ||
| } else { | ||
| if (!defaultConfigPaths || defaultConfigPaths.length === 0) { | ||
| throw new Error(`functional_tests: config is required`); | ||
| } else { | ||
| configs = defaultConfigPaths; | ||
| } | ||
| } | ||
|
|
||
| function createLogger() { | ||
| const log = createToolingLog(pickLevelFromFlags(userOptions)); | ||
| log.pipe(process.stdout); | ||
| return log; | ||
| } | ||
|
|
||
| return { | ||
| ...userOptions, | ||
| configs, | ||
| createLogger, | ||
| extraKbnOpts: userOptions._, | ||
| }; | ||
| } | ||
|
|
||
| function validateOptions(userOptions) { | ||
| Object.entries(userOptions).forEach(([key, val]) => { | ||
| if (key === '_') return; | ||
|
|
||
| // Validate flags passed | ||
| if (options[key] === undefined) { | ||
| throw new Error(`functional_tests: invalid option [${key}]`); | ||
| } | ||
|
|
||
| if ( | ||
| // Validate boolean flags | ||
| (!options[key].arg && typeof val !== 'boolean') || | ||
| // Validate string/array flags | ||
| (options[key].arg && typeof val !== 'string' && !Array.isArray(val)) || | ||
| // Validate enum flags | ||
| (options[key].choices && !options[key].choices.includes(val)) | ||
| ) { | ||
| throw new Error( | ||
| `functional_tests: invalid argument [${val}] to option [${key}]` | ||
| ); | ||
| } | ||
| }); | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: it's the only parameter that uses dashes now, maybe we can make it
--kibanaInsallDirjust for consistency?