mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
Add option to functional test server to run elasticsearch from instal… (#22608)
* Add option to functional test server to run elasticsearch from install dir * Fix variable * Fix server CLI test * Updates to include install path in esFrom command line option * Fix snapshot * Update args/cli tests * Keep default snapshot in args/help
This commit is contained in:
parent
f2bb7dbf9d
commit
5d9d7242e5
7 changed files with 37 additions and 40 deletions
|
@ -26,6 +26,7 @@ import { esTestConfig } from './es_test_config';
|
|||
import { rmrfSync } from './rmrf_sync';
|
||||
import { KIBANA_ROOT } from '../';
|
||||
import elasticsearch from 'elasticsearch';
|
||||
const path = require('path');
|
||||
|
||||
export function createEsTestCluster(options = {}) {
|
||||
const {
|
||||
|
@ -61,10 +62,17 @@ export function createEsTestCluster(options = {}) {
|
|||
}
|
||||
|
||||
async start(esArgs = []) {
|
||||
const { installPath } =
|
||||
esFrom === 'source'
|
||||
? await cluster.installSource(config)
|
||||
: await cluster.installSnapshot(config);
|
||||
let installPath;
|
||||
|
||||
if (esFrom === 'source') {
|
||||
installPath = (await cluster.installSource(config)).installPath;
|
||||
} else if (esFrom === 'snapshot') {
|
||||
installPath = (await cluster.installSnapshot(config)).installPath;
|
||||
} else if (path.isAbsolute(esFrom)) {
|
||||
installPath = esFrom;
|
||||
} else {
|
||||
throw new Error(`unknown option esFrom "${esFrom}"`);
|
||||
}
|
||||
|
||||
await cluster.start(installPath, {
|
||||
esArgs: [
|
||||
|
|
|
@ -9,14 +9,14 @@ Usage:
|
|||
node scripts/functional_tests_server [options] [-- --<other args>]
|
||||
|
||||
Options:
|
||||
--help Display this menu and exit.
|
||||
--config <file> Pass in a config
|
||||
--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.
|
||||
--verbose Log everything.
|
||||
--debug Run in debug mode.
|
||||
--quiet Only log errors.
|
||||
--silent Log nothing."
|
||||
--help Display this menu and exit.
|
||||
--config <file> Pass in a config
|
||||
--esFrom <snapshot|source|path> Build Elasticsearch from source, snapshot or path to existing install dir. Default: snapshot
|
||||
--kibana-install-dir <dir> Run Kibana from existing install directory instead of from source.
|
||||
--verbose Log everything.
|
||||
--debug Run in debug mode.
|
||||
--quiet Only log errors.
|
||||
--silent Log nothing."
|
||||
`;
|
||||
|
||||
exports[`process options for start servers CLI accepts debug option 1`] = `
|
||||
|
@ -26,6 +26,7 @@ Object {
|
|||
],
|
||||
"createLogger": [Function],
|
||||
"debug": true,
|
||||
"esFrom": "snapshot",
|
||||
"extraKbnOpts": undefined,
|
||||
}
|
||||
`;
|
||||
|
@ -36,6 +37,7 @@ Object {
|
|||
"foo",
|
||||
],
|
||||
"createLogger": [Function],
|
||||
"esFrom": "snapshot",
|
||||
"extraKbnOpts": undefined,
|
||||
}
|
||||
`;
|
||||
|
@ -49,6 +51,7 @@ Object {
|
|||
"foo",
|
||||
],
|
||||
"createLogger": [Function],
|
||||
"esFrom": "snapshot",
|
||||
"extraKbnOpts": Object {
|
||||
"server.foo": "bar",
|
||||
},
|
||||
|
@ -61,6 +64,7 @@ Object {
|
|||
"foo",
|
||||
],
|
||||
"createLogger": [Function],
|
||||
"esFrom": "snapshot",
|
||||
"extraKbnOpts": undefined,
|
||||
"quiet": true,
|
||||
}
|
||||
|
@ -72,6 +76,7 @@ Object {
|
|||
"foo",
|
||||
],
|
||||
"createLogger": [Function],
|
||||
"esFrom": "snapshot",
|
||||
"extraKbnOpts": undefined,
|
||||
"silent": true,
|
||||
}
|
||||
|
@ -94,6 +99,7 @@ Object {
|
|||
"foo",
|
||||
],
|
||||
"createLogger": [Function],
|
||||
"esFrom": "snapshot",
|
||||
"extraKbnOpts": undefined,
|
||||
"installDir": "foo",
|
||||
}
|
||||
|
@ -105,6 +111,7 @@ Object {
|
|||
"foo",
|
||||
],
|
||||
"createLogger": [Function],
|
||||
"esFrom": "snapshot",
|
||||
"extraKbnOpts": undefined,
|
||||
"verbose": true,
|
||||
}
|
||||
|
|
|
@ -40,11 +40,4 @@ exports[`start servers CLI options rejects invalid options even if valid options
|
|||
[31mfunctional_tests_server: invalid option [grep][39m
|
||||
...stack trace...
|
||||
"
|
||||
`;
|
||||
|
||||
exports[`start servers CLI options rejects non-enum value for esFrom 1`] = `
|
||||
"
|
||||
[31mfunctional_tests_server: invalid argument [butter] to option [esFrom][39m
|
||||
...stack trace...
|
||||
"
|
||||
`;
|
||||
`;
|
|
@ -27,9 +27,8 @@ const options = {
|
|||
desc: 'Pass in a config',
|
||||
},
|
||||
esFrom: {
|
||||
arg: '<snapshot|source>',
|
||||
choices: ['snapshot', 'source'],
|
||||
desc: 'Build Elasticsearch from source or run from snapshot.',
|
||||
arg: '<snapshot|source|path>',
|
||||
desc: 'Build Elasticsearch from source, snapshot or path to existing install dir.',
|
||||
default: 'snapshot',
|
||||
},
|
||||
'kibana-install-dir': {
|
||||
|
@ -54,7 +53,7 @@ export function displayHelp() {
|
|||
};
|
||||
})
|
||||
.map(option => {
|
||||
return `--${option.usage.padEnd(28)} ${option.desc} ${option.default}`;
|
||||
return `--${option.usage.padEnd(30)} ${option.desc} ${option.default}`;
|
||||
})
|
||||
.join(`\n `);
|
||||
|
||||
|
@ -80,6 +79,10 @@ export function processOptions(userOptions, defaultConfigPath) {
|
|||
throw new Error(`functional_tests_server: config is required`);
|
||||
}
|
||||
|
||||
if (!userOptions.esFrom) {
|
||||
userOptions.esFrom = 'snapshot';
|
||||
}
|
||||
|
||||
if (userOptions['kibana-install-dir']) {
|
||||
userOptions.installDir = userOptions['kibana-install-dir'];
|
||||
delete userOptions['kibana-install-dir'];
|
||||
|
|
|
@ -65,12 +65,6 @@ describe('process options for start servers CLI', () => {
|
|||
expect(options).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('rejects non-enum value for esFrom', () => {
|
||||
expect(() => {
|
||||
processOptions({ esFrom: 'butter' }, ['foo']);
|
||||
}).toThrow('functional_tests_server: invalid argument [butter] to option [esFrom]');
|
||||
});
|
||||
|
||||
it('accepts debug option', () => {
|
||||
const options = processOptions({ debug: true }, ['foo']);
|
||||
expect(options).toMatchSnapshot();
|
||||
|
|
|
@ -126,15 +126,6 @@ describe('start servers CLI', () => {
|
|||
expect(exitMock).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('rejects non-enum value for esFrom', async () => {
|
||||
global.process.argv.push('--esFrom', 'butter');
|
||||
|
||||
await startServersCli('foo');
|
||||
|
||||
expect(exitMock).toHaveBeenCalledWith(1);
|
||||
checkMockConsoleLogSnapshot(logMock);
|
||||
});
|
||||
|
||||
it('accepts debug option', async () => {
|
||||
global.process.argv.push('--debug');
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ import { createEsTestCluster } from '../../es';
|
|||
import { setupUsers, DEFAULT_SUPERUSER_PASS } from './auth';
|
||||
|
||||
export async function runElasticsearch({ config, options }) {
|
||||
const { log, esFrom } = options;
|
||||
const { log, esFrom, esInstallDir } = options;
|
||||
const isOss = config.get('esTestCluster.license') === 'oss';
|
||||
|
||||
const cluster = createEsTestCluster({
|
||||
|
@ -34,6 +34,7 @@ export async function runElasticsearch({ config, options }) {
|
|||
log,
|
||||
basePath: resolve(KIBANA_ROOT, '.es'),
|
||||
esFrom: esFrom || config.get('esTestCluster.from'),
|
||||
esInstallDir,
|
||||
});
|
||||
|
||||
const esArgs = config.get('esTestCluster.serverArgs');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue