Skip to content

Commit c777e79

Browse files
committed
[scout] support flaky test runner (elastic#234918)
## Summary Extending `.buildkite/pipelines/flaky_tests/pipeline.ts` with new `scoutConfig` type, that should trigger Scout tests execution from CI stats flaky-test-runner (cherry picked from commit 1fe19a3)
1 parent 8e10e98 commit c777e79

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) {
@@ -157,6 +171,33 @@ for (const testSuite of testSuites) {
157171
continue;
158172
}
159173

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