mirror of
https://github.com/larvit/adf-codec.git
synced 2026-11-21 23:46:21 +01:00
Answer stability round 1: 0 🔴, 2 🟡 (0 misread); check the exit status, chain the kill, close the timeout path
This commit is contained in:
@@ -45,25 +45,22 @@ boundaries_fire() {
|
|||||||
|
|
||||||
leg "import boundaries fire ($node_image)" boundaries_fire
|
leg "import boundaries fire ($node_image)" boundaries_fire
|
||||||
|
|
||||||
# Without `docker run --init`, process 1 ignores the SIGINT docker forwards and the container runs to its end.
|
|
||||||
interrupt_stops_container() {
|
interrupt_stops_container() {
|
||||||
local pid ready started waited=0
|
local pid ready status=0 waited=0
|
||||||
ready=$(mktemp) || return 1
|
ready=$(mktemp) || return 1
|
||||||
in_image "$node_image" sh -c 'echo ready; sleep 60' > "$ready" &
|
in_image "$node_image" sh -c 'echo ready; sleep 60' > "$ready" &
|
||||||
pid=$!
|
pid=$!
|
||||||
until grep -q ready "$ready"; do
|
until grep -q ready "$ready"; do
|
||||||
waited=$((waited + 1))
|
waited=$((waited + 1))
|
||||||
[ "$waited" -le 300 ] || return 1
|
[ "$waited" -le 300 ] || { kill -INT "$pid"; rm -f "$ready"; return 1; }
|
||||||
sleep 0.2
|
sleep 0.2
|
||||||
done
|
done
|
||||||
kill -INT "$pid"
|
kill -INT "$pid" && wait "$pid" || status=$?
|
||||||
started=$SECONDS
|
|
||||||
wait "$pid" || true
|
|
||||||
rm -f "$ready"
|
rm -f "$ready"
|
||||||
[ $((SECONDS - started)) -lt 20 ]
|
[ "$status" -eq 130 ]
|
||||||
}
|
}
|
||||||
|
|
||||||
leg "Ctrl-C stops a leg's container ($node_image)" interrupt_stops_container
|
leg "Ctrl-C stops an in_image container ($node_image)" interrupt_stops_container
|
||||||
|
|
||||||
test_log=$(mktemp)
|
test_log=$(mktemp)
|
||||||
node_tests() {
|
node_tests() {
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ firefox_image=selenium/standalone-firefox:159.0.1
|
|||||||
floor_image=node:18.20.8-alpine3.21
|
floor_image=node:18.20.8-alpine3.21
|
||||||
node_image=node:26.13.0-alpine3.24
|
node_image=node:26.13.0-alpine3.24
|
||||||
|
|
||||||
|
# --init: the container's process 1 ignores a SIGINT it has no handler for, so without it Ctrl-C leaves the container running.
|
||||||
in_image() {
|
in_image() {
|
||||||
local image=$1 entrypoint=$2
|
local image=$1 entrypoint=$2
|
||||||
shift 2
|
shift 2
|
||||||
|
|||||||
Reference in New Issue
Block a user