kibana/x-pack/test/scalability/config.ts
Dzmitry Lemechko bc44f524ac
[performance] use journey own ftr config to run scalability test (#152596)
While debugging scalability testing failure for
`cloud_security_dashboard` journey, I found that we hardcoded base FTR
config to `x-pack/performance/journeys/login.ts` and main issue is that
Kibana is not started properly.

This PR makes few changes:
- update `kbn-performance-testing-dataset-extractor` to save journey
path as `configPath` so it can be later used to start ES/Kibana in the
scalability run with the same configuration it was run for the single
user journey run.
- update scalability entry configuration to read base FTR config from
generated scalability json file (`configPath` property)

How to test:
- make sure to clone the latest
[kibana-load-testing](https://github.com/elastic/kibana-load-testing)
repo and build it `mvn clean test-compile`
- from kibana root directory run any api capacity test
```
node scripts/run_scalability.js --journey-path x-pack/test/scalability/apis/api.core.capabilities.json
```
Expected result: logs should display
```
debg Loading config file from x-pack/performance/journeys/login.ts
```
- download the latest artifacts from
[buildkite](https://buildkite.com/elastic/kibana-performance-data-set-extraction/builds/171#0186a342-9dea-4a9b-bbe4-c96449563269),
find `cloud_security_dashboard-<uuid>.json`
- from kibana root directory run scalability test for
`cloud_security_dashboard` journey
```
node scripts/run_scalability.js --journey-path <path to cloud_security_dashboard-<uuid>.json>
```
Expected result: logs should display 
```
debg Loading config file from x-pack/performance/journeys/cloud_security_dashboard.ts
```

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
2023-03-07 13:20:21 +01:00

107 lines
4.1 KiB
TypeScript

/*
* 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; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
import { FtrConfigProviderContext, getKibanaCliLoggers } from '@kbn/test';
import fs from 'fs';
import path from 'path';
// @ts-expect-error we have to check types with "allowJs: false" for now, causing this import to fail
import { REPO_ROOT } from '@kbn/repo-info';
import { createFlagError } from '@kbn/dev-cli-errors';
import { commonFunctionalServices } from '@kbn/ftr-common-functional-services';
import { v4 as uuidV4 } from 'uuid';
import { ScalabilityTestRunner } from './runner';
import { FtrProviderContext } from './ftr_provider_context';
import { ScalabilityJourney } from './types';
// These "secret" values are intentionally written in the source.
const APM_SERVER_URL = 'https://142fea2d3047486e925eb8b223559cae.apm.europe-west1.gcp.cloud.es.io';
const APM_PUBLIC_TOKEN = 'pWFFEym07AKBBhUE2i';
const AGGS_SHARD_DELAY = process.env.LOAD_TESTING_SHARD_DELAY;
const DISABLE_PLUGINS = process.env.LOAD_TESTING_DISABLE_PLUGINS;
const scalabilityJsonPath = process.env.SCALABILITY_JOURNEY_PATH;
const gatlingProjectRootPath: string =
process.env.GATLING_PROJECT_PATH || path.resolve(REPO_ROOT, '../kibana-load-testing');
export default async function ({ readConfigFile }: FtrConfigProviderContext) {
if (!fs.existsSync(gatlingProjectRootPath)) {
throw createFlagError(
`Incorrect path to load testing project: '${gatlingProjectRootPath}'\n
Clone 'elastic/kibana-load-testing' and set path using 'GATLING_PROJECT_PATH' env var`
);
}
if (!scalabilityJsonPath) {
throw createFlagError(
`Set path to scalability journey json using 'SCALABILITY_JOURNEY_PATH' env var`
);
}
const journey: ScalabilityJourney = JSON.parse(fs.readFileSync(scalabilityJsonPath, 'utf8'));
const configPath = journey.configPath ?? 'x-pack/performance/journeys/login.ts';
const baseConfig = (await readConfigFile(path.resolve(REPO_ROOT, configPath))).getAll();
return {
...baseConfig,
services: commonFunctionalServices,
pageObjects: {},
testRunner: (context: FtrProviderContext) =>
ScalabilityTestRunner(context, scalabilityJsonPath, gatlingProjectRootPath),
esTestCluster: {
...baseConfig.esTestCluster,
esJavaOpts: '-Xms8g -Xmx8g',
},
kbnTestServer: {
...baseConfig.kbnTestServer,
serverArgs: [
...baseConfig.kbnTestServer.serverArgs,
`--logging.loggers=${JSON.stringify([
...getKibanaCliLoggers(baseConfig.kbnTestServer.serverArgs),
// Enable logger for the Ops Metrics
{
name: 'metrics.ops',
level: 'all',
appenders: ['default'],
},
])}`,
],
sourceArgs: [
...baseConfig.kbnTestServer.sourceArgs,
...(!!AGGS_SHARD_DELAY ? ['--data.search.aggs.shardDelay.enabled=true'] : []),
...(!!DISABLE_PLUGINS ? ['--plugins.initialize=false'] : []),
],
env: {
ELASTIC_APM_ACTIVE: true,
ELASTIC_APM_CENTRAL_CONFIG: false,
ELASTIC_APM_TRANSACTION_SAMPLE_RATE: '0.1',
ELASTIC_APM_BREAKDOWN_METRICS: false,
ELASTIC_APM_CAPTURE_SPAN_STACK_TRACES: false,
ELASTIC_APM_METRICS_INTERVAL: '120s',
ELASTIC_APM_MAX_QUEUE_SIZE: 20480,
ELASTIC_APM_ENVIRONMENT: process.env.CI ? 'ci' : 'development',
ELASTIC_APM_SERVER_URL: APM_SERVER_URL,
ELASTIC_APM_SECRET_TOKEN: APM_PUBLIC_TOKEN,
ELASTIC_APM_GLOBAL_LABELS: Object.entries({
testBuildId: process.env.BUILDKITE_BUILD_ID ?? `local-${uuidV4()}`,
testJobId: process.env.BUILDKITE_JOB_ID ?? `local-${uuidV4()}`,
journeyName: journey.journeyName,
ftrConfig: path.basename(scalabilityJsonPath),
branch: process.env.BUILDKITE_BRANCH,
gitRev: process.env.BUILDKITE_COMMIT,
ciBuildName: process.env.BUILDKITE_PIPELINE_SLUG,
})
.flatMap(([key, value]) => (value == null ? [] : `${key}=${value}`))
.join(','),
},
},
};
}