Skip to content
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
28b5abd
Upload FTR reports after each test config completes
maryam-saeidi Oct 6, 2025
4ab4097
temporary: pipeline adjustment
maryam-saeidi Oct 2, 2025
fc0e9cc
temporary: removing jest tests from CI
maryam-saeidi Oct 6, 2025
c2337f6
Add check-event scout command
maryam-saeidi Oct 6, 2025
3e1f974
Check for stats before and after running a config
maryam-saeidi Oct 6, 2025
072add6
Fix check-event env var
maryam-saeidi Oct 7, 2025
275255e
Fix check-event query
maryam-saeidi Oct 7, 2025
e0f86cb
temporary: reducing number of test files
maryam-saeidi Oct 7, 2025
ca195db
Refresh index before query
maryam-saeidi Oct 7, 2025
93fb1a4
Fix index
maryam-saeidi Oct 7, 2025
2489f1a
Skip config when there is already telemetry data
maryam-saeidi Oct 7, 2025
7b6416f
Fix logging
maryam-saeidi Oct 7, 2025
00287dd
Revert "temporary: reducing number of test files"
maryam-saeidi Oct 7, 2025
22a9fdf
Revert "temporary: removing jest tests from CI"
maryam-saeidi Oct 7, 2025
7ac1259
Revert "temporary: pipeline adjustment"
maryam-saeidi Oct 7, 2025
b53270c
Improve log messages
maryam-saeidi Oct 7, 2025
0300adf
Merge branch 'main' into improve-ftr-retry
maryam-saeidi Oct 8, 2025
3dc9673
Use BK metadata to check successful config execution and address revi…
maryam-saeidi Oct 9, 2025
ebfc43a
Add missing fi
maryam-saeidi Oct 9, 2025
e27c24c
Merge branch 'main' into improve-ftr-retry
maryam-saeidi Oct 9, 2025
75ab482
Add missing continue
maryam-saeidi Oct 9, 2025
507199c
Revert check-event cli command
maryam-saeidi Oct 9, 2025
c9e4e0c
Revert scout_upload_report_events.sh changes
maryam-saeidi Oct 9, 2025
2f6bf4e
Merge branch 'main' into improve-ftr-retry
maryam-saeidi Oct 9, 2025
6f21b5c
Suppress metadata warning
maryam-saeidi Oct 10, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 25 additions & 3 deletions .buildkite/scripts/steps/test/ftr_configs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,15 @@ while read -r config; do
continue;
fi

echo "--- Checking for existing scout event for config $config"
# We do not use --dontFailOnError here because we need a real exit code to determine if we should skip
if node scripts/scout check-event --buildNumber "${BUILDKITE_BUILD_NUMBER:-}" --testConfig "$config"; then
echo "--- Scout event found for config $config, skipping"
continue
else
echo "--- Scout event not found for config $config, running tests"
fi

FULL_COMMAND="node scripts/functional_tests --bail --config $config $EXTRA_ARGS"
echo "--- $ $FULL_COMMAND"

Expand Down Expand Up @@ -80,6 +89,22 @@ while read -r config; do
lastCode=$?
set -e;

# Scout reporter
REPORT_DIR=$(ls -td .scout/reports/scout-ftr-*/ 2>/dev/null | head -n 1)
if [ -n "$REPORT_DIR" ]; then
EVENT_LOG_FILE="${REPORT_DIR}event-log.ndjson"
if [ -f "$EVENT_LOG_FILE" ]; then
# Upload events after running each config
export SCOUT_EVENT_LOG_PATH="$EVENT_LOG_FILE"
source .buildkite/scripts/steps/test/scout_upload_report_events.sh
unset SCOUT_EVENT_LOG_PATH
else
echo "Could not find event log file '$EVENT_LOG_FILE' for config $config"
fi
else
echo "Could not find any scout report directory '$EVENT_LOG_FILE'."
fi

timeSec=$(($(date +%s)-start))
if [[ $timeSec -gt 60 ]]; then
min=$((timeSec/60))
Expand Down Expand Up @@ -114,7 +139,4 @@ echo "--- FTR configs complete"
printf "%s\n" "${results[@]}"
echo ""

# Scout reporter
source .buildkite/scripts/steps/test/scout_upload_report_events.sh

exit $exitCode
8 changes: 7 additions & 1 deletion .buildkite/scripts/steps/test/scout_upload_report_events.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,15 @@

set -euo pipefail

