Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Rename] kbn-test in packages directory to osd-test/#37 [2] #54

Merged
merged 5 commits into from
Mar 8, 2021
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 0 additions & 69 deletions packages/kbn-test/src/functional_tests/lib/run_elasticsearch.js

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,23 @@
import { resolve } from 'path';

import dedent from 'dedent';
import { ToolingLog, pickLevelFromFlags } from '@kbn/dev-utils';
import { ToolingLog, pickLevelFromFlags } from '@osd/dev-utils';

const options = {
help: { desc: 'Display this menu and exit.' },
config: {
arg: '<file>',
desc: 'Pass in a config. Can pass in multiple configs.',
},
esFrom: {
opensearchFrom: {
arg: '<snapshot|source>',
choices: ['snapshot', 'source'],
desc: 'Build Elasticsearch from source or run from snapshot.',
defaultHelp: 'Default: $TEST_ES_FROM or snapshot',
defaultHelp: 'Default: $TEST_OPENSEARCH_FROM or snapshot',
},
'kibana-install-dir': {
'opensearch-dashboards-install-dir': {
arg: '<dir>',
desc: 'Run Kibana from existing install directory instead of from source.',
desc: 'Run Opensearch Dashboards from existing install directory instead of from source.',
},
bail: { desc: 'Stop the test run at the first failure.' },
grep: {
Expand Down Expand Up @@ -114,13 +114,13 @@ export function processOptions(userOptions, defaultConfigPaths) {
}
}

if (!userOptions.esFrom) {
userOptions.esFrom = process.env.TEST_ES_FROM || 'snapshot';
if (!userOptions.opensearchFrom) {
userOptions.opensearchFrom = process.env.TEST_OPENSEARCH_FROM || 'snapshot';
}

if (userOptions['kibana-install-dir']) {
userOptions.installDir = userOptions['kibana-install-dir'];
delete userOptions['kibana-install-dir'];
if (userOptions['opensearch-dashboards-install-dir']) {
userOptions.installDir = userOptions['opensearch-dashboards-install-dir'];
delete userOptions['opensearch-dashboards-install-dir'];
}

userOptions.suiteFiles = {
Expand Down Expand Up @@ -151,7 +151,7 @@ export function processOptions(userOptions, defaultConfigPaths) {
...userOptions,
configs: configs.map((c) => resolve(c)),
createLogger,
extraKbnOpts: userOptions._,
extraOsdOpts: userOptions._,
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@
*/

import { displayHelp, processOptions } from './args';
import { createAbsolutePathSerializer } from '@kbn/dev-utils';
import { createAbsolutePathSerializer } from '@osd/dev-utils';

expect.addSnapshotSerializer(createAbsolutePathSerializer(process.cwd()));

const INITIAL_TEST_ES_FROM = process.env.TEST_ES_FROM;
const INITIAL_TEST_OPENSEARCH_FROM = process.env.TEST_OPENSEARCH_FROM;
beforeEach(() => {
process.env.TEST_ES_FROM = 'snapshot';
process.env.TEST_OPENSEARCH_FROM = 'snapshot';
});
afterEach(() => {
process.env.TEST_ES_FROM = INITIAL_TEST_ES_FROM;
process.env.TEST_OPENSEARCH_FROM = INITIAL_TEST_OPENSEARCH_FROM;
});

describe('display help for run tests CLI', () => {
Expand Down Expand Up @@ -60,43 +60,43 @@ describe('process options for run tests CLI', () => {
}).toThrow('functional_tests: invalid argument [peanut] to option [bail]');
});

it('accepts string value for kibana-install-dir', () => {
const options = processOptions({ 'kibana-install-dir': 'foo' }, ['foo']);
it('accepts string value for opensearch-dashboards-install-dir', () => {
const options = processOptions({ 'opensearch-dashboards-install-dir': 'foo' }, ['foo']);
expect(options).toMatchSnapshot();
});

it('rejects boolean value for kibana-install-dir', () => {
it('rejects boolean value for opensearch-dashboards-install-dir', () => {
expect(() => {
processOptions({ 'kibana-install-dir': true }, ['foo']);
}).toThrow('functional_tests: invalid argument [true] to option [kibana-install-dir]');
processOptions({ 'opensearch-dashboards-install-dir': true }, ['foo']);
}).toThrow('functional_tests: invalid argument [true] to option [opensearch-dashboards-install-dir]');
});

it('accepts boolean value for updateBaselines', () => {
const options = processOptions({ updateBaselines: true }, ['foo']);
expect(options).toMatchSnapshot();
});

it('accepts source value for esFrom', () => {
const options = processOptions({ esFrom: 'source' }, ['foo']);
it('accepts source value for opensearchFrom', () => {
const options = processOptions({ opensearchFrom: 'source' }, ['foo']);
expect(options).toMatchSnapshot();
});

it('accepts source value for $TEST_ES_FROM', () => {
process.env.TEST_ES_FROM = 'source';
it('accepts source value for $TEST_OPENSEARCH_FROM', () => {
process.env.TEST_OPENSEARCH_FROM = 'source';
const options = processOptions({}, ['foo']);
expect(options).toMatchSnapshot();
});

it('prioritizes source flag over $TEST_ES_FROM', () => {
process.env.TEST_ES_FROM = 'source';
const options = processOptions({ esFrom: 'snapshot' }, ['foo']);
it('prioritizes source flag over $TEST_OPENSEARCH_FROM', () => {
process.env.TEST_OPENSEARCH_FROM = 'source';
const options = processOptions({ opensearchFrom: 'snapshot' }, ['foo']);
expect(options).toMatchSnapshot();
});

it('rejects non-enum value for esFrom', () => {
it('rejects non-enum value for opensearchFrom', () => {
expect(() => {
processOptions({ esFrom: 'butter' }, ['foo']);
}).toThrow('functional_tests: invalid argument [butter] to option [esFrom]');
processOptions({ opensearchFrom: 'butter' }, ['foo']);
}).toThrow('functional_tests: invalid argument [butter] to option [opensearchFrom]');
});

it('accepts value for grep', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ describe('run tests CLI', () => {
cwd: jest.fn(),
env: {
...originalObjects.process.env,
TEST_ES_FROM: 'snapshot',
TEST_OPENSEARCH_FROM: 'snapshot',
},
};

Expand All @@ -60,7 +60,7 @@ describe('run tests CLI', () => {
global.process.argv = [...argvMock];
global.process.env = {
...originalObjects.process.env,
TEST_ES_FROM: 'snapshot',
TEST_OPENSEARCH_FROM: 'snapshot',
};
jest.resetAllMocks();
});
Expand Down Expand Up @@ -100,16 +100,16 @@ describe('run tests CLI', () => {
checkMockConsoleLogSnapshot(logMock);
});

it('accepts string value for kibana-install-dir', async () => {
global.process.argv.push('--kibana-install-dir', 'foo');
it('accepts string value for opensearch-dashboards-install-dir', async () => {
global.process.argv.push('--opensearch-dashboards-install-dir', 'foo');

await runTestsCli(['foo']);

expect(exitMock).not.toHaveBeenCalled();
});

it('rejects boolean value for kibana-install-dir', async () => {
global.process.argv.push('--kibana-install-dir');
it('rejects boolean value for opensearch-dashboards-install-dir', async () => {
global.process.argv.push('--opensearch-dashboards-install-dir');

await runTestsCli(['foo']);

Expand All @@ -125,16 +125,16 @@ describe('run tests CLI', () => {
expect(exitMock).not.toHaveBeenCalledWith();
});

it('accepts source value for esFrom', async () => {
global.process.argv.push('--esFrom', 'source');
it('accepts source value for opensearchFrom', async () => {
global.process.argv.push('--opensearchFrom', 'source');

await runTestsCli(['foo']);

expect(exitMock).not.toHaveBeenCalled();
});

it('rejects non-enum value for esFrom', async () => {
global.process.argv.push('--esFrom', 'butter');
it('rejects non-enum value for opensearchFrom', async () => {
global.process.argv.push('--opensearchFrom', 'butter');

await runTestsCli(['foo']);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,22 @@
import { resolve } from 'path';

import dedent from 'dedent';
import { ToolingLog, pickLevelFromFlags } from '@kbn/dev-utils';
import { ToolingLog, pickLevelFromFlags } from '@osd/dev-utils';

const options = {
help: { desc: 'Display this menu and exit.' },
config: {
arg: '<file>',
desc: 'Pass in a config',
},
esFrom: {
opensearchFrom: {
arg: '<snapshot|source|path>',
desc: 'Build Elasticsearch from source, snapshot or path to existing install dir.',
defaultHelp: 'Default: $TEST_ES_FROM or snapshot',
defaultHelp: 'Default: $TEST_OPENSEARCH_FROM or snapshot',
},
'kibana-install-dir': {
'opensearch-dashboards-install-dir': {
arg: '<dir>',
desc: 'Run Kibana from existing install directory instead of from source.',
desc: 'Run Opensearch Dashboards from existing install directory instead of from source.',
},
verbose: { desc: 'Log everything.' },
debug: { desc: 'Run in debug mode.' },
Expand Down Expand Up @@ -81,13 +81,13 @@ export function processOptions(userOptions, defaultConfigPath) {
throw new Error(`functional_tests_server: config is required`);
}

if (!userOptions.esFrom) {
userOptions.esFrom = process.env.TEST_ES_FROM || 'snapshot';
if (!userOptions.opensearchFrom) {
userOptions.opensearchFrom = process.env.TEST_OPENSEARCH_FROM || 'snapshot';
}

if (userOptions['kibana-install-dir']) {
userOptions.installDir = userOptions['kibana-install-dir'];
delete userOptions['kibana-install-dir'];
if (userOptions['opensearch-dashboards-install-dir']) {
userOptions.installDir = userOptions['opensearch-dashboards-install-dir'];
delete userOptions['opensearch-dashboards-install-dir'];
}

function createLogger() {
Expand All @@ -101,7 +101,7 @@ export function processOptions(userOptions, defaultConfigPath) {
...userOptions,
config: resolve(config),
createLogger,
extraKbnOpts: userOptions._,
extraOsdOpts: userOptions._,
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@
*/

import { displayHelp, processOptions } from './args';
import { createAbsolutePathSerializer } from '@kbn/dev-utils';
import { createAbsolutePathSerializer } from '@osd/dev-utils';

expect.addSnapshotSerializer(createAbsolutePathSerializer(process.cwd()));

const INITIAL_TEST_ES_FROM = process.env.TEST_ES_FROM;
const INITIAL_TEST_OPENSEARCH_FROM = process.env.TEST_OPENSEARCH_FROM;
beforeEach(() => {
process.env.TEST_ES_FROM = 'snapshot';
process.env.TEST_OPENSEARCH_FROM = 'snapshot';
});
afterEach(() => {
process.env.TEST_ES_FROM = INITIAL_TEST_ES_FROM;
process.env.TEST_OPENSEARCH_FROM = INITIAL_TEST_OPENSEARCH_FROM;
});

describe('display help for start servers CLI', () => {
Expand Down Expand Up @@ -60,31 +60,31 @@ describe('process options for start servers CLI', () => {
}).toThrow('functional_tests_server: invalid option [bail]');
});

it('accepts string value for kibana-install-dir', () => {
const options = processOptions({ 'kibana-install-dir': 'foo' }, 'foo');
it('accepts string value for opensearch-dashboards-install-dir', () => {
const options = processOptions({ 'opensearch-dashboards-install-dir': 'foo' }, 'foo');
expect(options).toMatchSnapshot();
});

it('rejects boolean value for kibana-install-dir', () => {
it('rejects boolean value for opensearch-dashboards-install-dir', () => {
expect(() => {
processOptions({ 'kibana-install-dir': true }, 'foo');
}).toThrow('functional_tests_server: invalid argument [true] to option [kibana-install-dir]');
processOptions({ 'opensearch-dashboards-install-dir': true }, 'foo');
}).toThrow('functional_tests_server: invalid argument [true] to option [opensearch-dashboards-install-dir]');
});

it('accepts source value for esFrom', () => {
const options = processOptions({ esFrom: 'source' }, 'foo');
it('accepts source value for opensearchFrom', () => {
const options = processOptions({ opensearchFrom: 'source' }, 'foo');
expect(options).toMatchSnapshot();
});

it('accepts source value for $TEST_ES_FROM', () => {
process.env.TEST_ES_FROM = 'source';
it('accepts source value for $TEST_OPENSEARCH_FROM', () => {
process.env.TEST_OPENSEARCH_FROM = 'source';
const options = processOptions({}, 'foo');
expect(options).toMatchSnapshot();
});

it('prioritizes source flag over $TEST_ES_FROM', () => {
process.env.TEST_ES_FROM = 'source';
const options = processOptions({ esFrom: 'snapshot' }, 'foo');
it('prioritizes source flag over $TEST_OPENSEARCH_FROM', () => {
process.env.TEST_OPENSEARCH_FROM = 'source';
const options = processOptions({ opensearchFrom: 'snapshot' }, 'foo');
expect(options).toMatchSnapshot();
});

Expand Down
Loading