Skip to content

Commit

Permalink
Merge branch 'main' into feat/advanced-settings-slo
Browse files Browse the repository at this point in the history
  • Loading branch information
kdelemme authored Nov 26, 2024
2 parents 887fbb0 + fc674b7 commit b2c9133
Show file tree
Hide file tree
Showing 182 changed files with 4,613 additions and 777 deletions.
6 changes: 4 additions & 2 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,7 @@ packages/kbn-rrule @elastic/response-ops
packages/kbn-rule-data-utils @elastic/security-detections-response @elastic/response-ops @elastic/obs-ux-management-team
packages/kbn-safer-lodash-set @elastic/kibana-security
packages/kbn-saved-objects-settings @elastic/appex-sharedux
packages/kbn-scout @elastic/appex-qa
packages/kbn-screenshotting-server @elastic/appex-sharedux
packages/kbn-search-api-keys-components @elastic/search-kibana
packages/kbn-search-api-keys-server @elastic/search-kibana
Expand Down Expand Up @@ -1237,8 +1238,8 @@ packages/kbn-monaco/src/esql @elastic/kibana-esql
### Observability Plugins

# Observability AI Assistant
/x-pack/test_serverless/api_integration/test_suites/common/data_usage @elastic/obs-ai-assistant
/x-pack/test_serverless/functional/test_suites/common/data_usage @elastic/obs-ai-assistant @elastic/kibana-security
/x-pack/test_serverless/api_integration/test_suites/common/data_usage @elastic/obs-ai-assistant @elastic/security-solution
/x-pack/test_serverless/functional/test_suites/common/data_usage @elastic/obs-ai-assistant @elastic/security-solution
/x-pack/test/observability_ai_assistant_api_integration @elastic/obs-ai-assistant
/x-pack/test/observability_ai_assistant_functional @elastic/obs-ai-assistant
/x-pack/test_serverless/**/test_suites/observability/ai_assistant @elastic/obs-ai-assistant
Expand Down Expand Up @@ -1552,6 +1553,7 @@ packages/kbn-monaco/src/esql @elastic/kibana-esql
/.eslintignore @elastic/kibana-operations

# QA - Appex QA
/x-pack/plugins/discover_enhanced/ui_tests/ @elastic/appex-qa # temporarily
/x-pack/test/functional/fixtures/package_registry_config.yml @elastic/appex-qa # No usages found
/x-pack/test/functional/fixtures/kbn_archiver/packaging.json @elastic/appex-qa # No usages found
/x-pack/test/functional/es_archives/filebeat @elastic/appex-qa
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@ x-pack/test/security_api_integration/plugins/audit_log/audit.log
.ftr
role_users.json

# ignore Scout temp directory
.scout

.devcontainer/.env

Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1484,6 +1484,7 @@
"@kbn/repo-path": "link:packages/kbn-repo-path",
"@kbn/repo-source-classifier": "link:packages/kbn-repo-source-classifier",
"@kbn/repo-source-classifier-cli": "link:packages/kbn-repo-source-classifier-cli",
"@kbn/scout": "link:packages/kbn-scout",
"@kbn/security-api-integration-helpers": "link:x-pack/test/security_api_integration/packages/helpers",
"@kbn/serverless-storybook-config": "link:packages/serverless/storybook/config",
"@kbn/some-dev-log": "link:packages/kbn-some-dev-log",
Expand Down
1 change: 1 addition & 0 deletions packages/kbn-repo-source-classifier/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,6 @@ export const TEST_DIR = new Set([
'storybook',
'.storybook',
'integration_tests',
'ui_tests',
...RANDOM_TEST_FILE_NAMES,
]);
62 changes: 32 additions & 30 deletions packages/kbn-repo-source-classifier/src/group.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,36 +19,38 @@ const DEFAULT_MODULE_ATTRS: ModuleAttrs = {
visibility: 'shared',
};

