Skip to content

Commit 16eb033

Browse files
author
Spencer
authored
[ftr] support --kibana-install-dir flag (#44552)
* [ftr] support --kibana-install-dir flag * improve spacing/style of success message * Remove unused var
1 parent e383069 commit 16eb033

File tree

6 files changed

+45
-17
lines changed

6 files changed

+45
-17
lines changed

packages/kbn-dev-utils/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,5 @@ export { withProcRunner } from './proc_runner';
2121
export { ToolingLog, ToolingLogTextWriter, pickLevelFromFlags } from './tooling_log';
2222
export { createAbsolutePathSerializer } from './serializers';
2323
export { CA_CERT_PATH, ES_KEY_PATH, ES_CERT_PATH } from './certs';
24-
export { run, createFailError, createFlagError, combineErrors, isFailError } from './run';
24+
export { run, createFailError, createFlagError, combineErrors, isFailError, Flags } from './run';
2525
export { REPO_ROOT } from './constants';

packages/kbn-dev-utils/src/run/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,5 @@
1818
*/
1919

2020
export { run } from './run';
21+
export { Flags } from './flags';
2122
export { createFailError, createFlagError, combineErrors, isFailError } from './fail';

packages/kbn-test/src/functional_test_runner/cli.ts

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,24 +18,36 @@
1818
*/
1919

2020
import { resolve } from 'path';
21-
import { run } from '@kbn/dev-utils';
21+
import { run, createFlagError, Flags } from '@kbn/dev-utils';
2222
import { FunctionalTestRunner } from './functional_test_runner';
2323

24+
const makeAbsolutePath = (v: string) => resolve(process.cwd(), v);
25+
const toArray = (v: string | string[]) => ([] as string[]).concat(v || []);
26+
const parseInstallDir = (flags: Flags) => {
27+
const flag = flags['kibana-install-dir'];
28+
29+
if (typeof flag !== 'string' && flag !== undefined) {
30+
throw createFlagError('--kibana-install-dir must be a string or not defined');
31+
}
32+
33+
return flag ? makeAbsolutePath(flag) : undefined;
34+
};
35+
2436
export function runFtrCli() {
2537
run(
2638
async ({ flags, log }) => {
27-
const resolveConfigPath = (v: string) => resolve(process.cwd(), v);
28-
const toArray = (v: string | string[]) => ([] as string[]).concat(v || []);
29-
3039
const functionalTestRunner = new FunctionalTestRunner(
3140
log,
32-
resolveConfigPath(flags.config as string),
41+
makeAbsolutePath(flags.config as string),
3342
{
3443
mochaOpts: {
3544
bail: flags.bail,
3645
grep: flags.grep || undefined,
3746
invert: flags.invert,
3847
},
48+
kbnTestServer: {
49+
installDir: parseInstallDir(flags),
50+
},
3951
suiteTags: {
4052
include: toArray(flags['include-tag'] as string | string[]),
4153
exclude: toArray(flags['exclude-tag'] as string | string[]),
@@ -84,7 +96,7 @@ export function runFtrCli() {
8496
},
8597
{
8698
flags: {
87-
string: ['config', 'grep', 'exclude', 'include-tag', 'exclude-tag'],
99+
string: ['config', 'grep', 'exclude', 'include-tag', 'exclude-tag', 'kibana-install-dir'],
88100
boolean: ['bail', 'invert', 'test-stats', 'updateBaselines'],
89101
default: {
90102
config: 'test/functional/config.js',
@@ -100,6 +112,7 @@ export function runFtrCli() {
100112
--exclude-tag=tag a tag to be excluded, pass multiple times for multiple tags
101113
--test-stats print the number of tests (included and excluded) to STDERR
102114
--updateBaselines replace baseline screenshots with whatever is generated from the test
115+
--kibana-install-dir directory where the Kibana install being tested resides
103116
`,
104117
},
105118
}

packages/kbn-test/src/functional_test_runner/lib/config/schema.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ export const schema = Joi.object()
187187
buildArgs: Joi.array(),
188188
sourceArgs: Joi.array(),
189189
serverArgs: Joi.array(),
190+
installDir: Joi.string(),
190191
})
191192
.default(),
192193

packages/kbn-test/src/functional_tests/lib/run_ftr.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,20 @@
2020
import { FunctionalTestRunner, readConfigFile } from '../../functional_test_runner';
2121
import { CliError } from './run_cli';
2222

23-
async function createFtr({ configPath, options: { log, bail, grep, updateBaselines, suiteTags } }) {
23+
async function createFtr({
24+
configPath,
25+
options: { installDir, log, bail, grep, updateBaselines, suiteTags },
26+
}) {
2427
const config = await readConfigFile(log, configPath);
2528

2629
return new FunctionalTestRunner(log, configPath, {
2730
mochaOpts: {
2831
bail: !!bail,
2932
grep,
3033
},
34+
kbnTestServer: {
35+
installDir,
36+
},
3137
updateBaselines,
3238
suiteTags: {
3339
include: [...suiteTags.include, ...config.get('suiteTags.include')],

packages/kbn-test/src/functional_tests/tasks.js

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import { relative } from 'path';
2121
import * as Rx from 'rxjs';
2222
import { startWith, switchMap, take } from 'rxjs/operators';
2323
import { withProcRunner } from '@kbn/dev-utils';
24+
import dedent from 'dedent';
2425

2526
import {
2627
runElasticsearch,
@@ -33,14 +34,20 @@ import {
3334

3435
import { readConfigFile } from '../functional_test_runner/lib';
3536

36-
const SUCCESS_MESSAGE = `
37+
const makeSuccessMessage = options => {
38+
const installDirFlag = options.installDir ? ` --kibana-install-dir=${options.installDir}` : '';
3739

38-
Elasticsearch and Kibana are ready for functional testing. Start the functional tests
39-
in another terminal session by running this command from this directory:
40+
return (
41+
'\n\n' +
42+
dedent`
43+
Elasticsearch and Kibana are ready for functional testing. Start the functional tests
44+
in another terminal session by running this command from this directory:
4045
41-
node ${relative(process.cwd(), KIBANA_FTR_SCRIPT)}
42-
43-
`;
46+
node ${relative(process.cwd(), KIBANA_FTR_SCRIPT)}${installDirFlag}
47+
` +
48+
'\n\n'
49+
);
50+
};
4451

4552
/**
4653
* Run servers and tests for each config
@@ -118,15 +125,15 @@ export async function startServers(options) {
118125

119126
// wait for 5 seconds of silence before logging the
120127
// success message so that it doesn't get buried
121-
await silence(5000, { log });
122-
log.info(SUCCESS_MESSAGE);
128+
await silence(log, 5000);
129+
log.success(makeSuccessMessage(options));
123130

124131
await procs.waitForAllToStop();
125132
await es.cleanup();
126133
});
127134
}
128135

129-
async function silence(milliseconds, { log }) {
136+
async function silence(log, milliseconds) {
130137
await log
131138
.getWritten$()
132139
.pipe(

0 commit comments

Comments
 (0)