Skip to content

Commit 0c33f4e

Browse files
committed
fix: stabilize docker stats heartbeat test
1 parent 47dbc67 commit 0c33f4e

1 file changed

Lines changed: 11 additions & 22 deletions

File tree

test/scripts/docker-build-helper.test.ts

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2339,35 +2339,24 @@ docker_e2e_docker_cmd() {
23392339
23402340
sleep() {
23412341
SECONDS=$((SECONDS + \${1%%.*}))
2342-
command sleep 0.01
2342+
}
2343+
2344+
kill_checks=0
2345+
kill() {
2346+
if [[ "\${1:-}" == "-0" && "\${2:-}" == "sampled-docker-pid" ]]; then
2347+
kill_checks=$((kill_checks + 1))
2348+
[[ "$kill_checks" -le 6 ]]
2349+
return
2350+
fi
2351+
command kill "$@"
23432352
}
23442353
23452354
stats_log="$TMPDIR/stats.log"
23462355
run_log="$TMPDIR/run.log"
23472356
sampler_log="$TMPDIR/sampler.log"
23482357
printf "container output\\n" >"$run_log"
23492358
2350-
(
2351-
command sleep 30
2352-
) &
2353-
docker_pid="$!"
2354-
2355-
docker_e2e_sample_stats_until_exit demo "$docker_pid" "$stats_log" "$run_log" "Docker stats" 08 >"$sampler_log" 2>&1 &
2356-
sampler_pid="$!"
2357-
2358-
for _ in {1..200}; do
2359-
if grep -q "Docker stats still running (8s elapsed," "$sampler_log"; then
2360-
break
2361-
fi
2362-
if ! kill -0 "$sampler_pid" 2>/dev/null; then
2363-
break
2364-
fi
2365-
command sleep 0.01
2366-
done
2367-
2368-
kill "$docker_pid" 2>/dev/null || true
2369-
wait "$docker_pid" 2>/dev/null || true
2370-
wait "$sampler_pid"
2359+
docker_e2e_sample_stats_until_exit demo sampled-docker-pid "$stats_log" "$run_log" "Docker stats" 08 >"$sampler_log" 2>&1
23712360
output="$(cat "$sampler_log")"
23722361
23732362
[[ "$output" = *"Docker stats still running (8s elapsed,"* ]]

0 commit comments

Comments
 (0)