Skip to content

Commit c06dd21

Browse files
authored
[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
1 parent 9d93e06 commit c06dd21

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
@@ -34,6 +34,19 @@ if (Number.isNaN(concurrency)) {
3434
const BASE_JOBS = 1;
3535
const MAX_JOBS = 500;
3636

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

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