SCOUT_EXTRA_ARGS=""
if [ -n "${SCOUT_EVENT_LOG_PATH:-}" ]; then
SCOUT_EXTRA_ARGS="--eventLogPath $SCOUT_EVENT_LOG_PATH"
fi

echo "--- Upload Scout reporter events to AppEx QA's team cluster"
if [[ "${SCOUT_REPORTER_ENABLED:-}" == "true" ]]; then
node scripts/scout upload-events --dontFailOnError
# shellcheck disable=SC2086
node scripts/scout upload-events --dontFailOnError $SCOUT_EXTRA_ARGS
else
echo "⚠️ The SCOUT_REPORTER_ENABLED environment variable is not 'true'. Skipping event upload."
fi
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the "Elastic License
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/

import type { Command } from '@kbn/dev-cli-runner';
import {
SCOUT_REPORTER_ES_URL,
SCOUT_REPORTER_ES_API_KEY,
SCOUT_REPORTER_ES_VERIFY_CERTS,
SCOUT_TEST_EVENTS_DATA_STREAM_NAME,
} from '@kbn/scout-info';
import { getValidatedESClient } from '../helpers/elasticsearch';

export const checkEventCommand: Command<void> = {
name: 'check-event',
description:
'Check if a specific event exists in Elasticsearch for a given build and test config',
flags: {
string: ['buildNumber', 'testConfig', 'esURL', 'esAPIKey'],
boolean: ['verifyTLSCerts', 'dontFailOnError'],
default: {
esURL: SCOUT_REPORTER_ES_URL,
esAPIKey: SCOUT_REPORTER_ES_API_KEY,
verifyTLSCerts: SCOUT_REPORTER_ES_VERIFY_CERTS,
dontFailOnError: false,
},
help: `
--buildNumber (required) The Buildkite build number.
--testConfig (required) The path to the test config file.
--esURL (required) Elasticsearch URL [env: SCOUT_REPORTER_ES_URL]
--esAPIKey (required) Elasticsearch API Key [env: SCOUT_REPORTER_ES_API_KEY]
--verifyTLSCerts (optional) Verify TLS certificates [env: SCOUT_REPORTER_ES_VERIFY_CERTS]
--dontFailOnError (optional) If present, errors will be logged but the process will not fail (default: false)
`,
},
run: async ({ flagsReader, log }) => {
const buildNumber = flagsReader.requiredString('buildNumber');
const testConfig = flagsReader.requiredString('testConfig');
const esURL = flagsReader.requiredString('esURL');
const esAPIKey = flagsReader.requiredString('esAPIKey');
const verifyTLSCerts = flagsReader.boolean('verifyTLSCerts');
const dontFailOnError = flagsReader.boolean('dontFailOnError');

log.info(`Connecting to Elasticsearch at ${esURL}`);
const es = await getValidatedESClient(
{
node: esURL,
auth: { apiKey: esAPIKey },
tls: {
rejectUnauthorized: verifyTLSCerts,
},
},
{ log, cli: true }
);

log.info(`Checking for events with buildNumber: ${buildNumber} and testConfig: ${testConfig}`);

try {
const result = await es.search({
index: SCOUT_TEST_EVENTS_DATA_STREAM_NAME,
size: 0,
query: {
bool: {
filter: [
{
range: {
'@timestamp': {
gte: 'now-1d/d',
lte: 'now',
},
},
},
],
must: [
{ term: { 'buildkite.build.number': buildNumber } },
{ term: { 'test_run.config.file.path': testConfig } },
],
},
},
});

if ((result.hits.total as any).value > 0) {
log.success(`Found events for buildNumber: ${buildNumber} and testConfig: ${testConfig}`);
} else {
log.info(
`No events was found for buildNumber: ${buildNumber} and testConfig: ${testConfig}`
);
if (!dontFailOnError) {
process.exitCode = 1;
}
}
} catch (error) {
log.error(
`Error checking events for buildNumber: ${buildNumber} and testConfig: ${testConfig}`
);
log.error(error);
if (!dontFailOnError) {
process.exitCode = 1;
}
}
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@
export { initializeReportDatastream } from './initialize_report_datastream';
export { uploadEvents } from './upload_events';
export { updateTestConfigStats } from './update_test_config_stats';
export { checkEventCommand } from './check_event';
1 change: 1 addition & 0 deletions src/platform/packages/shared/kbn-scout/src/cli/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export async function run() {
reportingCLI.initializeReportDatastream,
reportingCLI.uploadEvents,
reportingCLI.updateTestConfigStats,
reportingCLI.checkEventCommand,
createTestTrack,
]
).execute();
Expand Down