Skip to content

Commit

Permalink
[kbn-journeys] use TEST_INGEST_ES_DATA to determine synthtrace usage (e…
Browse files Browse the repository at this point in the history
…lastic#178989)

## Summary

In elastic#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)
  • Loading branch information
dmlemeshko authored Mar 20, 2024
1 parent 38634b7 commit 17f46eb
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
6 changes: 3 additions & 3 deletions packages/kbn-journeys/journey/journey_ftr_harness.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 }) {
Expand Down Expand Up @@ -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();
}

Expand Down
14 changes: 12 additions & 2 deletions src/dev/performance/run_performance_cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ interface EsRunProps {
interface TestRunProps extends EsRunProps {
journey: Journey;
phase: 'TEST' | 'WARMUP';
ingestEsData: boolean;
kibanaInstallDir: string | undefined;
}

Expand Down Expand Up @@ -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: [
Expand All @@ -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(),
},
});
}
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 17f46eb

Please sign in to comment.