[ftr] support --kibana-install-dir flag (#44552) (#44935)

* [ftr] support --kibana-install-dir flag

* improve spacing/style of success message

* Remove unused var
This commit is contained in:
Spencer 2019-09-06 10:50:00 -07:00 committed by GitHub
parent 2491e92bef
commit 124f91c48b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 45 additions and 17 deletions

View file

@ -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';

View file

@ -18,4 +18,5 @@
*/
export { run } from './run';
export { Flags } from './flags';
export { createFailError, createFlagError, combineErrors, isFailError } from './fail';

View file

@ -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
`,
},
}

View file

@ -187,6 +187,7 @@ export const schema = Joi.object()
buildArgs: Joi.array(),
sourceArgs: Joi.array(),
serverArgs: Joi.array(),
installDir: Joi.string(),
})
.default(),

View file

@ -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')],

View file

@ -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(