Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -652,6 +652,7 @@ src/platform/packages/shared/kbn-synthtrace-client @elastic/obs-presentation-tea
src/platform/packages/shared/kbn-telemetry @elastic/kibana-core @elastic/obs-ai-team
src/platform/packages/shared/kbn-telemetry-config @elastic/kibana-core
src/platform/packages/shared/kbn-test @elastic/kibana-operations @elastic/appex-qa
src/platform/packages/shared/kbn-test-es-server @elastic/kibana-operations @elastic/appex-qa
src/platform/packages/shared/kbn-test-jest-helpers @elastic/kibana-operations @elastic/appex-qa
src/platform/packages/shared/kbn-test-subj-selector @elastic/kibana-operations @elastic/appex-qa
src/platform/packages/shared/kbn-timerange @elastic/obs-onboarding-team
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1798,6 +1798,7 @@
"@kbn/synthtrace-client": "link:src/platform/packages/shared/kbn-synthtrace-client",
"@kbn/telemetry-tools": "link:src/platform/packages/private/kbn-telemetry-tools",
"@kbn/test": "link:src/platform/packages/shared/kbn-test",
"@kbn/test-es-server": "link:src/platform/packages/shared/kbn-test-es-server",
"@kbn/test-eui-helpers": "link:src/platform/packages/private/kbn-test-eui-helpers",
"@kbn/test-jest-helpers": "link:src/platform/packages/shared/kbn-test-jest-helpers",
"@kbn/test-subj-selector": "link:src/platform/packages/shared/kbn-test-subj-selector",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,11 @@ export class RepoSourceClassifier {

const { pkgId, rel } = pkgInfo;

if (pkgId === '@kbn/test' || pkgId === '@kbn/test-subj-selector') {
if (
pkgId === '@kbn/test' ||
pkgId === '@kbn/test-es-server' ||
pkgId === '@kbn/test-subj-selector'
) {
return 'common package';
}

Expand Down
1 change: 1 addition & 0 deletions src/platform/packages/shared/kbn-scout/moon.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ dependsOn:
- '@kbn/es'
- '@kbn/dev-proc-runner'
- '@kbn/kbn-client'
- '@kbn/test-es-server'
- '@kbn/test'
- '@kbn/es-archiver'
- '@kbn/dev-utils'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*/

import { KbnClient } from '@kbn/kbn-client';
import { createEsClientForTesting } from '@kbn/test';
import { createEsClientForTesting } from '@kbn/test-es-server';
import type { ScoutLogger } from './logger';
import type { ScoutTestConfig, EsClient } from '../../types';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import type { ArtifactLicense, ServerlessProjectType } from '@kbn/es';
import { isServerlessProjectType, runLinkedServerlessCluster } from '@kbn/es/src/utils';
import { MOCK_IDP_UIAM_PROJECT_ID2 } from '@kbn/mock-idp-utils';
import { REPO_ROOT } from '@kbn/repo-info';
import { cleanupElasticsearch, createTestEsCluster, esTestConfig } from '@kbn/test';
import { cleanupElasticsearch, createTestEsCluster, esTestConfig } from '@kbn/test-es-server';
import type { ToolingLog } from '@kbn/tooling-log';
import { resolve } from 'path';
import Url from 'url';
Expand Down
14 changes: 4 additions & 10 deletions src/platform/packages/shared/kbn-scout/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,10 @@
"extends": "@kbn/tsconfig-base/tsconfig.json",
"compilerOptions": {
"outDir": "target/types",
"types": [
"jest",
"node"
]
"types": ["jest", "node"]
},
"include": [
"**/*.ts",
],
"exclude": [
"target/**/*"
],
"include": ["**/*.ts"],
"exclude": ["target/**/*"],
"kbn_references": [
"@kbn/tooling-log",
"@kbn/dev-cli-runner",
Expand All @@ -23,6 +16,7 @@
"@kbn/es",
"@kbn/dev-proc-runner",
"@kbn/kbn-client",
"@kbn/test-es-server",
"@kbn/test",
"@kbn/es-archiver",
"@kbn/dev-utils",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,16 @@
* License v3.0 only", or the "Server Side Public License, v 1".
*/

export { createTestEsCluster } from './test_es_cluster';
export type { CreateTestEsClusterOptions, EsTestCluster, ICluster } from './test_es_cluster';
export { esTestConfig } from './es_test_config';
export { CI_PARALLEL_PROCESS_PREFIX } from './src/ci_parallel_process_prefix';
export { cleanupElasticsearch } from './src/cleanup_elasticsearch';
export {
createEsClientForTesting,
createEsClientForFtrConfig,
createRemoteEsClientForFtrConfig,
} from './es_client_for_testing';
export type { EsClientForTestingOptions } from './es_client_for_testing';
type EsClientForTestingOptions,
} from './src/es_client_for_testing';
export { esTestConfig } from './src/es_test_config';
export {
createTestEsCluster,
type CreateTestEsClusterOptions,
type EsTestCluster,
type ICluster,
} from './src/test_es_cluster';
14 changes: 14 additions & 0 deletions src/platform/packages/shared/kbn-test-es-server/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the "Elastic License
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/

module.exports = {
preset: '@kbn/test',
rootDir: '../../../../..',
roots: ['<rootDir>/src/platform/packages/shared/kbn-test-es-server'],
};
11 changes: 11 additions & 0 deletions src/platform/packages/shared/kbn-test-es-server/kibana.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"type": "shared-common",
"id": "@kbn/test-es-server",
"owner": [
"@elastic/kibana-operations",
"@elastic/appex-qa"
],
"group": "platform",
"visibility": "shared",
"devOnly": true
}
58 changes: 58 additions & 0 deletions src/platform/packages/shared/kbn-test-es-server/moon.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# This file is generated by the @kbn/moon package. Any manual edits will be erased!
# To extend this, write your extensions/overrides to 'moon.extend.yml'
# then regenerate this file with: 'node scripts/regenerate_moon_projects.js --update --filter @kbn/test-es-server'

$schema: https://moonrepo.dev/schemas/project.json
id: '@kbn/test-es-server'
layer: unknown
owners:
defaultOwner: '@elastic/kibana-operations'
toolchains:
default: node
language: typescript
project:
title: '@kbn/test-es-server'
description: Moon project for @kbn/test-es-server
channel: ''
owner: '@elastic/kibana-operations'
sourceRoot: src/platform/packages/shared/kbn-test-es-server
dependsOn:
- '@kbn/dev-utils'
- '@kbn/es'
- '@kbn/repo-info'
- '@kbn/tooling-log'
tags:
- shared-common
- package
- dev
- group-platform
- shared
- jest-unit-tests
fileGroups:
src:
- '**/*.ts'
- '**/*.js'
- '!target/**/*'
tasks:
jest:
command: node
args:
- '--no-experimental-require-module'
- $workspaceRoot/scripts/jest
- '--config'
- $projectRoot/jest.config.js
options:
runFromWorkspaceRoot: true
inputs:
- '@group(src)'
jestCI:
command: node
args:
- '--no-experimental-require-module'
- $workspaceRoot/scripts/jest
- '--config'
- $projectRoot/jest.config.js
options:
runFromWorkspaceRoot: true
inputs:
- '@group(src)'
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "@kbn/test-es-server",
"author": "Operations",
"version": "1.0.0",
"private": true,
"license": "Elastic License 2.0 OR AGPL-3.0-only OR SSPL-1.0"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the "Elastic License
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/

import type { ToolingLog } from '@kbn/tooling-log';
import { extractAndArchiveLogs } from '@kbn/es/src/utils';
import type { ICluster } from './test_es_cluster';

export async function cleanupElasticsearch(
node: ICluster,
isServerless: boolean,
logsDir: string | undefined,
log: ToolingLog
): Promise<void> {
await node.cleanup();

if (isServerless) {
await extractAndArchiveLogs({ outputFolder: logsDir, log });
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import * as Fs from 'fs';
import { CA_CERT_PATH } from '@kbn/dev-utils';
import type { ClientOptions } from '@elastic/elasticsearch';
import { Client as EsClient, HttpConnection } from '@elastic/elasticsearch';
import type { Config } from '../functional_test_runner';

/** options for creating es instances used in functional testing scenarios */
export interface EsClientForTestingOptions extends Omit<ClientOptions, 'node' | 'nodes' | 'tls'> {
Expand All @@ -29,36 +28,13 @@ export interface EsClientForTestingOptions extends Omit<ClientOptions, 'node' |
isCloud?: boolean;
}

export function createRemoteEsClientForFtrConfig(
config: Config,
overrides?: Omit<EsClientForTestingOptions, 'esUrl'>
) {
const ccsConfig = config.get('esTestCluster.ccs');
if (!ccsConfig) {
throw new Error('FTR config is missing esTestCluster.ccs');
}

return createEsClientForTesting({
esUrl: ccsConfig.remoteClusterUrl,
requestTimeout: config.get('timeouts.esRequestTimeout'),
...overrides,
});
}

export function createEsClientForFtrConfig(
config: Config,
overrides?: Omit<EsClientForTestingOptions, 'esUrl'>
) {
const esUrl = Url.format(config.get('servers.elasticsearch'));
return createEsClientForTesting({
esUrl,
requestTimeout: config.get('timeouts.esRequestTimeout'),
...overrides,
});
}

export function createEsClientForTesting(options: EsClientForTestingOptions) {
const { esUrl, authOverride, isCloud = !!process.env.TEST_CLOUD, ...otherOptions } = options;
const {
esUrl: _esUrl,
authOverride,
isCloud = !!process.env.TEST_CLOUD,
...otherOptions
} = options;

const url = options.authOverride
? Url.format({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import { kibanaPackageJson as pkg } from '@kbn/repo-info';
import Url from 'url';
import { systemIndicesSuperuser } from '../kbn';
import { SYSTEM_INDICES_SUPERUSER } from '@kbn/es';

class EsTestConfig {
getVersion() {
Expand Down Expand Up @@ -56,8 +56,8 @@ class EsTestConfig {
};
}

const username = process.env.TEST_ES_USERNAME || systemIndicesSuperuser.username;
const password = process.env.TEST_ES_PASSWORD || systemIndicesSuperuser.password;
const username = process.env.TEST_ES_USERNAME || SYSTEM_INDICES_SUPERUSER;
const password = process.env.TEST_ES_PASSWORD || process.env.TEST_ES_PASS || 'changeme';

const port = process.env.TEST_ES_PORT ? parseInt(process.env.TEST_ES_PORT, 10) : 9220;

Expand All @@ -69,7 +69,7 @@ class EsTestConfig {

return {
// Allow setting any individual component(s) of the URL,
// or use default values (username and password from ../kbn/users.js)
// or use default values (aligned with @kbn/test systemIndicesSuperuser defaults)
protocol: process.env.TEST_ES_PROTOCOL || 'http',
hostname: process.env.TEST_ES_HOSTNAME || 'localhost',
port,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { REPO_ROOT } from '@kbn/repo-info';
import type { ArtifactLicense } from '@kbn/es';
import type { ServerlessOptions } from '@kbn/es/src/utils';
import { getFips } from 'crypto';
import { CI_PARALLEL_PROCESS_PREFIX } from '../ci_parallel_process_prefix';
import { CI_PARALLEL_PROCESS_PREFIX } from './ci_parallel_process_prefix';
import { esTestConfig } from './es_test_config';

interface TestEsClusterNodesOptions {
Expand Down
16 changes: 16 additions & 0 deletions src/platform/packages/shared/kbn-test-es-server/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"extends": "@kbn/tsconfig-base/tsconfig.json",
"compilerOptions": {
"outDir": "target/types",
"stripInternal": true,
"types": ["jest", "node"]
},
"include": ["**/*.ts", "**/*.js"],
"exclude": ["target/**/*"],
"kbn_references": [
"@kbn/dev-utils",
"@kbn/es",
"@kbn/repo-info",
"@kbn/tooling-log"
]
}
13 changes: 4 additions & 9 deletions src/platform/packages/shared/kbn-test/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,9 @@ export type {
EsTestCluster,
ICluster,
EsClientForTestingOptions,
} from './src/es';
export {
esTestConfig,
createTestEsCluster,
createEsClientForTesting,
createEsClientForFtrConfig,
createRemoteEsClientForFtrConfig,
} from './src/es';
} from '@kbn/test-es-server';
export { esTestConfig, createTestEsCluster, createEsClientForTesting } from '@kbn/test-es-server';
export { createEsClientForFtrConfig, createRemoteEsClientForFtrConfig } from './src/ftr_es_client';

export { kbnTestConfig } from './kbn_test_config';
export type { UrlParts } from './kbn_test_config';
Expand All @@ -60,7 +55,7 @@ export {
// @internal
export { setupJUnitReportGeneration, escapeCdata } from './src/mocha';

export { CI_PARALLEL_PROCESS_PREFIX } from './src/ci_parallel_process_prefix';
export { CI_PARALLEL_PROCESS_PREFIX } from '@kbn/test-es-server';

export * from './src/functional_test_runner';

Expand Down
2 changes: 1 addition & 1 deletion src/platform/packages/shared/kbn-test/moon.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ project:
sourceRoot: src/platform/packages/shared/kbn-test
dependsOn:
- '@kbn/kbn-client'
- '@kbn/dev-utils'
- '@kbn/std'
- '@kbn/test-es-server'
- '@kbn/tooling-log'
- '@kbn/get-repo-files'
- '@kbn/peggy'
Expand Down
Loading
Loading