Files
mtusi2026lab3-fork/test/nginx-readiness-parallel.sh
qrtx 5c8bcf0f80 test: cover persistence failover and graceful draining
Add API integration checks, migration compatibility, rolling restart scenarios and a report verification collector.
2026-10-29 11:47:46 +03:00

36 lines
1.1 KiB
Bash
Executable File

#!/bin/sh
# A barrier makes sequential probes fail: all four requests must start together.
set -eu
sed '/^check_ready &/,$d' /source/start-nginx.sh > /tmp/readiness-under-test.sh
. /tmp/readiness-under-test.sh
mkdir -p /tmp/readiness-barrier
cycle=0
getent() {
for ip in 1 2 3 4; do printf '192.0.2.%s STREAM api\n' "$ip"; done
}
wget() {
for arg do
case "$arg" in http://*) address=${arg#http://}; address=${address%%:*} ;; esac
done
touch "/tmp/readiness-barrier/$address"
attempt=0
while [ "$attempt" -lt 50 ]; do
if [ "$(find /tmp/readiness-barrier -type f | wc -l)" -eq 4 ]; then return 0; fi
attempt=$((attempt + 1))
command sleep 0.01
done
return 1
}
nginx() { return 0; }
sleep() {
if [ "$cycle" -eq 2 ]; then
count=$(grep -c 'server 192.0.2.' "$upstreams" || true)
[ "$count" -eq 4 ] || { printf 'FAIL: readiness probes did not start in parallel\n'; exit 1; }
printf 'PASS: four concurrent probes admitted after two successful rounds\n'
exit 0
fi
rm -f /tmp/readiness-barrier/*
cycle=$((cycle + 1))
}
check_ready