Skip to content

Commit e51ebfa

Browse files
[9.1] [scout] support flaky test runner (#234918) (#235496)
# Backport This will backport the following commits from `main` to `9.1`: - [[scout] support flaky test runner (#234918)](#234918) <!--- Backport version: 9.6.6 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Dzmitry Lemechko","email":"[email protected]"},"sourceCommit":{"committedDate":"2025-09-18T09:18:59Z","message":"[scout] support flaky test runner (#234918)\n\n## Summary\n\nExtending `.buildkite/pipelines/flaky_tests/pipeline.ts` with new\n`scoutConfig` type, that should trigger Scout tests execution from CI\nstats flaky-test-runner","sha":"1fe19a39faf9f5d96bddc7db432732f703578549","branchLabelMapping":{"^v9.2.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","backport:all-open","test:scout","v9.2.0"],"title":"[scout] support flaky test runner","number":234918,"url":"https://github.com/elastic/kibana/pull/234918","mergeCommit":{"message":"[scout] support flaky test runner (#234918)\n\n## Summary\n\nExtending `.buildkite/pipelines/flaky_tests/pipeline.ts` with new\n`scoutConfig` type, that should trigger Scout tests execution from CI\nstats flaky-test-runner","sha":"1fe19a39faf9f5d96bddc7db432732f703578549"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.2.0","branchLabelMappingKey":"^v9.2.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/234918","number":234918,"mergeCommit":{"message":"[scout] support flaky test runner (#234918)\n\n## Summary\n\nExtending `.buildkite/pipelines/flaky_tests/pipeline.ts` with new\n`scoutConfig` type, that should trigger Scout tests execution from CI\nstats flaky-test-runner","sha":"1fe19a39faf9f5d96bddc7db432732f703578549"}}]}] BACKPORT--> Co-authored-by: Dzmitry Lemechko <[email protected]>
1 parent cbe8689 commit e51ebfa

File tree

2 files changed

+64
-16
lines changed

2 files changed

+64
-16
lines changed

.buildkite/pipelines/flaky_tests/pipeline.ts

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,19 @@ if (Number.isNaN(concurrency)) {
3333
const BASE_JOBS = 1;
3434
const MAX_JOBS = 500;
3535

36+
function getScoutConfigGroupType(configPath: string): string | null {
37+
// Match platform paths: x-pack/platform/... or src/platform/...
38+
if (/^(x-pack|src)\/platform\//.test(configPath)) {
39+
return 'platform';
40+
}
41+
// Match solution paths: x-pack/solutions/<solution>/plugins/...
42+
const match = configPath.match(/^x-pack\/solutions\/([^/]+)\/plugins\//);
43+
if (match) {
44+
return match[1];
45+
}
46+
return null;
47+
}
48+
3649
function getTestSuitesFromJson(json: string) {
3750
const fail = (errorMsg: string) => {
3851
console.error('+++ Invalid test config provided');
@@ -54,6 +67,7 @@ function getTestSuitesFromJson(json: string) {
5467
const testSuites: Array<
5568
| { type: 'group'; key: string; count: number }
5669
| { type: 'ftrConfig'; ftrConfig: string; count: number }
70+
| { type: 'scoutConfig'; scoutConfig: string; count: number }
5771
> = [];
5872
for (const item of parsed) {
5973
if (typeof item !== 'object' || item === null) {
@@ -159,6 +173,33 @@ for (const testSuite of testSuites) {
159173
continue;
160174
}
161175

176+
if (testSuite.type === 'scoutConfig') {
177+
const usesParallelWorkers = testSuite.scoutConfig.endsWith('parallel.playwright.config.ts');
178+
const scoutConfigGroupType = getScoutConfigGroupType(testSuite.scoutConfig);
179+
180+
steps.push({
181+
command: `.buildkite/scripts/steps/test/scout_configs.sh`,
182+
env: {
183+
SCOUT_CONFIG: testSuite.scoutConfig,
184+
SCOUT_CONFIG_GROUP_TYPE: scoutConfigGroupType!,
185+
},
186+
key: `scout-suite-${suiteIndex++}`,
187+
label: `${testSuite.scoutConfig}`,
188+
parallelism: testSuite.count,
189+
concurrency,
190+
concurrency_group: process.env.UUID,
191+
concurrency_method: 'eager',
192+
agents: expandAgentQueue(usesParallelWorkers ? 'n2-8-spot' : 'n2-4-spot'),
193+
depends_on: 'build',
194+
timeout_in_minutes: 30,
195+
cancel_on_build_failing: true,
196+
retry: {
197+
automatic: [{ exit_status: '-1', limit: 3 }],
198+
},
199+
});
200+
continue;
201+
}
202+
162203
const [category, suiteName] = testSuite.key.split('/');
163204
switch (category) {
164205
case 'cypress':

.buildkite/scripts/steps/test/scout_configs.sh

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,44 +7,51 @@ source .buildkite/scripts/steps/functional/common.sh
77
BUILDKITE_PARALLEL_JOB=${BUILDKITE_PARALLEL_JOB:-}
88
SCOUT_CONFIG_GROUP_KEY=${SCOUT_CONFIG_GROUP_KEY:-}
99
SCOUT_CONFIG_GROUP_TYPE=${SCOUT_CONFIG_GROUP_TYPE:-}
10+
SCOUT_CONFIG=${SCOUT_CONFIG:-}
1011

11-
if [ "$SCOUT_CONFIG_GROUP_KEY" == "" ] && [ "$BUILDKITE_PARALLEL_JOB" == "" ]; then
12-
echo "Missing SCOUT_CONFIG_GROUP_KEY env var"
13-
exit 1
14-
fi
12+
EXTRA_ARGS=${FTR_EXTRA_ARGS:-}
13+
test -z "$EXTRA_ARGS" || buildkite-agent meta-data set "ftr-extra-args" "$EXTRA_ARGS"
14+
15+
configs=""
1516

1617
if [ "$SCOUT_CONFIG_GROUP_TYPE" == "" ]; then
1718
echo "Missing SCOUT_CONFIG_GROUP_TYPE env var"
1819
exit 1
1920
fi
2021

21-
EXTRA_ARGS=${FTR_EXTRA_ARGS:-}
22-
test -z "$EXTRA_ARGS" || buildkite-agent meta-data set "ftr-extra-args" "$EXTRA_ARGS"
23-
24-
export JOB="$SCOUT_CONFIG_GROUP_KEY"
25-
26-
FAILED_CONFIGS_KEY="${BUILDKITE_STEP_ID}${SCOUT_CONFIG_GROUP_KEY}"
27-
28-
configs=""
2922
group=$SCOUT_CONFIG_GROUP_TYPE
3023

24+
if [ "$SCOUT_CONFIG" != "" ]; then
25+
configs="$SCOUT_CONFIG"
26+
export JOB="$SCOUT_CONFIG"
27+
FAILED_CONFIGS_KEY="${BUILDKITE_STEP_ID}${SCOUT_CONFIG}"
28+
elif [ "$SCOUT_CONFIG_GROUP_KEY" != "" ]; then
29+
export JOB="$SCOUT_CONFIG_GROUP_KEY"
30+
FAILED_CONFIGS_KEY="${BUILDKITE_STEP_ID}${SCOUT_CONFIG_GROUP_KEY}"
31+
else
32+
if [ "$BUILDKITE_PARALLEL_JOB" == "" ]; then
33+
echo "Missing SCOUT_CONFIG_GROUP_KEY or SCOUT_CONFIG env var"
34+
exit 1
35+
fi
36+
fi
37+
3138
# The first retry should only run the configs that failed in the previous attempt
3239
# Any subsequent retries, which would generally only happen by someone clicking the button in the UI, will run everything
33-
if [[ ! "$configs" && "${BUILDKITE_RETRY_COUNT:-0}" == "1" ]]; then
40+
if [[ -z "$configs" && "${BUILDKITE_RETRY_COUNT:-0}" == "1" ]]; then
3441
configs=$(buildkite-agent meta-data get "$FAILED_CONFIGS_KEY" --default '')
35-
if [[ "$configs" ]]; then
42+
if [[ -n "$configs" ]]; then
3643
echo "--- Retrying only failed configs"
3744
echo "$configs"
3845
fi
3946
fi
4047

41-
if [ "$configs" == "" ] && [ "$SCOUT_CONFIG_GROUP_KEY" != "" ]; then
48+
if [ -z "$configs" ] && [ "$SCOUT_CONFIG_GROUP_KEY" != "" ]; then
4249
echo "--- downloading scout test configuration"
4350
download_artifact scout_playwright_configs.json .
4451
configs=$(jq -r '.[env.SCOUT_CONFIG_GROUP_KEY].configs[]' scout_playwright_configs.json)
4552
fi
4653

47-
if [ "$configs" == "" ]; then
54+
if [ -z "$configs" ]; then
4855
echo "unable to determine configs to run"
4956
exit 1
5057
fi

0 commit comments

Comments
 (0)