Skip to content

Commit

Permalink
ci(ftr): notify owners in the slack message when failures
Browse files Browse the repository at this point in the history
  • Loading branch information
v1v committed Dec 30, 2024
1 parent b64ff10 commit d470111
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 6 deletions.
12 changes: 12 additions & 0 deletions .buildkite/pipeline-utils/test-failures/annotate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,3 +188,15 @@ export const annotateTestFailures = async () => {
);
}
};

export const pingTeam = async () => {
if (process.env.ELASTIC_SLACK_NOTIFICATIONS_ENABLED === 'true') {
const reportSlackDir = 'target/report-slack-team';
const team: string = recursiveReadDir(reportSlackDir).find((file) => file.endsWith('.slack')) || '';

buildkite.setMetadata(
'slack:ping_team:body',
`@${team}, can you please take a look at the test failures?`
);
}
};
1 change: 1 addition & 0 deletions .buildkite/scripts/common/env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export CI=true
KIBANA_DIR=$(pwd)
export KIBANA_DIR
export XPACK_DIR="$KIBANA_DIR/x-pack"
export REPORT_SLACK_TEAM="target/report-slack-team"

export CACHE_DIR="$HOME/.kibana"
export ES_CACHE_DIR="$HOME/.es-snapshot-cache"
Expand Down
23 changes: 23 additions & 0 deletions .buildkite/scripts/lifecycle/ping_team_ftrs.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* 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 { TestFailures } from '#pipeline-utils';

(async () => {
try {
await TestFailures.pingTeam();
} catch (ex) {
console.error('Ping team for the test failures error', ex.message);
if (ex.response) {
console.error('HTTP Error Response Status', ex.response.status);
console.error('HTTP Error Response Body', ex.response.data);
}
process.exit(1);
}
})();
4 changes: 4 additions & 0 deletions .buildkite/scripts/lifecycle/post_command.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,8 @@ if [[ "$IS_TEST_EXECUTION_STEP" == "true" ]]; then
buildkite-agent artifact upload 'target/test_failures/**/*'
ts-node .buildkite/scripts/lifecycle/annotate_test_failures.ts
fi

if [[ -d "${REPORT_SLACK_TEAM}" ]]; then
ts-node .buildkite/scripts/lifecycle/ping_team_ftrs.ts
fi
fi
13 changes: 10 additions & 3 deletions .buildkite/scripts/steps/functional/apm_cypress.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,15 @@ fi

echo "--- APM Cypress Tests"

cd "$XPACK_DIR"
pushd "$XPACK_DIR"

node solutions/observability/plugins/apm/scripts/test/e2e.js \
if ! node solutions/observability/plugins/apm/scripts/test/e2e.js \
--kibana-install-dir "$KIBANA_BUILD_LOCATION" \
$CYPRESS_ARGS
$CYPRESS_ARGS ; then

# Report the error to the team using the subfolder matching the Slack Team
popd
mkdir "$REPORT_SLACK_TEAM"
touch "$REPORT_SLACK_TEAM"/obs-ux-infra_services-team.slack
exit 1
fi
12 changes: 9 additions & 3 deletions .buildkite/scripts/steps/functional/profiling_cypress.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,13 @@ export JOB=kibana-profiling-cypress

echo "--- Profiling Cypress Tests"

cd "$XPACK_DIR"
pushd "$XPACK_DIR"

NODE_OPTIONS=--openssl-legacy-provider node solutions/observability/plugins/profiling/scripts/test/e2e.js \
--kibana-install-dir "$KIBANA_BUILD_LOCATION" \
if ! NODE_OPTIONS=--openssl-legacy-provider node solutions/observability/plugins/profiling/scripts/test/e2e.js \
--kibana-install-dir "$KIBANA_BUILD_LOCATION" ; then
# Report the error to the team using the subfolder matching the Slack Team
popd
mkdir "$REPORT_SLACK_TEAM"
touch "$REPORT_SLACK_TEAM"/obs-ux-infra_services-team.slack
exit 1
fi

0 comments on commit d470111

Please sign in to comment.