Skip to content

Commit c761b19

Browse files
author
Shane Wall
committed
New script: demo/postgres-survive-kill9/ci-smoke.sh (bash, marked executable). It brings the stack up, waits for readiness, records the pgbench count, sends SIGKILL, runs docker compose up -d postgres to bring it back, re-checks the count, greps diffkeeper_recovery_total, and tears down the stack.
Updated demo/postgres-survive-kill9/README.md to document the new ./ci-smoke.sh.
1 parent 2c9bc0f commit c761b19

2 files changed

Lines changed: 64 additions & 0 deletions

File tree

demo/postgres-survive-kill9/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,14 @@ chaos.bat # restarts the container after each kill
2626

2727
```bash
2828
./verify.sh
29+
30+
## CI smoke test (one-shot)
31+
32+
For the scripted check that kills Postgres once and asserts the counter never drops:
33+
34+
```bash
35+
./ci-smoke.sh
36+
```
2937
```
3038

3139
You should see the transaction count increase continuously, even while the container is being killed.
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#!/usr/bin/env bash
2+
3+
set -euo pipefail
4+
5+
cd "$(dirname "$0")"
6+
7+
cleanup() {
8+
docker compose down -v >/dev/null 2>&1 || true
9+
}
10+
trap cleanup EXIT
11+
12+
docker compose up -d
13+
14+
echo "Waiting for Postgres to be ready..."
15+
ready=0
16+
for i in {1..30}; do
17+
if docker compose exec -T postgres pg_isready -U postgres >/dev/null 2>&1; then
18+
ready=1
19+
break
20+
fi
21+
sleep 2
22+
done
23+
if [[ "${ready}" != "1" ]]; then
24+
echo "Postgres did not become ready in time" >&2
25+
exit 1
26+
fi
27+
28+
baseline=$(docker compose exec -T postgres psql -U postgres -d bench -t -A -c "SELECT count(*) FROM pgbench_history;" 2>/dev/null || echo "0")
29+
echo "Baseline transactions: ${baseline}"
30+
31+
docker kill -s KILL "$(docker compose ps -q postgres)"
32+
33+
echo "Waiting for Postgres to restart..."
34+
docker compose up -d postgres >/dev/null 2>&1
35+
ready=0
36+
for i in {1..30}; do
37+
sleep 2
38+
if docker compose exec -T postgres pg_isready -U postgres >/dev/null 2>&1; then
39+
ready=1
40+
break
41+
fi
42+
done
43+
if [[ "${ready}" != "1" ]]; then
44+
echo "Postgres did not restart" >&2
45+
exit 1
46+
fi
47+
48+
after=$(docker compose exec -T postgres psql -U postgres -d bench -t -A -c "SELECT count(*) FROM pgbench_history;" 2>/dev/null || echo "0")
49+
echo "Post-restart transactions: ${after}"
50+
if (( after < baseline )); then
51+
echo "Transaction count decreased after kill -9" >&2
52+
exit 1
53+
fi
54+
55+
curl -sf http://localhost:9911/metrics | grep diffkeeper_recovery_total
56+
echo "CI smoke test: PASS"

0 commit comments

Comments
 (0)