[8.7] [ftr/journeys] allow override ftr base config in journey (#151277) (#151401)

# Backport

This will backport the following commits from `main` to `8.7`:
- [[ftr/journeys] allow override ftr base config in journey
(#151277)](https://github.com/elastic/kibana/pull/151277)

<!--- Backport version: 8.9.7 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Dzmitry
Lemechko","email":"dzmitry.lemechko@elastic.co"},"sourceCommit":{"committedDate":"2023-02-16T07:52:05Z","message":"[ftr/journeys]
allow override ftr base config in journey (#151277)\n\n##
Summary\r\n\r\nCurrently journeys use pre-defined base FTR config and
there is no way\r\nto re-configure Kibana to be loaded with extras, e.g.
Fleet
plugin\r\nconfiguration.\r\n\r\nf443109eea/packages/kbn-journeys/journey/journey_ftr_config.ts (L32-L34)\r\n\r\nProbably
the easiest way to address it is to path custom FTR config\r\ndirectly
in the journey.\r\n\r\n```\r\nexport const journey = new Journey({\r\n
ftrConfigPath: 'x-pack/test/cloud_security_posture_api/config.ts',\r\n
...\r\n})\r\n```\r\n\r\n\r\nIt can be also considered as a step towards
using journeys as future\r\nalternative to Webdriver functional
tests.","sha":"b46d25a7ca700b7e4e01970c55dbc25357acf27a","branchLabelMapping":{"^v8.8.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","wg:performance","v8.7.0","v8.6.2","v8.8.0"],"number":151277,"url":"https://github.com/elastic/kibana/pull/151277","mergeCommit":{"message":"[ftr/journeys]
allow override ftr base config in journey (#151277)\n\n##
Summary\r\n\r\nCurrently journeys use pre-defined base FTR config and
there is no way\r\nto re-configure Kibana to be loaded with extras, e.g.
Fleet
plugin\r\nconfiguration.\r\n\r\nf443109eea/packages/kbn-journeys/journey/journey_ftr_config.ts (L32-L34)\r\n\r\nProbably
the easiest way to address it is to path custom FTR config\r\ndirectly
in the journey.\r\n\r\n```\r\nexport const journey = new Journey({\r\n
ftrConfigPath: 'x-pack/test/cloud_security_posture_api/config.ts',\r\n
...\r\n})\r\n```\r\n\r\n\r\nIt can be also considered as a step towards
using journeys as future\r\nalternative to Webdriver functional
tests.","sha":"b46d25a7ca700b7e4e01970c55dbc25357acf27a"}},"sourceBranch":"main","suggestedTargetBranches":["8.7","8.6"],"targetPullRequestStates":[{"branch":"8.7","label":"v8.7.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.6","label":"v8.6.2","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.8.0","labelRegex":"^v8.8.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/151277","number":151277,"mergeCommit":{"message":"[ftr/journeys]
allow override ftr base config in journey (#151277)\n\n##
Summary\r\n\r\nCurrently journeys use pre-defined base FTR config and
there is no way\r\nto re-configure Kibana to be loaded with extras, e.g.
Fleet
plugin\r\nconfiguration.\r\n\r\nf443109eea/packages/kbn-journeys/journey/journey_ftr_config.ts (L32-L34)\r\n\r\nProbably
the easiest way to address it is to path custom FTR config\r\ndirectly
in the journey.\r\n\r\n```\r\nexport const journey = new Journey({\r\n
ftrConfigPath: 'x-pack/test/cloud_security_posture_api/config.ts',\r\n
...\r\n})\r\n```\r\n\r\n\r\nIt can be also considered as a step towards
using journeys as future\r\nalternative to Webdriver functional
tests.","sha":"b46d25a7ca700b7e4e01970c55dbc25357acf27a"}}]}]
BACKPORT-->

Co-authored-by: Dzmitry Lemechko <dzmitry.lemechko@elastic.co>
This commit is contained in:
Kibana Machine 2023-02-16 03:56:20 -05:00 committed by GitHub
parent 38c25b3612
commit 84bcbafaa7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 10 deletions

View file

@ -70,6 +70,11 @@ export interface ScalabilitySetup {
}
export interface JourneyConfigOptions<CtxExt> {
/**
* Relative path to FTR config file. Use to override the default ones:
* 'x-pack/test/functional/config.base.js', 'test/functional/config.base.js'
*/
ftrConfigPath?: string;
/**
* Set to `true` to skip this journey. should probably be preceded
* by a link to a Github issue where the reasoning for why this was
@ -122,6 +127,10 @@ export class JourneyConfig<CtxExt extends object> {
this.#opts = opts;
}
getFtrConfigPath() {
return this.#opts.ftrConfigPath;
}
getEsArchives() {
return this.#opts.esArchives ?? [];
}

View file

@ -25,16 +25,12 @@ export function makeFtrConfigProvider(
steps: AnyStep[]
): FtrConfigProvider {
return async ({ readConfigFile }: FtrConfigProviderContext) => {
const baseConfig = (
await readConfigFile(
Path.resolve(
REPO_ROOT,
config.isXpack()
? 'x-pack/test/functional/config.base.js'
: 'test/functional/config.base.js'
)
)
).getAll();
const configPath = config.getFtrConfigPath();
const defaultConfigPath = config.isXpack()
? 'x-pack/test/functional/config.base.js'
: 'test/functional/config.base.js';
const ftrConfigPath = configPath ?? defaultConfigPath;
const baseConfig = (await readConfigFile(Path.resolve(REPO_ROOT, ftrConfigPath))).getAll();
const testBuildId = process.env.BUILDKITE_BUILD_ID ?? `local-${uuidV4()}`;
const testJobId = process.env.BUILDKITE_JOB_ID ?? `local-${uuidV4()}`;