-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.postgres-test.yml
More file actions
54 lines (51 loc) · 2.31 KB
/
Copy pathdocker-compose.postgres-test.yml
File metadata and controls
54 lines (51 loc) · 2.31 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
# A disposable PostgreSQL 16 for dbprofiler's integration tests.
#
# Every credential here is a ${...} substitution read from .env.test.local,
# which is gitignored. This file holds no password, no port, and no connection
# string, so it is safe to commit and safe to read in a public repository.
#
# docker compose --env-file .env.test.local \
# -f docker-compose.postgres-test.yml up -d --wait
#
# See docs/TESTING.md for the full loop, including how to reset the volume.
name: dbprofiler-postgres-test
services:
postgres:
image: postgres:16
# :? rather than a default value. A default would let a typo in the env
# file start a container with credentials nobody chose, and the integration
# test would then fail somewhere less obvious than here.
environment:
POSTGRES_USER: ${DBPROFILER_TEST_PGUSER:?missing from .env.test.local}
POSTGRES_PASSWORD: ${DBPROFILER_TEST_PGPASSWORD:?missing from .env.test.local}
POSTGRES_DB: ${DBPROFILER_TEST_PGDATABASE:?missing from .env.test.local}
command:
- postgres
# pg_stat_statements needs a preload, so the profiler's degradation path
# is not the one under test here. track=all counts statements inside
# functions too, which is closer to what a real source looks like.
- -c
- shared_preload_libraries=pg_stat_statements
- -c
- pg_stat_statements.track=all
ports:
# Loopback only. The fixtures are disposable and the credentials are
# synthetic, but a PostgreSQL listening on 0.0.0.0 is not something to
# leave running on a laptop on a conference network.
- "127.0.0.1:${DBPROFILER_TEST_PGPORT:?missing from .env.test.local}:5432"
volumes:
- pgdata:/var/lib/postgresql/data
# Runs once, when the volume is empty. `down -v` and up again is how you
# get a clean database; see docs/TESTING.md.
- ./testdata/postgres-test-init.sql:/docker-entrypoint-initdb.d/10-dbprofiler.sql:ro
healthcheck:
# $$ escapes the substitution so the shell inside the container expands
# it, not Compose. --wait blocks on this, so a test run never races the
# first connection.
test: ["CMD-SHELL", "pg_isready -U \"$$POSTGRES_USER\" -d \"$$POSTGRES_DB\""]
interval: 2s
timeout: 5s
retries: 30
start_period: 5s
volumes:
pgdata: