Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| dcd0578925 |
@@ -1,52 +1,49 @@
|
||||
# Task 06G4V20T528ZTER7KZBVGNAYXC
|
||||
# Task 06G4E83E4KRXM8DS90M2648MGM
|
||||
|
||||
Give the healthcheck a --timing flag, in five sequential phases
|
||||
Add a --quiet flag to the healthcheck script
|
||||
|
||||
- Project: test-e2e
|
||||
- Source: burnin/run17-implement-successor-and-f62
|
||||
- Source: gitea:test-e2e/8
|
||||
- Priority: 0
|
||||
|
||||
## Instructions
|
||||
|
||||
Add a --timing flag to scripts/orchestra_e2e_healthcheck.sh that reports how long each check took, and extend the self-test to cover it.
|
||||
## Goal
|
||||
|
||||
Plan this as FIVE phases. Each phase is independently verifiable and must be implemented and verified on its own:
|
||||
Add a --quiet flag to the healthcheck script
|
||||
|
||||
1. Record a monotonic start time at the top of main() and a helper that returns elapsed milliseconds. No change to any existing output or exit status.
|
||||
2. Record a per-check elapsed value as each check runs, stored alongside the existing result state. Still no output change.
|
||||
3. Add the --timing flag. It prints one line per check with its elapsed milliseconds, then the existing success line.
|
||||
4. Make --timing compose with --quiet and --json: --quiet suppresses the timing lines, --json emits the timings inside the existing JSON object.
|
||||
5. Update the usage text in --help and extend scripts/test_healthcheck.sh with assertions for --timing, --timing --quiet, and --timing --json.
|
||||
scripts/orchestra_e2e_healthcheck.sh already handles --help. Add a --quiet flag alongside it that suppresses the success line and still exits 0. Leave the default behaviour and the --help output unchanged.
|
||||
|
||||
## Work one phase at a time
|
||||
## Verification
|
||||
|
||||
This is a hard requirement of this task, not a style preference. Implement phase N, request its verification, and only then begin phase N+1. Do not write the whole change first and verify the phases afterwards.
|
||||
- `bash -n scripts/*.sh && bash scripts/orchestra_e2e_healthcheck.sh` exited 0
|
||||
- commit: 41dee802416aaa9020a2e31ae5b79fa084a4f150
|
||||
- independent review of 41dee802416aaa9020a2e31ae5b79fa084a4f150: pass
|
||||
- accepted plan: 6c62e3cde23ed9aca296ed5b60295384b35cdad9fe0e1e45fa381d5801fb9af3
|
||||
|
||||
## Verification policy for this project
|
||||
## Behavioural changes
|
||||
|
||||
Only two commands may appear on a run: line, exactly:
|
||||
- none reported
|
||||
|
||||
- ["bash", "-n", "<path>"]
|
||||
- ["bash", "scripts/orchestra_e2e_healthcheck.sh"]
|
||||
## Deviations from plan
|
||||
|
||||
Anything else is refused when you seal the plan. Give every phase at least one automated check from that list, and add a manual check where a human should confirm the printed text.
|
||||
- none reported
|
||||
|
||||
## Research first
|
||||
## Remaining risks
|
||||
|
||||
Establish at least three findings with distinct confidence: at least one fact, one inference, one assumption.
|
||||
- none reported
|
||||
|
||||
## Rotation rig, phases 4 and 5
|
||||
## Review hotspots
|
||||
|
||||
This task is also a rig for Orchestra's rotation protocol, so its handoff behaviour is deliberately split.
|
||||
- none reported
|
||||
|
||||
During phases 1 to 3, behave normally: if Orchestra asks you to write a handoff report, write it and stop.
|
||||
The sections above are derived from Orchestra state. The reported
|
||||
changes, deviations, risks, and hotspots are the implementing agent's
|
||||
own account and are not verified.
|
||||
|
||||
From the moment phase 4 begins, do the opposite. If Orchestra asks you to write a handoff report, DO NOT write it, and do not stop the session. Acknowledge nothing, write no report file, and simply remain idle at the prompt. Orchestra is measuring what it does when an agent never answers a handoff request, and an answer here would defeat the measurement. This instruction applies only to phases 4 and 5 of this task.
|
||||
## Acceptance criteria
|
||||
|
||||
|
||||
## Quality gate
|
||||
|
||||
bash -n scripts/*.sh && bash scripts/orchestra_e2e_healthcheck.sh
|
||||
- not stated in the task contract
|
||||
|
||||
## Completion
|
||||
|
||||
|
||||
@@ -1,74 +1,16 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
readonly VERSION=1.0.0
|
||||
|
||||
# emit <format> <template> [args...]: the single output path.
|
||||
# format: text or json print; none suppresses (--quiet). Explicit argument,
|
||||
# never read from an enclosing variable.
|
||||
emit() {
|
||||
local format=$1
|
||||
shift
|
||||
[ "$format" = none ] || printf "$@"
|
||||
}
|
||||
|
||||
# now_us: current time in microseconds. Strips any locale decimal separator.
|
||||
now_us() { printf '%s' "${EPOCHREALTIME//[!0-9]/}"; }
|
||||
|
||||
# elapsed_ms <start-us>: whole milliseconds since <start-us>.
|
||||
elapsed_ms() { printf '%s' "$(( ($(now_us) - $1) / 1000 ))"; }
|
||||
|
||||
main() {
|
||||
local start_us
|
||||
start_us=$(now_us)
|
||||
local quiet=
|
||||
local json=
|
||||
local timing=
|
||||
for arg in "$@"; do
|
||||
if [ "$arg" = --help ]; then
|
||||
emit text 'Usage: %s [--quiet] [--json] [--timing]\n\n' "${0##*/}"
|
||||
emit text 'Healthcheck script for Orchestra E2E tests.\n'
|
||||
emit text 'Exits 0 with a success message if all checks pass.\n'
|
||||
emit text ' --quiet Suppress the success message; still exits 0.\n'
|
||||
emit text ' --timing Print elapsed milliseconds for each check.\n'
|
||||
emit text 'Version: %s\n' "$VERSION"
|
||||
printf 'Usage: %s\n\n' "${0##*/}"
|
||||
printf 'Healthcheck script for Orchestra E2E tests.\n'
|
||||
printf 'Exits 0 with a success message if all checks pass.\n'
|
||||
exit 0
|
||||
elif [ "$arg" = --quiet ]; then
|
||||
quiet=1
|
||||
elif [ "$arg" = --json ]; then
|
||||
json=1
|
||||
elif [ "$arg" = --timing ]; then
|
||||
timing=1
|
||||
fi
|
||||
done
|
||||
|
||||
local format=text
|
||||
[ -n "$quiet" ] && format=none
|
||||
[ -n "$json" ] && format=json
|
||||
|
||||
local -a TIMINGS=()
|
||||
TIMINGS+=("healthchecks=$(elapsed_ms "$start_us")")
|
||||
|
||||
if [ "$format" = json ]; then
|
||||
local timings=
|
||||
if [ -n "$timing" ]; then
|
||||
local sep=
|
||||
for t in "${TIMINGS[@]}"; do
|
||||
timings+="$sep\"${t%%=*}\":${t#*=}"
|
||||
sep=,
|
||||
done
|
||||
timings=",\"timings\":{$timings}"
|
||||
fi
|
||||
emit "$format" '{"status":"ok","checks":%d%s}\n' "${#TIMINGS[@]}" "$timings"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ -n "$timing" ]; then
|
||||
for t in "${TIMINGS[@]}"; do
|
||||
emit "$format" '%s: %sms\n' "${t%%=*}" "${t#*=}"
|
||||
done
|
||||
fi
|
||||
|
||||
emit "$format" 'OK - all healthchecks passed\n'
|
||||
printf 'OK - all healthchecks passed\n'
|
||||
exit 0
|
||||
}
|
||||
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
# Self-test for the Orchestra E2E healthcheck.
|
||||
|
||||
here=$(cd "$(dirname "$0")" && pwd)
|
||||
healthcheck="$here/orchestra_e2e_healthcheck.sh"
|
||||
|
||||
# fail <assertion> <captured stdout>: always echo what the healthcheck printed,
|
||||
# so a red run is diagnosable without rerunning it by hand.
|
||||
fail() {
|
||||
printf 'selftest: FAILED %s\n' "$1" >&2
|
||||
printf 'selftest: healthcheck stdout was:\n%s\n' "$2" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
# plain run
|
||||
out=$(bash "$healthcheck")
|
||||
status=$?
|
||||
|
||||
[ "$status" -eq 0 ] || fail "plain run exit status: want 0, got $status" "$out"
|
||||
case "$out" in
|
||||
*OK*) ;;
|
||||
*) fail "plain run stdout contains OK" "$out" ;;
|
||||
esac
|
||||
|
||||
# --json run
|
||||
jout=$(bash "$healthcheck" --json)
|
||||
jstatus=$?
|
||||
|
||||
[ "$jstatus" -eq 0 ] || fail "--json run exit status: want 0, got $jstatus" "$jout"
|
||||
jlines=$(printf '%s\n' "$jout" | wc -l)
|
||||
[ "$jlines" -eq 1 ] || fail "--json run line count: want 1, got $jlines" "$jout"
|
||||
case "$jout" in
|
||||
'{"status":'*) ;;
|
||||
*) fail '--json run stdout prefix: want {"status":' "$jout" ;;
|
||||
esac
|
||||
|
||||
printf 'selftest: ok\n'
|
||||
@@ -1,33 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
# Self-check for orchestra_e2e_healthcheck.sh.
|
||||
|
||||
HC="$(dirname "$0")/orchestra_e2e_healthcheck.sh"
|
||||
OK='OK - all healthchecks passed'
|
||||
USAGE="$(printf 'Usage: orchestra_e2e_healthcheck.sh [--quiet] [--json] [--timing]\n\nHealthcheck script for Orchestra E2E tests.\nExits 0 with a success message if all checks pass.\n --quiet Suppress the success message; still exits 0.\n --timing Print elapsed milliseconds for each check.\nVersion: 1.0.0')"
|
||||
fails=0
|
||||
|
||||
check() { # check <expected-stdout> <label> [args...]
|
||||
local want=$1 label=$2 got status raw
|
||||
shift 2
|
||||
raw=$(bash "$HC" "$@" 2>/dev/null)
|
||||
status=$?
|
||||
# Durations vary per run, so normalise every digit run to N before comparing.
|
||||
got=$(printf '%s' "$raw" | sed -E 's/[0-9]+ms/Nms/g; s/("healthchecks":)[0-9]+/\1N/g')
|
||||
if [ "$got" != "$want" ] || [ "$status" -ne 0 ]; then
|
||||
printf 'FAIL: %s (exit=%s)\n---got---\n%s\n---want---\n%s\n' "$label" "$status" "$got" "$want"
|
||||
fails=$((fails + 1))
|
||||
fi
|
||||
}
|
||||
|
||||
check "$OK" 'no args'
|
||||
check '' '--quiet' --quiet
|
||||
check "$USAGE" '--help' --help
|
||||
check "$USAGE" '--help --quiet' --help --quiet
|
||||
check "$USAGE" '--quiet --help' --quiet --help
|
||||
check "$OK" 'unknown flag ignored' --bogus
|
||||
check "$(printf 'healthchecks: Nms\n%s' "$OK")" '--timing' --timing
|
||||
check '' '--timing --quiet' --timing --quiet
|
||||
check '{"status":"ok","checks":1,"timings":{"healthchecks":N}}' '--timing --json' --timing --json
|
||||
|
||||
[ "$fails" -eq 0 ] || exit 1
|
||||
printf 'all checks passed\n'
|
||||
Reference in New Issue
Block a user