test: wait for dependency lock fixture readiness

This commit is contained in:
udo 2026-07-13 22:21:18 +00:00
parent 8da6cad305
commit 36ea0cd2a5

View File

@ -14,6 +14,7 @@ cache_dir=""
mutation_file="/tmp/uce-dependency-mutation-$$" mutation_file="/tmp/uce-dependency-mutation-$$"
post_body="/tmp/uce-dependency-post-body-$$" post_body="/tmp/uce-dependency-post-body-$$"
post_headers="/tmp/uce-dependency-post-headers-$$" post_headers="/tmp/uce-dependency-post-headers-$$"
lock_ready_file="/tmp/uce-dependency-lock-ready-$$"
http_host="${UCE_TEST_HTTP_HOST:-uce.openfu.com}" http_host="${UCE_TEST_HTTP_HOST:-uce.openfu.com}"
cleanup() { cleanup() {
@ -21,7 +22,7 @@ cleanup() {
if [[ -n "$cache_dir" ]]; then if [[ -n "$cache_dir" ]]; then
rm -rf "$cache_dir" rm -rf "$cache_dir"
fi fi
rm -f "$mutation_file" "$post_body" "$post_headers" rm -f "$mutation_file" "$post_body" "$post_headers" "$lock_ready_file"
} }
trap cleanup EXIT trap cleanup EXIT
mkdir -p "$source_dir" mkdir -p "$source_dir"
@ -108,10 +109,22 @@ child_wasm="$cache_dir/child.uce.wasm"
exec 9>"$child_wasm.lock" exec 9>"$child_wasm.lock"
flock 8 flock 8
flock 9 flock 9
: >"$lock_ready_file"
sleep 3 sleep 3
) & ) &
rebuild_lock_pid=$! rebuild_lock_pid=$!
sleep 0.2 deadline=$((SECONDS + 5))
while [[ ! -e "$lock_ready_file" && $SECONDS -lt $deadline ]]; do
if ! kill -0 "$rebuild_lock_pid" 2>/dev/null; then
echo "test rebuild lock process exited before acquiring locks" >&2
exit 1
fi
sleep 0.05
done
if [[ ! -e "$lock_ready_file" ]]; then
echo "test rebuild lock process did not acquire locks before deadline" >&2
exit 1
fi
sed -i 's/dependency-marker-b/dependency-marker-d/' "$source_dir/child.uce" sed -i 's/dependency-marker-b/dependency-marker-d/' "$source_dir/child.uce"
started_at=$(date +%s%N) started_at=$(date +%s%N)
http_during_lock=$(http_marker) http_during_lock=$(http_marker)