Skip to content

Commit 324c4e3

Browse files
AchoArnoldCopilot
andcommitted
test: replace postgres with cockroachdb in integration tests
Use cockroachdb/cockroach:latest in single-node insecure mode with in-memory storage. Add cockroachdb-init service to create the database and update the seed service to use cockroach sql CLI. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent ea534b8 commit 324c4e3

1 file changed

Lines changed: 31 additions & 23 deletions

File tree

tests/docker-compose.yml

Lines changed: 31 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,31 @@
11
services:
2-
postgres:
3-
image: postgres:alpine
4-
environment:
5-
POSTGRES_DB: httpsms
6-
POSTGRES_PASSWORD: dbpassword
7-
POSTGRES_USER: dbusername
2+
cockroachdb:
3+
image: cockroachdb/cockroach:latest
4+
command: start-single-node --insecure --store=type=mem,size=256MiB
85
ports:
9-
- "5435:5432"
6+
- "26257:26257"
7+
- "8081:8080"
108
healthcheck:
11-
test: ["CMD-SHELL", "pg_isready -U dbusername -d httpsms"]
9+
test: ["CMD", "curl", "-f", "http://localhost:8080/health?ready=1"]
1210
interval: 5s
1311
timeout: 5s
1412
retries: 10
15-
start_period: 5s
13+
start_period: 10s
14+
15+
cockroachdb-init:
16+
image: cockroachdb/cockroach:latest
17+
depends_on:
18+
cockroachdb:
19+
condition: service_healthy
20+
entrypoint:
21+
[
22+
"cockroach",
23+
"sql",
24+
"--insecure",
25+
"--host=cockroachdb",
26+
"--execute=CREATE DATABASE IF NOT EXISTS httpsms;",
27+
]
28+
restart: "no"
1629

1730
redis:
1831
image: redis:latest
@@ -61,8 +74,8 @@ services:
6174
ports:
6275
- "8000:8000"
6376
depends_on:
64-
postgres:
65-
condition: service_healthy
77+
cockroachdb-init:
78+
condition: service_completed_successfully
6679
redis:
6780
condition: service_healthy
6881
wiremock:
@@ -81,24 +94,19 @@ services:
8194
start_period: 30s
8295

8396
seed:
84-
image: postgres:alpine
97+
image: cockroachdb/cockroach:latest
8598
depends_on:
8699
api:
87100
condition: service_healthy
88-
environment:
89-
PGPASSWORD: dbpassword
90101
volumes:
91102
- ./seed.sql:/seed.sql:ro
92103
entrypoint:
93104
[
94-
"psql",
95-
"-h",
96-
"postgres",
97-
"-U",
98-
"dbusername",
99-
"-d",
100-
"httpsms",
101-
"-f",
102-
"/seed.sql",
105+
"cockroach",
106+
"sql",
107+
"--insecure",
108+
"--host=cockroachdb",
109+
"--database=httpsms",
110+
"--file=/seed.sql",
103111
]
104112
restart: "no"

0 commit comments

Comments
 (0)