const MODULE_GROUPING_BY_PATH: Record<string, ModuleAttrs> = {
'src/platform/plugins/shared': {
group: 'platform',
visibility: 'shared',
},
'src/platform/plugins/internal': {
group: 'platform',
visibility: 'private',
},
'x-pack/platform/plugins/shared': {
group: 'platform',
visibility: 'shared',
},
'x-pack/platform/plugins/internal': {
group: 'platform',
visibility: 'private',
},
'x-pack/solutions/observability/plugins': {
group: 'observability',
visibility: 'private',
},
'x-pack/solutions/security/plugins': {
group: 'security',
visibility: 'private',
},
'x-pack/solutions/search/plugins': {
group: 'search',
visibility: 'private',
},
};
const MODULE_GROUPING_BY_PATH: Record<string, ModuleAttrs> = ['packages', 'plugins']
.map<Record<string, ModuleAttrs>>((type) => ({
[`src/platform/${type}/shared`]: {
group: 'platform',
visibility: 'shared',
},
[`src/platform/${type}/private`]: {
group: 'platform',
visibility: 'private',
},
[`x-pack/platform/${type}/shared`]: {
group: 'platform',
visibility: 'shared',
},
[`x-pack/platform/${type}/private`]: {
group: 'platform',
visibility: 'private',
},
[`x-pack/solutions/observability/${type}`]: {
group: 'observability',
visibility: 'private',
},
[`x-pack/solutions/security/${type}`]: {
group: 'security',
visibility: 'private',
},
[`x-pack/solutions/search/${type}`]: {
group: 'search',
visibility: 'private',
},
}))
.reduce((acc, current) => ({ ...acc, ...current }), {});

/**
* Determine a plugin's grouping information based on the path where it is defined
Expand Down
9 changes: 9 additions & 0 deletions packages/kbn-scout/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# @kbn/scout

The package is designed to streamline the setup and execution of Playwright tests for Kibana. It consolidates server management and testing capabilities by wrapping both the Kibana/Elasticsearch server launcher and the Playwright test runner. It includes:

- core test and worker-scoped fixtures for reliable setup across test suites
- page objects combined into the fixture for for core Kibana apps UI interactions
- configurations for seamless test execution in both local and CI environments

This package aims to simplify test setup and enhance modularity, making it easier to create, run, and maintain deployment-agnostic tests, that are located in the plugin they actually test.
19 changes: 19 additions & 0 deletions packages/kbn-scout/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
* 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".
*/

export { startServersCli, runTestsCli } from './src/cli';
export { expect, test, createPlaywrightConfig, createLazyPageObject } from './src/playwright';
export type {
ScoutPage,
ScoutPlaywrightOptions,
ScoutTestOptions,
PageObjects,
ScoutTestFixtures,
ScoutWorkerFixtures,
} from './src/playwright';
14 changes: 14 additions & 0 deletions packages/kbn-scout/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/jest_node',
rootDir: '../..',
roots: ['<rootDir>/packages/kbn-scout'],
};
6 changes: 6 additions & 0 deletions packages/kbn-scout/kibana.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"type": "test-helper",
"id": "@kbn/scout",
"owner": "@elastic/appex-qa",
"devOnly": true
}
6 changes: 6 additions & 0 deletions packages/kbn-scout/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "@kbn/scout",
"private": true,
"version": "1.0.0",
"license": "Elastic License 2.0 OR AGPL-3.0-only OR SSPL-1.0"
}
11 changes: 11 additions & 0 deletions packages/kbn-scout/src/cli/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/*
* 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".
*/

export { runTestsCli } from './run_tests_cli';
export { startServersCli } from './start_servers_cli';
39 changes: 39 additions & 0 deletions packages/kbn-scout/src/cli/run_tests_cli.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* 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 { run } from '@kbn/dev-cli-runner';
import { initLogsDir } from '@kbn/test';
import { TEST_FLAG_OPTIONS, parseTestFlags, runTests } from '../playwright/runner';

