[ftr] add first-class support for playwrite journeys (#140680)

* [ftr] add first-class support for playwrite journeys

* [CI] Auto-commit changed files from 'node scripts/generate codeowners'

* fix jest test

* remove ability to customize kibana server args, if we need it we can add it back

* remove dev dir that doesn't exist

* fix typo

* prevent duplicated array converstion logic by sharing flag reader

* remove destructuring of option

* fix scalability config and config_path import

* fix start_servers args and tests

* include simple readme

* fix jest tests and support build re-use when changes are just to jest tests

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
Spencer 2022-09-22 03:06:46 -05:00 committed by GitHub
parent 2bc9b77e9c
commit 50b3b57d9e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
197 changed files with 4828 additions and 4096 deletions

View file

@ -66,8 +66,8 @@ RUNTIME_DEPS = [
TYPES_DEPS = [
"//packages/kbn-dev-cli-errors:npm_module_types",
"//packages/kbn-dev-cli-runner:npm_module_types",
"//packages/kbn-test:npm_module_types",
"//packages/kbn-tooling-log:npm_module_types",
"//packages/kbn-journeys:npm_module_types",
"@npm//@elastic/elasticsearch",
"@npm//@types/node",
"@npm//@types/jest",

View file

@ -12,16 +12,13 @@
*
*************************************************************/
import path from 'path';
import { run } from '@kbn/dev-cli-runner';
import { createFlagError } from '@kbn/dev-cli-errors';
import { EsVersion, readConfigFile } from '@kbn/test';
import path from 'path';
import { extractor } from './extractor';
import { ScalabilitySetup, TestData } from './types';
import { Journey } from '@kbn/journeys';
interface Vars {
[key: string]: string;
}
import { extractor } from './extractor';
export async function runExtractor() {
run(
@ -50,50 +47,7 @@ export async function runExtractor() {
throw createFlagError('--es-password must be defined');
}
const configPath = flags.config;
if (typeof configPath !== 'string') {
throw createFlagError('--config must be a string');
}
const config = await readConfigFile(log, EsVersion.getDefault(), path.resolve(configPath));
const scalabilitySetup: ScalabilitySetup = config.get('scalabilitySetup');
if (!scalabilitySetup) {
log.warning(
`'scalabilitySetup' is not defined in config file, output file for Kibana scalability run won't be generated`
);
}
const testData: TestData = config.get('testData');
const env = config.get(`kbnTestServer.env`);
if (
typeof env !== 'object' ||
typeof env.ELASTIC_APM_GLOBAL_LABELS !== 'string' ||
!env.ELASTIC_APM_GLOBAL_LABELS.includes('journeyName=')
) {
log.error(
`'journeyName' must be defined in config file:
env: {
...config.kbnTestServer.env,
ELASTIC_APM_GLOBAL_LABELS: Object.entries({
journeyName: <journey name>,
})
},`
);
return;
}
const envVars: Vars = env.ELASTIC_APM_GLOBAL_LABELS.split(',').reduce(
(acc: Vars, pair: string) => {
const [key, value] = pair.split('=');
return { ...acc, [key]: value };
},
{}
);
const journeyName = envVars.journeyName;
const withoutStaticResources = !!flags['without-static-resources'] || false;
const buildId = flags.buildId;
if (buildId && typeof buildId !== 'string') {
throw createFlagError('--buildId must be a string');
@ -102,11 +56,37 @@ export async function runExtractor() {
throw createFlagError('--buildId must be defined');
}
const withoutStaticResources = !!flags['without-static-resources'] || false;
const configPath = flags.config;
if (typeof configPath !== 'string') {
throw createFlagError('--config must be a string');
}
const journey = await Journey.load(path.resolve(configPath));
const scalabilitySetup = journey.config.getScalabilityConfig();
if (!scalabilitySetup) {
log.warning(
`'scalabilitySetup' is not defined in config file, output file for Kibana scalability run won't be generated`
);
}
const testData = {
esArchives: journey.config.getEsArchives(),
kbnArchives: journey.config.getKbnArchives(),
};
return extractor({
param: { journeyName, scalabilitySetup, testData, buildId, withoutStaticResources },
client: { baseURL, username, password },
param: {
journeyName: journey.config.getName(),
scalabilitySetup,
testData,
buildId,
withoutStaticResources,
},
client: {
baseURL,
username,
password,
},
log,
});
},

View file

@ -7,6 +7,7 @@
*/
import { ToolingLog } from '@kbn/tooling-log';
import { ScalabilitySetup } from '@kbn/journeys';
export interface Request {
transactionId: string;
@ -31,19 +32,6 @@ export interface Stream<T extends Request> {
requests: T[];
}
export interface InjectionStep {
action: string;
minUsersCount?: number;
maxUsersCount: number;
duration: string;
}
export interface ScalabilitySetup {
warmup: InjectionStep[];
test: InjectionStep[];
maxDuration: string;
}
export interface TestData {
kbnArchives?: string[];
esArchives?: string[];
@ -52,7 +40,7 @@ export interface TestData {
export interface CLIParams {
param: {
journeyName: string;
scalabilitySetup: ScalabilitySetup;
scalabilitySetup?: ScalabilitySetup;
testData: TestData;
buildId: string;
withoutStaticResources: boolean;