From 7658e9c631d7a823028a37baa87ef39227a54b8d Mon Sep 17 00:00:00 2001 From: Dmitry Lemeshko Date: Wed, 11 Dec 2019 19:41:25 +0100 Subject: [PATCH] FTR: add 'throttle' option to cli (#33241) * [ftr/cli] add throttling option * [ftr/cli] add headless option, fix test --- .../kbn-test/src/functional_test_runner/cli.ts | 12 +++++++++++- .../functional_tests/cli/run_tests/cli.test.js | 16 ++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/packages/kbn-test/src/functional_test_runner/cli.ts b/packages/kbn-test/src/functional_test_runner/cli.ts index 36412961ce75b..11b9450f2af6e 100644 --- a/packages/kbn-test/src/functional_test_runner/cli.ts +++ b/packages/kbn-test/src/functional_test_runner/cli.ts @@ -57,6 +57,14 @@ export function runFtrCli() { } ); + if (flags.throttle) { + process.env.TEST_THROTTLE_NETWORK = '1'; + } + + if (flags.headless) { + process.env.TEST_BROWSER_HEADLESS = '1'; + } + let teardownRun = false; const teardown = async (err?: Error) => { if (teardownRun) return; @@ -97,7 +105,7 @@ export function runFtrCli() { { flags: { string: ['config', 'grep', 'exclude', 'include-tag', 'exclude-tag', 'kibana-install-dir'], - boolean: ['bail', 'invert', 'test-stats', 'updateBaselines'], + boolean: ['bail', 'invert', 'test-stats', 'updateBaselines', 'throttle', 'headless'], default: { config: 'test/functional/config.js', debug: true, @@ -113,6 +121,8 @@ export function runFtrCli() { --test-stats print the number of tests (included and excluded) to STDERR --updateBaselines replace baseline screenshots with whatever is generated from the test --kibana-install-dir directory where the Kibana install being tested resides + --throttle enable network throttling in Chrome browser + --headless run browser in headless mode `, }, } diff --git a/packages/kbn-test/src/functional_tests/cli/run_tests/cli.test.js b/packages/kbn-test/src/functional_tests/cli/run_tests/cli.test.js index 97b74a3b2b541..9f9a8f59fde9a 100644 --- a/packages/kbn-test/src/functional_tests/cli/run_tests/cli.test.js +++ b/packages/kbn-test/src/functional_tests/cli/run_tests/cli.test.js @@ -182,6 +182,22 @@ describe('run tests CLI', () => { expect(exitMock).not.toHaveBeenCalled(); }); + it('accepts network throttle option', async () => { + global.process.argv.push('--throttle'); + + await runTestsCli(['foo']); + + expect(exitMock).toHaveBeenCalledWith(1); + }); + + it('accepts headless option', async () => { + global.process.argv.push('--headless'); + + await runTestsCli(['foo']); + + expect(exitMock).toHaveBeenCalledWith(1); + }); + it('accepts extra server options', async () => { global.process.argv.push('--', '--server.foo=bar');