From 17f46eb2982f09657ea88e270ee9e67ebab18cf9 Mon Sep 17 00:00:00 2001 From: Dzmitry Lemechko Date: Wed, 20 Mar 2024 08:26:54 +0100 Subject: [PATCH] [kbn-journeys] use TEST_INGEST_ES_DATA to determine synthtrace usage (#178989) ## Summary In #178599 we moved synthrace logic inside kbn-journey. It works well except the case when we run journeys in [kibana / performance-data-set-extraction](https://buildkite.com/elastic/kibana-performance-data-set-extraction) pipeline: we run it with `--skip-warmup` flag which runs only TEST phase but without ES data being ingested, causing journey to [fail](https://buildkite.com/elastic/kibana-performance-data-set-extraction/builds/1322#018e5629-deb8-4707-b5cf-25191d7d45d6). Synthtrace has no soft ingest option like esArchiver `loadIfNeeded`, so we can't re-use the approach we do with es/kbn archives. We must know explicitly when to run synthtrace and the easy way is to pass env var directly from the managing script: `TEST_INGEST_ES_DATA` is set via performance run script and is used to define when synthrace indexing to be run. Validating fix in [pipeline](https://buildkite.com/elastic/kibana-performance-data-set-extraction/builds/1323) --- .../kbn-journeys/journey/journey_ftr_harness.ts | 6 +++--- src/dev/performance/run_performance_cli.ts | 14 ++++++++++++-- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/packages/kbn-journeys/journey/journey_ftr_harness.ts b/packages/kbn-journeys/journey/journey_ftr_harness.ts index a2657646954a8..b6234acfcfe9b 100644 --- a/packages/kbn-journeys/journey/journey_ftr_harness.ts +++ b/packages/kbn-journeys/journey/journey_ftr_harness.ts @@ -70,9 +70,9 @@ export class JourneyFtrHarness { private apm: apmNode.Agent | null = null; // journey can be run to collect EBT/APM metrics or just as a functional test - // TEST_PERFORMANCE_PHASE is defined via scripts/run_perfomance.js run only + // TEST_INGEST_ES_DATA is defined via scripts/run_perfomance.js run only private readonly isPerformanceRun = process.env.TEST_PERFORMANCE_PHASE || false; - private readonly isWarmupPhase = process.env.TEST_PERFORMANCE_PHASE === 'WARMUP'; + private readonly shouldIngestEsData = !!process.env.TEST_INGEST_ES_DATA; // Update the Telemetry and APM global labels to link traces with journey private async updateTelemetryAndAPMLabels(labels: { [k: string]: string }) { @@ -206,7 +206,7 @@ export class JourneyFtrHarness { */ // To insure we ingest data with synthtrace only once during performance run - if (!this.isPerformanceRun || this.isWarmupPhase) { + if (!this.isPerformanceRun || this.shouldIngestEsData) { await this.runSynthtrace(); } diff --git a/src/dev/performance/run_performance_cli.ts b/src/dev/performance/run_performance_cli.ts index d25795efc2c8a..5660324c6c3ea 100644 --- a/src/dev/performance/run_performance_cli.ts +++ b/src/dev/performance/run_performance_cli.ts @@ -30,6 +30,7 @@ interface EsRunProps { interface TestRunProps extends EsRunProps { journey: Journey; phase: 'TEST' | 'WARMUP'; + ingestEsData: boolean; kibanaInstallDir: string | undefined; } @@ -79,7 +80,7 @@ async function startEs(props: EsRunProps) { } async function runFunctionalTest(props: TestRunProps) { - const { procRunner, journey, phase, kibanaInstallDir, logsDir } = props; + const { procRunner, journey, phase, kibanaInstallDir, logsDir, ingestEsData } = props; await procRunner.run('functional-tests', { cmd: 'node', args: [ @@ -103,6 +104,7 @@ async function runFunctionalTest(props: TestRunProps) { TEST_PERFORMANCE_PHASE: phase, TEST_ES_URL: 'http://elastic:changeme@localhost:9200', TEST_ES_DISABLE_STARTUP: 'true', + TEST_INGEST_ES_DATA: ingestEsData.toString(), }, }); } @@ -162,10 +164,18 @@ run( phase: 'WARMUP', kibanaInstallDir, logsDir, + ingestEsData: true, }); } process.stdout.write(`--- Running journey: ${journey.name} [collect metrics]\n`); - await runFunctionalTest({ procRunner, log, journey, phase: 'TEST', kibanaInstallDir }); + await runFunctionalTest({ + procRunner, + log, + journey, + phase: 'TEST', + kibanaInstallDir, + ingestEsData: skipWarmup, // if warmup was skipped, we need to ingest data as part of TEST phase + }); } catch (e) { log.error(e); failedJourneys.push(journey.name);