forked from mtusi2026/mtusi2026lab6
Лабораторная 6: наблюдаемость мессенджера
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
#!/bin/sh
|
||||
# Run against a lab5 stage-3 stand without a worker.
|
||||
set -eu
|
||||
cd "$(dirname "$0")/.."
|
||||
base_url=${BASE_URL:-http://localhost:18082}
|
||||
sql() {
|
||||
docker compose exec -T postgres psql -U messenger -d messenger -At -v ON_ERROR_STOP=1 -c "$1"
|
||||
}
|
||||
docker compose stop outbox-publisher
|
||||
trap 'docker compose start outbox-publisher >/dev/null' EXIT
|
||||
upload=$(PYTHONDONTWRITEBYTECODE=1 python3 student-tests/queued_upload.py --base-url "$base_url")
|
||||
printf '%s\n' "$upload"
|
||||
aid=$(printf '%s\n' "$upload" | awk '/Attachment ID:/ {print $3}')
|
||||
query="SELECT count(*) FROM attachment_outbox o JOIN attachment_jobs j ON j.id=o.job_id WHERE j.attachment_id='$aid' AND o.published_at IS"
|
||||
test "$(sql "$query NULL")" = 1
|
||||
echo 'PASS: upload committed while publisher was stopped'
|
||||
docker compose start outbox-publisher
|
||||
trap - EXIT
|
||||
for i in $(seq 1 40); do
|
||||
if test "$(sql "$query NOT NULL")" = 1; then
|
||||
echo 'PASS: same attachment job confirmed after publisher startup'
|
||||
exit 0
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
echo 'FAIL: outbox row not confirmed' >&2
|
||||
exit 1
|
||||
Reference in New Issue
Block a user