From 24fda7ed565652203eba3040c74b8b9be2171a8d Mon Sep 17 00:00:00 2001 From: Mihir Soni Date: Wed, 3 Mar 2021 22:15:41 +0000 Subject: [PATCH 1/8] [Rename] kbn-test in packages directory to osd-test/functional_test_runner Signed-off-by: Mihir Soni --- .../__tests__/fixtures/failure_hooks/config.js | 0 .../fixtures/failure_hooks/tests/after_hook.js | 0 .../fixtures/failure_hooks/tests/before_hook.js | 0 .../__tests__/fixtures/failure_hooks/tests/it.js | 0 .../__tests__/fixtures/simple_project/config.js | 0 .../__tests__/fixtures/simple_project/tests.js | 2 +- .../__tests__/integration/basic.js | 4 ++-- .../__tests__/integration/failure_hooks.js | 4 ++-- .../src/functional_test_runner/cli.ts | 12 ++++++------ .../functional_test_runner/fake_mocha_types.d.ts | 0 .../functional_test_runner.ts | 2 +- .../src/functional_test_runner/index.ts | 0 .../lib/config/__tests__/fixtures/config.1.js | 0 .../lib/config/__tests__/fixtures/config.2.js | 0 .../lib/config/__tests__/fixtures/config.3.js | 0 .../lib/config/__tests__/fixtures/config.4.js | 0 .../config/__tests__/fixtures/config.invalid.js | 0 .../lib/config/__tests__/read_config_file.js | 4 ++-- .../functional_test_runner/lib/config/config.ts | 0 .../functional_test_runner/lib/config/index.ts | 0 .../lib/config/read_config_file.ts | 2 +- .../functional_test_runner/lib/config/schema.ts | 16 ++++++++-------- .../lib/docker_servers/README.md | 2 +- .../lib/docker_servers/container_logs.ts | 2 +- .../lib/docker_servers/container_running.ts | 2 +- .../define_docker_servers_config.ts | 0 .../lib/docker_servers/docker_servers_service.ts | 2 +- .../lib/docker_servers/index.ts | 0 .../lib/failure_metadata.test.ts | 0 .../lib/failure_metadata.ts | 2 +- .../src/functional_test_runner/lib/index.ts | 0 .../src/functional_test_runner/lib/lifecycle.ts | 0 .../lib/lifecycle_event.ts | 0 .../lib/lifecycle_phase.test.ts | 0 .../lib/lifecycle_phase.ts | 0 .../functional_test_runner/lib/load_tracer.ts | 0 .../lib/mocha/assignment_proxy.js | 0 .../lib/mocha/decorate_mocha_ui.js | 2 +- .../lib/mocha/filter_suites_by_tags.js | 0 .../lib/mocha/filter_suites_by_tags.test.js | 0 .../functional_test_runner/lib/mocha/index.ts | 0 .../lib/mocha/load_test_files.js | 2 +- .../lib/mocha/reporter/colors.js | 0 .../lib/mocha/reporter/index.js | 0 .../lib/mocha/reporter/ms.js | 0 .../lib/mocha/reporter/reporter.js | 2 +- .../lib/mocha/reporter/symbols.js | 0 .../lib/mocha/reporter/write_epilogue.js | 0 .../lib/mocha/run_tests.ts | 0 .../lib/mocha/setup_mocha.js | 2 +- .../lib/mocha/wrap_function.js | 0 .../lib/mocha/wrap_runnable_args.js | 0 .../lib/providers/async_instance.ts | 0 .../lib/providers/index.ts | 0 .../lib/providers/provider_collection.ts | 2 +- .../lib/providers/read_provider_spec.ts | 0 .../lib/providers/verbose_instance.ts | 2 +- .../lib/suite_tracker.test.ts | 4 ++-- .../functional_test_runner/lib/suite_tracker.ts | 2 +- 59 files changed, 37 insertions(+), 37 deletions(-) rename packages/{kbn-test => osd-test}/src/functional_test_runner/__tests__/fixtures/failure_hooks/config.js (100%) rename packages/{kbn-test => osd-test}/src/functional_test_runner/__tests__/fixtures/failure_hooks/tests/after_hook.js (100%) rename packages/{kbn-test => osd-test}/src/functional_test_runner/__tests__/fixtures/failure_hooks/tests/before_hook.js (100%) rename packages/{kbn-test => osd-test}/src/functional_test_runner/__tests__/fixtures/failure_hooks/tests/it.js (100%) rename packages/{kbn-test => osd-test}/src/functional_test_runner/__tests__/fixtures/simple_project/config.js (100%) rename packages/{kbn-test => osd-test}/src/functional_test_runner/__tests__/fixtures/simple_project/tests.js (96%) rename packages/{kbn-test => osd-test}/src/functional_test_runner/__tests__/integration/basic.js (95%) rename packages/{kbn-test => osd-test}/src/functional_test_runner/__tests__/integration/failure_hooks.js (97%) rename packages/{kbn-test => osd-test}/src/functional_test_runner/cli.ts (91%) rename packages/{kbn-test => osd-test}/src/functional_test_runner/fake_mocha_types.d.ts (100%) rename packages/{kbn-test => osd-test}/src/functional_test_runner/functional_test_runner.ts (99%) rename packages/{kbn-test => osd-test}/src/functional_test_runner/index.ts (100%) rename packages/{kbn-test => osd-test}/src/functional_test_runner/lib/config/__tests__/fixtures/config.1.js (100%) rename packages/{kbn-test => osd-test}/src/functional_test_runner/lib/config/__tests__/fixtures/config.2.js (100%) rename packages/{kbn-test => osd-test}/src/functional_test_runner/lib/config/__tests__/fixtures/config.3.js (100%) rename packages/{kbn-test => osd-test}/src/functional_test_runner/lib/config/__tests__/fixtures/config.4.js (100%) rename packages/{kbn-test => osd-test}/src/functional_test_runner/lib/config/__tests__/fixtures/config.invalid.js (100%) rename packages/{kbn-test => osd-test}/src/functional_test_runner/lib/config/__tests__/read_config_file.js (96%) rename packages/{kbn-test => osd-test}/src/functional_test_runner/lib/config/config.ts (100%) rename packages/{kbn-test => osd-test}/src/functional_test_runner/lib/config/index.ts (100%) rename packages/{kbn-test => osd-test}/src/functional_test_runner/lib/config/read_config_file.ts (97%) rename packages/{kbn-test => osd-test}/src/functional_test_runner/lib/config/schema.ts (95%) rename packages/{kbn-test => osd-test}/src/functional_test_runner/lib/docker_servers/README.md (98%) rename packages/{kbn-test => osd-test}/src/functional_test_runner/lib/docker_servers/container_logs.ts (96%) rename packages/{kbn-test => osd-test}/src/functional_test_runner/lib/docker_servers/container_running.ts (97%) rename packages/{kbn-test => osd-test}/src/functional_test_runner/lib/docker_servers/define_docker_servers_config.ts (100%) rename packages/{kbn-test => osd-test}/src/functional_test_runner/lib/docker_servers/docker_servers_service.ts (99%) rename packages/{kbn-test => osd-test}/src/functional_test_runner/lib/docker_servers/index.ts (100%) rename packages/{kbn-test => osd-test}/src/functional_test_runner/lib/failure_metadata.test.ts (100%) rename packages/{kbn-test => osd-test}/src/functional_test_runner/lib/failure_metadata.ts (98%) rename packages/{kbn-test => osd-test}/src/functional_test_runner/lib/index.ts (100%) rename packages/{kbn-test => osd-test}/src/functional_test_runner/lib/lifecycle.ts (100%) rename packages/{kbn-test => osd-test}/src/functional_test_runner/lib/lifecycle_event.ts (100%) rename packages/{kbn-test => osd-test}/src/functional_test_runner/lib/lifecycle_phase.test.ts (100%) rename packages/{kbn-test => osd-test}/src/functional_test_runner/lib/lifecycle_phase.ts (100%) rename packages/{kbn-test => osd-test}/src/functional_test_runner/lib/load_tracer.ts (100%) rename packages/{kbn-test => osd-test}/src/functional_test_runner/lib/mocha/assignment_proxy.js (100%) rename packages/{kbn-test => osd-test}/src/functional_test_runner/lib/mocha/decorate_mocha_ui.js (99%) rename packages/{kbn-test => osd-test}/src/functional_test_runner/lib/mocha/filter_suites_by_tags.js (100%) rename packages/{kbn-test => osd-test}/src/functional_test_runner/lib/mocha/filter_suites_by_tags.test.js (100%) rename packages/{kbn-test => osd-test}/src/functional_test_runner/lib/mocha/index.ts (100%) rename packages/{kbn-test => osd-test}/src/functional_test_runner/lib/mocha/load_test_files.js (96%) rename packages/{kbn-test => osd-test}/src/functional_test_runner/lib/mocha/reporter/colors.js (100%) rename packages/{kbn-test => osd-test}/src/functional_test_runner/lib/mocha/reporter/index.js (100%) rename packages/{kbn-test => osd-test}/src/functional_test_runner/lib/mocha/reporter/ms.js (100%) rename packages/{kbn-test => osd-test}/src/functional_test_runner/lib/mocha/reporter/reporter.js (99%) rename packages/{kbn-test => osd-test}/src/functional_test_runner/lib/mocha/reporter/symbols.js (100%) rename packages/{kbn-test => osd-test}/src/functional_test_runner/lib/mocha/reporter/write_epilogue.js (100%) rename packages/{kbn-test => osd-test}/src/functional_test_runner/lib/mocha/run_tests.ts (100%) rename packages/{kbn-test => osd-test}/src/functional_test_runner/lib/mocha/setup_mocha.js (98%) rename packages/{kbn-test => osd-test}/src/functional_test_runner/lib/mocha/wrap_function.js (100%) rename packages/{kbn-test => osd-test}/src/functional_test_runner/lib/mocha/wrap_runnable_args.js (100%) rename packages/{kbn-test => osd-test}/src/functional_test_runner/lib/providers/async_instance.ts (100%) rename packages/{kbn-test => osd-test}/src/functional_test_runner/lib/providers/index.ts (100%) rename packages/{kbn-test => osd-test}/src/functional_test_runner/lib/providers/provider_collection.ts (98%) rename packages/{kbn-test => osd-test}/src/functional_test_runner/lib/providers/read_provider_spec.ts (100%) rename packages/{kbn-test => osd-test}/src/functional_test_runner/lib/providers/verbose_instance.ts (98%) rename packages/{kbn-test => osd-test}/src/functional_test_runner/lib/suite_tracker.test.ts (98%) rename packages/{kbn-test => osd-test}/src/functional_test_runner/lib/suite_tracker.ts (99%) diff --git a/packages/kbn-test/src/functional_test_runner/__tests__/fixtures/failure_hooks/config.js b/packages/osd-test/src/functional_test_runner/__tests__/fixtures/failure_hooks/config.js similarity index 100% rename from packages/kbn-test/src/functional_test_runner/__tests__/fixtures/failure_hooks/config.js rename to packages/osd-test/src/functional_test_runner/__tests__/fixtures/failure_hooks/config.js diff --git a/packages/kbn-test/src/functional_test_runner/__tests__/fixtures/failure_hooks/tests/after_hook.js b/packages/osd-test/src/functional_test_runner/__tests__/fixtures/failure_hooks/tests/after_hook.js similarity index 100% rename from packages/kbn-test/src/functional_test_runner/__tests__/fixtures/failure_hooks/tests/after_hook.js rename to packages/osd-test/src/functional_test_runner/__tests__/fixtures/failure_hooks/tests/after_hook.js diff --git a/packages/kbn-test/src/functional_test_runner/__tests__/fixtures/failure_hooks/tests/before_hook.js b/packages/osd-test/src/functional_test_runner/__tests__/fixtures/failure_hooks/tests/before_hook.js similarity index 100% rename from packages/kbn-test/src/functional_test_runner/__tests__/fixtures/failure_hooks/tests/before_hook.js rename to packages/osd-test/src/functional_test_runner/__tests__/fixtures/failure_hooks/tests/before_hook.js diff --git a/packages/kbn-test/src/functional_test_runner/__tests__/fixtures/failure_hooks/tests/it.js b/packages/osd-test/src/functional_test_runner/__tests__/fixtures/failure_hooks/tests/it.js similarity index 100% rename from packages/kbn-test/src/functional_test_runner/__tests__/fixtures/failure_hooks/tests/it.js rename to packages/osd-test/src/functional_test_runner/__tests__/fixtures/failure_hooks/tests/it.js diff --git a/packages/kbn-test/src/functional_test_runner/__tests__/fixtures/simple_project/config.js b/packages/osd-test/src/functional_test_runner/__tests__/fixtures/simple_project/config.js similarity index 100% rename from packages/kbn-test/src/functional_test_runner/__tests__/fixtures/simple_project/config.js rename to packages/osd-test/src/functional_test_runner/__tests__/fixtures/simple_project/config.js diff --git a/packages/kbn-test/src/functional_test_runner/__tests__/fixtures/simple_project/tests.js b/packages/osd-test/src/functional_test_runner/__tests__/fixtures/simple_project/tests.js similarity index 96% rename from packages/kbn-test/src/functional_test_runner/__tests__/fixtures/simple_project/tests.js rename to packages/osd-test/src/functional_test_runner/__tests__/fixtures/simple_project/tests.js index 02e49fefc587..471b1adec85b 100644 --- a/packages/kbn-test/src/functional_test_runner/__tests__/fixtures/simple_project/tests.js +++ b/packages/osd-test/src/functional_test_runner/__tests__/fixtures/simple_project/tests.js @@ -17,7 +17,7 @@ * under the License. */ -import expect from '@kbn/expect'; +import expect from '@osd/expect'; export default () => { describe('app one', () => { diff --git a/packages/kbn-test/src/functional_test_runner/__tests__/integration/basic.js b/packages/osd-test/src/functional_test_runner/__tests__/integration/basic.js similarity index 95% rename from packages/kbn-test/src/functional_test_runner/__tests__/integration/basic.js rename to packages/osd-test/src/functional_test_runner/__tests__/integration/basic.js index a010d9f0b038..c9c257bed85d 100644 --- a/packages/kbn-test/src/functional_test_runner/__tests__/integration/basic.js +++ b/packages/osd-test/src/functional_test_runner/__tests__/integration/basic.js @@ -20,8 +20,8 @@ import { spawnSync } from 'child_process'; import { resolve } from 'path'; -import expect from '@kbn/expect'; -import { REPO_ROOT } from '@kbn/utils'; +import expect from '@osd/expect'; +import { REPO_ROOT } from '@osd/utils'; const SCRIPT = resolve(REPO_ROOT, 'scripts/functional_test_runner.js'); const BASIC_CONFIG = require.resolve('../fixtures/simple_project/config.js'); diff --git a/packages/kbn-test/src/functional_test_runner/__tests__/integration/failure_hooks.js b/packages/osd-test/src/functional_test_runner/__tests__/integration/failure_hooks.js similarity index 97% rename from packages/kbn-test/src/functional_test_runner/__tests__/integration/failure_hooks.js rename to packages/osd-test/src/functional_test_runner/__tests__/integration/failure_hooks.js index fa4ef88fd3e7..ab82ff75c26f 100644 --- a/packages/kbn-test/src/functional_test_runner/__tests__/integration/failure_hooks.js +++ b/packages/osd-test/src/functional_test_runner/__tests__/integration/failure_hooks.js @@ -21,8 +21,8 @@ import { spawnSync } from 'child_process'; import { resolve } from 'path'; import stripAnsi from 'strip-ansi'; -import expect from '@kbn/expect'; -import { REPO_ROOT } from '@kbn/utils'; +import expect from '@osd/expect'; +import { REPO_ROOT } from '@osd/utils'; const SCRIPT = resolve(REPO_ROOT, 'scripts/functional_test_runner.js'); const FAILURE_HOOKS_CONFIG = require.resolve('../fixtures/failure_hooks/config.js'); diff --git a/packages/kbn-test/src/functional_test_runner/cli.ts b/packages/osd-test/src/functional_test_runner/cli.ts similarity index 91% rename from packages/kbn-test/src/functional_test_runner/cli.ts rename to packages/osd-test/src/functional_test_runner/cli.ts index 8a2075b2e7bd..5f17d8d8e497 100644 --- a/packages/kbn-test/src/functional_test_runner/cli.ts +++ b/packages/osd-test/src/functional_test_runner/cli.ts @@ -20,7 +20,7 @@ import { resolve } from 'path'; import { inspect } from 'util'; -import { run, createFlagError, Flags } from '@kbn/dev-utils'; +import { run, createFlagError, Flags } from '@osd/dev-utils'; import exitHook from 'exit-hook'; import { FunctionalTestRunner } from './functional_test_runner'; @@ -28,10 +28,10 @@ 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']; + const flag = flags['opensearch-dashboards-install-dir']; if (typeof flag !== 'string' && flag !== undefined) { - throw createFlagError('--kibana-install-dir must be a string or not defined'); + throw createFlagError('--opensearch-dashboards-install-dir must be a string or not defined'); } return flag ? makeAbsolutePath(flag) : undefined; @@ -49,7 +49,7 @@ export function runFtrCli() { grep: flags.grep || undefined, invert: flags.invert, }, - kbnTestServer: { + osdTestServer: { installDir: parseInstallDir(flags), }, suiteFiles: { @@ -116,7 +116,7 @@ export function runFtrCli() { 'exclude', 'include-tag', 'exclude-tag', - 'kibana-install-dir', + 'opensearch-dashboards-install-dir', ], boolean: ['bail', 'invert', 'test-stats', 'updateBaselines'], default: { @@ -133,7 +133,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 + --opensearch-dashboards-install-dir directory where the OpenSearch Dashbaords install being tested resides `, }, } diff --git a/packages/kbn-test/src/functional_test_runner/fake_mocha_types.d.ts b/packages/osd-test/src/functional_test_runner/fake_mocha_types.d.ts similarity index 100% rename from packages/kbn-test/src/functional_test_runner/fake_mocha_types.d.ts rename to packages/osd-test/src/functional_test_runner/fake_mocha_types.d.ts diff --git a/packages/kbn-test/src/functional_test_runner/functional_test_runner.ts b/packages/osd-test/src/functional_test_runner/functional_test_runner.ts similarity index 99% rename from packages/kbn-test/src/functional_test_runner/functional_test_runner.ts rename to packages/osd-test/src/functional_test_runner/functional_test_runner.ts index 24f5cdceac95..92edaf02664f 100644 --- a/packages/kbn-test/src/functional_test_runner/functional_test_runner.ts +++ b/packages/osd-test/src/functional_test_runner/functional_test_runner.ts @@ -17,7 +17,7 @@ * under the License. */ -import { ToolingLog } from '@kbn/dev-utils'; +import { ToolingLog } from '@osd/dev-utils'; import { Suite, Test } from './fake_mocha_types'; import { diff --git a/packages/kbn-test/src/functional_test_runner/index.ts b/packages/osd-test/src/functional_test_runner/index.ts similarity index 100% rename from packages/kbn-test/src/functional_test_runner/index.ts rename to packages/osd-test/src/functional_test_runner/index.ts diff --git a/packages/kbn-test/src/functional_test_runner/lib/config/__tests__/fixtures/config.1.js b/packages/osd-test/src/functional_test_runner/lib/config/__tests__/fixtures/config.1.js similarity index 100% rename from packages/kbn-test/src/functional_test_runner/lib/config/__tests__/fixtures/config.1.js rename to packages/osd-test/src/functional_test_runner/lib/config/__tests__/fixtures/config.1.js diff --git a/packages/kbn-test/src/functional_test_runner/lib/config/__tests__/fixtures/config.2.js b/packages/osd-test/src/functional_test_runner/lib/config/__tests__/fixtures/config.2.js similarity index 100% rename from packages/kbn-test/src/functional_test_runner/lib/config/__tests__/fixtures/config.2.js rename to packages/osd-test/src/functional_test_runner/lib/config/__tests__/fixtures/config.2.js diff --git a/packages/kbn-test/src/functional_test_runner/lib/config/__tests__/fixtures/config.3.js b/packages/osd-test/src/functional_test_runner/lib/config/__tests__/fixtures/config.3.js similarity index 100% rename from packages/kbn-test/src/functional_test_runner/lib/config/__tests__/fixtures/config.3.js rename to packages/osd-test/src/functional_test_runner/lib/config/__tests__/fixtures/config.3.js diff --git a/packages/kbn-test/src/functional_test_runner/lib/config/__tests__/fixtures/config.4.js b/packages/osd-test/src/functional_test_runner/lib/config/__tests__/fixtures/config.4.js similarity index 100% rename from packages/kbn-test/src/functional_test_runner/lib/config/__tests__/fixtures/config.4.js rename to packages/osd-test/src/functional_test_runner/lib/config/__tests__/fixtures/config.4.js diff --git a/packages/kbn-test/src/functional_test_runner/lib/config/__tests__/fixtures/config.invalid.js b/packages/osd-test/src/functional_test_runner/lib/config/__tests__/fixtures/config.invalid.js similarity index 100% rename from packages/kbn-test/src/functional_test_runner/lib/config/__tests__/fixtures/config.invalid.js rename to packages/osd-test/src/functional_test_runner/lib/config/__tests__/fixtures/config.invalid.js diff --git a/packages/kbn-test/src/functional_test_runner/lib/config/__tests__/read_config_file.js b/packages/osd-test/src/functional_test_runner/lib/config/__tests__/read_config_file.js similarity index 96% rename from packages/kbn-test/src/functional_test_runner/lib/config/__tests__/read_config_file.js rename to packages/osd-test/src/functional_test_runner/lib/config/__tests__/read_config_file.js index 8d02e7262409..4f11b7a52e27 100644 --- a/packages/kbn-test/src/functional_test_runner/lib/config/__tests__/read_config_file.js +++ b/packages/osd-test/src/functional_test_runner/lib/config/__tests__/read_config_file.js @@ -17,9 +17,9 @@ * under the License. */ -import expect from '@kbn/expect'; +import expect from '@osd/expect'; -import { ToolingLog } from '@kbn/dev-utils'; +import { ToolingLog } from '@osd/dev-utils'; import { readConfigFile } from '../read_config_file'; import { Config } from '../config'; diff --git a/packages/kbn-test/src/functional_test_runner/lib/config/config.ts b/packages/osd-test/src/functional_test_runner/lib/config/config.ts similarity index 100% rename from packages/kbn-test/src/functional_test_runner/lib/config/config.ts rename to packages/osd-test/src/functional_test_runner/lib/config/config.ts diff --git a/packages/kbn-test/src/functional_test_runner/lib/config/index.ts b/packages/osd-test/src/functional_test_runner/lib/config/index.ts similarity index 100% rename from packages/kbn-test/src/functional_test_runner/lib/config/index.ts rename to packages/osd-test/src/functional_test_runner/lib/config/index.ts diff --git a/packages/kbn-test/src/functional_test_runner/lib/config/read_config_file.ts b/packages/osd-test/src/functional_test_runner/lib/config/read_config_file.ts similarity index 97% rename from packages/kbn-test/src/functional_test_runner/lib/config/read_config_file.ts rename to packages/osd-test/src/functional_test_runner/lib/config/read_config_file.ts index 2e40aeec4f43..6388df13838b 100644 --- a/packages/kbn-test/src/functional_test_runner/lib/config/read_config_file.ts +++ b/packages/osd-test/src/functional_test_runner/lib/config/read_config_file.ts @@ -17,7 +17,7 @@ * under the License. */ -import { ToolingLog } from '@kbn/dev-utils'; +import { ToolingLog } from '@osd/dev-utils'; import { defaultsDeep } from 'lodash'; import { Config } from './config'; diff --git a/packages/kbn-test/src/functional_test_runner/lib/config/schema.ts b/packages/osd-test/src/functional_test_runner/lib/config/schema.ts similarity index 95% rename from packages/kbn-test/src/functional_test_runner/lib/config/schema.ts rename to packages/osd-test/src/functional_test_runner/lib/config/schema.ts index 6ed114d62e24..9c093ef6b475 100644 --- a/packages/kbn-test/src/functional_test_runner/lib/config/schema.ts +++ b/packages/osd-test/src/functional_test_runner/lib/config/schema.ts @@ -105,8 +105,8 @@ export const schema = Joi.object() find: Joi.number().default(10000), try: Joi.number().default(120000), waitFor: Joi.number().default(20000), - esRequestTimeout: Joi.number().default(30000), - kibanaStabilize: Joi.number().default(15000), + opensearchRequestTimeout: Joi.number().default(30000), + opensearchDashboardsStabilize: Joi.number().default(15000), navigateStatusPageCheck: Joi.number().default(250), // Many of our tests use the `exists` functions to determine where the user is. For @@ -173,8 +173,8 @@ export const schema = Joi.object() servers: Joi.object() .keys({ - kibana: urlPartsSchema(), - elasticsearch: urlPartsSchema(), + opensearchDashboards: urlPartsSchema(), + opensearch: urlPartsSchema(), }) .default(), @@ -189,7 +189,7 @@ export const schema = Joi.object() }) .default(), - kbnTestServer: Joi.object() + osdTestServer: Joi.object() .keys({ buildArgs: Joi.array(), sourceArgs: Joi.array(), @@ -217,14 +217,14 @@ export const schema = Joi.object() // definition of apps that work with `common.navigateToApp()` apps: Joi.object().pattern(ID_PATTERN, appUrlPartsSchema()).default(), - // settings for the esArchiver module - esArchiver: Joi.object() + // settings for the opensearchArchiver module + opensearchArchiver: Joi.object() .keys({ directory: Joi.string().default(defaultRelativeToConfigPath('fixtures/es_archiver')), }) .default(), - // settings for the kibanaServer.uiSettings module + // settings for the opensearchDashboardsServer.uiSettings module uiSettings: Joi.object() .keys({ defaults: Joi.object().unknown(true), diff --git a/packages/kbn-test/src/functional_test_runner/lib/docker_servers/README.md b/packages/osd-test/src/functional_test_runner/lib/docker_servers/README.md similarity index 98% rename from packages/kbn-test/src/functional_test_runner/lib/docker_servers/README.md rename to packages/osd-test/src/functional_test_runner/lib/docker_servers/README.md index d75faf4c854a..1b132b378a2a 100644 --- a/packages/kbn-test/src/functional_test_runner/lib/docker_servers/README.md +++ b/packages/osd-test/src/functional_test_runner/lib/docker_servers/README.md @@ -6,7 +6,7 @@ To configure docker servers in your FTR config add the `dockerServers` key to yo ```ts // import this helper to get TypeScript support for this section of the config -import { defineDockerServersConfig } from '@kbn/test'; +import { defineDockerServersConfig } from '@osd/test'; export default function () { return { diff --git a/packages/kbn-test/src/functional_test_runner/lib/docker_servers/container_logs.ts b/packages/osd-test/src/functional_test_runner/lib/docker_servers/container_logs.ts similarity index 96% rename from packages/kbn-test/src/functional_test_runner/lib/docker_servers/container_logs.ts rename to packages/osd-test/src/functional_test_runner/lib/docker_servers/container_logs.ts index f8e8137ce40a..58fe6be8e5a4 100644 --- a/packages/kbn-test/src/functional_test_runner/lib/docker_servers/container_logs.ts +++ b/packages/osd-test/src/functional_test_runner/lib/docker_servers/container_logs.ts @@ -20,7 +20,7 @@ import execa from 'execa'; import * as Rx from 'rxjs'; import { tap } from 'rxjs/operators'; -import { ToolingLog, observeLines } from '@kbn/dev-utils'; +import { ToolingLog, observeLines } from '@osd/dev-utils'; /** * Observe the logs for a container, reflecting the log lines diff --git a/packages/kbn-test/src/functional_test_runner/lib/docker_servers/container_running.ts b/packages/osd-test/src/functional_test_runner/lib/docker_servers/container_running.ts similarity index 97% rename from packages/kbn-test/src/functional_test_runner/lib/docker_servers/container_running.ts rename to packages/osd-test/src/functional_test_runner/lib/docker_servers/container_running.ts index 3e3247a6ae3b..27169cf4cb2d 100644 --- a/packages/kbn-test/src/functional_test_runner/lib/docker_servers/container_running.ts +++ b/packages/osd-test/src/functional_test_runner/lib/docker_servers/container_running.ts @@ -19,7 +19,7 @@ import execa from 'execa'; import * as Rx from 'rxjs'; -import { ToolingLog } from '@kbn/dev-utils'; +import { ToolingLog } from '@osd/dev-utils'; /** * Create an observable that errors if a docker diff --git a/packages/kbn-test/src/functional_test_runner/lib/docker_servers/define_docker_servers_config.ts b/packages/osd-test/src/functional_test_runner/lib/docker_servers/define_docker_servers_config.ts similarity index 100% rename from packages/kbn-test/src/functional_test_runner/lib/docker_servers/define_docker_servers_config.ts rename to packages/osd-test/src/functional_test_runner/lib/docker_servers/define_docker_servers_config.ts diff --git a/packages/kbn-test/src/functional_test_runner/lib/docker_servers/docker_servers_service.ts b/packages/osd-test/src/functional_test_runner/lib/docker_servers/docker_servers_service.ts similarity index 99% rename from packages/kbn-test/src/functional_test_runner/lib/docker_servers/docker_servers_service.ts rename to packages/osd-test/src/functional_test_runner/lib/docker_servers/docker_servers_service.ts index e5bad88e5e7b..fb6f5f4a68fd 100644 --- a/packages/kbn-test/src/functional_test_runner/lib/docker_servers/docker_servers_service.ts +++ b/packages/osd-test/src/functional_test_runner/lib/docker_servers/docker_servers_service.ts @@ -21,7 +21,7 @@ import Url from 'url'; import execa from 'execa'; import * as Rx from 'rxjs'; import { filter, take, map } from 'rxjs/operators'; -import { ToolingLog } from '@kbn/dev-utils'; +import { ToolingLog } from '@osd/dev-utils'; import { Lifecycle } from '../lifecycle'; import { observeContainerRunning } from './container_running'; diff --git a/packages/kbn-test/src/functional_test_runner/lib/docker_servers/index.ts b/packages/osd-test/src/functional_test_runner/lib/docker_servers/index.ts similarity index 100% rename from packages/kbn-test/src/functional_test_runner/lib/docker_servers/index.ts rename to packages/osd-test/src/functional_test_runner/lib/docker_servers/index.ts diff --git a/packages/kbn-test/src/functional_test_runner/lib/failure_metadata.test.ts b/packages/osd-test/src/functional_test_runner/lib/failure_metadata.test.ts similarity index 100% rename from packages/kbn-test/src/functional_test_runner/lib/failure_metadata.test.ts rename to packages/osd-test/src/functional_test_runner/lib/failure_metadata.test.ts diff --git a/packages/kbn-test/src/functional_test_runner/lib/failure_metadata.ts b/packages/osd-test/src/functional_test_runner/lib/failure_metadata.ts similarity index 98% rename from packages/kbn-test/src/functional_test_runner/lib/failure_metadata.ts rename to packages/osd-test/src/functional_test_runner/lib/failure_metadata.ts index e5c60f1d208b..d2378d40e93d 100644 --- a/packages/kbn-test/src/functional_test_runner/lib/failure_metadata.ts +++ b/packages/osd-test/src/functional_test_runner/lib/failure_metadata.ts @@ -19,7 +19,7 @@ import Path from 'path'; -import { REPO_ROOT } from '@kbn/utils'; +import { REPO_ROOT } from '@osd/utils'; import { Lifecycle } from './lifecycle'; diff --git a/packages/kbn-test/src/functional_test_runner/lib/index.ts b/packages/osd-test/src/functional_test_runner/lib/index.ts similarity index 100% rename from packages/kbn-test/src/functional_test_runner/lib/index.ts rename to packages/osd-test/src/functional_test_runner/lib/index.ts diff --git a/packages/kbn-test/src/functional_test_runner/lib/lifecycle.ts b/packages/osd-test/src/functional_test_runner/lib/lifecycle.ts similarity index 100% rename from packages/kbn-test/src/functional_test_runner/lib/lifecycle.ts rename to packages/osd-test/src/functional_test_runner/lib/lifecycle.ts diff --git a/packages/kbn-test/src/functional_test_runner/lib/lifecycle_event.ts b/packages/osd-test/src/functional_test_runner/lib/lifecycle_event.ts similarity index 100% rename from packages/kbn-test/src/functional_test_runner/lib/lifecycle_event.ts rename to packages/osd-test/src/functional_test_runner/lib/lifecycle_event.ts diff --git a/packages/kbn-test/src/functional_test_runner/lib/lifecycle_phase.test.ts b/packages/osd-test/src/functional_test_runner/lib/lifecycle_phase.test.ts similarity index 100% rename from packages/kbn-test/src/functional_test_runner/lib/lifecycle_phase.test.ts rename to packages/osd-test/src/functional_test_runner/lib/lifecycle_phase.test.ts diff --git a/packages/kbn-test/src/functional_test_runner/lib/lifecycle_phase.ts b/packages/osd-test/src/functional_test_runner/lib/lifecycle_phase.ts similarity index 100% rename from packages/kbn-test/src/functional_test_runner/lib/lifecycle_phase.ts rename to packages/osd-test/src/functional_test_runner/lib/lifecycle_phase.ts diff --git a/packages/kbn-test/src/functional_test_runner/lib/load_tracer.ts b/packages/osd-test/src/functional_test_runner/lib/load_tracer.ts similarity index 100% rename from packages/kbn-test/src/functional_test_runner/lib/load_tracer.ts rename to packages/osd-test/src/functional_test_runner/lib/load_tracer.ts diff --git a/packages/kbn-test/src/functional_test_runner/lib/mocha/assignment_proxy.js b/packages/osd-test/src/functional_test_runner/lib/mocha/assignment_proxy.js similarity index 100% rename from packages/kbn-test/src/functional_test_runner/lib/mocha/assignment_proxy.js rename to packages/osd-test/src/functional_test_runner/lib/mocha/assignment_proxy.js diff --git a/packages/kbn-test/src/functional_test_runner/lib/mocha/decorate_mocha_ui.js b/packages/osd-test/src/functional_test_runner/lib/mocha/decorate_mocha_ui.js similarity index 99% rename from packages/kbn-test/src/functional_test_runner/lib/mocha/decorate_mocha_ui.js rename to packages/osd-test/src/functional_test_runner/lib/mocha/decorate_mocha_ui.js index 92137a8c4f84..ea7ade67369c 100644 --- a/packages/kbn-test/src/functional_test_runner/lib/mocha/decorate_mocha_ui.js +++ b/packages/osd-test/src/functional_test_runner/lib/mocha/decorate_mocha_ui.js @@ -17,7 +17,7 @@ * under the License. */ import { relative } from 'path'; -import { REPO_ROOT } from '@kbn/utils'; +import { REPO_ROOT } from '@osd/utils'; import { createAssignmentProxy } from './assignment_proxy'; import { wrapFunction } from './wrap_function'; import { wrapRunnableArgs } from './wrap_runnable_args'; diff --git a/packages/kbn-test/src/functional_test_runner/lib/mocha/filter_suites_by_tags.js b/packages/osd-test/src/functional_test_runner/lib/mocha/filter_suites_by_tags.js similarity index 100% rename from packages/kbn-test/src/functional_test_runner/lib/mocha/filter_suites_by_tags.js rename to packages/osd-test/src/functional_test_runner/lib/mocha/filter_suites_by_tags.js diff --git a/packages/kbn-test/src/functional_test_runner/lib/mocha/filter_suites_by_tags.test.js b/packages/osd-test/src/functional_test_runner/lib/mocha/filter_suites_by_tags.test.js similarity index 100% rename from packages/kbn-test/src/functional_test_runner/lib/mocha/filter_suites_by_tags.test.js rename to packages/osd-test/src/functional_test_runner/lib/mocha/filter_suites_by_tags.test.js diff --git a/packages/kbn-test/src/functional_test_runner/lib/mocha/index.ts b/packages/osd-test/src/functional_test_runner/lib/mocha/index.ts similarity index 100% rename from packages/kbn-test/src/functional_test_runner/lib/mocha/index.ts rename to packages/osd-test/src/functional_test_runner/lib/mocha/index.ts diff --git a/packages/kbn-test/src/functional_test_runner/lib/mocha/load_test_files.js b/packages/osd-test/src/functional_test_runner/lib/mocha/load_test_files.js similarity index 96% rename from packages/kbn-test/src/functional_test_runner/lib/mocha/load_test_files.js rename to packages/osd-test/src/functional_test_runner/lib/mocha/load_test_files.js index 5c23be636186..f629613ab38e 100644 --- a/packages/kbn-test/src/functional_test_runner/lib/mocha/load_test_files.js +++ b/packages/osd-test/src/functional_test_runner/lib/mocha/load_test_files.js @@ -41,7 +41,7 @@ export const loadTestFiles = ({ mocha, log, lifecycle, providers, paths, updateB log.verbose('Loading test file %s', path); const testModule = require(path); // eslint-disable-line import/no-dynamic-require - const testProvider = testModule.__esModule ? testModule.default : testModule; + const testProvider = testModule.__opensearchModule ? testModule.default : testModule; runTestProvider(testProvider, path); // eslint-disable-line }); diff --git a/packages/kbn-test/src/functional_test_runner/lib/mocha/reporter/colors.js b/packages/osd-test/src/functional_test_runner/lib/mocha/reporter/colors.js similarity index 100% rename from packages/kbn-test/src/functional_test_runner/lib/mocha/reporter/colors.js rename to packages/osd-test/src/functional_test_runner/lib/mocha/reporter/colors.js diff --git a/packages/kbn-test/src/functional_test_runner/lib/mocha/reporter/index.js b/packages/osd-test/src/functional_test_runner/lib/mocha/reporter/index.js similarity index 100% rename from packages/kbn-test/src/functional_test_runner/lib/mocha/reporter/index.js rename to packages/osd-test/src/functional_test_runner/lib/mocha/reporter/index.js diff --git a/packages/kbn-test/src/functional_test_runner/lib/mocha/reporter/ms.js b/packages/osd-test/src/functional_test_runner/lib/mocha/reporter/ms.js similarity index 100% rename from packages/kbn-test/src/functional_test_runner/lib/mocha/reporter/ms.js rename to packages/osd-test/src/functional_test_runner/lib/mocha/reporter/ms.js diff --git a/packages/kbn-test/src/functional_test_runner/lib/mocha/reporter/reporter.js b/packages/osd-test/src/functional_test_runner/lib/mocha/reporter/reporter.js similarity index 99% rename from packages/kbn-test/src/functional_test_runner/lib/mocha/reporter/reporter.js rename to packages/osd-test/src/functional_test_runner/lib/mocha/reporter/reporter.js index 9f89efddf49b..6d4c10b984e0 100644 --- a/packages/kbn-test/src/functional_test_runner/lib/mocha/reporter/reporter.js +++ b/packages/osd-test/src/functional_test_runner/lib/mocha/reporter/reporter.js @@ -20,7 +20,7 @@ import { format } from 'util'; import Mocha from 'mocha'; -import { ToolingLogTextWriter } from '@kbn/dev-utils'; +import { ToolingLogTextWriter } from '@osd/dev-utils'; import moment from 'moment'; import { setupJUnitReportGeneration } from '../../../../../../../src/dev'; diff --git a/packages/kbn-test/src/functional_test_runner/lib/mocha/reporter/symbols.js b/packages/osd-test/src/functional_test_runner/lib/mocha/reporter/symbols.js similarity index 100% rename from packages/kbn-test/src/functional_test_runner/lib/mocha/reporter/symbols.js rename to packages/osd-test/src/functional_test_runner/lib/mocha/reporter/symbols.js diff --git a/packages/kbn-test/src/functional_test_runner/lib/mocha/reporter/write_epilogue.js b/packages/osd-test/src/functional_test_runner/lib/mocha/reporter/write_epilogue.js similarity index 100% rename from packages/kbn-test/src/functional_test_runner/lib/mocha/reporter/write_epilogue.js rename to packages/osd-test/src/functional_test_runner/lib/mocha/reporter/write_epilogue.js diff --git a/packages/kbn-test/src/functional_test_runner/lib/mocha/run_tests.ts b/packages/osd-test/src/functional_test_runner/lib/mocha/run_tests.ts similarity index 100% rename from packages/kbn-test/src/functional_test_runner/lib/mocha/run_tests.ts rename to packages/osd-test/src/functional_test_runner/lib/mocha/run_tests.ts diff --git a/packages/kbn-test/src/functional_test_runner/lib/mocha/setup_mocha.js b/packages/osd-test/src/functional_test_runner/lib/mocha/setup_mocha.js similarity index 98% rename from packages/kbn-test/src/functional_test_runner/lib/mocha/setup_mocha.js rename to packages/osd-test/src/functional_test_runner/lib/mocha/setup_mocha.js index 39eb69a15191..66195ac2e223 100644 --- a/packages/kbn-test/src/functional_test_runner/lib/mocha/setup_mocha.js +++ b/packages/osd-test/src/functional_test_runner/lib/mocha/setup_mocha.js @@ -19,7 +19,7 @@ import Mocha from 'mocha'; import { relative } from 'path'; -import { REPO_ROOT } from '@kbn/utils'; +import { REPO_ROOT } from '@osd/utils'; import { loadTestFiles } from './load_test_files'; import { filterSuitesByTags } from './filter_suites_by_tags'; diff --git a/packages/kbn-test/src/functional_test_runner/lib/mocha/wrap_function.js b/packages/osd-test/src/functional_test_runner/lib/mocha/wrap_function.js similarity index 100% rename from packages/kbn-test/src/functional_test_runner/lib/mocha/wrap_function.js rename to packages/osd-test/src/functional_test_runner/lib/mocha/wrap_function.js diff --git a/packages/kbn-test/src/functional_test_runner/lib/mocha/wrap_runnable_args.js b/packages/osd-test/src/functional_test_runner/lib/mocha/wrap_runnable_args.js similarity index 100% rename from packages/kbn-test/src/functional_test_runner/lib/mocha/wrap_runnable_args.js rename to packages/osd-test/src/functional_test_runner/lib/mocha/wrap_runnable_args.js diff --git a/packages/kbn-test/src/functional_test_runner/lib/providers/async_instance.ts b/packages/osd-test/src/functional_test_runner/lib/providers/async_instance.ts similarity index 100% rename from packages/kbn-test/src/functional_test_runner/lib/providers/async_instance.ts rename to packages/osd-test/src/functional_test_runner/lib/providers/async_instance.ts diff --git a/packages/kbn-test/src/functional_test_runner/lib/providers/index.ts b/packages/osd-test/src/functional_test_runner/lib/providers/index.ts similarity index 100% rename from packages/kbn-test/src/functional_test_runner/lib/providers/index.ts rename to packages/osd-test/src/functional_test_runner/lib/providers/index.ts diff --git a/packages/kbn-test/src/functional_test_runner/lib/providers/provider_collection.ts b/packages/osd-test/src/functional_test_runner/lib/providers/provider_collection.ts similarity index 98% rename from packages/kbn-test/src/functional_test_runner/lib/providers/provider_collection.ts rename to packages/osd-test/src/functional_test_runner/lib/providers/provider_collection.ts index c58747e07dcf..70b34b296a11 100644 --- a/packages/kbn-test/src/functional_test_runner/lib/providers/provider_collection.ts +++ b/packages/osd-test/src/functional_test_runner/lib/providers/provider_collection.ts @@ -17,7 +17,7 @@ * under the License. */ -import { ToolingLog } from '@kbn/dev-utils'; +import { ToolingLog } from '@osd/dev-utils'; import { loadTracer } from '../load_tracer'; import { createAsyncInstance, isAsyncInstance } from './async_instance'; diff --git a/packages/kbn-test/src/functional_test_runner/lib/providers/read_provider_spec.ts b/packages/osd-test/src/functional_test_runner/lib/providers/read_provider_spec.ts similarity index 100% rename from packages/kbn-test/src/functional_test_runner/lib/providers/read_provider_spec.ts rename to packages/osd-test/src/functional_test_runner/lib/providers/read_provider_spec.ts diff --git a/packages/kbn-test/src/functional_test_runner/lib/providers/verbose_instance.ts b/packages/osd-test/src/functional_test_runner/lib/providers/verbose_instance.ts similarity index 98% rename from packages/kbn-test/src/functional_test_runner/lib/providers/verbose_instance.ts rename to packages/osd-test/src/functional_test_runner/lib/providers/verbose_instance.ts index 1967e98306d4..8207c75e941b 100644 --- a/packages/kbn-test/src/functional_test_runner/lib/providers/verbose_instance.ts +++ b/packages/osd-test/src/functional_test_runner/lib/providers/verbose_instance.ts @@ -19,7 +19,7 @@ import { inspect } from 'util'; -import { ToolingLog } from '@kbn/dev-utils'; +import { ToolingLog } from '@osd/dev-utils'; function printArgs(args: any[]): string { return args diff --git a/packages/kbn-test/src/functional_test_runner/lib/suite_tracker.test.ts b/packages/osd-test/src/functional_test_runner/lib/suite_tracker.test.ts similarity index 98% rename from packages/kbn-test/src/functional_test_runner/lib/suite_tracker.test.ts rename to packages/osd-test/src/functional_test_runner/lib/suite_tracker.test.ts index 5350b2709843..3554df658a1e 100644 --- a/packages/kbn-test/src/functional_test_runner/lib/suite_tracker.test.ts +++ b/packages/osd-test/src/functional_test_runner/lib/suite_tracker.test.ts @@ -21,11 +21,11 @@ import fs from 'fs'; import { join, resolve } from 'path'; jest.mock('fs'); -jest.mock('@kbn/utils', () => { +jest.mock('@osd/utils', () => { return { REPO_ROOT: '/dev/null/root' }; }); -import { REPO_ROOT } from '@kbn/dev-utils'; +import { REPO_ROOT } from '@osd/dev-utils'; import { Lifecycle } from './lifecycle'; import { SuiteTracker } from './suite_tracker'; diff --git a/packages/kbn-test/src/functional_test_runner/lib/suite_tracker.ts b/packages/osd-test/src/functional_test_runner/lib/suite_tracker.ts similarity index 99% rename from packages/kbn-test/src/functional_test_runner/lib/suite_tracker.ts rename to packages/osd-test/src/functional_test_runner/lib/suite_tracker.ts index 6cbd74467106..e6f9dc166f43 100644 --- a/packages/kbn-test/src/functional_test_runner/lib/suite_tracker.ts +++ b/packages/osd-test/src/functional_test_runner/lib/suite_tracker.ts @@ -19,7 +19,7 @@ import fs from 'fs'; import { dirname, relative, resolve } from 'path'; -import { REPO_ROOT } from '@kbn/utils'; +import { REPO_ROOT } from '@osd/utils'; import { Lifecycle } from './lifecycle'; From 60e7a68b06ee317676d4166f74cfb441fc25e654 Mon Sep 17 00:00:00 2001 From: Mihir Soni Date: Wed, 3 Mar 2021 22:16:29 +0000 Subject: [PATCH 2/8] [Rename] kbn-test in packages directory to osd-test/functional_tests Signed-off-by: Mihir Soni --- .../src/functional_tests/cli/index.js | 23 -- .../run_tests/__snapshots__/args.test.js.snap | 281 ------------------ .../run_tests/__snapshots__/cli.test.js.snap | 71 ----- .../functional_tests/cli/run_tests/args.js | 180 ----------- .../cli/run_tests/args.test.js | 137 --------- .../src/functional_tests/cli/run_tests/cli.js | 37 --- .../cli/run_tests/cli.test.js | 211 ------------- .../__snapshots__/args.test.js.snap | 120 -------- .../__snapshots__/cli.test.js.snap | 43 --- .../cli/start_servers/args.js | 128 -------- .../cli/start_servers/args.test.js | 121 -------- .../functional_tests/cli/start_servers/cli.js | 34 --- .../cli/start_servers/cli.test.js | 194 ------------ .../lib/__snapshots__/run_cli.test.js.snap | 26 -- .../kbn-test/src/functional_tests/lib/auth.js | 162 ---------- .../lib/babel_register_for_test_plugins.js | 39 --- .../src/functional_tests/lib/index.js | 24 -- .../src/functional_tests/lib/paths.js | 34 --- .../src/functional_tests/lib/run_cli.js | 66 ---- .../src/functional_tests/lib/run_cli.test.js | 133 --------- .../functional_tests/lib/run_elasticsearch.js | 69 ----- .../src/functional_tests/lib/run_ftr.js | 94 ------ .../functional_tests/lib/run_kibana_server.js | 143 --------- .../kbn-test/src/functional_tests/tasks.js | 166 ----------- .../src/functional_tests/test_helpers.js | 30 -- 25 files changed, 2566 deletions(-) delete mode 100644 packages/kbn-test/src/functional_tests/cli/index.js delete mode 100644 packages/kbn-test/src/functional_tests/cli/run_tests/__snapshots__/args.test.js.snap delete mode 100644 packages/kbn-test/src/functional_tests/cli/run_tests/__snapshots__/cli.test.js.snap delete mode 100644 packages/kbn-test/src/functional_tests/cli/run_tests/args.js delete mode 100644 packages/kbn-test/src/functional_tests/cli/run_tests/args.test.js delete mode 100644 packages/kbn-test/src/functional_tests/cli/run_tests/cli.js delete mode 100644 packages/kbn-test/src/functional_tests/cli/run_tests/cli.test.js delete mode 100644 packages/kbn-test/src/functional_tests/cli/start_servers/__snapshots__/args.test.js.snap delete mode 100644 packages/kbn-test/src/functional_tests/cli/start_servers/__snapshots__/cli.test.js.snap delete mode 100644 packages/kbn-test/src/functional_tests/cli/start_servers/args.js delete mode 100644 packages/kbn-test/src/functional_tests/cli/start_servers/args.test.js delete mode 100644 packages/kbn-test/src/functional_tests/cli/start_servers/cli.js delete mode 100644 packages/kbn-test/src/functional_tests/cli/start_servers/cli.test.js delete mode 100644 packages/kbn-test/src/functional_tests/lib/__snapshots__/run_cli.test.js.snap delete mode 100644 packages/kbn-test/src/functional_tests/lib/auth.js delete mode 100644 packages/kbn-test/src/functional_tests/lib/babel_register_for_test_plugins.js delete mode 100644 packages/kbn-test/src/functional_tests/lib/index.js delete mode 100644 packages/kbn-test/src/functional_tests/lib/paths.js delete mode 100644 packages/kbn-test/src/functional_tests/lib/run_cli.js delete mode 100644 packages/kbn-test/src/functional_tests/lib/run_cli.test.js delete mode 100644 packages/kbn-test/src/functional_tests/lib/run_elasticsearch.js delete mode 100644 packages/kbn-test/src/functional_tests/lib/run_ftr.js delete mode 100644 packages/kbn-test/src/functional_tests/lib/run_kibana_server.js delete mode 100644 packages/kbn-test/src/functional_tests/tasks.js delete mode 100644 packages/kbn-test/src/functional_tests/test_helpers.js diff --git a/packages/kbn-test/src/functional_tests/cli/index.js b/packages/kbn-test/src/functional_tests/cli/index.js deleted file mode 100644 index 4671a4f652af..000000000000 --- a/packages/kbn-test/src/functional_tests/cli/index.js +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -export { runTestsCli } from './run_tests/cli'; -export { processOptions as processRunTestsCliOptions } from './run_tests/args'; -export { startServersCli } from './start_servers/cli'; -export { processOptions as processStartServersCliOptions } from './start_servers/args'; diff --git a/packages/kbn-test/src/functional_tests/cli/run_tests/__snapshots__/args.test.js.snap b/packages/kbn-test/src/functional_tests/cli/run_tests/__snapshots__/args.test.js.snap deleted file mode 100644 index 434c374d5d23..000000000000 --- a/packages/kbn-test/src/functional_tests/cli/run_tests/__snapshots__/args.test.js.snap +++ /dev/null @@ -1,281 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`display help for run tests CLI displays as expected 1`] = ` -"Run Functional Tests - -Usage: - node scripts/functional_tests --help - node scripts/functional_tests [--config [--config ...]] - node scripts/functional_tests [options] [-- --] - -Options: - --help Display this menu and exit. - --config Pass in a config. Can pass in multiple configs. - --esFrom Build Elasticsearch from source or run from snapshot. Default: $TEST_ES_FROM or snapshot - --kibana-install-dir Run Kibana from existing install directory instead of from source. - --bail Stop the test run at the first failure. - --grep Pattern to select which tests to run. - --updateBaselines Replace baseline screenshots with whatever is generated from the test. - --include Files that must included to be run, can be included multiple times. - --exclude Files that must NOT be included to be run, can be included multiple times. - --include-tag Tags that suites must include to be run, can be included multiple times. - --exclude-tag Tags that suites must NOT include to be run, can be included multiple times. - --assert-none-excluded Exit with 1/0 based on if any test is excluded with the current set of tags. - --verbose Log everything. - --debug Run in debug mode. - --quiet Only log errors. - --silent Log nothing." -`; - -exports[`process options for run tests CLI accepts boolean value for updateBaselines 1`] = ` -Object { - "assertNoneExcluded": false, - "configs": Array [ - /foo, - ], - "createLogger": [Function], - "esFrom": "snapshot", - "extraKbnOpts": undefined, - "suiteFiles": Object { - "exclude": Array [], - "include": Array [], - }, - "suiteTags": Object { - "exclude": Array [], - "include": Array [], - }, - "updateBaselines": true, -} -`; - -exports[`process options for run tests CLI accepts debug option 1`] = ` -Object { - "assertNoneExcluded": false, - "configs": Array [ - /foo, - ], - "createLogger": [Function], - "debug": true, - "esFrom": "snapshot", - "extraKbnOpts": undefined, - "suiteFiles": Object { - "exclude": Array [], - "include": Array [], - }, - "suiteTags": Object { - "exclude": Array [], - "include": Array [], - }, -} -`; - -exports[`process options for run tests CLI accepts empty config value if default passed 1`] = ` -Object { - "assertNoneExcluded": false, - "config": "", - "configs": Array [ - /foo, - ], - "createLogger": [Function], - "esFrom": "snapshot", - "extraKbnOpts": undefined, - "suiteFiles": Object { - "exclude": Array [], - "include": Array [], - }, - "suiteTags": Object { - "exclude": Array [], - "include": Array [], - }, -} -`; - -exports[`process options for run tests CLI accepts extra server options 1`] = ` -Object { - "_": Object { - "server.foo": "bar", - }, - "assertNoneExcluded": false, - "configs": Array [ - /foo, - ], - "createLogger": [Function], - "esFrom": "snapshot", - "extraKbnOpts": Object { - "server.foo": "bar", - }, - "suiteFiles": Object { - "exclude": Array [], - "include": Array [], - }, - "suiteTags": Object { - "exclude": Array [], - "include": Array [], - }, -} -`; - -exports[`process options for run tests CLI accepts quiet option 1`] = ` -Object { - "assertNoneExcluded": false, - "configs": Array [ - /foo, - ], - "createLogger": [Function], - "esFrom": "snapshot", - "extraKbnOpts": undefined, - "quiet": true, - "suiteFiles": Object { - "exclude": Array [], - "include": Array [], - }, - "suiteTags": Object { - "exclude": Array [], - "include": Array [], - }, -} -`; - -exports[`process options for run tests CLI accepts silent option 1`] = ` -Object { - "assertNoneExcluded": false, - "configs": Array [ - /foo, - ], - "createLogger": [Function], - "esFrom": "snapshot", - "extraKbnOpts": undefined, - "silent": true, - "suiteFiles": Object { - "exclude": Array [], - "include": Array [], - }, - "suiteTags": Object { - "exclude": Array [], - "include": Array [], - }, -} -`; - -exports[`process options for run tests CLI accepts source value for $TEST_ES_FROM 1`] = ` -Object { - "assertNoneExcluded": false, - "configs": Array [ - /foo, - ], - "createLogger": [Function], - "esFrom": "source", - "extraKbnOpts": undefined, - "suiteFiles": Object { - "exclude": Array [], - "include": Array [], - }, - "suiteTags": Object { - "exclude": Array [], - "include": Array [], - }, -} -`; - -exports[`process options for run tests CLI accepts source value for esFrom 1`] = ` -Object { - "assertNoneExcluded": false, - "configs": Array [ - /foo, - ], - "createLogger": [Function], - "esFrom": "source", - "extraKbnOpts": undefined, - "suiteFiles": Object { - "exclude": Array [], - "include": Array [], - }, - "suiteTags": Object { - "exclude": Array [], - "include": Array [], - }, -} -`; - -exports[`process options for run tests CLI accepts string value for kibana-install-dir 1`] = ` -Object { - "assertNoneExcluded": false, - "configs": Array [ - /foo, - ], - "createLogger": [Function], - "esFrom": "snapshot", - "extraKbnOpts": undefined, - "installDir": "foo", - "suiteFiles": Object { - "exclude": Array [], - "include": Array [], - }, - "suiteTags": Object { - "exclude": Array [], - "include": Array [], - }, -} -`; - -exports[`process options for run tests CLI accepts value for grep 1`] = ` -Object { - "assertNoneExcluded": false, - "configs": Array [ - /foo, - ], - "createLogger": [Function], - "esFrom": "snapshot", - "extraKbnOpts": undefined, - "grep": "management", - "suiteFiles": Object { - "exclude": Array [], - "include": Array [], - }, - "suiteTags": Object { - "exclude": Array [], - "include": Array [], - }, -} -`; - -exports[`process options for run tests CLI accepts verbose option 1`] = ` -Object { - "assertNoneExcluded": false, - "configs": Array [ - /foo, - ], - "createLogger": [Function], - "esFrom": "snapshot", - "extraKbnOpts": undefined, - "suiteFiles": Object { - "exclude": Array [], - "include": Array [], - }, - "suiteTags": Object { - "exclude": Array [], - "include": Array [], - }, - "verbose": true, -} -`; - -exports[`process options for run tests CLI prioritizes source flag over $TEST_ES_FROM 1`] = ` -Object { - "assertNoneExcluded": false, - "configs": Array [ - /foo, - ], - "createLogger": [Function], - "esFrom": "snapshot", - "extraKbnOpts": undefined, - "suiteFiles": Object { - "exclude": Array [], - "include": Array [], - }, - "suiteTags": Object { - "exclude": Array [], - "include": Array [], - }, -} -`; diff --git a/packages/kbn-test/src/functional_tests/cli/run_tests/__snapshots__/cli.test.js.snap b/packages/kbn-test/src/functional_tests/cli/run_tests/__snapshots__/cli.test.js.snap deleted file mode 100644 index 6ede71a6c394..000000000000 --- a/packages/kbn-test/src/functional_tests/cli/run_tests/__snapshots__/cli.test.js.snap +++ /dev/null @@ -1,71 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`run tests CLI options accepts help option even if invalid options passed 1`] = ` -"Run Functional Tests - -Usage: - node scripts/functional_tests --help - node scripts/functional_tests [--config [--config ...]] - node scripts/functional_tests [options] [-- --] - -Options: - --help Display this menu and exit. - --config Pass in a config. Can pass in multiple configs. - --esFrom Build Elasticsearch from source or run from snapshot. Default: $TEST_ES_FROM or snapshot - --kibana-install-dir Run Kibana from existing install directory instead of from source. - --bail Stop the test run at the first failure. - --grep Pattern to select which tests to run. - --updateBaselines Replace baseline screenshots with whatever is generated from the test. - --include Files that must included to be run, can be included multiple times. - --exclude Files that must NOT be included to be run, can be included multiple times. - --include-tag Tags that suites must include to be run, can be included multiple times. - --exclude-tag Tags that suites must NOT include to be run, can be included multiple times. - --assert-none-excluded Exit with 1/0 based on if any test is excluded with the current set of tags. - --verbose Log everything. - --debug Run in debug mode. - --quiet Only log errors. - --silent Log nothing. -" -`; - -exports[`run tests CLI options rejects boolean config value 1`] = ` -" -functional_tests: invalid argument [true] to option [config] - ...stack trace... -" -`; - -exports[`run tests CLI options rejects boolean value for kibana-install-dir 1`] = ` -" -functional_tests: invalid argument [true] to option [kibana-install-dir] - ...stack trace... -" -`; - -exports[`run tests CLI options rejects empty config value if no default passed 1`] = ` -" -functional_tests: config is required - ...stack trace... -" -`; - -exports[`run tests CLI options rejects invalid options even if valid options exist 1`] = ` -" -functional_tests: invalid option [aintnothang] - ...stack trace... -" -`; - -exports[`run tests CLI options rejects non-boolean value for bail 1`] = ` -" -functional_tests: invalid argument [peanut] to option [bail] - ...stack trace... -" -`; - -exports[`run tests CLI options rejects non-enum value for esFrom 1`] = ` -" -functional_tests: invalid argument [butter] to option [esFrom] - ...stack trace... -" -`; diff --git a/packages/kbn-test/src/functional_tests/cli/run_tests/args.js b/packages/kbn-test/src/functional_tests/cli/run_tests/args.js deleted file mode 100644 index 94d510915d8e..000000000000 --- a/packages/kbn-test/src/functional_tests/cli/run_tests/args.js +++ /dev/null @@ -1,180 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import { resolve } from 'path'; - -import dedent from 'dedent'; -import { ToolingLog, pickLevelFromFlags } from '@kbn/dev-utils'; - -const options = { - help: { desc: 'Display this menu and exit.' }, - config: { - arg: '', - desc: 'Pass in a config. Can pass in multiple configs.', - }, - esFrom: { - arg: '', - choices: ['snapshot', 'source'], - desc: 'Build Elasticsearch from source or run from snapshot.', - defaultHelp: 'Default: $TEST_ES_FROM or snapshot', - }, - 'kibana-install-dir': { - arg: '', - desc: 'Run Kibana from existing install directory instead of from source.', - }, - bail: { desc: 'Stop the test run at the first failure.' }, - grep: { - arg: '', - desc: 'Pattern to select which tests to run.', - }, - updateBaselines: { - desc: 'Replace baseline screenshots with whatever is generated from the test.', - }, - include: { - arg: '', - desc: 'Files that must included to be run, can be included multiple times.', - }, - exclude: { - arg: '', - desc: 'Files that must NOT be included to be run, can be included multiple times.', - }, - 'include-tag': { - arg: '', - desc: 'Tags that suites must include to be run, can be included multiple times.', - }, - 'exclude-tag': { - arg: '', - desc: 'Tags that suites must NOT include to be run, can be included multiple times.', - }, - 'assert-none-excluded': { - desc: 'Exit with 1/0 based on if any test is excluded with the current set of tags.', - }, - verbose: { desc: 'Log everything.' }, - debug: { desc: 'Run in debug mode.' }, - quiet: { desc: 'Only log errors.' }, - silent: { desc: 'Log nothing.' }, -}; - -export function displayHelp() { - const helpOptions = Object.keys(options) - .filter((name) => name !== '_') - .map((name) => { - const option = options[name]; - return { - ...option, - usage: `${name} ${option.arg || ''}`, - default: option.defaultHelp || '', - }; - }) - .map((option) => { - return `--${option.usage.padEnd(28)} ${option.desc} ${option.default}`; - }) - .join(`\n `); - - return dedent(` - Run Functional Tests - - Usage: - node scripts/functional_tests --help - node scripts/functional_tests [--config [--config ...]] - node scripts/functional_tests [options] [-- --] - - Options: - ${helpOptions} - `); -} - -export function processOptions(userOptions, defaultConfigPaths) { - validateOptions(userOptions); - - let configs; - if (userOptions.config) { - configs = [].concat(userOptions.config); - } else { - if (!defaultConfigPaths || defaultConfigPaths.length === 0) { - throw new Error(`functional_tests: config is required`); - } else { - configs = defaultConfigPaths; - } - } - - if (!userOptions.esFrom) { - userOptions.esFrom = process.env.TEST_ES_FROM || 'snapshot'; - } - - if (userOptions['kibana-install-dir']) { - userOptions.installDir = userOptions['kibana-install-dir']; - delete userOptions['kibana-install-dir']; - } - - userOptions.suiteFiles = { - include: [].concat(userOptions.include || []), - exclude: [].concat(userOptions.exclude || []), - }; - delete userOptions.include; - delete userOptions.exclude; - - userOptions.suiteTags = { - include: [].concat(userOptions['include-tag'] || []), - exclude: [].concat(userOptions['exclude-tag'] || []), - }; - delete userOptions['include-tag']; - delete userOptions['exclude-tag']; - - userOptions.assertNoneExcluded = !!userOptions['assert-none-excluded']; - delete userOptions['assert-none-excluded']; - - function createLogger() { - return new ToolingLog({ - level: pickLevelFromFlags(userOptions), - writeTo: process.stdout, - }); - } - - return { - ...userOptions, - configs: configs.map((c) => resolve(c)), - createLogger, - extraKbnOpts: userOptions._, - }; -} - -function validateOptions(userOptions) { - Object.entries(userOptions).forEach(([key, val]) => { - if (key === '_' || key === 'suiteTags') { - return; - } - - // Validate flags passed - if (options[key] === undefined) { - throw new Error(`functional_tests: invalid option [${key}]`); - } - - if ( - // Validate boolean flags - (!options[key].arg && typeof val !== 'boolean') || - // Validate string/array flags - (options[key].arg && typeof val !== 'string' && !Array.isArray(val)) || - // Validate enum flags - (options[key].choices && !options[key].choices.includes(val)) - ) { - throw new Error(`functional_tests: invalid argument [${val}] to option [${key}]`); - } - }); -} diff --git a/packages/kbn-test/src/functional_tests/cli/run_tests/args.test.js b/packages/kbn-test/src/functional_tests/cli/run_tests/args.test.js deleted file mode 100644 index 35e4cef5b3a6..000000000000 --- a/packages/kbn-test/src/functional_tests/cli/run_tests/args.test.js +++ /dev/null @@ -1,137 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import { displayHelp, processOptions } from './args'; -import { createAbsolutePathSerializer } from '@kbn/dev-utils'; - -expect.addSnapshotSerializer(createAbsolutePathSerializer(process.cwd())); - -const INITIAL_TEST_ES_FROM = process.env.TEST_ES_FROM; -beforeEach(() => { - process.env.TEST_ES_FROM = 'snapshot'; -}); -afterEach(() => { - process.env.TEST_ES_FROM = INITIAL_TEST_ES_FROM; -}); - -describe('display help for run tests CLI', () => { - it('displays as expected', () => { - expect(displayHelp()).toMatchSnapshot(); - }); -}); - -describe('process options for run tests CLI', () => { - it('rejects boolean config value', () => { - expect(() => { - processOptions({ config: true }); - }).toThrow('functional_tests: invalid argument [true] to option [config]'); - }); - - it('rejects empty config value if no default passed', () => { - expect(() => { - processOptions({}); - }).toThrow('functional_tests: config is required'); - }); - - it('accepts empty config value if default passed', () => { - const options = processOptions({ config: '' }, ['foo']); - expect(options).toMatchSnapshot(); - }); - - it('rejects non-boolean value for bail', () => { - expect(() => { - processOptions({ bail: 'peanut' }, ['foo']); - }).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']); - expect(options).toMatchSnapshot(); - }); - - it('rejects boolean value for kibana-install-dir', () => { - expect(() => { - processOptions({ 'kibana-install-dir': true }, ['foo']); - }).toThrow('functional_tests: invalid argument [true] to option [kibana-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']); - expect(options).toMatchSnapshot(); - }); - - it('accepts source value for $TEST_ES_FROM', () => { - process.env.TEST_ES_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']); - expect(options).toMatchSnapshot(); - }); - - it('rejects non-enum value for esFrom', () => { - expect(() => { - processOptions({ esFrom: 'butter' }, ['foo']); - }).toThrow('functional_tests: invalid argument [butter] to option [esFrom]'); - }); - - it('accepts value for grep', () => { - const options = processOptions({ grep: 'management' }, ['foo']); - expect(options).toMatchSnapshot(); - }); - - it('accepts debug option', () => { - const options = processOptions({ debug: true }, ['foo']); - expect(options).toMatchSnapshot(); - }); - - it('accepts silent option', () => { - const options = processOptions({ silent: true }, ['foo']); - expect(options).toMatchSnapshot(); - }); - - it('accepts quiet option', () => { - const options = processOptions({ quiet: true }, ['foo']); - expect(options).toMatchSnapshot(); - }); - - it('accepts verbose option', () => { - const options = processOptions({ verbose: true }, ['foo']); - expect(options).toMatchSnapshot(); - }); - - it('accepts extra server options', () => { - const options = processOptions({ _: { 'server.foo': 'bar' } }, ['foo']); - expect(options).toMatchSnapshot(); - }); - - it('rejects invalid options even if valid options exist', () => { - expect(() => { - processOptions({ debug: true, aintnothang: true, bail: true }, ['foo']); - }).toThrow('functional_tests: invalid option [aintnothang]'); - }); -}); diff --git a/packages/kbn-test/src/functional_tests/cli/run_tests/cli.js b/packages/kbn-test/src/functional_tests/cli/run_tests/cli.js deleted file mode 100644 index cf49fc77e479..000000000000 --- a/packages/kbn-test/src/functional_tests/cli/run_tests/cli.js +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import { runTests } from '../../tasks'; -import { runCli } from '../../lib'; -import { processOptions, displayHelp } from './args'; - -/** - * Run servers and tests for each config - * Only cares about --config option. Other options - * are passed directly to functional_test_runner, such as - * --bail, --verbose, etc. - * @param {string[]} defaultConfigPaths Optional paths to configs - * if no config option is passed - */ -export async function runTestsCli(defaultConfigPaths) { - await runCli(displayHelp, async (userOptions) => { - const options = processOptions(userOptions, defaultConfigPaths); - await runTests(options); - }); -} diff --git a/packages/kbn-test/src/functional_tests/cli/run_tests/cli.test.js b/packages/kbn-test/src/functional_tests/cli/run_tests/cli.test.js deleted file mode 100644 index 97b74a3b2b54..000000000000 --- a/packages/kbn-test/src/functional_tests/cli/run_tests/cli.test.js +++ /dev/null @@ -1,211 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import { Writable } from 'stream'; - -import { runTestsCli } from './cli'; -import { checkMockConsoleLogSnapshot } from '../../test_helpers'; - -// Note: Stub the runTests function to keep testing only around the cli -// method and arguments. -jest.mock('../../tasks', () => ({ - runTests: jest.fn(), -})); - -describe('run tests CLI', () => { - describe('options', () => { - const originalObjects = { process, console }; - const exitMock = jest.fn(); - const logMock = jest.fn(); // mock logging so we don't send output to the test results - const argvMock = ['foo', 'foo']; - - const processMock = { - exit: exitMock, - argv: argvMock, - stdout: new Writable(), - cwd: jest.fn(), - env: { - ...originalObjects.process.env, - TEST_ES_FROM: 'snapshot', - }, - }; - - beforeAll(() => { - global.process = processMock; - global.console = { log: logMock }; - }); - - afterAll(() => { - global.process = originalObjects.process; - global.console = originalObjects.console; - }); - - beforeEach(() => { - global.process.argv = [...argvMock]; - global.process.env = { - ...originalObjects.process.env, - TEST_ES_FROM: 'snapshot', - }; - jest.resetAllMocks(); - }); - - it('rejects boolean config value', async () => { - global.process.argv.push('--config'); - - await runTestsCli(); - - expect(exitMock).toHaveBeenCalledWith(1); - checkMockConsoleLogSnapshot(logMock); - }); - - it('rejects empty config value if no default passed', async () => { - global.process.argv.push('--config', ''); - - await runTestsCli(); - - expect(exitMock).toHaveBeenCalledWith(1); - checkMockConsoleLogSnapshot(logMock); - }); - - it('accepts empty config value if default passed', async () => { - global.process.argv.push('--config', ''); - - await runTestsCli(['foo']); - - expect(exitMock).not.toHaveBeenCalled(); - }); - - it('rejects non-boolean value for bail', async () => { - global.process.argv.push('--bail', 'peanut'); - - await runTestsCli(['foo']); - - expect(exitMock).toHaveBeenCalledWith(1); - checkMockConsoleLogSnapshot(logMock); - }); - - it('accepts string value for kibana-install-dir', async () => { - global.process.argv.push('--kibana-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'); - - await runTestsCli(['foo']); - - expect(exitMock).toHaveBeenCalledWith(1); - checkMockConsoleLogSnapshot(logMock); - }); - - it('accepts boolean value for updateBaselines', async () => { - global.process.argv.push('--updateBaselines'); - - await runTestsCli(['foo']); - - expect(exitMock).not.toHaveBeenCalledWith(); - }); - - it('accepts source value for esFrom', async () => { - global.process.argv.push('--esFrom', 'source'); - - await runTestsCli(['foo']); - - expect(exitMock).not.toHaveBeenCalled(); - }); - - it('rejects non-enum value for esFrom', async () => { - global.process.argv.push('--esFrom', 'butter'); - - await runTestsCli(['foo']); - - expect(exitMock).toHaveBeenCalledWith(1); - checkMockConsoleLogSnapshot(logMock); - }); - - it('accepts value for grep', async () => { - global.process.argv.push('--grep', 'management'); - - await runTestsCli(['foo']); - - expect(exitMock).not.toHaveBeenCalled(); - }); - - it('accepts debug option', async () => { - global.process.argv.push('--debug'); - - await runTestsCli(['foo']); - - expect(exitMock).not.toHaveBeenCalled(); - }); - - it('accepts silent option', async () => { - global.process.argv.push('--silent'); - - await runTestsCli(['foo']); - - expect(exitMock).not.toHaveBeenCalled(); - }); - - it('accepts quiet option', async () => { - global.process.argv.push('--quiet'); - - await runTestsCli(['foo']); - - expect(exitMock).not.toHaveBeenCalled(); - }); - - it('accepts verbose option', async () => { - global.process.argv.push('--verbose'); - - await runTestsCli(['foo']); - - expect(exitMock).not.toHaveBeenCalled(); - }); - - it('accepts extra server options', async () => { - global.process.argv.push('--', '--server.foo=bar'); - - await runTestsCli(['foo']); - - expect(exitMock).not.toHaveBeenCalled(); - }); - - it('accepts help option even if invalid options passed', async () => { - global.process.argv.push('--debug', '--aintnothang', '--help'); - - await runTestsCli(['foo']); - - expect(exitMock).not.toHaveBeenCalledWith(1); - checkMockConsoleLogSnapshot(logMock); - }); - - it('rejects invalid options even if valid options exist', async () => { - global.process.argv.push('--debug', '--aintnothang', '--bail'); - - await runTestsCli(['foo']); - - expect(exitMock).toHaveBeenCalledWith(1); - checkMockConsoleLogSnapshot(logMock); - }); - }); -}); diff --git a/packages/kbn-test/src/functional_tests/cli/start_servers/__snapshots__/args.test.js.snap b/packages/kbn-test/src/functional_tests/cli/start_servers/__snapshots__/args.test.js.snap deleted file mode 100644 index 809b635369a3..000000000000 --- a/packages/kbn-test/src/functional_tests/cli/start_servers/__snapshots__/args.test.js.snap +++ /dev/null @@ -1,120 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`display help for start servers CLI displays as expected 1`] = ` -"Start Functional Test Servers - -Usage: - node scripts/functional_tests_server --help - node scripts/functional_tests_server [--config ] - node scripts/functional_tests_server [options] [-- --] - -Options: - --help Display this menu and exit. - --config Pass in a config - --esFrom Build Elasticsearch from source, snapshot or path to existing install dir. Default: $TEST_ES_FROM or snapshot - --kibana-install-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`] = ` -Object { - "config": /foo, - "createLogger": [Function], - "debug": true, - "esFrom": "snapshot", - "extraKbnOpts": undefined, -} -`; - -exports[`process options for start servers CLI accepts empty config value if default passed 1`] = ` -Object { - "config": /foo, - "createLogger": [Function], - "esFrom": "snapshot", - "extraKbnOpts": undefined, -} -`; - -exports[`process options for start servers CLI accepts extra server options 1`] = ` -Object { - "_": Object { - "server.foo": "bar", - }, - "config": /foo, - "createLogger": [Function], - "esFrom": "snapshot", - "extraKbnOpts": Object { - "server.foo": "bar", - }, -} -`; - -exports[`process options for start servers CLI accepts quiet option 1`] = ` -Object { - "config": /foo, - "createLogger": [Function], - "esFrom": "snapshot", - "extraKbnOpts": undefined, - "quiet": true, -} -`; - -exports[`process options for start servers CLI accepts silent option 1`] = ` -Object { - "config": /foo, - "createLogger": [Function], - "esFrom": "snapshot", - "extraKbnOpts": undefined, - "silent": true, -} -`; - -exports[`process options for start servers CLI accepts source value for $TEST_ES_FROM 1`] = ` -Object { - "config": /foo, - "createLogger": [Function], - "esFrom": "source", - "extraKbnOpts": undefined, -} -`; - -exports[`process options for start servers CLI accepts source value for esFrom 1`] = ` -Object { - "config": /foo, - "createLogger": [Function], - "esFrom": "source", - "extraKbnOpts": undefined, -} -`; - -exports[`process options for start servers CLI accepts string value for kibana-install-dir 1`] = ` -Object { - "config": /foo, - "createLogger": [Function], - "esFrom": "snapshot", - "extraKbnOpts": undefined, - "installDir": "foo", -} -`; - -exports[`process options for start servers CLI accepts verbose option 1`] = ` -Object { - "config": /foo, - "createLogger": [Function], - "esFrom": "snapshot", - "extraKbnOpts": undefined, - "verbose": true, -} -`; - -exports[`process options for start servers CLI prioritizes source flag over $TEST_ES_FROM 1`] = ` -Object { - "config": /foo, - "createLogger": [Function], - "esFrom": "snapshot", - "extraKbnOpts": undefined, -} -`; diff --git a/packages/kbn-test/src/functional_tests/cli/start_servers/__snapshots__/cli.test.js.snap b/packages/kbn-test/src/functional_tests/cli/start_servers/__snapshots__/cli.test.js.snap deleted file mode 100644 index b54bf5dc84dd..000000000000 --- a/packages/kbn-test/src/functional_tests/cli/start_servers/__snapshots__/cli.test.js.snap +++ /dev/null @@ -1,43 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`start servers CLI options accepts boolean value for updateBaselines 1`] = ` -" -functional_tests_server: invalid option [updateBaselines] - ...stack trace... -" -`; - -exports[`start servers CLI options rejects bail 1`] = ` -" -functional_tests_server: invalid option [bail] - ...stack trace... -" -`; - -exports[`start servers CLI options rejects boolean config value 1`] = ` -" -functional_tests_server: invalid argument [true] to option [config] - ...stack trace... -" -`; - -exports[`start servers CLI options rejects boolean value for kibana-install-dir 1`] = ` -" -functional_tests_server: invalid argument [true] to option [kibana-install-dir] - ...stack trace... -" -`; - -exports[`start servers CLI options rejects empty config value if no default passed 1`] = ` -" -functional_tests_server: config is required - ...stack trace... -" -`; - -exports[`start servers CLI options rejects invalid options even if valid options exist 1`] = ` -" -functional_tests_server: invalid option [grep] - ...stack trace... -" -`; \ No newline at end of file diff --git a/packages/kbn-test/src/functional_tests/cli/start_servers/args.js b/packages/kbn-test/src/functional_tests/cli/start_servers/args.js deleted file mode 100644 index e604e86de8b3..000000000000 --- a/packages/kbn-test/src/functional_tests/cli/start_servers/args.js +++ /dev/null @@ -1,128 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import { resolve } from 'path'; - -import dedent from 'dedent'; -import { ToolingLog, pickLevelFromFlags } from '@kbn/dev-utils'; - -const options = { - help: { desc: 'Display this menu and exit.' }, - config: { - arg: '', - desc: 'Pass in a config', - }, - esFrom: { - arg: '', - desc: 'Build Elasticsearch from source, snapshot or path to existing install dir.', - defaultHelp: 'Default: $TEST_ES_FROM or snapshot', - }, - 'kibana-install-dir': { - arg: '', - desc: 'Run Kibana from existing install directory instead of from source.', - }, - verbose: { desc: 'Log everything.' }, - debug: { desc: 'Run in debug mode.' }, - quiet: { desc: 'Only log errors.' }, - silent: { desc: 'Log nothing.' }, -}; - -export function displayHelp() { - const helpOptions = Object.keys(options) - .filter((name) => name !== '_') - .map((name) => { - const option = options[name]; - return { - ...option, - usage: `${name} ${option.arg || ''}`, - default: option.defaultHelp || '', - }; - }) - .map((option) => { - return `--${option.usage.padEnd(30)} ${option.desc} ${option.default}`; - }) - .join(`\n `); - - return dedent(` - Start Functional Test Servers - - Usage: - node scripts/functional_tests_server --help - node scripts/functional_tests_server [--config ] - node scripts/functional_tests_server [options] [-- --] - - Options: - ${helpOptions} - `); -} - -export function processOptions(userOptions, defaultConfigPath) { - validateOptions(userOptions); - - const config = userOptions.config || defaultConfigPath; - - if (!config) { - throw new Error(`functional_tests_server: config is required`); - } - - if (!userOptions.esFrom) { - userOptions.esFrom = process.env.TEST_ES_FROM || 'snapshot'; - } - - if (userOptions['kibana-install-dir']) { - userOptions.installDir = userOptions['kibana-install-dir']; - delete userOptions['kibana-install-dir']; - } - - function createLogger() { - return new ToolingLog({ - level: pickLevelFromFlags(userOptions), - writeTo: process.stdout, - }); - } - - return { - ...userOptions, - config: resolve(config), - createLogger, - extraKbnOpts: userOptions._, - }; -} - -function validateOptions(userOptions) { - Object.entries(userOptions).forEach(([key, val]) => { - if (key === '_') return; - - // Validate flags passed - if (options[key] === undefined) { - throw new Error(`functional_tests_server: invalid option [${key}]`); - } - - if ( - // Validate boolean flags - (!options[key].arg && typeof val !== 'boolean') || - // Validate string/array flags - (options[key].arg && typeof val !== 'string' && !Array.isArray(val)) || - // Validate enum flags - (options[key].choices && !options[key].choices.includes(val)) - ) { - throw new Error(`functional_tests_server: invalid argument [${val}] to option [${key}]`); - } - }); -} diff --git a/packages/kbn-test/src/functional_tests/cli/start_servers/args.test.js b/packages/kbn-test/src/functional_tests/cli/start_servers/args.test.js deleted file mode 100644 index 0c842c8c7df4..000000000000 --- a/packages/kbn-test/src/functional_tests/cli/start_servers/args.test.js +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import { displayHelp, processOptions } from './args'; -import { createAbsolutePathSerializer } from '@kbn/dev-utils'; - -expect.addSnapshotSerializer(createAbsolutePathSerializer(process.cwd())); - -const INITIAL_TEST_ES_FROM = process.env.TEST_ES_FROM; -beforeEach(() => { - process.env.TEST_ES_FROM = 'snapshot'; -}); -afterEach(() => { - process.env.TEST_ES_FROM = INITIAL_TEST_ES_FROM; -}); - -describe('display help for start servers CLI', () => { - it('displays as expected', () => { - expect(displayHelp()).toMatchSnapshot(); - }); -}); - -describe('process options for start servers CLI', () => { - it('rejects boolean config value', () => { - expect(() => { - processOptions({ config: true }); - }).toThrow('functional_tests_server: invalid argument [true] to option [config]'); - }); - - it('rejects empty config value if no default passed', () => { - expect(() => { - processOptions({}); - }).toThrow('functional_tests_server: config is required'); - }); - - it('accepts empty config value if default passed', () => { - const options = processOptions({ config: '' }, 'foo'); - expect(options).toMatchSnapshot(); - }); - - it('rejects invalid option', () => { - expect(() => { - processOptions({ bail: true }, 'foo'); - }).toThrow('functional_tests_server: invalid option [bail]'); - }); - - it('accepts string value for kibana-install-dir', () => { - const options = processOptions({ 'kibana-install-dir': 'foo' }, 'foo'); - expect(options).toMatchSnapshot(); - }); - - it('rejects boolean value for kibana-install-dir', () => { - expect(() => { - processOptions({ 'kibana-install-dir': true }, 'foo'); - }).toThrow('functional_tests_server: invalid argument [true] to option [kibana-install-dir]'); - }); - - it('accepts source value for esFrom', () => { - const options = processOptions({ esFrom: 'source' }, 'foo'); - expect(options).toMatchSnapshot(); - }); - - it('accepts source value for $TEST_ES_FROM', () => { - process.env.TEST_ES_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'); - expect(options).toMatchSnapshot(); - }); - - it('accepts debug option', () => { - const options = processOptions({ debug: true }, 'foo'); - expect(options).toMatchSnapshot(); - }); - - it('accepts silent option', () => { - const options = processOptions({ silent: true }, 'foo'); - expect(options).toMatchSnapshot(); - }); - - it('accepts quiet option', () => { - const options = processOptions({ quiet: true }, 'foo'); - expect(options).toMatchSnapshot(); - }); - - it('accepts verbose option', () => { - const options = processOptions({ verbose: true }, 'foo'); - expect(options).toMatchSnapshot(); - }); - - it('accepts extra server options', () => { - const options = processOptions({ _: { 'server.foo': 'bar' } }, 'foo'); - expect(options).toMatchSnapshot(); - }); - - it('rejects invalid options even if valid options exist', () => { - expect(() => { - processOptions({ debug: true, aintnothang: true, bail: true }, 'foo'); - }).toThrow('functional_tests_server: invalid option [aintnothang]'); - }); -}); diff --git a/packages/kbn-test/src/functional_tests/cli/start_servers/cli.js b/packages/kbn-test/src/functional_tests/cli/start_servers/cli.js deleted file mode 100644 index d4499ee76e31..000000000000 --- a/packages/kbn-test/src/functional_tests/cli/start_servers/cli.js +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import { startServers } from '../../tasks'; -import { runCli } from '../../lib'; -import { processOptions, displayHelp } from './args'; - -/** - * Start servers - * @param {string} defaultConfigPath Optional path to config - * if no config option is passed - */ -export async function startServersCli(defaultConfigPath) { - await runCli(displayHelp, async (userOptions) => { - const options = processOptions(userOptions, defaultConfigPath); - await startServers(options); - }); -} diff --git a/packages/kbn-test/src/functional_tests/cli/start_servers/cli.test.js b/packages/kbn-test/src/functional_tests/cli/start_servers/cli.test.js deleted file mode 100644 index 3ceecb280662..000000000000 --- a/packages/kbn-test/src/functional_tests/cli/start_servers/cli.test.js +++ /dev/null @@ -1,194 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import { Writable } from 'stream'; - -import { startServersCli } from './cli'; -import { checkMockConsoleLogSnapshot } from '../../test_helpers'; - -// Note: Stub the startServers function to keep testing only around the cli -// method and arguments. -jest.mock('../../tasks', () => ({ - startServers: jest.fn(), -})); - -describe('start servers CLI', () => { - describe('options', () => { - const originalObjects = { process, console }; - const exitMock = jest.fn(); - const logMock = jest.fn(); // mock logging so we don't send output to the test results - const argvMock = ['foo', 'foo']; - - const processMock = { - exit: exitMock, - argv: argvMock, - stdout: new Writable(), - cwd: jest.fn(), - env: { - ...originalObjects.process.env, - TEST_ES_FROM: 'snapshot', - }, - }; - - beforeAll(() => { - global.process = processMock; - global.console = { log: logMock }; - }); - - afterAll(() => { - global.process = originalObjects.process; - global.console = originalObjects.console; - }); - - beforeEach(() => { - global.process.argv = [...argvMock]; - global.process.env = { - ...originalObjects.process.env, - TEST_ES_FROM: 'snapshot', - }; - jest.resetAllMocks(); - }); - - it('rejects boolean config value', async () => { - global.process.argv.push('--config'); - - await startServersCli(); - - expect(exitMock).toHaveBeenCalledWith(1); - checkMockConsoleLogSnapshot(logMock); - }); - - it('rejects empty config value if no default passed', async () => { - global.process.argv.push('--config', ''); - - await startServersCli(); - - expect(exitMock).toHaveBeenCalledWith(1); - checkMockConsoleLogSnapshot(logMock); - }); - - it('accepts empty config value if default passed', async () => { - global.process.argv.push('--config', ''); - - await startServersCli('foo'); - - expect(exitMock).not.toHaveBeenCalled(); - }); - - it('rejects bail', async () => { - global.process.argv.push('--bail', true); - - await startServersCli('foo'); - - expect(exitMock).toHaveBeenCalledWith(1); - checkMockConsoleLogSnapshot(logMock); - }); - - it('accepts string value for kibana-install-dir', async () => { - global.process.argv.push('--kibana-install-dir', 'foo'); - - await startServersCli('foo'); - - expect(exitMock).not.toHaveBeenCalled(); - }); - - it('rejects boolean value for kibana-install-dir', async () => { - global.process.argv.push('--kibana-install-dir'); - - await startServersCli('foo'); - - expect(exitMock).toHaveBeenCalledWith(1); - checkMockConsoleLogSnapshot(logMock); - }); - - it('accepts boolean value for updateBaselines', async () => { - global.process.argv.push('--updateBaselines'); - - await startServersCli('foo'); - - expect(exitMock).toHaveBeenCalledWith(1); - checkMockConsoleLogSnapshot(logMock); - }); - - it('accepts source value for esFrom', async () => { - global.process.argv.push('--esFrom', 'source'); - - await startServersCli('foo'); - - expect(exitMock).not.toHaveBeenCalled(); - }); - - it('accepts debug option', async () => { - global.process.argv.push('--debug'); - - await startServersCli('foo'); - - expect(exitMock).not.toHaveBeenCalled(); - }); - - it('accepts silent option', async () => { - global.process.argv.push('--silent'); - - await startServersCli('foo'); - - expect(exitMock).not.toHaveBeenCalled(); - }); - - it('accepts quiet option', async () => { - global.process.argv.push('--quiet'); - - await startServersCli('foo'); - - expect(exitMock).not.toHaveBeenCalled(); - }); - - it('accepts verbose option', async () => { - global.process.argv.push('--verbose'); - - await startServersCli('foo'); - - expect(exitMock).not.toHaveBeenCalled(); - }); - - it('accepts extra server options', async () => { - global.process.argv.push('--', '--server.foo=bar'); - - await startServersCli('foo'); - - expect(exitMock).not.toHaveBeenCalled(); - }); - - it('accepts help option even if invalid options passed', async () => { - global.process.argv.push('--debug', '--grep', '--help'); - - await startServersCli('foo'); - - expect(exitMock).not.toHaveBeenCalledWith(1); - }); - - it('rejects invalid options even if valid options exist', async () => { - global.process.argv.push('--debug', '--grep', '--bail'); - - await startServersCli('foo'); - - expect(exitMock).toHaveBeenCalledWith(1); - checkMockConsoleLogSnapshot(logMock); - }); - }); -}); diff --git a/packages/kbn-test/src/functional_tests/lib/__snapshots__/run_cli.test.js.snap b/packages/kbn-test/src/functional_tests/lib/__snapshots__/run_cli.test.js.snap deleted file mode 100644 index 6506675cea9b..000000000000 --- a/packages/kbn-test/src/functional_tests/lib/__snapshots__/run_cli.test.js.snap +++ /dev/null @@ -1,26 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`does right thing when non-error is thrown 1`] = ` -" -'foo bar' thrown! - ...stack trace... -" -`; - -exports[`logs no stack trace then exits when stack missing 1`] = ` -" -foo error - (no stack trace) - -" -`; - -exports[`logs the stack then exits when run function throws an error 1`] = ` -" -foo error - stack 1 - stack 2 - stack 3 - -" -`; diff --git a/packages/kbn-test/src/functional_tests/lib/auth.js b/packages/kbn-test/src/functional_tests/lib/auth.js deleted file mode 100644 index 358b16c562b1..000000000000 --- a/packages/kbn-test/src/functional_tests/lib/auth.js +++ /dev/null @@ -1,162 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import fs from 'fs'; -import util from 'util'; -import { format as formatUrl } from 'url'; - -import request from 'request'; -import { delay } from 'bluebird'; - -export const DEFAULT_SUPERUSER_PASS = 'changeme'; - -const readFile = util.promisify(fs.readFile); - -async function updateCredentials({ - port, - auth, - username, - password, - retries = 10, - protocol, - caCert, -}) { - const result = await new Promise((resolve, reject) => - request( - { - method: 'PUT', - uri: formatUrl({ - protocol: `${protocol}:`, - auth, - hostname: 'localhost', - port, - pathname: `/_security/user/${username}/_password`, - }), - json: true, - body: { password }, - ca: caCert, - }, - (err, httpResponse, body) => { - if (err) return reject(err); - resolve({ httpResponse, body }); - } - ) - ); - - const { body, httpResponse } = result; - const { statusCode } = httpResponse; - - if (statusCode === 200) { - return; - } - - if (retries > 0) { - await delay(2500); - return await updateCredentials({ - port, - auth, - username, - password, - retries: retries - 1, - protocol, - caCert, - }); - } - - throw new Error(`${statusCode} response, expected 200 -- ${JSON.stringify(body)}`); -} - -export async function setupUsers({ log, esPort, updates, protocol = 'http', caPath }) { - // track the current credentials for the `elastic` user as - // they will likely change as we apply updates - let auth = `elastic:${DEFAULT_SUPERUSER_PASS}`; - const caCert = caPath && (await readFile(caPath)); - - for (const { username, password, roles } of updates) { - // If working with a built-in user, just change the password - if (['logstash_system', 'elastic', 'kibana'].includes(username)) { - await updateCredentials({ port: esPort, auth, username, password, protocol, caCert }); - log.info('setting %j user password to %j', username, password); - - // If not a builtin user, add them - } else { - await insertUser({ port: esPort, auth, username, password, roles, protocol, caCert }); - log.info('Added %j user with password to %j', username, password); - } - - if (username === 'elastic') { - auth = `elastic:${password}`; - } - } -} - -async function insertUser({ - port, - auth, - username, - password, - roles = [], - retries = 10, - protocol, - caCert, -}) { - const result = await new Promise((resolve, reject) => - request( - { - method: 'POST', - uri: formatUrl({ - protocol: `${protocol}:`, - auth, - hostname: 'localhost', - port, - pathname: `/_security/user/${username}`, - }), - json: true, - body: { password, roles }, - ca: caCert, - }, - (err, httpResponse, body) => { - if (err) return reject(err); - resolve({ httpResponse, body }); - } - ) - ); - - const { body, httpResponse } = result; - const { statusCode } = httpResponse; - if (statusCode === 200) { - return; - } - - if (retries > 0) { - await delay(2500); - return await insertUser({ - port, - auth, - username, - password, - roles, - retries: retries - 1, - protocol, - caCert, - }); - } - - throw new Error(`${statusCode} response, expected 200 -- ${JSON.stringify(body)}`); -} diff --git a/packages/kbn-test/src/functional_tests/lib/babel_register_for_test_plugins.js b/packages/kbn-test/src/functional_tests/lib/babel_register_for_test_plugins.js deleted file mode 100644 index 44ff579411bd..000000000000 --- a/packages/kbn-test/src/functional_tests/lib/babel_register_for_test_plugins.js +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -const Path = require('path'); - -const { REPO_ROOT } = require('@kbn/dev-utils'); - -// modifies all future calls to require() to automatically -// compile the required source with babel -require('@babel/register')({ - ignore: [/[\/\\](node_modules|target|dist)[\/\\]/], - only: [ - Path.resolve(REPO_ROOT, 'test'), - Path.resolve(REPO_ROOT, 'x-pack/test'), - Path.resolve(REPO_ROOT, 'examples'), - Path.resolve(REPO_ROOT, 'x-pack/examples'), - // TODO: should should probably remove this link back to the source - Path.resolve(REPO_ROOT, 'x-pack/plugins/task_manager/server/config.ts'), - ], - babelrc: false, - presets: [require.resolve('@kbn/babel-preset/node_preset')], - extensions: ['.js', '.ts', '.tsx'], -}); diff --git a/packages/kbn-test/src/functional_tests/lib/index.js b/packages/kbn-test/src/functional_tests/lib/index.js deleted file mode 100644 index ec381b56b069..000000000000 --- a/packages/kbn-test/src/functional_tests/lib/index.js +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -export { runKibanaServer } from './run_kibana_server'; -export { runElasticsearch } from './run_elasticsearch'; -export { runFtr, hasTests, assertNoneExcluded } from './run_ftr'; -export { KIBANA_ROOT, KIBANA_FTR_SCRIPT, FUNCTIONAL_CONFIG_PATH, API_CONFIG_PATH } from './paths'; -export { runCli } from './run_cli'; diff --git a/packages/kbn-test/src/functional_tests/lib/paths.js b/packages/kbn-test/src/functional_tests/lib/paths.js deleted file mode 100644 index 9ede5a105b08..000000000000 --- a/packages/kbn-test/src/functional_tests/lib/paths.js +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import { resolve, relative } from 'path'; - -// resolve() treats relative paths as relative to process.cwd(), -// so to return a relative path we use relative() -function resolveRelative(path) { - return relative(process.cwd(), resolve(path)); -} - -export const KIBANA_EXEC = 'node'; -export const KIBANA_EXEC_PATH = resolveRelative('scripts/kibana'); -export const KIBANA_ROOT = resolve(__dirname, '../../../../../'); -export const KIBANA_FTR_SCRIPT = resolve(KIBANA_ROOT, 'scripts/functional_test_runner'); -export const PROJECT_ROOT = resolve(__dirname, '../../../../../../'); -export const FUNCTIONAL_CONFIG_PATH = resolve(KIBANA_ROOT, 'test/functional/config'); -export const API_CONFIG_PATH = resolve(KIBANA_ROOT, 'test/api_integration/config'); diff --git a/packages/kbn-test/src/functional_tests/lib/run_cli.js b/packages/kbn-test/src/functional_tests/lib/run_cli.js deleted file mode 100644 index 51a970e1a305..000000000000 --- a/packages/kbn-test/src/functional_tests/lib/run_cli.js +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import { inspect } from 'util'; - -import chalk from 'chalk'; -import getopts from 'getopts'; - -export class CliError extends Error { - constructor(message, exitCode = 1) { - super(message); - this.exitCode = exitCode; - Error.captureStackTrace(this, CliError); - } -} - -export async function runCli(getHelpText, run) { - try { - const userOptions = getopts(process.argv.slice(2)) || {}; - if (userOptions.help) { - console.log(getHelpText()); - return; - } - - await run(userOptions); - } catch (error) { - if (!(error instanceof Error)) { - error = new Error(`${inspect(error)} thrown!`); - } - - console.log(); - console.log(chalk.red(error.message)); - - // CliError is a special error class that indicates that the error is produced as a part - // of using the CLI, and does not need a stack trace to make sense, so we skip the stack - // trace logging if the error thrown is an instance of this class - if (!(error instanceof CliError)) { - // first line in the stack trace is the message, skip it as we log it directly and color it red - if (error.stack) { - console.log(error.stack.split('\n').slice(1).join('\n')); - } else { - console.log(' (no stack trace)'); - } - } - - console.log(); - - process.exit(error.exitCode || 1); - } -} diff --git a/packages/kbn-test/src/functional_tests/lib/run_cli.test.js b/packages/kbn-test/src/functional_tests/lib/run_cli.test.js deleted file mode 100644 index 959f96591753..000000000000 --- a/packages/kbn-test/src/functional_tests/lib/run_cli.test.js +++ /dev/null @@ -1,133 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import { runCli } from './run_cli'; -import { checkMockConsoleLogSnapshot } from '../test_helpers'; - -const mockProcessExit = jest.spyOn(process, 'exit').mockImplementation(() => {}); -const mockConsoleLog = jest.spyOn(console, 'log').mockImplementation(() => {}); - -const actualProcessArgv = process.argv; - -const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms)); - -beforeEach(() => { - process.argv = actualProcessArgv.slice(0, 2); - jest.clearAllMocks(); -}); - -afterAll(() => { - process.argv = actualProcessArgv; -}); - -it('accepts help option even if invalid options passed', async () => { - process.argv.push('--foo', '--bar', '--help'); - - const mockGetHelpText = jest.fn().mockReturnValue('mock help text'); - const mockRun = jest.fn(); - await runCli(mockGetHelpText, mockRun); - - expect(mockProcessExit).not.toHaveBeenCalled(); - expect(mockGetHelpText).toHaveBeenCalledTimes(1); - expect(mockConsoleLog).toHaveBeenCalledTimes(1); - expect(mockConsoleLog).toHaveBeenCalledWith('mock help text'); - expect(mockRun).not.toHaveBeenCalled(); -}); - -it('passes parsed argv to run function', async () => { - process.argv.push('--foo', 'bar', '--baz=box', '--', 'a', 'b', 'c'); - - const mockGetHelpText = jest.fn(); - const mockRun = jest.fn(); - await runCli(mockGetHelpText, mockRun); - - expect(mockGetHelpText).not.toHaveBeenCalled(); - expect(mockConsoleLog).not.toHaveBeenCalled(); - expect(mockProcessExit).not.toHaveBeenCalled(); - expect(mockRun).toHaveBeenCalledTimes(1); - expect(mockRun).toHaveBeenCalledWith({ - foo: 'bar', - baz: 'box', - _: ['a', 'b', 'c'], - }); -}); - -it('waits for promise returned from run function to resolve before resolving', async () => { - let resolveMockRun; - const mockRun = jest.fn().mockImplementation( - () => - new Promise((resolve) => { - resolveMockRun = resolve; - }) - ); - - const onResolved = jest.fn(); - const promise = runCli(null, mockRun).then(onResolved); - - expect(mockRun).toHaveBeenCalled(); - expect(onResolved).not.toHaveBeenCalled(); - - await sleep(500); - - expect(onResolved).not.toHaveBeenCalled(); - - resolveMockRun(); - await promise; - expect(onResolved).toHaveBeenCalled(); -}); - -it('logs the stack then exits when run function throws an error', async () => { - await runCli(null, () => { - const error = new Error('foo error'); - error.stack = 'foo error\n stack 1\n stack 2\n stack 3'; - throw error; - }); - - expect(mockProcessExit).toHaveBeenCalledTimes(1); - expect(mockProcessExit).toHaveBeenCalledWith(1); - - expect(mockConsoleLog).toHaveBeenCalled(); - checkMockConsoleLogSnapshot(mockConsoleLog); -}); - -it('logs no stack trace then exits when stack missing', async () => { - await runCli(null, () => { - const error = new Error('foo error'); - error.stack = undefined; - throw error; - }); - - expect(mockProcessExit).toHaveBeenCalledTimes(1); - expect(mockProcessExit).toHaveBeenCalledWith(1); - - expect(mockConsoleLog).toHaveBeenCalled(); - checkMockConsoleLogSnapshot(mockConsoleLog); -}); - -it('does right thing when non-error is thrown', async () => { - await runCli(null, () => { - throw 'foo bar'; - }); - - expect(mockProcessExit).toHaveBeenCalledTimes(1); - expect(mockProcessExit).toHaveBeenCalledWith(1); - - expect(mockConsoleLog).toHaveBeenCalled(); - checkMockConsoleLogSnapshot(mockConsoleLog); -}); diff --git a/packages/kbn-test/src/functional_tests/lib/run_elasticsearch.js b/packages/kbn-test/src/functional_tests/lib/run_elasticsearch.js deleted file mode 100644 index 3d174791fffc..000000000000 --- a/packages/kbn-test/src/functional_tests/lib/run_elasticsearch.js +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import { resolve } from 'path'; -import { KIBANA_ROOT } from './paths'; -import { createLegacyEsTestCluster } from '../../legacy_es'; - -import { setupUsers, DEFAULT_SUPERUSER_PASS } from './auth'; - -export async function runElasticsearch({ config, options }) { - const { log, esFrom } = options; - const ssl = config.get('esTestCluster.ssl'); - const license = config.get('esTestCluster.license'); - const esArgs = config.get('esTestCluster.serverArgs'); - const esEnvVars = config.get('esTestCluster.serverEnvVars'); - const isSecurityEnabled = esArgs.includes('xpack.security.enabled=true'); - - const cluster = createLegacyEsTestCluster({ - port: config.get('servers.elasticsearch.port'), - password: isSecurityEnabled - ? DEFAULT_SUPERUSER_PASS - : config.get('servers.elasticsearch.password'), - license, - log, - basePath: resolve(KIBANA_ROOT, '.es'), - esFrom: esFrom || config.get('esTestCluster.from'), - dataArchive: config.get('esTestCluster.dataArchive'), - esArgs, - esEnvVars, - ssl, - }); - - await cluster.start(); - - if (isSecurityEnabled) { - await setupUsers({ - log, - esPort: config.get('servers.elasticsearch.port'), - updates: [config.get('servers.elasticsearch'), config.get('servers.kibana')], - protocol: config.get('servers.elasticsearch').protocol, - caPath: getRelativeCertificateAuthorityPath(config.get('kbnTestServer.serverArgs')), - }); - } - - return cluster; -} - -function getRelativeCertificateAuthorityPath(esConfig = []) { - const caConfig = esConfig.find( - (config) => config.indexOf('--elasticsearch.ssl.certificateAuthorities') === 0 - ); - return caConfig ? caConfig.split('=')[1] : undefined; -} diff --git a/packages/kbn-test/src/functional_tests/lib/run_ftr.js b/packages/kbn-test/src/functional_tests/lib/run_ftr.js deleted file mode 100644 index 14883ac977c4..000000000000 --- a/packages/kbn-test/src/functional_tests/lib/run_ftr.js +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import { FunctionalTestRunner, readConfigFile } from '../../functional_test_runner'; -import { CliError } from './run_cli'; - -async function createFtr({ - configPath, - options: { installDir, log, bail, grep, updateBaselines, suiteFiles, suiteTags }, -}) { - const config = await readConfigFile(log, configPath); - - return { - config, - ftr: new FunctionalTestRunner(log, configPath, { - mochaOpts: { - bail: !!bail, - grep, - }, - kbnTestServer: { - installDir, - }, - updateBaselines, - suiteFiles: { - include: [...suiteFiles.include, ...config.get('suiteFiles.include')], - exclude: [...suiteFiles.exclude, ...config.get('suiteFiles.exclude')], - }, - suiteTags: { - include: [...suiteTags.include, ...config.get('suiteTags.include')], - exclude: [...suiteTags.exclude, ...config.get('suiteTags.exclude')], - }, - }), - }; -} - -export async function assertNoneExcluded({ configPath, options }) { - const { config, ftr } = await createFtr({ configPath, options }); - - if (config.get('testRunner')) { - // tests with custom test runners are not included in this check - return; - } - - const stats = await ftr.getTestStats(); - if (stats.excludedTests.length > 0) { - throw new CliError(` - ${stats.excludedTests.length} tests in the ${configPath} config - are excluded when filtering by the tags run on CI. Make sure that all suites are - tagged with one of the following tags, or extend the list of tags in test/scripts/jenkins_xpack.sh - - tags: ${JSON.stringify(options.suiteTags)} - - - ${stats.excludedTests.join('\n - ')} - `); - } -} - -export async function runFtr({ configPath, options }) { - const { ftr } = await createFtr({ configPath, options }); - - const failureCount = await ftr.run(); - if (failureCount > 0) { - throw new CliError( - `${failureCount} functional test ${failureCount === 1 ? 'failure' : 'failures'}` - ); - } -} - -export async function hasTests({ configPath, options }) { - const { ftr, config } = await createFtr({ configPath, options }); - - if (config.get('testRunner')) { - // configs with custom test runners are assumed to always have tests - return true; - } - const stats = await ftr.getTestStats(); - return stats.testCount > 0; -} diff --git a/packages/kbn-test/src/functional_tests/lib/run_kibana_server.js b/packages/kbn-test/src/functional_tests/lib/run_kibana_server.js deleted file mode 100644 index e7ec99467ecf..000000000000 --- a/packages/kbn-test/src/functional_tests/lib/run_kibana_server.js +++ /dev/null @@ -1,143 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import { resolve, relative } from 'path'; -import { KIBANA_ROOT, KIBANA_EXEC, KIBANA_EXEC_PATH } from './paths'; - -function extendNodeOptions(installDir) { - if (!installDir) { - return {}; - } - - const testOnlyRegisterPath = relative( - installDir, - require.resolve('./babel_register_for_test_plugins') - ); - - return { - NODE_OPTIONS: `--require=${testOnlyRegisterPath}${ - process.env.NODE_OPTIONS ? ` ${process.env.NODE_OPTIONS}` : '' - }`, - }; -} - -export async function runKibanaServer({ procs, config, options }) { - const { installDir } = options; - - await procs.run('kibana', { - cmd: getKibanaCmd(installDir), - args: filterCliArgs(collectCliArgs(config, options)), - env: { - FORCE_COLOR: 1, - ...process.env, - ...extendNodeOptions(installDir), - }, - cwd: installDir || KIBANA_ROOT, - wait: /http server running/, - }); -} - -function getKibanaCmd(installDir) { - if (installDir) { - return process.platform.startsWith('win') - ? resolve(installDir, 'bin/kibana.bat') - : resolve(installDir, 'bin/kibana'); - } - - return KIBANA_EXEC; -} - -/** - * When installDir is passed, we run from a built version of Kibana, - * which uses different command line arguments. If installDir is not - * passed, we run from source code. We also allow passing in extra - * Kibana server options, so we tack those on here. - */ -function collectCliArgs(config, { installDir, extraKbnOpts }) { - const buildArgs = config.get('kbnTestServer.buildArgs') || []; - const sourceArgs = config.get('kbnTestServer.sourceArgs') || []; - const serverArgs = config.get('kbnTestServer.serverArgs') || []; - - return pipe( - serverArgs, - (args) => (installDir ? args.filter((a) => a !== '--oss') : args), - (args) => (installDir ? [...buildArgs, ...args] : [KIBANA_EXEC_PATH, ...sourceArgs, ...args]), - (args) => args.concat(extraKbnOpts || []) - ); -} - -/** - * Filter the cli args to remove duplications and - * overridden options - */ -function filterCliArgs(args) { - return args.reduce((acc, val, ind) => { - // If original argv has a later basepath setting, skip this val. - if (isBasePathSettingOverridden(args, val, ind)) { - return acc; - } - - // Check if original argv has a later setting that overrides - // the current val. If so, skip this val. - if ( - !allowsDuplicate(val) && - findIndexFrom(args, ++ind, (opt) => opt.split('=')[0] === val.split('=')[0]) > -1 - ) { - return acc; - } - - return [...acc, val]; - }, []); -} - -/** - * Apply each function in fns to the result of the - * previous function. The first function's input - * is the arr array. - */ -function pipe(arr, ...fns) { - return fns.reduce((acc, fn) => { - return fn(acc); - }, arr); -} - -/** - * Checks whether a specific parameter is allowed to appear multiple - * times in the Kibana parameters. - */ -function allowsDuplicate(val) { - return ['--plugin-path'].includes(val.split('=')[0]); -} - -function isBasePathSettingOverridden(args, val, ind) { - const key = val.split('=')[0]; - const basePathKeys = ['--no-base-path', '--server.basePath']; - - if (basePathKeys.includes(key)) { - if (findIndexFrom(args, ++ind, (opt) => basePathKeys.includes(opt.split('=')[0])) > -1) { - return true; - } - } - - return false; -} - -function findIndexFrom(array, index, ...args) { - return [...array].slice(index).findIndex(...args); -} diff --git a/packages/kbn-test/src/functional_tests/tasks.js b/packages/kbn-test/src/functional_tests/tasks.js deleted file mode 100644 index 7d4fc84d47bd..000000000000 --- a/packages/kbn-test/src/functional_tests/tasks.js +++ /dev/null @@ -1,166 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -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, - runKibanaServer, - runFtr, - assertNoneExcluded, - hasTests, - KIBANA_FTR_SCRIPT, -} from './lib'; - -import { readConfigFile } from '../functional_test_runner/lib'; - -const makeSuccessMessage = (options) => { - const installDirFlag = options.installDir ? ` --kibana-install-dir=${options.installDir}` : ''; - - 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)}${installDirFlag} - ` + - '\n\n' - ); -}; - -/** - * Run servers and tests for each config - * @param {object} options Optional - * @property {string[]} options.configs Array of paths to configs - * @property {function} options.log An instance of the ToolingLog - * @property {string} options.installDir Optional installation dir from which to run Kibana - * @property {boolean} options.bail Whether to exit test run at the first failure - * @property {string} options.esFrom Optionally run from source instead of snapshot - */ -export async function runTests(options) { - if (!process.env.KBN_NP_PLUGINS_BUILT) { - const log = options.createLogger(); - log.warning('❗️❗️❗️'); - log.warning('❗️❗️❗️'); - log.warning('❗️❗️❗️'); - log.warning( - " Don't forget to use `node scripts/build_kibana_platform_plugins` to build plugins you plan on testing" - ); - log.warning('❗️❗️❗️'); - log.warning('❗️❗️❗️'); - log.warning('❗️❗️❗️'); - } - - for (const configPath of options.configs) { - const log = options.createLogger(); - const opts = { - ...options, - log, - }; - - log.info('Running', configPath); - log.indent(2); - - if (options.assertNoneExcluded) { - await assertNoneExcluded({ configPath, options: opts }); - continue; - } - - if (!(await hasTests({ configPath, options: opts }))) { - log.info('Skipping', configPath, 'since all tests are excluded'); - continue; - } - - await withProcRunner(log, async (procs) => { - const config = await readConfigFile(log, configPath); - - let es; - try { - es = await runElasticsearch({ config, options: opts }); - await runKibanaServer({ procs, config, options: opts }); - await runFtr({ configPath, options: opts }); - } finally { - try { - await procs.stop('kibana'); - } finally { - if (es) { - await es.cleanup(); - } - } - } - }); - } -} - -/** - * Start only servers using single config - * @param {object} options Optional - * @property {string} options.config Path to a config file - * @property {function} options.log An instance of the ToolingLog - * @property {string} options.installDir Optional installation dir from which to run Kibana - * @property {string} options.esFrom Optionally run from source instead of snapshot - */ -export async function startServers(options) { - const log = options.createLogger(); - const opts = { - ...options, - log, - }; - - await withProcRunner(log, async (procs) => { - const config = await readConfigFile(log, options.config); - - const es = await runElasticsearch({ config, options: opts }); - await runKibanaServer({ - procs, - config, - options: { - ...opts, - extraKbnOpts: [ - ...options.extraKbnOpts, - ...(options.installDir ? [] : ['--dev', '--no-dev-config']), - ], - }, - }); - - // wait for 5 seconds of silence before logging the - // success message so that it doesn't get buried - await silence(log, 5000); - log.success(makeSuccessMessage(options)); - - await procs.waitForAllToStop(); - await es.cleanup(); - }); -} - -async function silence(log, milliseconds) { - await log - .getWritten$() - .pipe( - startWith(null), - switchMap(() => Rx.timer(milliseconds)), - take(1) - ) - .toPromise(); -} diff --git a/packages/kbn-test/src/functional_tests/test_helpers.js b/packages/kbn-test/src/functional_tests/test_helpers.js deleted file mode 100644 index cf36a794466c..000000000000 --- a/packages/kbn-test/src/functional_tests/test_helpers.js +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/* eslint-env jest */ - -import { format } from 'util'; - -export function checkMockConsoleLogSnapshot(logMock) { - const output = logMock.mock.calls - .reduce((acc, args) => `${acc}${format(...args)}\n`, '') - .replace(/(^ at.+[>)\d]$\n?)+/m, ' ...stack trace...'); - - expect(output).toMatchSnapshot(); -} From c10204e04c2944b0254913da3e79aa4515e6e72e Mon Sep 17 00:00:00 2001 From: Mihir Soni Date: Wed, 3 Mar 2021 22:17:24 +0000 Subject: [PATCH 3/8] [Rename] kbn-test/src/failed_tests_reporter in packages directory to osd-test/failed_tests_reporter Signed-off-by: Mihir Soni --- .../src/failed_tests_reporter/README.md | 21 -- .../__fixtures__/cypress_report.xml | 50 --- .../__fixtures__/ftr_report.xml | 53 --- .../__fixtures__/index.ts | 25 -- .../__fixtures__/jest_report.xml | 15 - .../__fixtures__/mocha_report.xml | 38 -- .../add_messages_to_report.test.ts | 334 ------------------ .../add_messages_to_report.ts | 92 ----- .../get_failures.test.ts | 124 ------- .../src/failed_tests_reporter/get_failures.ts | 89 ----- .../src/failed_tests_reporter/github_api.ts | 254 ------------- .../src/failed_tests_reporter/index.ts | 20 -- .../issue_metadata.test.ts | 134 ------- .../failed_tests_reporter/issue_metadata.ts | 69 ---- .../report_failure.test.ts | 126 ------- .../failed_tests_reporter/report_failure.ts | 58 --- .../report_metadata.test.ts | 46 --- .../failed_tests_reporter/report_metadata.ts | 42 --- .../run_failed_tests_reporter_cli.ts | 174 --------- .../src/failed_tests_reporter/test_report.ts | 106 ------ 20 files changed, 1870 deletions(-) delete mode 100644 packages/kbn-test/src/failed_tests_reporter/README.md delete mode 100644 packages/kbn-test/src/failed_tests_reporter/__fixtures__/cypress_report.xml delete mode 100644 packages/kbn-test/src/failed_tests_reporter/__fixtures__/ftr_report.xml delete mode 100644 packages/kbn-test/src/failed_tests_reporter/__fixtures__/index.ts delete mode 100644 packages/kbn-test/src/failed_tests_reporter/__fixtures__/jest_report.xml delete mode 100644 packages/kbn-test/src/failed_tests_reporter/__fixtures__/mocha_report.xml delete mode 100644 packages/kbn-test/src/failed_tests_reporter/add_messages_to_report.test.ts delete mode 100644 packages/kbn-test/src/failed_tests_reporter/add_messages_to_report.ts delete mode 100644 packages/kbn-test/src/failed_tests_reporter/get_failures.test.ts delete mode 100644 packages/kbn-test/src/failed_tests_reporter/get_failures.ts delete mode 100644 packages/kbn-test/src/failed_tests_reporter/github_api.ts delete mode 100644 packages/kbn-test/src/failed_tests_reporter/index.ts delete mode 100644 packages/kbn-test/src/failed_tests_reporter/issue_metadata.test.ts delete mode 100644 packages/kbn-test/src/failed_tests_reporter/issue_metadata.ts delete mode 100644 packages/kbn-test/src/failed_tests_reporter/report_failure.test.ts delete mode 100644 packages/kbn-test/src/failed_tests_reporter/report_failure.ts delete mode 100644 packages/kbn-test/src/failed_tests_reporter/report_metadata.test.ts delete mode 100644 packages/kbn-test/src/failed_tests_reporter/report_metadata.ts delete mode 100644 packages/kbn-test/src/failed_tests_reporter/run_failed_tests_reporter_cli.ts delete mode 100644 packages/kbn-test/src/failed_tests_reporter/test_report.ts diff --git a/packages/kbn-test/src/failed_tests_reporter/README.md b/packages/kbn-test/src/failed_tests_reporter/README.md deleted file mode 100644 index 0473ae7357de..000000000000 --- a/packages/kbn-test/src/failed_tests_reporter/README.md +++ /dev/null @@ -1,21 +0,0 @@ -# failed tests reporter - -A little CLI that runs in CI to find the failed tests in the JUnit reports, then create/update github issues for each failure. - -## Test this script locally - -To fetch some JUnit reports from a recent build on CI, visit its `Google Cloud Storage Upload Report` and execute the following in the JS Console: - -```js -copy(`wget -x -nH --cut-dirs 5 -P "target/downloaded_junit" "${Array.from($$('a[href$=".xml"]')).filter(a => a.innerText === 'Download').map(a => a.href.replace('https://storage.cloud.google.com/', 'https://storage.googleapis.com/')).join('" "')}"`) -``` - -This copies a script to download the reports, which you should execute in the root of the Kibana repository. - -Next, run the CLI in `--no-github-update` mode so that it doesn't actually communicate with Github and `--no-report-update` to prevent the script from mutating the reports on disk and instead log the updated report. - -```sh -node scripts/report_failed_tests.js --verbose --no-github-update --no-report-update target/downloaded_junit/**/*.xml -``` - -Unless you specify the `GITHUB_TOKEN` environment variable requests to read existing issues will use anonymous access which is limited to 60 requests per hour. \ No newline at end of file diff --git a/packages/kbn-test/src/failed_tests_reporter/__fixtures__/cypress_report.xml b/packages/kbn-test/src/failed_tests_reporter/__fixtures__/cypress_report.xml deleted file mode 100644 index ed0e154552ca..000000000000 --- a/packages/kbn-test/src/failed_tests_reporter/__fixtures__/cypress_report.xml +++ /dev/null @@ -1,50 +0,0 @@ - - - - - - - - - ...` - -You can fix this problem by: - - Passing `{force: true}` which disables all error checking - - Passing `{waitForAnimations: false}` which disables waiting on animations - - Passing `{animationDistanceThreshold: 20}` which decreases the sensitivity - -https://on.cypress.io/element-is-animating - -Because this error occurred during a `after each` hook we are skipping the remaining tests in the current suite: `timeline flyout button` - at cypressErr (http://elastic:changeme@localhost:61141/__cypress/runner/cypress_runner.js:146621:16) - at cypressErrByPath (http://elastic:changeme@localhost:61141/__cypress/runner/cypress_runner.js:146630:10) - at Object.throwErrByPath (http://elastic:changeme@localhost:61141/__cypress/runner/cypress_runner.js:146593:11) - at Object.ensureElementIsNotAnimating (http://elastic:changeme@localhost:61141/__cypress/runner/cypress_runner.js:137560:24) - at ensureNotAnimating (http://elastic:changeme@localhost:61141/__cypress/runner/cypress_runner.js:127434:13) - at runAllChecks (http://elastic:changeme@localhost:61141/__cypress/runner/cypress_runner.js:127522:9) - at retryActionability (http://elastic:changeme@localhost:61141/__cypress/runner/cypress_runner.js:127542:16) - at tryCatcher (http://elastic:changeme@localhost:61141/__cypress/runner/cypress_runner.js:9065:23) - at Function.Promise.attempt.Promise.try (http://elastic:changeme@localhost:61141/__cypress/runner/cypress_runner.js:6339:29) - at tryFn (http://elastic:changeme@localhost:61141/__cypress/runner/cypress_runner.js:140680:21) - at whenStable (http://elastic:changeme@localhost:61141/__cypress/runner/cypress_runner.js:140715:12) - at http://elastic:changeme@localhost:61141/__cypress/runner/cypress_runner.js:140259:16 - at tryCatcher (http://elastic:changeme@localhost:61141/__cypress/runner/cypress_runner.js:9065:23) - at Promise._settlePromiseFromHandler (http://elastic:changeme@localhost:61141/__cypress/runner/cypress_runner.js:7000:31) - at Promise._settlePromise (http://elastic:changeme@localhost:61141/__cypress/runner/cypress_runner.js:7057:18) - at Promise._settlePromise0 (http://elastic:changeme@localhost:61141/__cypress/runner/cypress_runner.js:7102:10)]]> - - - diff --git a/packages/kbn-test/src/failed_tests_reporter/__fixtures__/ftr_report.xml b/packages/kbn-test/src/failed_tests_reporter/__fixtures__/ftr_report.xml deleted file mode 100644 index 3bfc686f9e84..000000000000 --- a/packages/kbn-test/src/failed_tests_reporter/__fixtures__/ftr_report.xml +++ /dev/null @@ -1,53 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/packages/kbn-test/src/failed_tests_reporter/__fixtures__/index.ts b/packages/kbn-test/src/failed_tests_reporter/__fixtures__/index.ts deleted file mode 100644 index 11d6cb6a2b47..000000000000 --- a/packages/kbn-test/src/failed_tests_reporter/__fixtures__/index.ts +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -const Fs = jest.requireActual('fs'); - -export const FTR_REPORT = Fs.readFileSync(require.resolve('./ftr_report.xml'), 'utf8'); -export const JEST_REPORT = Fs.readFileSync(require.resolve('./jest_report.xml'), 'utf8'); -export const MOCHA_REPORT = Fs.readFileSync(require.resolve('./mocha_report.xml'), 'utf8'); -export const CYPRESS_REPORT = Fs.readFileSync(require.resolve('./cypress_report.xml'), 'utf8'); diff --git a/packages/kbn-test/src/failed_tests_reporter/__fixtures__/jest_report.xml b/packages/kbn-test/src/failed_tests_reporter/__fixtures__/jest_report.xml deleted file mode 100644 index c49b8d7f59f3..000000000000 --- a/packages/kbn-test/src/failed_tests_reporter/__fixtures__/jest_report.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - .test (/var/lib/jenkins/workspace/elastic+kibana+master/JOB/x-pack-intake/node/immutable/kibana/x-pack/legacy/plugins/code/server/lsp/abstract_launcher.test.ts:166:10)]]> - - - - - - diff --git a/packages/kbn-test/src/failed_tests_reporter/__fixtures__/mocha_report.xml b/packages/kbn-test/src/failed_tests_reporter/__fixtures__/mocha_report.xml deleted file mode 100644 index 64cb7ce551ee..000000000000 --- a/packages/kbn-test/src/failed_tests_reporter/__fixtures__/mocha_report.xml +++ /dev/null @@ -1,38 +0,0 @@ - - - - - - - - - -503 Service Temporarily Unavailable - -

503 Service Temporarily Unavailable

-
nginx/1.13.7
- - - - at Function.getSnapshot (/var/lib/jenkins/workspace/elastic+kibana+master/JOB/x-pack-intake/node/immutable/kibana/packages/kbn-es/src/artifact.js:95:13) - at process._tickCallback (internal/process/next_tick.js:68:7)]]> -
-
- - - - - - - - - - - - - -
-
diff --git a/packages/kbn-test/src/failed_tests_reporter/add_messages_to_report.test.ts b/packages/kbn-test/src/failed_tests_reporter/add_messages_to_report.test.ts deleted file mode 100644 index 505e898c62ad..000000000000 --- a/packages/kbn-test/src/failed_tests_reporter/add_messages_to_report.test.ts +++ /dev/null @@ -1,334 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import Path from 'path'; - -import { ToolingLog } from '@kbn/dev-utils'; -// @ts-ignore -import { createPatch } from 'diff'; - -// turns out Jest can't encode xml diffs in their JUnit reports... -expect.addSnapshotSerializer({ - test: (v) => typeof v === 'string' && (v.includes('<') || v.includes('>')), - serialize: (v) => v.replace(//g, '›').replace(/^\s+$/gm, ''), -}); - -jest.mock('fs', () => { - const realFs = jest.requireActual('fs'); - return { - ...realFs, - writeFile: (...args: any[]) => { - setTimeout(args[args.length - 1], 0); - }, - }; -}); - -import { FTR_REPORT, JEST_REPORT, MOCHA_REPORT, CYPRESS_REPORT } from './__fixtures__'; -import { parseTestReport } from './test_report'; -import { addMessagesToReport } from './add_messages_to_report'; - -beforeEach(() => { - jest.resetAllMocks(); -}); - -const log = new ToolingLog(); - -it('rewrites ftr reports with minimal changes', async () => { - const xml = await addMessagesToReport({ - report: await parseTestReport(FTR_REPORT), - messages: [ - { - name: 'maps app maps loaded from sample data ecommerce "before all" hook', - classname: - 'Chrome X-Pack UI Functional Tests.x-pack/test/functional/apps/maps/sample_data·js', - message: 'foo bar', - }, - ], - log, - reportPath: Path.resolve(__dirname, './__fixtures__/ftr_report.xml'), - }); - - expect(createPatch('ftr.xml', FTR_REPORT, xml, { context: 0 })).toMatchInlineSnapshot(` - Index: ftr.xml - =================================================================== - --- ftr.xml [object Object] - +++ ftr.xml - @@ -1,53 +1,56 @@ - ‹?xml version="1.0" encoding="utf-8"?› - ‹testsuites› - ‹testsuite timestamp="2019-06-05T23:37:10" time="903.670" tests="129" failures="5" skipped="71"› - ‹testcase name="maps app maps loaded from sample data ecommerce "before all" hook" classname="Chrome X-Pack UI Functional Tests.x-pack/test/functional/apps/maps/sample_data·js" time="154.378"› - - ‹system-out› - - ‹![CDATA[[00:00:00] │ - + ‹system-out›Failed Tests Reporter: - + - foo bar - + - + - + [00:00:00] │ - [00:07:04] └-: maps app - ... - [00:15:02] │ - -]]› - + - ‹/system-out› - ‹failure› - - ‹![CDATA[Error: retry.try timeout: TimeoutError: Waiting for element to be located By(css selector, [data-test-subj~="layerTocActionsPanelToggleButtonRoad_Map_-_Bright"]) - + Error: retry.try timeout: TimeoutError: Waiting for element to be located By(css selector, [data-test-subj~="layerTocActionsPanelToggleButtonRoad_Map_-_Bright"]) - Wait timed out after 10055ms - at /var/lib/jenkins/workspace/elastic+kibana+master/JOB/x-pack-ciGroup7/node/immutable/kibana/node_modules/selenium-webdriver/lib/webdriver.js:834:17 - at process._tickCallback (internal/process/next_tick.js:68:7) - at lastError (/var/lib/jenkins/workspace/elastic+kibana+master/JOB/x-pack-ciGroup7/node/immutable/kibana/test/common/services/retry/retry_for_success.ts:28:9) - - at onFailure (/var/lib/jenkins/workspace/elastic+kibana+master/JOB/x-pack-ciGroup7/node/immutable/kibana/test/common/services/retry/retry_for_success.ts:68:13)]]› - + at onFailure (/var/lib/jenkins/workspace/elastic+kibana+master/JOB/x-pack-ciGroup7/node/immutable/kibana/test/common/services/retry/retry_for_success.ts:68:13) - ‹/failure› - ‹/testcase› - ‹testcase name="maps app "after all" hook" classname="Chrome X-Pack UI Functional Tests.x-pack/test/functional/apps/maps" time="0.179" metadata-json="{"messages":["foo"],"screenshots":[{"name":"failure[dashboard app using current data dashboard snapshots compare TSVB snapshot]","url":"https://storage.googleapis.com/kibana-ci-artifacts/jobs/elastic+kibana+7.x/1632/kibana-oss-tests/test/functional/screenshots/failure/dashboard%20app%20using%20current%20data%20dashboard%20snapshots%20compare%20TSVB%20snapshot.png"}]}"› - ‹system-out› - - ‹![CDATA[[00:00:00] │ - + [00:00:00] │ - [00:07:04] └-: maps app - ... - -]]› - + - ‹/system-out› - ‹failure› - - ‹![CDATA[{ NoSuchSessionError: This driver instance does not have a valid session ID (did you call WebDriver.quit()?) and may no longer be used. - + { NoSuchSessionError: This driver instance does not have a valid session ID (did you call WebDriver.quit()?) and may no longer be used. - at promise.finally (/var/lib/jenkins/workspace/elastic+kibana+master/JOB/x-pack-ciGroup7/node/immutable/kibana/node_modules/selenium-webdriver/lib/webdriver.js:726:38) - at Object.thenFinally [as finally] (/var/lib/jenkins/workspace/elastic+kibana+master/JOB/x-pack-ciGroup7/node/immutable/kibana/node_modules/selenium-webdriver/lib/promise.js:124:12) - - at process._tickCallback (internal/process/next_tick.js:68:7) name: 'NoSuchSessionError', remoteStacktrace: '' }]]› - + at process._tickCallback (internal/process/next_tick.js:68:7) name: 'NoSuchSessionError', remoteStacktrace: '' } - ‹/failure› - ‹/testcase› - ‹testcase name="InfraOps app feature controls infrastructure security global infrastructure all privileges shows infrastructure navlink" classname="Chrome X-Pack UI Functional Tests.x-pack/test/functional/apps/infra/feature_controls/infrastructure_security·ts"› - ‹system-out› - - ‹![CDATA[[00:00:00] │ - + [00:00:00] │ - [00:05:13] └-: InfraOps app - ... - -]]› - + - ‹/system-out› - ‹skipped/› - ‹/testcase› - ‹testcase name="machine learning anomaly detection saved search with lucene query job creation opens the advanced section" classname="Firefox XPack UI Functional Tests.x-pack/test/functional/apps/machine_learning/anomaly_detection/saved_search_job·ts" time="6.040"› - - ‹system-out›‹![CDATA[[00:21:57] └-: machine learning...]]›‹/system-out› - - ‹failure›‹![CDATA[{ NoSuchSessionError: Tried to run command without establishing a connection - + ‹system-out›[00:21:57] └-: machine learning...‹/system-out› - + ‹failure›{ NoSuchSessionError: Tried to run command without establishing a connection - at Object.throwDecodedError (/dev/shm/workspace/kibana/node_modules/selenium-webdriver/lib/error.js:550:15) - at parseHttpResponse (/dev/shm/workspace/kibana/node_modules/selenium-webdriver/lib/http.js:563:13) - at Executor.execute (/dev/shm/workspace/kibana/node_modules/selenium-webdriver/lib/http.js:489:26) - - at process._tickCallback (internal/process/next_tick.js:68:7) name: 'NoSuchSessionError', remoteStacktrace: '' }]]›‹/failure› - + at process._tickCallback (internal/process/next_tick.js:68:7) name: 'NoSuchSessionError', remoteStacktrace: '' }‹/failure› - ‹/testcase› - ‹/testsuite› - -‹/testsuites› - +‹/testsuites› - \\ No newline at end of file - - `); -}); - -it('rewrites jest reports with minimal changes', async () => { - const xml = await addMessagesToReport({ - report: await parseTestReport(JEST_REPORT), - messages: [ - { - classname: 'X-Pack Jest Tests.x-pack/legacy/plugins/code/server/lsp', - name: 'launcher can reconnect if process died', - message: 'foo bar', - }, - ], - log, - reportPath: Path.resolve(__dirname, './__fixtures__/jest_report.xml'), - }); - - expect(createPatch('jest.xml', JEST_REPORT, xml, { context: 0 })).toMatchInlineSnapshot(` - Index: jest.xml - =================================================================== - --- jest.xml [object Object] - +++ jest.xml - @@ -3,13 +3,17 @@ - ‹testsuite name="x-pack/legacy/plugins/code/server/lsp/abstract_launcher.test.ts" timestamp="2019-06-07T03:42:21" time="14.504" tests="5" failures="1" skipped="0" file="/var/lib/jenkins/workspace/elastic+kibana+master/JOB/x-pack-intake/node/immutable/kibana/x-pack/legacy/plugins/code/server/lsp/abstract_launcher.test.ts"› - ‹testcase classname="X-Pack Jest Tests.x-pack/legacy/plugins/code/server/lsp" name="launcher can start and end a process" time="1.316"/› - ‹testcase classname="X-Pack Jest Tests.x-pack/legacy/plugins/code/server/lsp" name="launcher can force kill the process if langServer can not exit" time="3.182"/› - ‹testcase classname="X-Pack Jest Tests.x-pack/legacy/plugins/code/server/lsp" name="launcher can reconnect if process died" time="7.060"› - - ‹failure› - - ‹![CDATA[TypeError: Cannot read property '0' of undefined - - at Object.‹anonymous›.test (/var/lib/jenkins/workspace/elastic+kibana+master/JOB/x-pack-intake/node/immutable/kibana/x-pack/legacy/plugins/code/server/lsp/abstract_launcher.test.ts:166:10)]]› - - ‹/failure› - + ‹failure›‹![CDATA[ - + TypeError: Cannot read property '0' of undefined - + at Object.‹anonymous›.test (/var/lib/jenkins/workspace/elastic+kibana+master/JOB/x-pack-intake/node/immutable/kibana/x-pack/legacy/plugins/code/server/lsp/abstract_launcher.test.ts:166:10) - + ]]›‹/failure› - + ‹system-out›Failed Tests Reporter: - + - foo bar - + - +‹/system-out› - ‹/testcase› - ‹testcase classname="X-Pack Jest Tests.x-pack/legacy/plugins/code/server/lsp" name="passive launcher can start and end a process" time="0.435"/› - ‹testcase classname="X-Pack Jest Tests.x-pack/legacy/plugins/code/server/lsp" name="passive launcher should restart a process if a process died before connected" time="1.502"/› - ‹/testsuite› - -‹/testsuites› - +‹/testsuites› - \\ No newline at end of file - - `); -}); - -it('rewrites mocha reports with minimal changes', async () => { - const xml = await addMessagesToReport({ - report: await parseTestReport(MOCHA_REPORT), - messages: [ - { - name: 'code in multiple nodes "before all" hook', - classname: 'X-Pack Mocha Tests.x-pack/legacy/plugins/code/server/__tests__/multi_node·ts', - message: 'foo bar', - }, - ], - log, - reportPath: Path.resolve(__dirname, './__fixtures__/mocha_report.xml'), - }); - - expect(createPatch('mocha.xml', MOCHA_REPORT, xml, { context: 0 })).toMatchInlineSnapshot(` - Index: mocha.xml - =================================================================== - --- mocha.xml [object Object] - +++ mocha.xml - @@ -1,13 +1,16 @@ - ‹?xml version="1.0" encoding="utf-8"?› - ‹testsuites› - ‹testsuite timestamp="2019-06-13T23:29:36" time="30.739" tests="1444" failures="2" skipped="3"› - ‹testcase name="code in multiple nodes "before all" hook" classname="X-Pack Mocha Tests.x-pack/legacy/plugins/code/server/__tests__/multi_node·ts" time="0.121"› - - ‹system-out› - - ‹![CDATA[]]› - + ‹system-out›Failed Tests Reporter: - + - foo bar - + - + - + - ‹/system-out› - - ‹failure› - - ‹![CDATA[Error: Unable to read artifact info from https://artifacts-api.elastic.co/v1/versions/8.0.0-SNAPSHOT/builds/latest/projects/elasticsearch: Service Temporarily Unavailable - + ‹failure›‹![CDATA[ - + Error: Unable to read artifact info from https://artifacts-api.elastic.co/v1/versions/8.0.0-SNAPSHOT/builds/latest/projects/elasticsearch: Service Temporarily Unavailable - ‹html› - ‹head›‹title›503 Service Temporarily Unavailable‹/title›‹/head› - ‹body bgcolor="white"› - ‹center›‹h1›503 Service Temporarily Unavailable‹/h1›‹/center› - @@ -15,24 +18,24 @@ - ‹/body› - ‹/html› - - at Function.getSnapshot (/var/lib/jenkins/workspace/elastic+kibana+master/JOB/x-pack-intake/node/immutable/kibana/packages/kbn-es/src/artifact.js:95:13) - - at process._tickCallback (internal/process/next_tick.js:68:7)]]› - - ‹/failure› - + at process._tickCallback (internal/process/next_tick.js:68:7) - + ]]›‹/failure› - ‹/testcase› - ‹testcase name="code in multiple nodes "after all" hook" classname="X-Pack Mocha Tests.x-pack/legacy/plugins/code/server/__tests__/multi_node·ts" time="0.003"› - ‹system-out› - - ‹![CDATA[]]› - + - ‹/system-out› - ‹failure› - - ‹![CDATA[TypeError: Cannot read property 'shutdown' of undefined - + TypeError: Cannot read property 'shutdown' of undefined - at Context.shutdown (plugins/code/server/__tests__/multi_node.ts:125:23) - - at process.topLevelDomainCallback (domain.js:120:23)]]› - + at process.topLevelDomainCallback (domain.js:120:23) - ‹/failure› - ‹/testcase› - ‹testcase name="repository service test can not clone a repo by ssh without a key" classname="X-Pack Mocha Tests.x-pack/legacy/plugins/code/server/__tests__/repository_service·ts" time="0.005"› - ‹system-out› - - ‹![CDATA[]]› - + - ‹/system-out› - ‹/testcase› - ‹/testsuite› - -‹/testsuites› - +‹/testsuites› - \\ No newline at end of file - - `); -}); - -it('rewrites cypress reports with minimal changes', async () => { - const xml = await addMessagesToReport({ - messages: [ - { - classname: '"after each" hook for "toggles open the timeline"', - name: 'timeline flyout button "after each" hook for "toggles open the timeline"', - message: 'Some extra content\n', - }, - ], - report: await parseTestReport(CYPRESS_REPORT), - log, - reportPath: Path.resolve(__dirname, './__fixtures__/cypress_report.xml'), - }); - - expect(createPatch('cypress.xml', CYPRESS_REPORT, xml, { context: 0 })).toMatchInlineSnapshot(` - Index: cypress.xml - =================================================================== - --- cypress.xml [object Object] - +++ cypress.xml - @@ -1,25 +1,16 @@ - -‹?xml version="1.0" encoding="UTF-8"?› - +‹?xml version="1.0" encoding="utf-8"?› - ‹testsuites name="Mocha Tests" time="16.198" tests="2" failures="1"› - - ‹testsuite name="Root Suite" timestamp="2020-07-22T15:06:26" tests="0" file="cypress/integration/timeline_flyout_button.spec.ts" failures="0" time="0"› - - ‹/testsuite› - + ‹testsuite name="Root Suite" timestamp="2020-07-22T15:06:26" tests="0" file="cypress/integration/timeline_flyout_button.spec.ts" failures="0" time="0"/› - ‹testsuite name="timeline flyout button" timestamp="2020-07-22T15:06:26" tests="2" failures="1" time="16.198"› - - ‹testcase name="timeline flyout button toggles open the timeline" time="8.099" classname="toggles open the timeline"› - - ‹/testcase› - + ‹testcase name="timeline flyout button toggles open the timeline" time="8.099" classname="toggles open the timeline"/› - ‹testcase name="timeline flyout button "after each" hook for "toggles open the timeline"" time="8.099" classname=""after each" hook for "toggles open the timeline""› - - ‹failure message="Timed out retrying: \`cy.click()\` could not be issued because this element is currently animating: - + ‹failure message="Timed out retrying: \`cy.click()\` could not be issued because this element is currently animating: \`<button class="euiButtonEmpty euiButtonEmpty--text" type="button" data-test-subj="timeline-new"›...</button›\` You can fix this problem by: - Passing \`{force: true}\` which disables all error checking - Passing \`{waitForAnimations: false}\` which disables waiting on animations - Passing \`{animationDistanceThreshold: 20}\` which decreases the sensitivity https://on.cypress.io/element-is-animating Because this error occurred during a \`after each\` hook we are skipping the remaining tests in the current suite: \`timeline flyout button\`" type="CypressError"›‹![CDATA[Failed Tests Reporter: - + - Some extra content - - -\`<button class="euiButtonEmpty euiButtonEmpty--text" type="button" data-test-subj="timeline-new">...</button>\` - - -You can fix this problem by: - - - Passing \`{force: true}\` which disables all error checking - - - Passing \`{waitForAnimations: false}\` which disables waiting on animations - - - Passing \`{animationDistanceThreshold: 20}\` which decreases the sensitivity - +CypressError: Timed out retrying: \`cy.click()\` could not be issued because this element is currently animating: - - -https://on.cypress.io/element-is-animating - - - -Because this error occurred during a \`after each\` hook we are skipping the remaining tests in the current suite: \`timeline flyout button\`" type="CypressError"›‹![CDATA[CypressError: Timed out retrying: \`cy.click()\` could not be issued because this element is currently animating: - - - \`‹button class="euiButtonEmpty euiButtonEmpty--text" type="button" data-test-subj="timeline-new"›...‹/button›\` - - You can fix this problem by: - - Passing \`{force: true}\` which disables all error checking - @@ -46,5 +37,5 @@ - at Promise._settlePromise (http://elastic:changeme@localhost:61141/__cypress/runner/cypress_runner.js:7057:18) - at Promise._settlePromise0 (http://elastic:changeme@localhost:61141/__cypress/runner/cypress_runner.js:7102:10)]]›‹/failure› - ‹/testcase› - ‹/testsuite› - -‹/testsuites› - +‹/testsuites› - \\ No newline at end of file - - `); -}); diff --git a/packages/kbn-test/src/failed_tests_reporter/add_messages_to_report.ts b/packages/kbn-test/src/failed_tests_reporter/add_messages_to_report.ts deleted file mode 100644 index 27bf8a9c7549..000000000000 --- a/packages/kbn-test/src/failed_tests_reporter/add_messages_to_report.ts +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import Fs from 'fs'; -import { promisify } from 'util'; - -import { ToolingLog } from '@kbn/dev-utils'; -import xml2js from 'xml2js'; - -import { TestReport, makeFailedTestCaseIter } from './test_report'; - -const writeAsync = promisify(Fs.writeFile); - -export interface Message { - classname: string; - name: string; - message: string; -} - -/** - * Mutate the report to include mentions of Github issues related to test failures, - * then write the updated report to disk - */ -export async function addMessagesToReport(options: { - log: ToolingLog; - report: TestReport; - messages: Message[]; - reportPath: string; - dryRun?: boolean; -}) { - const { log, report, messages, reportPath, dryRun } = options; - - for (const testCase of makeFailedTestCaseIter(report)) { - const { classname, name } = testCase.$; - const messageList = messages - .filter((u) => u.classname === classname && u.name === name) - .reduce((acc, u) => `${acc}\n - ${u.message}`, ''); - - if (!messageList) { - continue; - } - - log.info(`${classname} - ${name}:${messageList}`); - const output = `Failed Tests Reporter:${messageList}\n\n`; - - if (typeof testCase.failure[0] === 'object' && testCase.failure[0].$.message) { - // failure with "messages" ignore the system-out on jenkins - // so we instead extend the failure message - testCase.failure[0]._ = output + testCase.failure[0]._; - } else if (!testCase['system-out']) { - testCase['system-out'] = [{ _: output }]; - } else if (typeof testCase['system-out'][0] === 'string') { - testCase['system-out'][0] = { _: output + testCase['system-out'][0] }; - } else { - testCase['system-out'][0]._ = output + testCase['system-out'][0]._; - } - } - - const builder = new xml2js.Builder({ - cdata: true, - xmldec: { version: '1.0', encoding: 'utf-8' }, - }); - - const xml = builder - .buildObject(report) - .split('\n') - .map((line) => (line.trim() === '' ? '' : line)) - .join('\n'); - - if (dryRun) { - log.info(`updated ${reportPath}\n${xml}`); - } else { - await writeAsync(reportPath, xml, 'utf8'); - } - return xml; -} diff --git a/packages/kbn-test/src/failed_tests_reporter/get_failures.test.ts b/packages/kbn-test/src/failed_tests_reporter/get_failures.test.ts deleted file mode 100644 index f570ed36111b..000000000000 --- a/packages/kbn-test/src/failed_tests_reporter/get_failures.test.ts +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import { getFailures } from './get_failures'; -import { parseTestReport } from './test_report'; -import { FTR_REPORT, JEST_REPORT, MOCHA_REPORT } from './__fixtures__'; - -it('discovers failures in ftr report', async () => { - const failures = getFailures(await parseTestReport(FTR_REPORT)); - expect(failures).toMatchInlineSnapshot(` - Array [ - Object { - "classname": "Chrome X-Pack UI Functional Tests.x-pack/test/functional/apps/maps/sample_data·js", - "failure": " - Error: retry.try timeout: TimeoutError: Waiting for element to be located By(css selector, [data-test-subj~=\\"layerTocActionsPanelToggleButtonRoad_Map_-_Bright\\"]) - Wait timed out after 10055ms - at /var/lib/jenkins/workspace/elastic+kibana+master/JOB/x-pack-ciGroup7/node/immutable/kibana/node_modules/selenium-webdriver/lib/webdriver.js:834:17 - at process._tickCallback (internal/process/next_tick.js:68:7) - at lastError (/var/lib/jenkins/workspace/elastic+kibana+master/JOB/x-pack-ciGroup7/node/immutable/kibana/test/common/services/retry/retry_for_success.ts:28:9) - at onFailure (/var/lib/jenkins/workspace/elastic+kibana+master/JOB/x-pack-ciGroup7/node/immutable/kibana/test/common/services/retry/retry_for_success.ts:68:13) - ", - "likelyIrrelevant": false, - "name": "maps app maps loaded from sample data ecommerce \\"before all\\" hook", - "time": "154.378", - }, - Object { - "classname": "Chrome X-Pack UI Functional Tests.x-pack/test/functional/apps/maps", - "failure": " - { NoSuchSessionError: This driver instance does not have a valid session ID (did you call WebDriver.quit()?) and may no longer be used. - at promise.finally (/var/lib/jenkins/workspace/elastic+kibana+master/JOB/x-pack-ciGroup7/node/immutable/kibana/node_modules/selenium-webdriver/lib/webdriver.js:726:38) - at Object.thenFinally [as finally] (/var/lib/jenkins/workspace/elastic+kibana+master/JOB/x-pack-ciGroup7/node/immutable/kibana/node_modules/selenium-webdriver/lib/promise.js:124:12) - at process._tickCallback (internal/process/next_tick.js:68:7) name: 'NoSuchSessionError', remoteStacktrace: '' } - ", - "likelyIrrelevant": true, - "metadata-json": "{\\"messages\\":[\\"foo\\"],\\"screenshots\\":[{\\"name\\":\\"failure[dashboard app using current data dashboard snapshots compare TSVB snapshot]\\",\\"url\\":\\"https://storage.googleapis.com/kibana-ci-artifacts/jobs/elastic+kibana+7.x/1632/kibana-oss-tests/test/functional/screenshots/failure/dashboard%20app%20using%20current%20data%20dashboard%20snapshots%20compare%20TSVB%20snapshot.png\\"}]}", - "name": "maps app \\"after all\\" hook", - "time": "0.179", - }, - Object { - "classname": "Firefox XPack UI Functional Tests.x-pack/test/functional/apps/machine_learning/anomaly_detection/saved_search_job·ts", - "failure": "{ NoSuchSessionError: Tried to run command without establishing a connection - at Object.throwDecodedError (/dev/shm/workspace/kibana/node_modules/selenium-webdriver/lib/error.js:550:15) - at parseHttpResponse (/dev/shm/workspace/kibana/node_modules/selenium-webdriver/lib/http.js:563:13) - at Executor.execute (/dev/shm/workspace/kibana/node_modules/selenium-webdriver/lib/http.js:489:26) - at process._tickCallback (internal/process/next_tick.js:68:7) name: 'NoSuchSessionError', remoteStacktrace: '' }", - "likelyIrrelevant": true, - "name": "machine learning anomaly detection saved search with lucene query job creation opens the advanced section", - "time": "6.040", - }, - ] - `); -}); - -it('discovers failures in jest report', async () => { - const failures = getFailures(await parseTestReport(JEST_REPORT)); - expect(failures).toMatchInlineSnapshot(` - Array [ - Object { - "classname": "X-Pack Jest Tests.x-pack/legacy/plugins/code/server/lsp", - "failure": " - TypeError: Cannot read property '0' of undefined - at Object..test (/var/lib/jenkins/workspace/elastic+kibana+master/JOB/x-pack-intake/node/immutable/kibana/x-pack/legacy/plugins/code/server/lsp/abstract_launcher.test.ts:166:10) - ", - "likelyIrrelevant": false, - "name": "launcher can reconnect if process died", - "time": "7.060", - }, - ] - `); -}); - -it('discovers failures in mocha report', async () => { - const failures = getFailures(await parseTestReport(MOCHA_REPORT)); - expect(failures).toMatchInlineSnapshot(` - Array [ - Object { - "classname": "X-Pack Mocha Tests.x-pack/legacy/plugins/code/server/__tests__/multi_node·ts", - "failure": " - Error: Unable to read artifact info from https://artifacts-api.elastic.co/v1/versions/8.0.0-SNAPSHOT/builds/latest/projects/elasticsearch: Service Temporarily Unavailable - - 503 Service Temporarily Unavailable - -

503 Service Temporarily Unavailable

-
nginx/1.13.7
- - - - at Function.getSnapshot (/var/lib/jenkins/workspace/elastic+kibana+master/JOB/x-pack-intake/node/immutable/kibana/packages/kbn-es/src/artifact.js:95:13) - at process._tickCallback (internal/process/next_tick.js:68:7) - ", - "likelyIrrelevant": true, - "name": "code in multiple nodes \\"before all\\" hook", - "time": "0.121", - }, - Object { - "classname": "X-Pack Mocha Tests.x-pack/legacy/plugins/code/server/__tests__/multi_node·ts", - "failure": " - TypeError: Cannot read property 'shutdown' of undefined - at Context.shutdown (plugins/code/server/__tests__/multi_node.ts:125:23) - at process.topLevelDomainCallback (domain.js:120:23) - ", - "likelyIrrelevant": true, - "name": "code in multiple nodes \\"after all\\" hook", - "time": "0.003", - }, - ] - `); -}); diff --git a/packages/kbn-test/src/failed_tests_reporter/get_failures.ts b/packages/kbn-test/src/failed_tests_reporter/get_failures.ts deleted file mode 100644 index be058791f737..000000000000 --- a/packages/kbn-test/src/failed_tests_reporter/get_failures.ts +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import stripAnsi from 'strip-ansi'; - -import { FailedTestCase, TestReport, makeFailedTestCaseIter } from './test_report'; - -export type TestFailure = FailedTestCase['$'] & { - failure: string; - likelyIrrelevant: boolean; -}; - -const getFailureText = (failure: FailedTestCase['failure']) => { - const [failureNode] = failure; - - if (failureNode && typeof failureNode === 'object' && typeof failureNode._ === 'string') { - return stripAnsi(failureNode._); - } - - return stripAnsi(String(failureNode)); -}; - -const isLikelyIrrelevant = (name: string, failure: string) => { - if ( - failure.includes('NoSuchSessionError: This driver instance does not have a valid session ID') || - failure.includes('NoSuchSessionError: Tried to run command without establishing a connection') - ) { - return true; - } - - if (failure.includes('Error: No Living connections')) { - return true; - } - - if ( - name.includes('"after all" hook') && - failure.includes(`Cannot read property 'shutdown' of undefined`) - ) { - return true; - } - - if ( - failure.includes('Unable to read artifact info') && - failure.includes('Service Temporarily Unavailable') - ) { - return true; - } - - if (failure.includes('Unable to fetch Kibana status API response from Kibana')) { - return true; - } - - return false; -}; - -export function getFailures(report: TestReport) { - const failures: TestFailure[] = []; - - for (const testCase of makeFailedTestCaseIter(report)) { - const failure = getFailureText(testCase.failure); - const likelyIrrelevant = isLikelyIrrelevant(testCase.$.name, failure); - - failures.push({ - // unwrap xml weirdness - ...testCase.$, - // Strip ANSI color characters - failure, - likelyIrrelevant, - }); - } - - return failures; -} diff --git a/packages/kbn-test/src/failed_tests_reporter/github_api.ts b/packages/kbn-test/src/failed_tests_reporter/github_api.ts deleted file mode 100644 index a0e3bcafdf19..000000000000 --- a/packages/kbn-test/src/failed_tests_reporter/github_api.ts +++ /dev/null @@ -1,254 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import Url from 'url'; - -import Axios, { AxiosRequestConfig, AxiosInstance } from 'axios'; -import parseLinkHeader from 'parse-link-header'; -import { ToolingLog, isAxiosResponseError, isAxiosRequestError } from '@kbn/dev-utils'; - -const BASE_URL = 'https://api.github.com/repos/elastic/kibana/'; - -export interface GithubIssue { - html_url: string; - number: number; - title: string; - labels: unknown[]; - body: string; -} - -/** - * Minimal GithubIssue type that can be easily replicated by dry-run helpers - */ -export interface GithubIssueMini { - number: GithubIssue['number']; - body: GithubIssue['body']; - html_url: GithubIssue['html_url']; -} - -type RequestOptions = AxiosRequestConfig & { - safeForDryRun?: boolean; - maxAttempts?: number; - attempt?: number; -}; - -export class GithubApi { - private readonly log: ToolingLog; - private readonly token: string | undefined; - private readonly dryRun: boolean; - private readonly x: AxiosInstance; - - /** - * Create a GithubApi helper object, if token is undefined requests won't be - * sent, but will instead be logged. - */ - constructor(options: { - log: GithubApi['log']; - token: GithubApi['token']; - dryRun: GithubApi['dryRun']; - }) { - this.log = options.log; - this.token = options.token; - this.dryRun = options.dryRun; - - if (!this.token && !this.dryRun) { - throw new TypeError('token parameter is required'); - } - - this.x = Axios.create({ - headers: { - ...(this.token ? { Authorization: `token ${this.token}` } : {}), - 'User-Agent': 'elastic/kibana#failed_test_reporter', - }, - }); - } - - private failedTestIssuesPageCache: { - pages: GithubIssue[][]; - nextRequest: RequestOptions | undefined; - } = { - pages: [], - nextRequest: { - safeForDryRun: true, - method: 'GET', - url: Url.resolve(BASE_URL, 'issues'), - params: { - state: 'all', - per_page: '100', - labels: 'failed-test', - sort: 'updated', - direction: 'desc', - }, - }, - }; - - /** - * Iterate the `failed-test` issues from elastic/kibana, each response - * from Github is cached and subsequent calls to this method will first - * iterate the previous responses from Github, then start requesting - * more pages of issues from github until all pages have been cached. - * - * Aborting the iterator part way through will prevent unnecessary request - * to Github from being issued. - */ - async *iterateCachedFailedTestIssues() { - const cache = this.failedTestIssuesPageCache; - - // start from page 0, and progress forward if we have cache or a request that will load that cache page - for (let page = 0; page < cache.pages.length || cache.nextRequest; page++) { - if (page >= cache.pages.length && cache.nextRequest) { - const resp = await this.request(cache.nextRequest, []); - cache.pages.push(resp.data); - - const link = - typeof resp.headers.link === 'string' ? parseLinkHeader(resp.headers.link) : undefined; - - cache.nextRequest = - link && link.next && link.next.url - ? { - safeForDryRun: true, - method: 'GET', - url: link.next.url, - } - : undefined; - } - - for (const issue of cache.pages[page]) { - yield issue; - } - } - } - - async findFailedTestIssue(test: (issue: GithubIssue) => boolean) { - for await (const issue of this.iterateCachedFailedTestIssues()) { - if (test(issue)) { - return issue; - } - } - } - - async editIssueBodyAndEnsureOpen(issueNumber: number, newBody: string) { - await this.request( - { - method: 'PATCH', - url: Url.resolve(BASE_URL, `issues/${encodeURIComponent(issueNumber)}`), - data: { - state: 'open', // Reopen issue if it was closed. - body: newBody, - }, - }, - undefined - ); - } - - async addIssueComment(issueNumber: number, commentBody: string) { - await this.request( - { - method: 'POST', - url: Url.resolve(BASE_URL, `issues/${encodeURIComponent(issueNumber)}/comments`), - data: { - body: commentBody, - }, - }, - undefined - ); - } - - async createIssue(title: string, body: string, labels?: string[]) { - const resp = await this.request( - { - method: 'POST', - url: Url.resolve(BASE_URL, 'issues'), - data: { - title, - body, - labels, - }, - }, - { - body, - number: 999, - html_url: 'https://dryrun', - } - ); - - return resp.data; - } - - private async request( - options: RequestOptions, - dryRunResponse: T - ): Promise<{ - status: number; - statusText: string; - headers: Record; - data: T; - }> { - const executeRequest = !this.dryRun || options.safeForDryRun; - const maxAttempts = options.maxAttempts || 5; - const attempt = options.attempt || 1; - - this.log.verbose('Github API', executeRequest ? 'Request' : 'Dry Run', options); - - if (!executeRequest) { - return { - status: 200, - statusText: 'OK', - headers: {}, - data: dryRunResponse, - }; - } - - try { - return await this.x.request(options); - } catch (error) { - const unableToReachGithub = isAxiosRequestError(error); - const githubApiFailed = isAxiosResponseError(error) && error.response.status >= 500; - const errorResponseLog = - isAxiosResponseError(error) && - `[${error.config.method} ${error.config.url}] ${error.response.status} ${error.response.statusText} Error`; - - if ((unableToReachGithub || githubApiFailed) && attempt < maxAttempts) { - const waitMs = 1000 * attempt; - - if (errorResponseLog) { - this.log.error(`${errorResponseLog}: waiting ${waitMs}ms to retry`); - } else { - this.log.error(`Unable to reach github, waiting ${waitMs}ms to retry`); - } - - await new Promise((resolve) => setTimeout(resolve, waitMs)); - return await this.request( - { - ...options, - maxAttempts, - attempt: attempt + 1, - }, - dryRunResponse - ); - } - - if (errorResponseLog) { - throw new Error(`${errorResponseLog}: ${JSON.stringify(error.response.data)}`); - } - - throw error; - } - } -} diff --git a/packages/kbn-test/src/failed_tests_reporter/index.ts b/packages/kbn-test/src/failed_tests_reporter/index.ts deleted file mode 100644 index 1332f08eb4e1..000000000000 --- a/packages/kbn-test/src/failed_tests_reporter/index.ts +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -export { runFailedTestsReporterCli } from './run_failed_tests_reporter_cli'; diff --git a/packages/kbn-test/src/failed_tests_reporter/issue_metadata.test.ts b/packages/kbn-test/src/failed_tests_reporter/issue_metadata.test.ts deleted file mode 100644 index f7585cb941a2..000000000000 --- a/packages/kbn-test/src/failed_tests_reporter/issue_metadata.test.ts +++ /dev/null @@ -1,134 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import dedent from 'dedent'; - -import { getIssueMetadata, updateIssueMetadata } from './issue_metadata'; - -const HAS_METADATA = dedent` - # my issue - - some text - - -`; - -const HAS_SOME_OTHER_METADATA = dedent` - # my issue - - some text - - -`; - -const INVALID_METADATA = dedent` - # my issue - - some text - - -`; - -const MISSING_METADATA = dedent` - # my issue - - some text -`; - -describe('getIssueMetadata', () => { - it('reads properly formatted metadata', () => { - expect(getIssueMetadata(HAS_METADATA, 'foo')).toBe('bar'); - }); - - it('returns undefined if JSON is malformed', () => { - expect(getIssueMetadata(INVALID_METADATA, 'foo')).toBe(undefined); - }); - - it('returns undefined if metadata is missing', () => { - expect(getIssueMetadata(MISSING_METADATA, 'foo')).toBe(undefined); - }); - - it('returns undefined if JSON is missing `failed-test` property', () => { - expect(getIssueMetadata(HAS_SOME_OTHER_METADATA, 'foo')).toBe(undefined); - }); - - it('returns defaultValue if specified', () => { - expect(getIssueMetadata(HAS_METADATA, 'foo2', 'bar2')).toBe('bar2'); - }); - - it('returns undefined if defaultValue is not specified', () => { - expect(getIssueMetadata(HAS_METADATA, 'foo2')).toBe(undefined); - }); -}); - -describe('updateIssueMetadata', () => { - it('merges new values with previous values', () => { - expect( - updateIssueMetadata(HAS_METADATA, { - box: 'baz', - }) - ).toMatchInlineSnapshot(` - "# my issue - - some text - - " - `); - }); - - it('adds metadata if not found', () => { - expect( - updateIssueMetadata(MISSING_METADATA, { - box: 'baz', - }) - ).toMatchInlineSnapshot(` - "# my issue - - some text - - " - `); - - expect( - updateIssueMetadata(HAS_SOME_OTHER_METADATA, { - box: 'baz', - }) - ).toMatchInlineSnapshot(` - "# my issue - - some text - - " - `); - }); - - it('overwrites metdata if JSON is malformed', () => { - expect( - updateIssueMetadata(INVALID_METADATA, { - box: 'baz', - }) - ).toMatchInlineSnapshot(` - "# my issue - - some text - - " - `); - }); -}); diff --git a/packages/kbn-test/src/failed_tests_reporter/issue_metadata.ts b/packages/kbn-test/src/failed_tests_reporter/issue_metadata.ts deleted file mode 100644 index e313aefe8a2f..000000000000 --- a/packages/kbn-test/src/failed_tests_reporter/issue_metadata.ts +++ /dev/null @@ -1,69 +0,0 @@ -/* eslint-disable @kbn/eslint/require-license-header */ - -/* @notice - * This product bundles code based on probot-metadata@1.0.0 which is - * available under a "MIT" license. - * - * ISC License - * - * Copyright (c) 2017 Brandon Keepers - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -/** - * Allows retrieving and setting key/value pairs on a Github Issue. Keys and values must be JSON-serializable. - * Derived from https://github.com/probot/metadata/blob/6ae1523d5035ba727d09c0e7f77a6a154d9a4777/index.js - * - * `body` is a string that contains markdown and any existing metadata (eg. an issue or comment body) - * `prefix` is a string that can be used to namespace the metadata, defaults to `ci`. - */ -const PREFIX = 'failed-test'; -const REGEX = /\n\n/; - -function safeJsonParse(json: string, onError: any) { - try { - return JSON.parse(json); - } catch { - return onError; - } -} - -/** - * Parse metadata from issue body - */ -export function getIssueMetadata(body: string, key: string, defaultValue: any = undefined) { - const match = body.match(REGEX); - - if (match) { - const data = safeJsonParse(match[1], {})[PREFIX]; - return data && data[key] !== undefined ? data[key] : defaultValue; - } else { - return defaultValue; - } -} - -/** - * Set data on the body. - */ -export function updateIssueMetadata(body: string, values: Record) { - if (REGEX.test(body)) { - return body.replace(REGEX, (match, json) => { - const data = safeJsonParse(json, {}); - data[PREFIX] = Object.assign(data[PREFIX] || {}, values); - return match.replace(json, JSON.stringify(data)); - }); - } - - return `${body}\n\n`; -} diff --git a/packages/kbn-test/src/failed_tests_reporter/report_failure.test.ts b/packages/kbn-test/src/failed_tests_reporter/report_failure.test.ts deleted file mode 100644 index 5bbc72fe04e8..000000000000 --- a/packages/kbn-test/src/failed_tests_reporter/report_failure.test.ts +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import dedent from 'dedent'; - -import { createFailureIssue, updateFailureIssue } from './report_failure'; - -jest.mock('./github_api'); -const { GithubApi } = jest.requireMock('./github_api'); - -describe('createFailureIssue()', () => { - it('creates new github issue with failure text, link to issue, and valid metadata', async () => { - const api = new GithubApi(); - - await createFailureIssue( - 'https://build-url', - { - classname: 'some.classname', - failure: 'this is the failure text', - name: 'test name', - time: '2018-01-01T01:00:00Z', - likelyIrrelevant: false, - }, - api - ); - - expect(api.createIssue).toMatchInlineSnapshot(` - [MockFunction] { - "calls": Array [ - Array [ - "Failing test: some.classname - test name", - "A test failed on a tracked branch - - \`\`\` - this is the failure text - \`\`\` - - First failure: [Jenkins Build](https://build-url) - - ", - Array [ - "failed-test", - ], - ], - ], - "results": Array [ - Object { - "type": "return", - "value": undefined, - }, - ], - } - `); - }); -}); - -describe('updateFailureIssue()', () => { - it('increments failure count and adds new comment to issue', async () => { - const api = new GithubApi(); - - await updateFailureIssue( - 'https://build-url', - { - html_url: 'https://github.com/issues/1234', - number: 1234, - body: dedent` - # existing issue body - - " - `, - }, - api - ); - - expect(api.editIssueBodyAndEnsureOpen).toMatchInlineSnapshot(` - [MockFunction] { - "calls": Array [ - Array [ - 1234, - "# existing issue body - - \\"", - ], - ], - "results": Array [ - Object { - "type": "return", - "value": undefined, - }, - ], - } - `); - expect(api.addIssueComment).toMatchInlineSnapshot(` - [MockFunction] { - "calls": Array [ - Array [ - 1234, - "New failure: [Jenkins Build](https://build-url)", - ], - ], - "results": Array [ - Object { - "type": "return", - "value": undefined, - }, - ], - } - `); - }); -}); diff --git a/packages/kbn-test/src/failed_tests_reporter/report_failure.ts b/packages/kbn-test/src/failed_tests_reporter/report_failure.ts deleted file mode 100644 index 1413d0549845..000000000000 --- a/packages/kbn-test/src/failed_tests_reporter/report_failure.ts +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import { TestFailure } from './get_failures'; -import { GithubIssueMini, GithubApi } from './github_api'; -import { getIssueMetadata, updateIssueMetadata } from './issue_metadata'; - -export async function createFailureIssue(buildUrl: string, failure: TestFailure, api: GithubApi) { - const title = `Failing test: ${failure.classname} - ${failure.name}`; - - const body = updateIssueMetadata( - [ - 'A test failed on a tracked branch', - '', - '```', - failure.failure, - '```', - '', - `First failure: [Jenkins Build](${buildUrl})`, - ].join('\n'), - { - 'test.class': failure.classname, - 'test.name': failure.name, - 'test.failCount': 1, - } - ); - - return await api.createIssue(title, body, ['failed-test']); -} - -export async function updateFailureIssue(buildUrl: string, issue: GithubIssueMini, api: GithubApi) { - // Increment failCount - const newCount = getIssueMetadata(issue.body, 'test.failCount', 0) + 1; - const newBody = updateIssueMetadata(issue.body, { - 'test.failCount': newCount, - }); - - await api.editIssueBodyAndEnsureOpen(issue.number, newBody); - await api.addIssueComment(issue.number, `New failure: [Jenkins Build](${buildUrl})`); - - return newCount; -} diff --git a/packages/kbn-test/src/failed_tests_reporter/report_metadata.test.ts b/packages/kbn-test/src/failed_tests_reporter/report_metadata.test.ts deleted file mode 100644 index c07908496560..000000000000 --- a/packages/kbn-test/src/failed_tests_reporter/report_metadata.test.ts +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import { getReportMessageIter } from './report_metadata'; -import { parseTestReport } from './test_report'; -import { FTR_REPORT, JEST_REPORT, MOCHA_REPORT } from './__fixtures__'; - -it('reads messages and screenshots from metadata-json properties', async () => { - const ftrReport = await parseTestReport(FTR_REPORT); - expect(Array.from(getReportMessageIter(ftrReport))).toMatchInlineSnapshot(` - Array [ - Object { - "classname": "Chrome X-Pack UI Functional Tests.x-pack/test/functional/apps/maps", - "message": "foo", - "name": "maps app \\"after all\\" hook", - }, - Object { - "classname": "Chrome X-Pack UI Functional Tests.x-pack/test/functional/apps/maps", - "message": "Screenshot: failure[dashboard app using current data dashboard snapshots compare TSVB snapshot] https://storage.googleapis.com/kibana-ci-artifacts/jobs/elastic+kibana+7.x/1632/kibana-oss-tests/test/functional/screenshots/failure/dashboard%20app%20using%20current%20data%20dashboard%20snapshots%20compare%20TSVB%20snapshot.png", - "name": "maps app \\"after all\\" hook", - }, - ] - `); - - const jestReport = await parseTestReport(JEST_REPORT); - expect(Array.from(getReportMessageIter(jestReport))).toMatchInlineSnapshot(`Array []`); - - const mochaReport = await parseTestReport(MOCHA_REPORT); - expect(Array.from(getReportMessageIter(mochaReport))).toMatchInlineSnapshot(`Array []`); -}); diff --git a/packages/kbn-test/src/failed_tests_reporter/report_metadata.ts b/packages/kbn-test/src/failed_tests_reporter/report_metadata.ts deleted file mode 100644 index 5484948e5997..000000000000 --- a/packages/kbn-test/src/failed_tests_reporter/report_metadata.ts +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import { TestReport, makeTestCaseIter } from './test_report'; - -export function* getReportMessageIter(report: TestReport) { - for (const testCase of makeTestCaseIter(report)) { - const metadata = testCase.$['metadata-json'] ? JSON.parse(testCase.$['metadata-json']) : {}; - - for (const message of metadata.messages || []) { - yield { - classname: testCase.$.classname, - name: testCase.$.name, - message: String(message), - }; - } - - for (const screenshot of metadata.screenshots || []) { - yield { - classname: testCase.$.classname, - name: testCase.$.name, - message: `Screenshot: ${screenshot.name} ${screenshot.url}`, - }; - } - } -} diff --git a/packages/kbn-test/src/failed_tests_reporter/run_failed_tests_reporter_cli.ts b/packages/kbn-test/src/failed_tests_reporter/run_failed_tests_reporter_cli.ts deleted file mode 100644 index 93616ce78a04..000000000000 --- a/packages/kbn-test/src/failed_tests_reporter/run_failed_tests_reporter_cli.ts +++ /dev/null @@ -1,174 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import Path from 'path'; - -import { REPO_ROOT } from '@kbn/utils'; -import { run, createFailError, createFlagError } from '@kbn/dev-utils'; -import globby from 'globby'; - -import { getFailures, TestFailure } from './get_failures'; -import { GithubApi, GithubIssueMini } from './github_api'; -import { updateFailureIssue, createFailureIssue } from './report_failure'; -import { getIssueMetadata } from './issue_metadata'; -import { readTestReport } from './test_report'; -import { addMessagesToReport } from './add_messages_to_report'; -import { getReportMessageIter } from './report_metadata'; - -const DEFAULT_PATTERNS = [Path.resolve(REPO_ROOT, 'target/junit/**/*.xml')]; - -export function runFailedTestsReporterCli() { - run( - async ({ log, flags }) => { - let updateGithub = flags['github-update']; - if (updateGithub && !process.env.GITHUB_TOKEN) { - throw createFailError( - 'GITHUB_TOKEN environment variable must be set, otherwise use --no-github-update flag' - ); - } - - if (updateGithub) { - // JOB_NAME is formatted as `elastic+kibana+7.x` in some places and `elastic+kibana+7.x/JOB=kibana-intake,node=immutable` in others - const jobNameSplit = (process.env.JOB_NAME || '').split(/\+|\//); - const branch = jobNameSplit.length >= 3 ? jobNameSplit[2] : process.env.GIT_BRANCH; - if (!branch) { - throw createFailError( - 'Unable to determine originating branch from job name or other environment variables' - ); - } - - const isPr = !!process.env.ghprbPullId; - const isMasterOrVersion = branch === 'master' || branch.match(/^\d+\.(x|\d+)$/); - if (!isMasterOrVersion || isPr) { - log.info('Failure issues only created on master/version branch jobs'); - updateGithub = false; - } - } - - const githubApi = new GithubApi({ - log, - token: process.env.GITHUB_TOKEN, - dryRun: !updateGithub, - }); - - const buildUrl = flags['build-url'] || (updateGithub ? '' : 'http://buildUrl'); - if (typeof buildUrl !== 'string' || !buildUrl) { - throw createFlagError('Missing --build-url or process.env.BUILD_URL'); - } - - const patterns = flags._.length ? flags._ : DEFAULT_PATTERNS; - log.info('Searching for reports at', patterns); - const reportPaths = await globby(patterns, { - absolute: true, - }); - - if (!reportPaths.length) { - throw createFailError(`Unable to find any junit reports with patterns [${patterns}]`); - } - - log.info('found', reportPaths.length, 'junit reports', reportPaths); - const newlyCreatedIssues: Array<{ - failure: TestFailure; - newIssue: GithubIssueMini; - }> = []; - - for (const reportPath of reportPaths) { - const report = await readTestReport(reportPath); - const messages = Array.from(getReportMessageIter(report)); - - for (const failure of await getFailures(report)) { - const pushMessage = (msg: string) => { - messages.push({ - classname: failure.classname, - name: failure.name, - message: msg, - }); - }; - - if (failure.likelyIrrelevant) { - pushMessage( - 'Failure is likely irrelevant' + - (updateGithub ? ', so an issue was not created or updated' : '') - ); - continue; - } - - let existingIssue: GithubIssueMini | undefined = await githubApi.findFailedTestIssue( - (i) => - getIssueMetadata(i.body, 'test.class') === failure.classname && - getIssueMetadata(i.body, 'test.name') === failure.name - ); - - if (!existingIssue) { - const newlyCreated = newlyCreatedIssues.find( - ({ failure: f }) => f.classname === failure.classname && f.name === failure.name - ); - - if (newlyCreated) { - existingIssue = newlyCreated.newIssue; - } - } - - if (existingIssue) { - const newFailureCount = await updateFailureIssue(buildUrl, existingIssue, githubApi); - const url = existingIssue.html_url; - pushMessage(`Test has failed ${newFailureCount - 1} times on tracked branches: ${url}`); - if (updateGithub) { - pushMessage(`Updated existing issue: ${url} (fail count: ${newFailureCount})`); - } - continue; - } - - const newIssue = await createFailureIssue(buildUrl, failure, githubApi); - pushMessage('Test has not failed recently on tracked branches'); - if (updateGithub) { - pushMessage(`Created new issue: ${newIssue.html_url}`); - } - newlyCreatedIssues.push({ failure, newIssue }); - } - - // mutates report to include messages and writes updated report to disk - await addMessagesToReport({ - report, - messages, - log, - reportPath, - dryRun: !flags['report-update'], - }); - } - }, - { - description: `a cli that opens issues or updates existing issues based on junit reports`, - flags: { - boolean: ['github-update', 'report-update'], - string: ['build-url'], - default: { - 'github-update': true, - 'report-update': true, - 'build-url': process.env.BUILD_URL, - }, - help: ` - --no-github-update Execute the CLI without writing to Github - --no-report-update Execute the CLI without writing to the JUnit reports - --build-url URL of the failed build, defaults to process.env.BUILD_URL - `, - }, - } - ); -} diff --git a/packages/kbn-test/src/failed_tests_reporter/test_report.ts b/packages/kbn-test/src/failed_tests_reporter/test_report.ts deleted file mode 100644 index 9907ca8b89ca..000000000000 --- a/packages/kbn-test/src/failed_tests_reporter/test_report.ts +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import Fs from 'fs'; -import { promisify } from 'util'; - -import xml2js from 'xml2js'; - -const readAsync = promisify(Fs.readFile); - -export type TestReport = - | { - testsuites: { - testsuite: TestSuite[]; - }; - } - | { - testsuite: TestSuite; - }; - -export interface TestSuite { - $: { - /* ISO8601 timetamp when test suite ran */ - timestamp: string; - /* number of second this tests suite took */ - time: string; - /* number of tests as a string */ - tests: string; - /* number of failed tests as a string */ - failures: string; - /* number of skipped tests as a string */ - skipped: string; - }; - testcase?: TestCase[]; -} - -export interface TestCase { - $: { - /* unique test name */ - name: string; - /* somewhat human readable combination of test name and file */ - classname: string; - /* number of seconds this test took */ - time: string; - /* optional JSON encoded metadata */ - 'metadata-json'?: string; - }; - /* contents of system-out elements */ - 'system-out'?: Array; - /* contents of failure elements */ - failure?: Array; - /* contents of skipped elements */ - skipped?: Array; -} - -export interface FailedTestCase extends TestCase { - failure: Array; -} - -/** - * Parse JUnit XML Files - */ -export async function parseTestReport(xml: string): Promise { - return await xml2js.parseStringPromise(xml); -} - -export async function readTestReport(testReportPath: string) { - return await parseTestReport(await readAsync(testReportPath, 'utf8')); -} - -export function* makeTestCaseIter(report: TestReport) { - // Reporters may report multiple testsuites in a single file. - const testSuites = 'testsuites' in report ? report.testsuites.testsuite : [report.testsuite]; - - for (const testSuite of testSuites) { - for (const testCase of testSuite.testcase || []) { - yield testCase; - } - } -} - -export function* makeFailedTestCaseIter(report: TestReport) { - for (const testCase of makeTestCaseIter(report)) { - if (!testCase.failure) { - continue; - } - - yield testCase as FailedTestCase; - } -} From 92a8dd055315a6dba0ea0eda7e3e09eba6977ca5 Mon Sep 17 00:00:00 2001 From: Mihir Soni Date: Wed, 3 Mar 2021 22:28:23 +0000 Subject: [PATCH 4/8] [Rename] kbn-test/src/ in packages directory to osd-test/src Signed-off-by: Mihir Soni --- packages/{kbn-test => osd-test}/README.md | 8 +-- .../{kbn-test => osd-test}/babel.config.js | 2 +- packages/{kbn-test => osd-test}/index.d.ts | 0 packages/{kbn-test => osd-test}/package.json | 12 ++-- .../src/ci_parallel_process_prefix.ts | 0 packages/{kbn-test => osd-test}/src/index.ts | 6 +- .../src/junit_report_path.ts | 0 .../src/legacy_es/index.js | 4 +- .../legacy_opensearch_test_cluster.js} | 70 +++++++++---------- .../src/legacy_es/opensearch_test_config.js} | 40 +++++------ .../src/kbn => osd-test/src/osd}/index.ts | 4 +- packages/osd-test/src/osd/osd_test_config.ts | 61 ++++++++++++++++ .../src/kbn => osd-test/src/osd}/users.ts | 16 ++--- packages/{kbn-test => osd-test}/tsconfig.json | 2 +- .../{kbn-test => osd-test}/types/README.md | 4 +- .../{kbn-test => osd-test}/types/ftr.d.ts | 2 +- packages/{kbn-test => osd-test}/yarn.lock | 0 17 files changed, 146 insertions(+), 85 deletions(-) rename packages/{kbn-test => osd-test}/README.md (71%) rename packages/{kbn-test => osd-test}/babel.config.js (94%) rename packages/{kbn-test => osd-test}/index.d.ts (100%) rename packages/{kbn-test => osd-test}/package.json (83%) rename packages/{kbn-test => osd-test}/src/ci_parallel_process_prefix.ts (100%) rename packages/{kbn-test => osd-test}/src/index.ts (86%) rename packages/{kbn-test => osd-test}/src/junit_report_path.ts (100%) rename packages/{kbn-test => osd-test}/src/legacy_es/index.js (83%) rename packages/{kbn-test/src/legacy_es/legacy_es_test_cluster.js => osd-test/src/legacy_es/legacy_opensearch_test_cluster.js} (61%) rename packages/{kbn-test/src/legacy_es/es_test_config.js => osd-test/src/legacy_es/opensearch_test_config.js} (51%) rename packages/{kbn-test/src/kbn => osd-test/src/osd}/index.ts (83%) create mode 100644 packages/osd-test/src/osd/osd_test_config.ts rename packages/{kbn-test/src/kbn => osd-test/src/osd}/users.ts (64%) rename packages/{kbn-test => osd-test}/tsconfig.json (69%) rename packages/{kbn-test => osd-test}/types/README.md (76%) rename packages/{kbn-test => osd-test}/types/ftr.d.ts (98%) rename packages/{kbn-test => osd-test}/yarn.lock (100%) diff --git a/packages/kbn-test/README.md b/packages/osd-test/README.md similarity index 71% rename from packages/kbn-test/README.md rename to packages/osd-test/README.md index 3159e5c2492b..edab0eda74e6 100644 --- a/packages/kbn-test/README.md +++ b/packages/osd-test/README.md @@ -1,14 +1,14 @@ Kibana Testing Library ====================== -The @kbn/test package provides ways to run tests. Currently only functional testing is provided by this library, with unit and other testing possibly added here. +The @osd/test package provides ways to run tests. Currently only functional testing is provided by this library, with unit and other testing possibly added here. Functional Testing ------------------- ### Dependencies -Functional testing methods exist in the `src/functional_tests` directory. They depend on the Functional Test Runner, which is found in [`{KIBANA_ROOT}/src/functional_test_runner`](../../src/functional_test_runner). Ideally libraries provided by kibana packages such as this one should not depend on kibana source code that lives in [`{KIBANA_ROOT}/src`](../../src). The goal is to start pulling test and development utilities out into packages so they can be used across Kibana and plugins. Accordingly the Functional Test Runner itself will be pulled out into a package (or part of a package), and this package's dependence on it will not be an issue. +Functional testing methods exist in the `src/functional_tests` directory. They depend on the Functional Test Runner, which is found in [`{OPENSEARCH_DASHBOARDS_ROOT}/src/functional_test_runner`](../../src/functional_test_runner). Ideally libraries provided by kibana packages such as this one should not depend on kibana source code that lives in [`{OPENSEARCH_DASHBOARDS_ROOT}/src`](../../src). The goal is to start pulling test and development utilities out into packages so they can be used across Kibana and plugins. Accordingly the Functional Test Runner itself will be pulled out into a package (or part of a package), and this package's dependence on it will not be an issue. ### Exposed methods @@ -17,7 +17,7 @@ For each config file specified in configPaths, starts Elasticsearch and Kibana o `configPaths`: array of strings, each an absolute path to a config file that looks like [this](../../test/functional/config.js), following the config schema specified [here](../../src/functional_test_runner/lib/config/schema.js). -Internally the method that starts Elasticsearch comes from [kbn-es](../../packages/kbn-es). +Internally the method that starts Elasticsearch comes from [osd-opensearch](../../packages/osd-opensearch). #### startServers(configPath: string) Starts Elasticsearch and Kibana servers given a specified config. @@ -36,4 +36,4 @@ We think it makes sense to specify the tests to run along with the particular se We also think it makes sense to have a test runner intelligently (but simply) start servers, run tests, tear down servers, and repeat for each config, uninterrupted. There's nothing special about each kind of config that specifies running some set of functional tests against some kind of Elasticsearch/Kibana servers. There doesn't need to be a separate job to run each kind of setup/test/teardown. These can all be orchestrated sequentially via the current `runTests` implementation. This is how we envision tests to run on CI. -This inherently means that grouping test files in configs matters, such that a group of test files that depends on a particular server config appears together in that config's `testFiles` list. Given how quickly and easily we can start servers using [@kbn/es](../../packages/kbn-es), it should not impact performance to logically group tests by domain even if multiple groups of tests share the same server config. We can think about how to group test files together across domains when that time comes. +This inherently means that grouping test files in configs matters, such that a group of test files that depends on a particular server config appears together in that config's `testFiles` list. Given how quickly and easily we can start servers using [@osd/opensearch](../../packages/osd-opensearch), it should not impact performance to logically group tests by domain even if multiple groups of tests share the same server config. We can think about how to group test files together across domains when that time comes. diff --git a/packages/kbn-test/babel.config.js b/packages/osd-test/babel.config.js similarity index 94% rename from packages/kbn-test/babel.config.js rename to packages/osd-test/babel.config.js index ff657603f4c8..0d4b6bc52f84 100644 --- a/packages/kbn-test/babel.config.js +++ b/packages/osd-test/babel.config.js @@ -18,6 +18,6 @@ */ module.exports = { - presets: ['@kbn/babel-preset/node_preset'], + presets: ['@osd/babel-preset/node_preset'], ignore: ['**/*.test.js'], }; diff --git a/packages/kbn-test/index.d.ts b/packages/osd-test/index.d.ts similarity index 100% rename from packages/kbn-test/index.d.ts rename to packages/osd-test/index.d.ts diff --git a/packages/kbn-test/package.json b/packages/osd-test/package.json similarity index 83% rename from packages/kbn-test/package.json rename to packages/osd-test/package.json index f5b34314052c..617ec5516f18 100644 --- a/packages/kbn-test/package.json +++ b/packages/osd-test/package.json @@ -1,22 +1,22 @@ { - "name": "@kbn/test", + "name": "@osd/test", "version": "1.0.0", "private": true, "license": "Apache-2.0", "main": "./target/index.js", "scripts": { "build": "babel src --out-dir target --delete-dir-on-start --extensions .ts,.js,.tsx --ignore *.test.js,**/__tests__/** --source-maps=inline", - "kbn:bootstrap": "yarn build", - "kbn:watch": "yarn build --watch" + "osd:bootstrap": "yarn build", + "osd:watch": "yarn build --watch" }, "kibana": { "devOnly": true }, "devDependencies": { "@babel/cli": "^7.10.5", - "@kbn/babel-preset": "1.0.0", - "@kbn/dev-utils": "1.0.0", - "@kbn/utils": "1.0.0", + "@osd/babel-preset": "1.0.0", + "@osd/dev-utils": "1.0.0", + "@osd/utils": "1.0.0", "@types/joi": "^13.4.2", "@types/lodash": "^4.14.159", "@types/parse-link-header": "^1.0.0", diff --git a/packages/kbn-test/src/ci_parallel_process_prefix.ts b/packages/osd-test/src/ci_parallel_process_prefix.ts similarity index 100% rename from packages/kbn-test/src/ci_parallel_process_prefix.ts rename to packages/osd-test/src/ci_parallel_process_prefix.ts diff --git a/packages/kbn-test/src/index.ts b/packages/osd-test/src/index.ts similarity index 86% rename from packages/kbn-test/src/index.ts rename to packages/osd-test/src/index.ts index bc487782a4a3..6eac99881d6c 100644 --- a/packages/kbn-test/src/index.ts +++ b/packages/osd-test/src/index.ts @@ -31,13 +31,13 @@ export { runTestsCli, processRunTestsCliOptions, startServersCli, processStartSe export { runTests, startServers } from './functional_tests/tasks'; // @ts-ignore not typed yet -export { KIBANA_ROOT } from './functional_tests/lib/paths'; +export { OPENSEARCH_DASHBOARDS_ROOT } from './functional_tests/lib/paths'; // @ts-ignore not typed yet -export { esTestConfig, createLegacyEsTestCluster } from './legacy_es'; +export { opensearchTestConfig, createLegacyEsTestCluster } from './legacy_opensearch'; // @ts-ignore not typed yet -export { kbnTestConfig, kibanaServerTestUser, kibanaTestUser, adminTestUser } from './kbn'; +export { osdTestConfig, opensearchDashboardsServerTestUser, opensearchDashboardsTestUser, adminTestUser } from './osd'; // @ts-ignore not typed yet export { setupUsers, DEFAULT_SUPERUSER_PASS } from './functional_tests/lib/auth'; diff --git a/packages/kbn-test/src/junit_report_path.ts b/packages/osd-test/src/junit_report_path.ts similarity index 100% rename from packages/kbn-test/src/junit_report_path.ts rename to packages/osd-test/src/junit_report_path.ts diff --git a/packages/kbn-test/src/legacy_es/index.js b/packages/osd-test/src/legacy_es/index.js similarity index 83% rename from packages/kbn-test/src/legacy_es/index.js rename to packages/osd-test/src/legacy_es/index.js index 8691b7b81152..ac72c15b9575 100644 --- a/packages/kbn-test/src/legacy_es/index.js +++ b/packages/osd-test/src/legacy_es/index.js @@ -17,5 +17,5 @@ * under the License. */ -export { createLegacyEsTestCluster } from './legacy_es_test_cluster.js'; -export { esTestConfig } from './es_test_config'; +export { createLegacyOpenSearchTestCluster } from './legacy_opensearch_test_cluster.js'; +export { opensearchTestConfig } from './opensearch_test_config'; diff --git a/packages/kbn-test/src/legacy_es/legacy_es_test_cluster.js b/packages/osd-test/src/legacy_es/legacy_opensearch_test_cluster.js similarity index 61% rename from packages/kbn-test/src/legacy_es/legacy_es_test_cluster.js rename to packages/osd-test/src/legacy_es/legacy_opensearch_test_cluster.js index 4606e68ba316..8f074873615d 100644 --- a/packages/kbn-test/src/legacy_es/legacy_es_test_cluster.js +++ b/packages/osd-test/src/legacy_es/legacy_opensearch_test_cluster.js @@ -20,72 +20,72 @@ import { resolve } from 'path'; import { format } from 'url'; import { get, toPath } from 'lodash'; -import { Cluster } from '@kbn/es'; +import { Cluster } from '@osd/opensearch'; import { CI_PARALLEL_PROCESS_PREFIX } from '../ci_parallel_process_prefix'; -import { esTestConfig } from './es_test_config'; +import { opensearchTestConfig } from './opensearch_test_config'; -import { KIBANA_ROOT } from '../'; -import * as legacyElasticsearch from 'elasticsearch'; +import { OPENSEARCH_DASHBOARDS_ROOT } from '../'; +import * as legacyOpenSearch from 'elasticsearch'; const path = require('path'); const del = require('del'); -export function createLegacyEsTestCluster(options = {}) { +export function createLegacyOpenSearchTestCluster(options = {}) { const { - port = esTestConfig.getPort(), + port = opensearchTestConfig.getPort(), password = 'changeme', license = 'oss', log, - basePath = resolve(KIBANA_ROOT, '.es'), - esFrom = esTestConfig.getBuildFrom(), + basePath = resolve(OPENSEARCH_DASHBOARDS_ROOT, '.opensearch'), + opensearchFrom = opensearchTestConfig.getBuildFrom(), dataArchive, - esArgs: customEsArgs = [], - esEnvVars, - clusterName: customClusterName = 'es-test-cluster', + opensearchArgs: customOpenSearchArgs = [], + opensearchEnvVars, + clusterName: customClusterName = 'opensearch-test-cluster', ssl, } = options; const clusterName = `${CI_PARALLEL_PROCESS_PREFIX}${customClusterName}`; - const esArgs = [ + const opensearchArgs = [ `cluster.name=${clusterName}`, `http.port=${port}`, 'discovery.type=single-node', - `transport.port=${esTestConfig.getTransportPort()}`, + `transport.port=${opensearchTestConfig.getTransportPort()}`, `indices.id_field_data.enabled=false`, - ...customEsArgs, + ...customOpenSearchArgs, ]; const config = { - version: esTestConfig.getVersion(), + version: opensearchTestConfig.getVersion(), installPath: resolve(basePath, clusterName), - sourcePath: resolve(KIBANA_ROOT, '../elasticsearch'), + sourcePath: resolve(OPENSEARCH_DASHBOARDS_ROOT, '../opensearch'), password, license, basePath, - esArgs, + opensearchArgs, }; const cluster = new Cluster({ log, ssl }); - return new (class EsTestCluster { + return new (class OpenSearchTestCluster { getStartTimeout() { const second = 1000; const minute = second * 60; - return esFrom === 'snapshot' ? 3 * minute : 6 * minute; + return opensearchFrom === 'snapshot' ? 3 * minute : 6 * minute; } async start() { let installPath; - if (esFrom === 'source') { + if (opensearchFrom === 'source') { installPath = (await cluster.installSource(config)).installPath; - } else if (esFrom === 'snapshot') { + } else if (opensearchFrom === 'snapshot') { installPath = (await cluster.installSnapshot(config)).installPath; - } else if (path.isAbsolute(esFrom)) { - installPath = esFrom; + } else if (path.isAbsolute(opensearchFrom)) { + installPath = opensearchFrom; } else { - throw new Error(`unknown option esFrom "${esFrom}"`); + throw new Error(`unknown option opensearchFrom "${opensearchFrom}"`); } if (dataArchive) { @@ -94,27 +94,27 @@ export function createLegacyEsTestCluster(options = {}) { await cluster.start(installPath, { password: config.password, - esArgs, - esEnvVars, + opensearchArgs, + opensearchEnvVars, }); } async stop() { await cluster.stop(); - log.info('[es] stopped'); + log.info('[opensearch] stopped'); } async cleanup() { await this.stop(); await del(config.installPath, { force: true }); - log.info('[es] cleanup complete'); + log.info('[opensearch] cleanup complete'); } /** - * Returns an ES Client to the configured cluster + * Returns an opensearch Client to the configured cluster */ getClient() { - return new legacyElasticsearch.Client({ + return new legacyOpenSearch.Client({ host: this.getUrl(), }); } @@ -124,7 +124,7 @@ export function createLegacyEsTestCluster(options = {}) { } getUrl() { - const parts = esTestConfig.getUrlParts(); + const parts = opensearchTestConfig.getUrlParts(); parts.port = port; return format(parts); @@ -136,16 +136,16 @@ export function createLegacyEsTestCluster(options = {}) { * Create a callCluster function that properly executes methods on an * elasticsearch-js client * - * @param {elasticsearch.Client} esClient + * @param {elasticsearch.Client} opensearchClient * @return {Function} */ -function createCallCluster(esClient) { +function createCallCluster(opensearchClient) { return function callCluster(method, params) { const path = toPath(method); const contextPath = path.slice(0, -1); - const action = get(esClient, path); - const context = contextPath.length ? get(esClient, contextPath) : esClient; + const action = get(opensearchClient, path); + const context = contextPath.length ? get(opensearchClient, contextPath) : opensearchClient; return action.call(context, params); }; diff --git a/packages/kbn-test/src/legacy_es/es_test_config.js b/packages/osd-test/src/legacy_es/opensearch_test_config.js similarity index 51% rename from packages/kbn-test/src/legacy_es/es_test_config.js rename to packages/osd-test/src/legacy_es/opensearch_test_config.js index d1d2b050c646..ee90b450ba7e 100644 --- a/packages/kbn-test/src/legacy_es/es_test_config.js +++ b/packages/osd-test/src/legacy_es/opensearch_test_config.js @@ -19,11 +19,11 @@ import url, { format as formatUrl } from 'url'; import pkg from '../../../../package.json'; -import { adminTestUser } from '../kbn'; +import { adminTestUser } from '../osd'; -export const esTestConfig = new (class EsTestConfig { +export const opensearchTestConfig = new (class OpenSearchTestConfig { getVersion() { - return process.env.TEST_ES_BRANCH || pkg.version; + return process.env.TEST_OPENSEARCH_BRANCH || pkg.version; } getPort() { @@ -35,37 +35,37 @@ export const esTestConfig = new (class EsTestConfig { } getBuildFrom() { - return process.env.TEST_ES_FROM || 'snapshot'; + return process.env.TEST_OPENSEARCH_FROM || 'snapshot'; } getTransportPort() { - return process.env.TEST_ES_TRANSPORT_PORT || '9300-9400'; + return process.env.TEST_OPENSEARCH_TRANSPORT_PORT || '9300-9400'; } getUrlParts() { - // Allow setting one complete TEST_ES_URL for Es like https://elastic:changeme@myCloudInstance:9200 - if (process.env.TEST_ES_URL) { - const testEsUrl = url.parse(process.env.TEST_ES_URL); + // Allow setting one complete TEST_OPENSEARCH_URL for opensearch like https://elastic:changeme@myCloudInstance:9200 + if (process.env.TEST_OPENSEARCH_URL) { + const testOpenSearchUrl = url.parse(process.env.TEST_OPENSEARCH_URL); return { // have to remove the ":" off protocol - protocol: testEsUrl.protocol.slice(0, -1), - hostname: testEsUrl.hostname, - port: parseInt(testEsUrl.port, 10), - username: testEsUrl.auth.split(':')[0], - password: testEsUrl.auth.split(':')[1], - auth: testEsUrl.auth, + protocol: testOpenSearchUrl.protocol.slice(0, -1), + hostname: testOpenSearchUrl.hostname, + port: parseInt(testOpenSearchUrl.port, 10), + username: testOpenSearchUrl.auth.split(':')[0], + password: testOpenSearchUrl.auth.split(':')[1], + auth: testOpenSearchUrl.auth, }; } - const username = process.env.TEST_ES_USERNAME || adminTestUser.username; - const password = process.env.TEST_ES_PASSWORD || adminTestUser.password; + const username = process.env.TEST_OPENSEARCH_USERNAME || adminTestUser.username; + const password = process.env.TEST_OPENSEARCH_PASSWORD || adminTestUser.password; return { // Allow setting any individual component(s) of the URL, - // or use default values (username and password from ../kbn/users.js) - protocol: process.env.TEST_ES_PROTOCOL || 'http', - hostname: process.env.TEST_ES_HOSTNAME || 'localhost', - port: parseInt(process.env.TEST_ES_PORT, 10) || 9220, + // or use default values (username and password from ../osd/users.js) + protocol: process.env.TEST_OPENSEARCH_PROTOCOL || 'http', + hostname: process.env.TEST_OPENSEARCH_HOSTNAME || 'localhost', + port: parseInt(process.env.TEST_OPENSEARCH_PORT, 10) || 9220, auth: `${username}:${password}`, username: username, password: password, diff --git a/packages/kbn-test/src/kbn/index.ts b/packages/osd-test/src/osd/index.ts similarity index 83% rename from packages/kbn-test/src/kbn/index.ts rename to packages/osd-test/src/osd/index.ts index 4ce3d06d3c8f..6f3f84af2fd1 100644 --- a/packages/kbn-test/src/kbn/index.ts +++ b/packages/osd-test/src/osd/index.ts @@ -17,5 +17,5 @@ * under the License. */ -export { kbnTestConfig } from './kbn_test_config'; -export { kibanaTestUser, kibanaServerTestUser, adminTestUser } from './users'; +export { osdTestConfig } from './osd_test_config'; +export { opensearchDashboardsTestUser, opensearchDashboardsServerTestUser, adminTestUser } from './users'; diff --git a/packages/osd-test/src/osd/osd_test_config.ts b/packages/osd-test/src/osd/osd_test_config.ts new file mode 100644 index 000000000000..285980ff3028 --- /dev/null +++ b/packages/osd-test/src/osd/osd_test_config.ts @@ -0,0 +1,61 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +import url from 'url'; +import { opensearchDashboardsTestUser } from './users'; + +interface UrlParts { + protocol?: string; + hostname?: string; + port?: number; + auth?: string; + username?: string; + password?: string; +} + +export const osdTestConfig = new (class OsdTestConfig { + getPort() { + return this.getUrlParts().port; + } + + getUrlParts(): UrlParts { + // allow setting one complete TEST_OPENSEARCH_DASHBOARDS_URL for opensearch like https://elastic:changeme@example.com:9200 + if (process.env.TEST_OPENSEARCH_DASHBOARDS_URL) { + const testOpenSearchDashboardsUrl = url.parse(process.env.TEST_OPENSEARCH_DASHBOARDS_URL); + return { + protocol: testOpenSearchDashboardsUrl.protocol?.slice(0, -1), + hostname: testOpenSearchDashboardsUrl.hostname, + port: testOpenSearchDashboardsUrl.port ? parseInt(testOpenSearchDashboardsUrl.port, 10) : undefined, + auth: testOpenSearchDashboardsUrl.auth, + username: testOpenSearchDashboardsUrl.auth?.split(':')[0], + password: testOpenSearchDashboardsUrl.auth?.split(':')[1], + }; + } + + const username = process.env.TEST_OPENSEARCH_DASHBOARDS_USERNAME || opensearchDashboardsTestUser.username; + const password = process.env.TEST_OPENSEARCH_DASHBOARDS_PASSWORD || opensearchDashboardsTestUser.password; + return { + protocol: process.env.TEST_OPENSEARCH_DASHBOARDS_PROTOCOL || 'http', + hostname: process.env.TEST_OPENSEARCH_DASHBOARDS_HOSTNAME || 'localhost', + port: process.env.TEST_OPENSEARCH_DASHBOARDS_PORT ? parseInt(process.env.TEST_OPENSEARCH_DASHBOARDS_PORT, 10) : 5620, + auth: `${username}:${password}`, + username, + password, + }; + } +})(); diff --git a/packages/kbn-test/src/kbn/users.ts b/packages/osd-test/src/osd/users.ts similarity index 64% rename from packages/kbn-test/src/kbn/users.ts rename to packages/osd-test/src/osd/users.ts index 1d4a903d60cf..f4166a85d687 100644 --- a/packages/kbn-test/src/kbn/users.ts +++ b/packages/osd-test/src/osd/users.ts @@ -19,17 +19,17 @@ const env = process.env; -export const kibanaTestUser = { - username: env.TEST_KIBANA_USER || 'elastic', - password: env.TEST_KIBANA_PASS || 'changeme', +export const opensearchDashboardsTestUser = { + username: env.TEST_OPENSEARCH_DASHBOARDS_USER || 'elastic', + password: env.TEST_OPENSEARCH_DASHBOARDS_PASS || 'changeme', }; -export const kibanaServerTestUser = { - username: env.TEST_KIBANA_SERVER_USER || 'kibana', - password: env.TEST_KIBANA_SERVER_PASS || 'changeme', +export const opensearchDashboardsServerTestUser = { + username: env.TEST_OPENSEARCH_DASHBOARDS_SERVER_USER || 'opensearch', + password: env.TEST_OPENSEARCH_DASHBOARDS_SERVER_PASS || 'changeme', }; export const adminTestUser = { - username: env.TEST_ES_USER || 'elastic', - password: env.TEST_ES_PASS || 'changeme', + username: env.TEST_OPENSEARCH_USER || 'elastic', + password: env.TEST_OPENSEARCH_PASS || 'changeme', }; diff --git a/packages/kbn-test/tsconfig.json b/packages/osd-test/tsconfig.json similarity index 69% rename from packages/kbn-test/tsconfig.json rename to packages/osd-test/tsconfig.json index fec35e45b2a1..5c765855fab3 100644 --- a/packages/kbn-test/tsconfig.json +++ b/packages/osd-test/tsconfig.json @@ -1,7 +1,7 @@ { "extends": "../../tsconfig.base.json", "compilerOptions": { - "tsBuildInfoFile": "../../build/tsbuildinfo/packages/kbn-test" + "tsBuildInfoFile": "../../build/tsbuildinfo/packages/osd-test" }, "include": [ "types/**/*", diff --git a/packages/kbn-test/types/README.md b/packages/osd-test/types/README.md similarity index 76% rename from packages/kbn-test/types/README.md rename to packages/osd-test/types/README.md index 1298d2a4afc0..efe8b4e6197a 100644 --- a/packages/kbn-test/types/README.md +++ b/packages/osd-test/types/README.md @@ -1,5 +1,5 @@ -# @kbn/test/types +# @osd/test/types Shared types used by different parts of the tests - - **`ftr.d.ts`**: These types are generic types for using the functional test runner. They are here because we plan to move the functional test runner into the `@kbn/test` package at some point and having them here makes them a lot easier to import from all over the place like we do. \ No newline at end of file + - **`ftr.d.ts`**: These types are generic types for using the functional test runner. They are here because we plan to move the functional test runner into the `@osd/test` package at some point and having them here makes them a lot easier to import from all over the place like we do. \ No newline at end of file diff --git a/packages/kbn-test/types/ftr.d.ts b/packages/osd-test/types/ftr.d.ts similarity index 98% rename from packages/kbn-test/types/ftr.d.ts rename to packages/osd-test/types/ftr.d.ts index 38eb69d3e681..b82ccb4e832e 100644 --- a/packages/kbn-test/types/ftr.d.ts +++ b/packages/osd-test/types/ftr.d.ts @@ -17,7 +17,7 @@ * under the License. */ -import { ToolingLog } from '@kbn/dev-utils'; +import { ToolingLog } from '@osd/dev-utils'; import { Config, Lifecycle, diff --git a/packages/kbn-test/yarn.lock b/packages/osd-test/yarn.lock similarity index 100% rename from packages/kbn-test/yarn.lock rename to packages/osd-test/yarn.lock From 29514ffb2092de1d07e9bfbb3610ae0ae078455e Mon Sep 17 00:00:00 2001 From: Mihir Soni Date: Fri, 12 Mar 2021 01:20:50 +0000 Subject: [PATCH 5/8] [Rename] addressed review feedbacks --- packages/osd-test/src/{legacy_es => legacy_opensearch}/index.js | 0 .../legacy_opensearch_test_cluster.js | 0 .../{legacy_es => legacy_opensearch}/opensearch_test_config.js | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename packages/osd-test/src/{legacy_es => legacy_opensearch}/index.js (100%) rename packages/osd-test/src/{legacy_es => legacy_opensearch}/legacy_opensearch_test_cluster.js (100%) rename packages/osd-test/src/{legacy_es => legacy_opensearch}/opensearch_test_config.js (100%) diff --git a/packages/osd-test/src/legacy_es/index.js b/packages/osd-test/src/legacy_opensearch/index.js similarity index 100% rename from packages/osd-test/src/legacy_es/index.js rename to packages/osd-test/src/legacy_opensearch/index.js diff --git a/packages/osd-test/src/legacy_es/legacy_opensearch_test_cluster.js b/packages/osd-test/src/legacy_opensearch/legacy_opensearch_test_cluster.js similarity index 100% rename from packages/osd-test/src/legacy_es/legacy_opensearch_test_cluster.js rename to packages/osd-test/src/legacy_opensearch/legacy_opensearch_test_cluster.js diff --git a/packages/osd-test/src/legacy_es/opensearch_test_config.js b/packages/osd-test/src/legacy_opensearch/opensearch_test_config.js similarity index 100% rename from packages/osd-test/src/legacy_es/opensearch_test_config.js rename to packages/osd-test/src/legacy_opensearch/opensearch_test_config.js From e7bd1f4aef1495c53c21b7b9203044213d8647d4 Mon Sep 17 00:00:00 2001 From: Mihir Soni Date: Fri, 12 Mar 2021 01:36:26 +0000 Subject: [PATCH 6/8] [Rename] addressed review feedbacks --- packages/osd-test/README.md | 12 ++++++------ packages/osd-test/package.json | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/osd-test/README.md b/packages/osd-test/README.md index edab0eda74e6..dbd11e6fa838 100644 --- a/packages/osd-test/README.md +++ b/packages/osd-test/README.md @@ -1,4 +1,4 @@ -Kibana Testing Library +OpenSearch Dashboards Testing Library ====================== The @osd/test package provides ways to run tests. Currently only functional testing is provided by this library, with unit and other testing possibly added here. @@ -8,19 +8,19 @@ Functional Testing ### Dependencies -Functional testing methods exist in the `src/functional_tests` directory. They depend on the Functional Test Runner, which is found in [`{OPENSEARCH_DASHBOARDS_ROOT}/src/functional_test_runner`](../../src/functional_test_runner). Ideally libraries provided by kibana packages such as this one should not depend on kibana source code that lives in [`{OPENSEARCH_DASHBOARDS_ROOT}/src`](../../src). The goal is to start pulling test and development utilities out into packages so they can be used across Kibana and plugins. Accordingly the Functional Test Runner itself will be pulled out into a package (or part of a package), and this package's dependence on it will not be an issue. +Functional testing methods exist in the `src/functional_tests` directory. They depend on the Functional Test Runner, which is found in [`{OPENSEARCH_DASHBOARDS_ROOT}/src/functional_test_runner`](../../src/functional_test_runner). Ideally libraries provided by opensearch-dashboards packages such as this one should not depend on opensearch-dashboards source code that lives in [`{OPENSEARCH_DASHBOARDS_ROOT}/src`](../../src). The goal is to start pulling test and development utilities out into packages so they can be used across OpenSearch Dashboards and plugins. Accordingly the Functional Test Runner itself will be pulled out into a package (or part of a package), and this package's dependence on it will not be an issue. ### Exposed methods #### runTests(configPaths: Array) -For each config file specified in configPaths, starts Elasticsearch and Kibana once, runs tests specified in that config file, and shuts down Elasticsearch and Kibana once completed. (Repeats for every config file.) +For each config file specified in configPaths, starts Elasticsearch and OpenSearch Dashboards once, runs tests specified in that config file, and shuts down Elasticsearch and OpenSearch Dashboards once completed. (Repeats for every config file.) `configPaths`: array of strings, each an absolute path to a config file that looks like [this](../../test/functional/config.js), following the config schema specified [here](../../src/functional_test_runner/lib/config/schema.js). Internally the method that starts Elasticsearch comes from [osd-opensearch](../../packages/osd-opensearch). #### startServers(configPath: string) -Starts Elasticsearch and Kibana servers given a specified config. +Starts Elasticsearch and OpenSearch Dashboards servers given a specified config. `configPath`: absolute path to a config file that looks like [this](../../test/functional/config.js), following the config schema specified [here](../../src/functional_test_runner/lib/config/schema.js). @@ -30,10 +30,10 @@ Allows users to start another process to run just the tests while keeping the se ### Single config per setup -We think it makes sense to specify the tests to run along with the particular server configuration for Elasticsearch and Kibana servers, because the tests expect a particular configuration. For example, saml api integration tests expect certain xml files to exist in Elasticsearch's config directory, and certain saml specific options to be passed in via the command line (or alternatively via the `.yml` config file) to both Elasticsearch and Kibana. It makes sense to keep all these config options together with the list of test files. +We think it makes sense to specify the tests to run along with the particular server configuration for Elasticsearch and OpenSearch Dashboards servers, because the tests expect a particular configuration. For example, saml api integration tests expect certain xml files to exist in Elasticsearch's config directory, and certain saml specific options to be passed in via the command line (or alternatively via the `.yml` config file) to both Elasticsearch and OpenSearch Dashboards. It makes sense to keep all these config options together with the list of test files. ### Multiple configs running in succession -We also think it makes sense to have a test runner intelligently (but simply) start servers, run tests, tear down servers, and repeat for each config, uninterrupted. There's nothing special about each kind of config that specifies running some set of functional tests against some kind of Elasticsearch/Kibana servers. There doesn't need to be a separate job to run each kind of setup/test/teardown. These can all be orchestrated sequentially via the current `runTests` implementation. This is how we envision tests to run on CI. +We also think it makes sense to have a test runner intelligently (but simply) start servers, run tests, tear down servers, and repeat for each config, uninterrupted. There's nothing special about each kind of config that specifies running some set of functional tests against some kind of Elasticsearch/OpenSearch Dashboards servers. There doesn't need to be a separate job to run each kind of setup/test/teardown. These can all be orchestrated sequentially via the current `runTests` implementation. This is how we envision tests to run on CI. This inherently means that grouping test files in configs matters, such that a group of test files that depends on a particular server config appears together in that config's `testFiles` list. Given how quickly and easily we can start servers using [@osd/opensearch](../../packages/osd-opensearch), it should not impact performance to logically group tests by domain even if multiple groups of tests share the same server config. We can think about how to group test files together across domains when that time comes. diff --git a/packages/osd-test/package.json b/packages/osd-test/package.json index 617ec5516f18..c51d63e5beb5 100644 --- a/packages/osd-test/package.json +++ b/packages/osd-test/package.json @@ -9,7 +9,7 @@ "osd:bootstrap": "yarn build", "osd:watch": "yarn build --watch" }, - "kibana": { + "opensearchDashboards": { "devOnly": true }, "devDependencies": { From 3412e9a04e23d5bc3b0eb6dc8a176202ea8f2908 Mon Sep 17 00:00:00 2001 From: Mihir Soni Date: Fri, 12 Mar 2021 01:37:57 +0000 Subject: [PATCH 7/8] [Rename] addressed review feedbacks --- packages/osd-test/README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/osd-test/README.md b/packages/osd-test/README.md index dbd11e6fa838..1d1afb2c226d 100644 --- a/packages/osd-test/README.md +++ b/packages/osd-test/README.md @@ -13,14 +13,14 @@ Functional testing methods exist in the `src/functional_tests` directory. They d ### Exposed methods #### runTests(configPaths: Array) -For each config file specified in configPaths, starts Elasticsearch and OpenSearch Dashboards once, runs tests specified in that config file, and shuts down Elasticsearch and OpenSearch Dashboards once completed. (Repeats for every config file.) +For each config file specified in configPaths, starts OpenSearch and OpenSearch Dashboards once, runs tests specified in that config file, and shuts down OpenSearch and OpenSearch Dashboards once completed. (Repeats for every config file.) `configPaths`: array of strings, each an absolute path to a config file that looks like [this](../../test/functional/config.js), following the config schema specified [here](../../src/functional_test_runner/lib/config/schema.js). -Internally the method that starts Elasticsearch comes from [osd-opensearch](../../packages/osd-opensearch). +Internally the method that starts OpenSearch comes from [osd-opensearch](../../packages/osd-opensearch). #### startServers(configPath: string) -Starts Elasticsearch and OpenSearch Dashboards servers given a specified config. +Starts OpenSearch and OpenSearch Dashboards servers given a specified config. `configPath`: absolute path to a config file that looks like [this](../../test/functional/config.js), following the config schema specified [here](../../src/functional_test_runner/lib/config/schema.js). @@ -30,10 +30,10 @@ Allows users to start another process to run just the tests while keeping the se ### Single config per setup -We think it makes sense to specify the tests to run along with the particular server configuration for Elasticsearch and OpenSearch Dashboards servers, because the tests expect a particular configuration. For example, saml api integration tests expect certain xml files to exist in Elasticsearch's config directory, and certain saml specific options to be passed in via the command line (or alternatively via the `.yml` config file) to both Elasticsearch and OpenSearch Dashboards. It makes sense to keep all these config options together with the list of test files. +We think it makes sense to specify the tests to run along with the particular server configuration for OpenSearch and OpenSearch Dashboards servers, because the tests expect a particular configuration. For example, saml api integration tests expect certain xml files to exist in OpenSearch's config directory, and certain saml specific options to be passed in via the command line (or alternatively via the `.yml` config file) to both OpenSearch and OpenSearch Dashboards. It makes sense to keep all these config options together with the list of test files. ### Multiple configs running in succession -We also think it makes sense to have a test runner intelligently (but simply) start servers, run tests, tear down servers, and repeat for each config, uninterrupted. There's nothing special about each kind of config that specifies running some set of functional tests against some kind of Elasticsearch/OpenSearch Dashboards servers. There doesn't need to be a separate job to run each kind of setup/test/teardown. These can all be orchestrated sequentially via the current `runTests` implementation. This is how we envision tests to run on CI. +We also think it makes sense to have a test runner intelligently (but simply) start servers, run tests, tear down servers, and repeat for each config, uninterrupted. There's nothing special about each kind of config that specifies running some set of functional tests against some kind of OpenSearch/OpenSearch Dashboards servers. There doesn't need to be a separate job to run each kind of setup/test/teardown. These can all be orchestrated sequentially via the current `runTests` implementation. This is how we envision tests to run on CI. This inherently means that grouping test files in configs matters, such that a group of test files that depends on a particular server config appears together in that config's `testFiles` list. Given how quickly and easily we can start servers using [@osd/opensearch](../../packages/osd-opensearch), it should not impact performance to logically group tests by domain even if multiple groups of tests share the same server config. We can think about how to group test files together across domains when that time comes. From 691e5a1f6c8bb93d90638ff7ec21f2fd39df9a0d Mon Sep 17 00:00:00 2001 From: Mihir Soni Date: Fri, 12 Mar 2021 04:30:42 +0000 Subject: [PATCH 8/8] [Rename] addressed review feedbacks --- packages/osd-test/src/osd/osd_test_config.ts | 2 +- packages/osd-test/src/osd/users.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/osd-test/src/osd/osd_test_config.ts b/packages/osd-test/src/osd/osd_test_config.ts index 285980ff3028..121b045b96b8 100644 --- a/packages/osd-test/src/osd/osd_test_config.ts +++ b/packages/osd-test/src/osd/osd_test_config.ts @@ -34,7 +34,7 @@ export const osdTestConfig = new (class OsdTestConfig { } getUrlParts(): UrlParts { - // allow setting one complete TEST_OPENSEARCH_DASHBOARDS_URL for opensearch like https://elastic:changeme@example.com:9200 + // allow setting one complete TEST_OPENSEARCH_DASHBOARDS_URL for opensearch like https://opensearch:changeme@example.com:9200 if (process.env.TEST_OPENSEARCH_DASHBOARDS_URL) { const testOpenSearchDashboardsUrl = url.parse(process.env.TEST_OPENSEARCH_DASHBOARDS_URL); return { diff --git a/packages/osd-test/src/osd/users.ts b/packages/osd-test/src/osd/users.ts index f4166a85d687..09ce08d47c64 100644 --- a/packages/osd-test/src/osd/users.ts +++ b/packages/osd-test/src/osd/users.ts @@ -20,7 +20,7 @@ const env = process.env; export const opensearchDashboardsTestUser = { - username: env.TEST_OPENSEARCH_DASHBOARDS_USER || 'elastic', + username: env.TEST_OPENSEARCH_DASHBOARDS_USER || 'opensearch', password: env.TEST_OPENSEARCH_DASHBOARDS_PASS || 'changeme', }; @@ -30,6 +30,6 @@ export const opensearchDashboardsServerTestUser = { }; export const adminTestUser = { - username: env.TEST_OPENSEARCH_USER || 'elastic', + username: env.TEST_OPENSEARCH_USER || 'opensearch', password: env.TEST_OPENSEARCH_PASS || 'changeme', };