-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
## Summary Rewrite the performance journey runner using TypeScript, to avoid dangling ES\node processes during test execution. Results are stable with this runner, as verified on CI ![image](https://user-images.githubusercontent.com/3016806/204506155-61c5807b-fad5-40bf-8284-a82693cd4c2a.png) Co-authored-by: Spencer <[email protected]> Co-authored-by: kibanamachine <[email protected]>
- Loading branch information
1 parent
f8849c5
commit 783ea14
Showing
4 changed files
with
113 additions
and
117 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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_performance_cli'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
/* | ||
* 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 { run } from '@kbn/dev-cli-runner'; | ||
import { REPO_ROOT } from '@kbn/utils'; | ||
import Fsp from 'fs/promises'; | ||
import path from 'path'; | ||
|
||
run( | ||
async ({ log, flagsReader, procRunner }) => { | ||
async function runFunctionalTest(journey: string, phase: 'TEST' | 'WARMUP') { | ||
// Pass in a clean APM environment, so that FTR can later | ||
// set it's own values. | ||
const cleanApmEnv = { | ||
ELASTIC_APM_TRANSACTION_SAMPLE_RATE: undefined, | ||
ELASTIC_APM_SERVER_URL: undefined, | ||
ELASTIC_APM_SECRET_TOKEN: undefined, | ||
ELASTIC_APM_ACTIVE: undefined, | ||
ELASTIC_APM_CONTEXT_PROPAGATION_ONLY: undefined, | ||
ELASTIC_APM_GLOBAL_LABELS: undefined, | ||
}; | ||
|
||
await procRunner.run('functional-tests', { | ||
cmd: 'node', | ||
args: [ | ||
'scripts/functional_tests', | ||
['--config', path.join(journeyBasePath, journey)], | ||
['--kibana-install-dir', kibanaInstallDir], | ||
'--debug', | ||
'--bail', | ||
].flat(), | ||
cwd: REPO_ROOT, | ||
wait: true, | ||
env: { | ||
TEST_PERFORMANCE_PHASE: phase, | ||
TEST_ES_URL: 'http://elastic:changeme@localhost:9200', | ||
TEST_ES_DISABLE_STARTUP: 'true', | ||
...cleanApmEnv, | ||
}, | ||
}); | ||
} | ||
|
||
async function startEs() { | ||
process.stdout.write(`--- Starting ES\n`); | ||
await procRunner.run('es', { | ||
cmd: 'node', | ||
args: ['scripts/es', 'snapshot'], | ||
cwd: REPO_ROOT, | ||
wait: /kbn\/es setup complete/, | ||
}); | ||
|
||
log.info(`✅ ES is ready and will run in the background`); | ||
} | ||
|
||
async function runWarmup(journey: string) { | ||
try { | ||
process.stdout.write(`--- Running warmup ${journey}\n`); | ||
// Set the phase to WARMUP, this will prevent the functional test server from starting Elasticsearch, opt in to telemetry, etc. | ||
await runFunctionalTest(journey, 'WARMUP'); | ||
} catch (e) { | ||
log.warning(`Warmup for ${journey} failed`); | ||
throw e; | ||
} | ||
} | ||
|
||
async function runTest(journey: string) { | ||
try { | ||
process.stdout.write(`--- Running test ${journey}\n`); | ||
await runFunctionalTest(journey, 'TEST'); | ||
} catch (e) { | ||
log.warning(`Journey ${journey} failed. Retrying once...`); | ||
await runFunctionalTest(journey, 'TEST'); | ||
} | ||
} | ||
|
||
const journeyBasePath = path.resolve(REPO_ROOT, 'x-pack/performance/journeys/'); | ||
const kibanaInstallDir = flagsReader.requiredPath('kibana-install-dir'); | ||
const journeys = await Fsp.readdir(journeyBasePath); | ||
log.info(`Found ${journeys.length} journeys to run`); | ||
|
||
for (const journey of journeys) { | ||
await startEs(); | ||
await runWarmup(journey); | ||
await runTest(journey); | ||
await procRunner.stop('es'); | ||
} | ||
}, | ||
{ | ||
flags: { | ||
string: ['kibana-install-dir'], | ||
}, | ||
} | ||
); |