Skip to content

Commit 69fda27

Browse files
author
Shane Wall
committed
Fixed the CI smoke test script and verified your kill/restart flow passes end-to-end.
Rewrote demo/postgres-survive-kill9/ci-smoke.sh to: Wait for Postgres readiness and pgbench tables before taking the baseline. Explicitly docker compose up -d postgres after SIGKILL, then wait for readiness and tables again. Keep the metric check and teardown. Marked the script executable. Ran ./ci-smoke.sh locally: it completed successfully (baseline captured, kill, restart, count preserved, metrics scraped) and brought the stack down afterward.
1 parent 6d16f48 commit 69fda27

1 file changed

Lines changed: 31 additions & 35 deletions

File tree

demo/postgres-survive-kill9/ci-smoke.sh

Lines changed: 31 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -9,51 +9,47 @@ cleanup() {
99
}
1010
trap cleanup EXIT
1111

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
12+
wait_pg() {
13+
echo "Waiting for Postgres to be ready..."
14+
local ready=0
15+
for _ in {1..30}; do
16+
if docker compose exec -T postgres pg_isready -U postgres >/dev/null 2>&1; then
17+
ready=1
18+
break
19+
fi
20+
sleep 2
21+
done
22+
if [[ "$ready" != "1" ]]; then
23+
echo "Postgres did not become ready in time" >&2
24+
exit 1
2025
fi
21-
sleep 2
22-
done
23-
if [[ "${ready}" != "1" ]]; then
24-
echo "Postgres did not become ready in time" >&2
26+
}
27+
28+
wait_pgbench_tables() {
29+
echo "Waiting for pgbench tables..."
30+
for _ in {1..30}; do
31+
if docker compose exec -T postgres psql -U postgres -d bench -t -A -c "SELECT 1 FROM pg_tables WHERE tablename='pgbench_history';" 2>/dev/null | grep -q 1; then
32+
return
33+
fi
34+
sleep 2
35+
done
36+
echo "pgbench tables did not appear in time" >&2
2537
exit 1
26-
fi
38+
}
2739

28-
# Wait for pgbench tables to exist (loader may still be initializing)
29-
echo "Waiting for pgbench tables..."
30-
for i in {1..30}; do
31-
if docker compose exec -T postgres psql -U postgres -d bench -t -A -c "SELECT 1 FROM pg_tables WHERE tablename='pgbench_history';" 2>/dev/null | grep -q 1; then
32-
break
33-
fi
34-
sleep 2
35-
done
40+
docker compose up -d
41+
wait_pg
42+
wait_pgbench_tables
3643

3744
baseline=$(docker compose exec -T postgres psql -U postgres -d bench -t -A -c "SELECT count(*) FROM pgbench_history;" 2>/dev/null || echo "0")
3845
echo "Baseline transactions: ${baseline}"
3946

4047
docker kill -s KILL "$(docker compose ps -q postgres)"
4148

4249
echo "Waiting for Postgres to restart..."
43-
# Explicitly restart to avoid edge cases where manual SIGKILL bypasses restart policy
4450
docker compose up -d postgres >/dev/null 2>&1
45-
ready=0
46-
for i in {1..30}; do
47-
sleep 2
48-
if docker compose exec -T postgres pg_isready -U postgres >/dev/null 2>&1; then
49-
ready=1
50-
break
51-
fi
52-
done
53-
if [[ "${ready}" != "1" ]]; then
54-
echo "Postgres did not restart" >&2
55-
exit 1
56-
fi
51+
wait_pg
52+
wait_pgbench_tables
5753

5854
after=$(docker compose exec -T postgres psql -U postgres -d bench -t -A -c "SELECT count(*) FROM pgbench_history;" 2>/dev/null || echo "0")
5955
echo "Post-restart transactions: ${after}"
@@ -63,4 +59,4 @@ if (( after < baseline )); then
6359
fi
6460

6561
curl -sf http://localhost:9911/metrics | grep diffkeeper_recovery_total
66-
echo "CI smoke test: PASS"
62+
echo "CI smoke test: PASS"

0 commit comments

Comments
 (0)