/**
* Start servers and run the tests
*/
export function runTestsCli() {
run(
async ({ flagsReader, log }) => {
const options = await parseTestFlags(flagsReader);

if (options.logsDir) {
initLogsDir(log, options.logsDir);
}

await runTests(log, options);
},
{
description: `Run Scout UI Tests`,
usage: `
Usage:
node scripts/scout_test --help
node scripts/scout_test --stateful --config <playwright_config_path>
node scripts/scout_test --serverless=es --headed --config <playwright_config_path>
`,
flags: TEST_FLAG_OPTIONS,
}
);
}
34 changes: 34 additions & 0 deletions packages/kbn-scout/src/cli/start_servers_cli.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* 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 { run } from '@kbn/dev-cli-runner';

import { initLogsDir } from '@kbn/test';

import { startServers, parseServerFlags, SERVER_FLAG_OPTIONS } from '../servers';

/**
* Start servers
*/
export function startServersCli() {
run(
async ({ flagsReader: flags, log }) => {
const options = parseServerFlags(flags);

if (options.logsDir) {
initLogsDir(log, options.logsDir);
}

await startServers(log, options);
},
{
flags: SERVER_FLAG_OPTIONS,
}
);
}
16 changes: 16 additions & 0 deletions packages/kbn-scout/src/common/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
* 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 { Role } from '@kbn/test/src/auth/types';

export const PROJECT_DEFAULT_ROLES = new Map<string, Role>([
['es', 'developer'],
['security', 'editor'],
['oblt', 'editor'],
]);
12 changes: 12 additions & 0 deletions packages/kbn-scout/src/common/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*
* 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".
*/

export * from './services';
export * from './constants';
export * from './utils';
58 changes: 58 additions & 0 deletions packages/kbn-scout/src/common/services/clients.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
* 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 { KbnClient, createEsClientForTesting } from '@kbn/test';
import type { ToolingLog } from '@kbn/tooling-log';
import { ScoutServerConfig } from '../../types';
import { serviceLoadedMsg } from '../../playwright/utils';

interface ClientOptions {
serviceName: string;
url: string;
username: string;
password: string;
log: ToolingLog;
}

function createClientUrlWithAuth({ serviceName, url, username, password, log }: ClientOptions) {
const clientUrl = new URL(url);
clientUrl.username = username;
clientUrl.password = password;

log.debug(serviceLoadedMsg(`${serviceName}client`));
return clientUrl.toString();
}

export function createEsClient(config: ScoutServerConfig, log: ToolingLog) {
const { username, password } = config.auth;
const elasticsearchUrl = createClientUrlWithAuth({
serviceName: 'Es',
url: config.hosts.elasticsearch,
username,
password,
log,
});

return createEsClientForTesting({
esUrl: elasticsearchUrl,
authOverride: { username, password },
});
}

export function createKbnClient(config: ScoutServerConfig, log: ToolingLog) {
const kibanaUrl = createClientUrlWithAuth({
serviceName: 'Kbn',
url: config.hosts.kibana,
username: config.auth.username,
password: config.auth.password,
log,
});

return new KbnClient({ log, url: kibanaUrl });
}
29 changes: 29 additions & 0 deletions packages/kbn-scout/src/common/services/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* 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 path from 'path';
import fs from 'fs';
import { ToolingLog } from '@kbn/tooling-log';
import { ScoutServerConfig } from '../../types';
import { serviceLoadedMsg } from '../../playwright/utils';

export function createScoutConfig(configDir: string, configName: string, log: ToolingLog) {
if (!configDir || !fs.existsSync(configDir)) {
throw new Error(`Directory with servers configuration is missing`);
}

const configPath = path.join(configDir, `${configName}.json`);
log.info(`Reading test servers confiuration from file: ${configPath}`);

const config = JSON.parse(fs.readFileSync(configPath, 'utf-8')) as ScoutServerConfig;

log.debug(serviceLoadedMsg('config'));

return config;
}
Loading

0 comments on commit b2c9133

Please sign in to comment.