diff --git a/packages/kbn-dev-utils/src/index.ts b/packages/kbn-dev-utils/src/index.ts index bea8ed11e87ac..6d3914eb56218 100644 --- a/packages/kbn-dev-utils/src/index.ts +++ b/packages/kbn-dev-utils/src/index.ts @@ -21,5 +21,5 @@ export { withProcRunner } from './proc_runner'; export { ToolingLog, ToolingLogTextWriter, pickLevelFromFlags } from './tooling_log'; export { createAbsolutePathSerializer } from './serializers'; export { CA_CERT_PATH, ES_KEY_PATH, ES_CERT_PATH } from './certs'; -export { run, createFailError, createFlagError, combineErrors, isFailError } from './run'; +export { run, createFailError, createFlagError, combineErrors, isFailError, Flags } from './run'; export { REPO_ROOT } from './constants'; diff --git a/packages/kbn-dev-utils/src/run/index.ts b/packages/kbn-dev-utils/src/run/index.ts index 9d81ff0c9af3b..5e1a42deefffb 100644 --- a/packages/kbn-dev-utils/src/run/index.ts +++ b/packages/kbn-dev-utils/src/run/index.ts @@ -18,4 +18,5 @@ */ export { run } from './run'; +export { Flags } from './flags'; export { createFailError, createFlagError, combineErrors, isFailError } from './fail'; diff --git a/packages/kbn-test/src/functional_test_runner/cli.ts b/packages/kbn-test/src/functional_test_runner/cli.ts index d864729a85236..36412961ce75b 100644 --- a/packages/kbn-test/src/functional_test_runner/cli.ts +++ b/packages/kbn-test/src/functional_test_runner/cli.ts @@ -18,24 +18,36 @@ */ import { resolve } from 'path'; -import { run } from '@kbn/dev-utils'; +import { run, createFlagError, Flags } from '@kbn/dev-utils'; import { FunctionalTestRunner } from './functional_test_runner'; +const makeAbsolutePath = (v: string) => resolve(process.cwd(), v); +const toArray = (v: string | string[]) => ([] as string[]).concat(v || []); +const parseInstallDir = (flags: Flags) => { + const flag = flags['kibana-install-dir']; + + if (typeof flag !== 'string' && flag !== undefined) { + throw createFlagError('--kibana-install-dir must be a string or not defined'); + } + + return flag ? makeAbsolutePath(flag) : undefined; +}; + export function runFtrCli() { run( async ({ flags, log }) => { - const resolveConfigPath = (v: string) => resolve(process.cwd(), v); - const toArray = (v: string | string[]) => ([] as string[]).concat(v || []); - const functionalTestRunner = new FunctionalTestRunner( log, - resolveConfigPath(flags.config as string), + makeAbsolutePath(flags.config as string), { mochaOpts: { bail: flags.bail, grep: flags.grep || undefined, invert: flags.invert, }, + kbnTestServer: { + installDir: parseInstallDir(flags), + }, suiteTags: { include: toArray(flags['include-tag'] as string | string[]), exclude: toArray(flags['exclude-tag'] as string | string[]), @@ -84,7 +96,7 @@ export function runFtrCli() { }, { flags: { - string: ['config', 'grep', 'exclude', 'include-tag', 'exclude-tag'], + string: ['config', 'grep', 'exclude', 'include-tag', 'exclude-tag', 'kibana-install-dir'], boolean: ['bail', 'invert', 'test-stats', 'updateBaselines'], default: { config: 'test/functional/config.js', @@ -100,6 +112,7 @@ export function runFtrCli() { --exclude-tag=tag a tag to be excluded, pass multiple times for multiple tags --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 `, }, } diff --git a/packages/kbn-test/src/functional_test_runner/lib/config/schema.ts b/packages/kbn-test/src/functional_test_runner/lib/config/schema.ts index 4887ad2c6e1d7..d9cf282d8f4b6 100644 --- a/packages/kbn-test/src/functional_test_runner/lib/config/schema.ts +++ b/packages/kbn-test/src/functional_test_runner/lib/config/schema.ts @@ -187,6 +187,7 @@ export const schema = Joi.object() buildArgs: Joi.array(), sourceArgs: Joi.array(), serverArgs: Joi.array(), + installDir: Joi.string(), }) .default(), diff --git a/packages/kbn-test/src/functional_tests/lib/run_ftr.js b/packages/kbn-test/src/functional_tests/lib/run_ftr.js index a0edfcdb8c7b5..aeda84f9524ed 100644 --- a/packages/kbn-test/src/functional_tests/lib/run_ftr.js +++ b/packages/kbn-test/src/functional_tests/lib/run_ftr.js @@ -20,7 +20,10 @@ import { FunctionalTestRunner, readConfigFile } from '../../functional_test_runner'; import { CliError } from './run_cli'; -async function createFtr({ configPath, options: { log, bail, grep, updateBaselines, suiteTags } }) { +async function createFtr({ + configPath, + options: { installDir, log, bail, grep, updateBaselines, suiteTags }, +}) { const config = await readConfigFile(log, configPath); return new FunctionalTestRunner(log, configPath, { @@ -28,6 +31,9 @@ async function createFtr({ configPath, options: { log, bail, grep, updateBaselin bail: !!bail, grep, }, + kbnTestServer: { + installDir, + }, updateBaselines, suiteTags: { include: [...suiteTags.include, ...config.get('suiteTags.include')], diff --git a/packages/kbn-test/src/functional_tests/tasks.js b/packages/kbn-test/src/functional_tests/tasks.js index 966b148f0ce6d..6ebc49679fbf3 100644 --- a/packages/kbn-test/src/functional_tests/tasks.js +++ b/packages/kbn-test/src/functional_tests/tasks.js @@ -21,6 +21,7 @@ import { relative } from 'path'; import * as Rx from 'rxjs'; import { startWith, switchMap, take } from 'rxjs/operators'; import { withProcRunner } from '@kbn/dev-utils'; +import dedent from 'dedent'; import { runElasticsearch, @@ -33,14 +34,20 @@ import { import { readConfigFile } from '../functional_test_runner/lib'; -const SUCCESS_MESSAGE = ` +const makeSuccessMessage = options => { + const installDirFlag = options.installDir ? ` --kibana-install-dir=${options.installDir}` : ''; -Elasticsearch and Kibana are ready for functional testing. Start the functional tests -in another terminal session by running this command from this directory: + return ( + '\n\n' + + dedent` + Elasticsearch and Kibana are ready for functional testing. Start the functional tests + in another terminal session by running this command from this directory: - node ${relative(process.cwd(), KIBANA_FTR_SCRIPT)} - -`; + node ${relative(process.cwd(), KIBANA_FTR_SCRIPT)}${installDirFlag} + ` + + '\n\n' + ); +}; /** * Run servers and tests for each config @@ -118,15 +125,15 @@ export async function startServers(options) { // wait for 5 seconds of silence before logging the // success message so that it doesn't get buried - await silence(5000, { log }); - log.info(SUCCESS_MESSAGE); + await silence(log, 5000); + log.success(makeSuccessMessage(options)); await procs.waitForAllToStop(); await es.cleanup(); }); } -async function silence(milliseconds, { log }) { +async function silence(log, milliseconds) { await log .getWritten$() .pipe(