mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
[scalability testing] typescript runner (#147002)
## Summary Closes #146546 This PR replaces bash script with node-based runner script. Script can take relative path to directory with scalability journey files or relative path to individual journey json file. `node scripts/run_scalability.js --journey-config-path scalability_traces/server` `node scripts/run_scalability.js --journey-config-path scalability_traces/server/api.core.capabilities.json` ### Checklist Delete any items that are not applicable to this PR. - [ ] Any text added follows [EUI's writing guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md) - [ ] [Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html) was added for features that require explanation or tutorials - [ ] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios - [ ] Any UI touched in this PR is usable by keyboard only (learn more about [keyboard accessibility](https://webaim.org/techniques/keyboard/)) - [ ] Any UI touched in this PR does not create any new axe failures (run axe in browser: [FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/), [Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US)) - [ ] If a plugin configuration key changed, check if it needs to be allowlisted in the cloud and added to the [docker list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker) - [ ] This renders correctly on smaller devices using a responsive layout. (You can test this [in your browser](https://www.browserstack.com/guide/responsive-testing-on-local-server)) - [ ] This was checked for [cross-browser compatibility](https://www.elastic.co/support/matrix#matrix_browsers) ### Risk Matrix Delete this section if it is not applicable to this PR. Before closing this PR, invite QA, stakeholders, and other developers to identify risks that should be tested prior to the change/feature release. When forming the risk matrix, consider some of the following examples and how they may potentially impact the change: | Risk | Probability | Severity | Mitigation/Notes | |---------------------------|-------------|----------|-------------------------| | Multiple Spaces—unexpected behavior in non-default Kibana Space. | Low | High | Integration tests will verify that all features are still supported in non-default Kibana Space and when user switches between spaces. | | Multiple nodes—Elasticsearch polling might have race conditions when multiple Kibana nodes are polling for the same tasks. | High | Low | Tasks are idempotent, so executing them multiple times will not result in logical error, but will degrade performance. To test for this case we add plenty of unit tests around this logic and document manual testing procedure. | | Code should gracefully handle cases when feature X or plugin Y are disabled. | Medium | High | Unit tests will verify that any feature flag or plugin combination still results in our service operational. | | [See more potential risk examples](https://github.com/elastic/kibana/blob/main/RISK_MATRIX.mdx) | ### For maintainers - [ ] This was checked for breaking API changes and was [labeled appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)
This commit is contained in:
parent
fba0aca193
commit
9f7db8f615
5 changed files with 119 additions and 48 deletions
|
@ -74,53 +74,9 @@ download_artifacts
|
|||
echo "--- Clone kibana-load-testing repo and compile project"
|
||||
checkout_and_compile_load_runner
|
||||
|
||||
echo "--- Run Scalability Tests with Elasticsearch started only once and Kibana restart before each journey"
|
||||
echo "--- Run Scalability Tests"
|
||||
cd "$KIBANA_DIR"
|
||||
node scripts/es snapshot&
|
||||
|
||||
esPid=$!
|
||||
# Set trap on EXIT to stop Elasticsearch process
|
||||
trap "kill -9 $esPid" EXIT
|
||||
|
||||
# unset env vars defined in other parts of CI for automatic APM collection of
|
||||
# Kibana. We manage APM config in our FTR config and performance service, and
|
||||
# APM treats config in the ENV with a very high precedence.
|
||||
unset ELASTIC_APM_ENVIRONMENT
|
||||
unset ELASTIC_APM_TRANSACTION_SAMPLE_RATE
|
||||
unset ELASTIC_APM_SERVER_URL
|
||||
unset ELASTIC_APM_SECRET_TOKEN
|
||||
unset ELASTIC_APM_ACTIVE
|
||||
unset ELASTIC_APM_CONTEXT_PROPAGATION_ONLY
|
||||
unset ELASTIC_APM_GLOBAL_LABELS
|
||||
unset ELASTIC_APM_MAX_QUEUE_SIZE
|
||||
unset ELASTIC_APM_METRICS_INTERVAL
|
||||
unset ELASTIC_APM_CAPTURE_SPAN_STACK_TRACES
|
||||
unset ELASTIC_APM_BREAKDOWN_METRICS
|
||||
|
||||
|
||||
export TEST_ES_DISABLE_STARTUP=true
|
||||
ES_HOST="localhost:9200"
|
||||
export TEST_ES_URL="http://elastic:changeme@${ES_HOST}"
|
||||
# Overriding Gatling default configuration
|
||||
export ES_URL="http://${ES_HOST}"
|
||||
|
||||
# Pings the ES server every second for 2 mins until its status is green
|
||||
curl --retry 120 \
|
||||
--retry-delay 1 \
|
||||
--retry-connrefused \
|
||||
-I -XGET "${TEST_ES_URL}/_cluster/health?wait_for_nodes=>=1&wait_for_status=yellow"
|
||||
|
||||
export ELASTIC_APM_ACTIVE=true
|
||||
|
||||
for journey in scalability_traces/server/*; do
|
||||
export SCALABILITY_JOURNEY_PATH="$KIBANA_DIR/$journey"
|
||||
echo "--- Run scalability file: $SCALABILITY_JOURNEY_PATH"
|
||||
node scripts/functional_tests \
|
||||
--config x-pack/test/scalability/config.ts \
|
||||
--kibana-install-dir "$KIBANA_BUILD_LOCATION" \
|
||||
--logToFile \
|
||||
--debug
|
||||
done
|
||||
node scripts/run_scalability --kibana-install-dir "$KIBANA_BUILD_LOCATION" --journey-config-path "scalability_traces/server"
|
||||
|
||||
echo "--- Upload test results"
|
||||
upload_test_results
|
||||
|
|
10
scripts/run_scalability.js
Normal file
10
scripts/run_scalability.js
Normal file
|
@ -0,0 +1,10 @@
|
|||
/*
|
||||
* 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 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 or the Server
|
||||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
require('../src/setup_node_env');
|
||||
require('../src/dev/performance/run_scalability_cli');
|
104
src/dev/performance/run_scalability_cli.ts
Normal file
104
src/dev/performance/run_scalability_cli.ts
Normal file
|
@ -0,0 +1,104 @@
|
|||
/*
|
||||
* 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 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 or the Server
|
||||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
import { createFlagError } from '@kbn/dev-cli-errors';
|
||||
import { run } from '@kbn/dev-cli-runner';
|
||||
import { REPO_ROOT } from '@kbn/utils';
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
|
||||
run(
|
||||
async ({ log, flagsReader, procRunner }) => {
|
||||
const kibanaInstallDir = flagsReader.path('kibana-install-dir');
|
||||
const journeyConfigPath = flagsReader.requiredPath('journey-config-path');
|
||||
|
||||
if (kibanaInstallDir && !fs.existsSync(kibanaInstallDir)) {
|
||||
throw createFlagError('--kibana-install-dir must be an existing directory');
|
||||
}
|
||||
if (
|
||||
!fs.existsSync(journeyConfigPath) ||
|
||||
(!fs.statSync(journeyConfigPath).isDirectory() && path.extname(journeyConfigPath) !== '.json')
|
||||
) {
|
||||
throw createFlagError(
|
||||
'--journey-config-path must be an existing directory or scalability json path'
|
||||
);
|
||||
}
|
||||
|
||||
const journeys = fs.statSync(journeyConfigPath).isDirectory()
|
||||
? fs
|
||||
.readdirSync(journeyConfigPath)
|
||||
.filter((fileName) => path.extname(fileName) === '.json')
|
||||
.map((fileName) => path.resolve(journeyConfigPath, fileName))
|
||||
: [journeyConfigPath];
|
||||
|
||||
log.info(`Found ${journeys.length} journeys to run:\n${JSON.stringify(journeys)}`);
|
||||
|
||||
const failedJourneys = [];
|
||||
|
||||
for (const journey of journeys) {
|
||||
try {
|
||||
process.stdout.write(`--- Running scalability journey: ${journey}\n`);
|
||||
await runScalabilityJourney(journey, kibanaInstallDir);
|
||||
} catch (e) {
|
||||
log.error(e);
|
||||
failedJourneys.push(journey);
|
||||
}
|
||||
}
|
||||
|
||||
if (failedJourneys.length > 0) {
|
||||
throw new Error(`${failedJourneys.length} journeys failed: ${failedJourneys.join(',')}`);
|
||||
}
|
||||
|
||||
async function runScalabilityJourney(filePath: string, kibanaDir?: string) {
|
||||
// Pass in a clean APM environment, so that FTR can later
|
||||
// set it's own values.
|
||||
const cleanApmEnv = {
|
||||
ELASTIC_APM_ACTIVE: undefined,
|
||||
ELASTIC_APM_BREAKDOWN_METRICS: undefined,
|
||||
ELASTIC_APM_CONTEXT_PROPAGATION_ONLY: undefined,
|
||||
ELASTIC_APM_CAPTURE_SPAN_STACK_TRACES: undefined,
|
||||
ELASTIC_APM_ENVIRONMENT: undefined,
|
||||
ELASTIC_APM_GLOBAL_LABELS: undefined,
|
||||
ELASTIC_APM_MAX_QUEUE_SIZE: undefined,
|
||||
ELASTIC_APM_METRICS_INTERVAL: undefined,
|
||||
ELASTIC_APM_SERVER_URL: undefined,
|
||||
ELASTIC_APM_SECRET_TOKEN: undefined,
|
||||
ELASTIC_APM_TRANSACTION_SAMPLE_RATE: undefined,
|
||||
};
|
||||
|
||||
await procRunner.run('scalability-tests', {
|
||||
cmd: 'node',
|
||||
args: [
|
||||
'scripts/functional_tests',
|
||||
['--config', 'x-pack/test/scalability/config.ts'],
|
||||
kibanaDir ? ['--kibana-install-dir', kibanaDir] : [],
|
||||
'--debug',
|
||||
'--logToFile',
|
||||
'--bail',
|
||||
].flat(),
|
||||
cwd: REPO_ROOT,
|
||||
wait: true,
|
||||
env: {
|
||||
...cleanApmEnv,
|
||||
SCALABILITY_JOURNEY_PATH: filePath, // journey json file for Gatling test runner
|
||||
KIBANA_DIR: REPO_ROOT, // Gatling test runner use it to find kbn/es archives
|
||||
},
|
||||
});
|
||||
}
|
||||
},
|
||||
{
|
||||
flags: {
|
||||
string: ['kibana-install-dir', 'journey-config-path'],
|
||||
help: `
|
||||
--kibana-install-dir Run Kibana from existing install directory instead of from source
|
||||
--journey-config-path Define a scalability journey config or directory with multiple
|
||||
configs that should be executed
|
||||
`,
|
||||
},
|
||||
}
|
||||
);
|
|
@ -62,8 +62,6 @@ export default async function ({ readConfigFile }: FtrConfigProviderContext) {
|
|||
...(!!AGGS_SHARD_DELAY ? ['--data.search.aggs.shardDelay.enabled=true'] : []),
|
||||
...(!!DISABLE_PLUGINS ? ['--plugins.initialize=false'] : []),
|
||||
],
|
||||
// delay shutdown to ensure that APM can report the data it collects during test execution
|
||||
delayShutdown: 90_000,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
*/
|
||||
|
||||
import { withProcRunner } from '@kbn/dev-proc-runner';
|
||||
import path from 'path';
|
||||
import { FtrProviderContext } from './ftr_provider_context';
|
||||
|
||||
/**
|
||||
|
@ -19,6 +20,7 @@ export async function ScalabilityTestRunner(
|
|||
gatlingProjectRootPath: string
|
||||
) {
|
||||
const log = getService('log');
|
||||
const gatlingReportBaseDir = path.parse(scalabilityJsonPath).name;
|
||||
|
||||
log.info(`Running scalability test with json file: '${scalabilityJsonPath}'`);
|
||||
|
||||
|
@ -28,6 +30,7 @@ export async function ScalabilityTestRunner(
|
|||
args: [
|
||||
'gatling:test',
|
||||
'-q',
|
||||
`-Dgatling.core.outputDirectoryBaseName=${gatlingReportBaseDir}`,
|
||||
'-Dgatling.simulationClass=org.kibanaLoadTest.simulation.generic.GenericJourney',
|
||||
`-DjourneyPath=${scalabilityJsonPath}`,
|
||||
],
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue