Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 4 additions & 1 deletion .github/actions/incremental-build/reactor_timing.sh
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,13 @@ sum_elapsed_seconds_from_tsv() {
render_top_slowest_modules() {
local tsv="$1"
local limit="${2:-${TOP_SLOWEST_LIMIT}}"
# Limit with awk, which reads all its input, not head: incremental-build.sh
# ignores SIGPIPE, so sort fails with a write error once head stops reading,
# and pipefail turns that into a failed build (CAMEL-24777).
echo "$tsv" | awk -F '\t' '
$2 != "" && $2 ~ /^[0-9]+(\.[0-9]+)?$/ {
printf "%s\t%s\n", $2, $1
}' | sort -t $'\t' -k1,1nr | head -n "$limit" | while IFS=$'\t' read -r seconds module; do
}' | sort -t $'\t' -k1,1nr | awk -v n="$limit" 'NR <= n' | while IFS=$'\t' read -r seconds module; do
local formatted
formatted=$(format_elapsed_seconds "$seconds")
echo "- \`${module}\` (${formatted})"
Expand Down
12 changes: 12 additions & 0 deletions .github/actions/incremental-build/reactor_timing_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,18 @@ append_reactor_timing_report "$empty_fixture" "$empty_report" "All tested module
assert_eq "" "$(cat "$empty_report")" "empty log yields empty report"
rm -f "$empty_fixture" "$empty_report"

# A large reactor with SIGPIPE ignored, as incremental-build.sh runs it: limiting
# the slowest modules must not fail the pipeline (CAMEL-24777)
large_tsv="$(seq 1 50000 | awk '{ printf "module-%d\t%d\tSUCCESS\n", $1, $1 }')"
if large_slowest="$(trap '' PIPE; render_top_slowest_modules "$large_tsv" 3 2>&1)"; then
pass=$((pass + 1))
else
echo "FAIL: render_top_slowest_modules fails on a large reactor with SIGPIPE ignored"
fail=$((fail + 1))
fi
assert_eq "3" "$(echo "$large_slowest" | grep -c .)" "large reactor lists only the limit"
assert_contains "$large_slowest" "\`module-50000\`" "large reactor lists the slowest module first"

echo ""
echo "reactor_timing_test.sh: ${pass} passed, ${fail} failed"
if [[ "$fail" -ne 0 ]]; then
Expand Down
Loading