diff --git a/scripts/test_dependency_invalidation.sh b/scripts/test_dependency_invalidation.sh index bb06022..a81fe4c 100755 --- a/scripts/test_dependency_invalidation.sh +++ b/scripts/test_dependency_invalidation.sh @@ -14,6 +14,7 @@ cache_dir="" mutation_file="/tmp/uce-dependency-mutation-$$" post_body="/tmp/uce-dependency-post-body-$$" post_headers="/tmp/uce-dependency-post-headers-$$" +lock_ready_file="/tmp/uce-dependency-lock-ready-$$" http_host="${UCE_TEST_HTTP_HOST:-uce.openfu.com}" cleanup() { @@ -21,7 +22,7 @@ cleanup() { if [[ -n "$cache_dir" ]]; then rm -rf "$cache_dir" fi - rm -f "$mutation_file" "$post_body" "$post_headers" + rm -f "$mutation_file" "$post_body" "$post_headers" "$lock_ready_file" } trap cleanup EXIT mkdir -p "$source_dir" @@ -108,10 +109,22 @@ child_wasm="$cache_dir/child.uce.wasm" exec 9>"$child_wasm.lock" flock 8 flock 9 + : >"$lock_ready_file" sleep 3 ) & 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" started_at=$(date +%s%N) http_during_lock=$(http_marker)