-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.sh
More file actions
executable file
·87 lines (75 loc) · 2.36 KB
/
Copy pathtest.sh
File metadata and controls
executable file
·87 lines (75 loc) · 2.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#!/usr/bin/env bash
# SPDX-License-Identifier: MPL-2.0
set -euo pipefail
cd "$(dirname "$0")"
use_docker="${WIPPY_CDC_TEST_DOCKER:-0}"
for arg in "$@"; do
case "$arg" in
--docker)
use_docker=1
;;
--help|-h)
echo "usage: $0 [--docker]"
echo
echo "Default: run focused CDC unit tests and compile integration tests."
echo "--docker: start a temporary Postgres with logical replication and run live CDC integration tests."
exit 0
;;
*)
echo "unknown argument: $arg" >&2
echo "usage: $0 [--docker]" >&2
exit 2
;;
esac
done
go test \
./api/service/cdc \
./api/service/sql \
./system/env/... \
./service/env/... \
./service/sql/... \
./service/cdc/postgres \
./runtime/lua/modules/cdc \
./boot/components/dispatchers
if [[ -n "${WIPPY_CDC_IT_REPL_DSN:-}" && -n "${WIPPY_CDC_IT_ADMIN_DSN:-}" ]]; then
go test -tags integration ./service/cdc/postgres
exit 0
fi
if [[ "$use_docker" != "1" ]]; then
echo "WIPPY_CDC_IT_REPL_DSN/WIPPY_CDC_IT_ADMIN_DSN not set; running CDC integration compile check only."
echo "Run '$0 --docker' for a live logical-replication Postgres proof."
go test -tags integration -run '^$' ./service/cdc/postgres
exit 0
fi
container="wippy-cdc-it-$$"
cleanup() {
if [[ "${WIPPY_CDC_KEEP_DOCKER:-0}" != "1" ]]; then
docker rm -f "$container" >/dev/null 2>&1 || true
fi
}
trap cleanup EXIT
docker run -d \
--name "$container" \
--label ai.wippy.owner=wippy \
--label ai.wippy.cdc-test=1 \
-e POSTGRES_PASSWORD=postgres \
-e POSTGRES_DB=wippy \
-p 127.0.0.1::5432 \
postgres:17 \
-c wal_level=logical \
-c max_wal_senders=16 \
-c max_replication_slots=32 >/dev/null
for _ in {1..60}; do
if docker exec "$container" pg_isready -U postgres -d wippy >/dev/null 2>&1; then
break
fi
sleep 1
done
docker exec "$container" pg_isready -U postgres -d wippy >/dev/null
docker exec "$container" psql -U postgres -d wippy -v ON_ERROR_STOP=1 \
-c "CREATE ROLE cdc_repl WITH REPLICATION LOGIN PASSWORD 'cdc_repl';" \
-c "GRANT ALL PRIVILEGES ON DATABASE wippy TO cdc_repl;" >/dev/null
port="$(docker port "$container" 5432/tcp | sed -n 's/.*://p' | head -n1)"
export WIPPY_CDC_IT_ADMIN_DSN="postgres://postgres:postgres@127.0.0.1:${port}/wippy?sslmode=disable"
export WIPPY_CDC_IT_REPL_DSN="postgres://cdc_repl:cdc_repl@127.0.0.1:${port}/wippy?sslmode=disable&replication=database"
go test -tags integration ./service/cdc/postgres