Skip to content

Commit

Permalink
fix: mongodb healthcheck, add first test
Browse files Browse the repository at this point in the history
  • Loading branch information
laplab committed May 14, 2024
1 parent 91a138b commit 8785ed8
Show file tree
Hide file tree
Showing 7 changed files with 1,397 additions and 22 deletions.
3 changes: 1 addition & 2 deletions packages/client/tests/e2e/mongodb-notablescan/_steps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { executeSteps } from '../_utils/executeSteps'

void executeSteps({
setup: async () => {
await $`echo "rs.status()" | mongosh --port 27017`
await $`pnpm install`
await $`pnpm prisma generate`
await $`pnpm prisma db push --force-reset --skip-generate`
Expand All @@ -15,5 +14,5 @@ void executeSteps({
finish: async () => {
await $`echo "done"`
},
keep: true, // keep docker open to debug it
// keep: true, // keep docker open to debug it
})
20 changes: 3 additions & 17 deletions packages/client/tests/e2e/mongodb-notablescan/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,18 @@ version: '3.7'
services:
test-e2e:
environment:
- DATABASE_URL=mongodb://prisma:prisma@mongo:27017/test_db?authSource=admin&retryWrites=true
- DATABASE_URL=mongodb://mongo:27017/test_db?retryWrites=true&replicaSet=rs0&directConnection=true
depends_on:
mongo:
condition: service_healthy

mongo:
image: mongo:7.0
command: ['--replSet', 'rs0', '--bind_ip_all', '--port', '27017']
# ports:
# - 27017:27017
environment:
MONGO_INITDB_ROOT_USERNAME: prisma
MONGO_INITDB_ROOT_PASSWORD: prisma
extra_hosts:
- 'host.docker.internal:host-gateway'
command: ['--replSet', 'rs0', '--bind_ip_all', '--port', '27017', '--setParameter', 'notablescan=1']
healthcheck:
test: echo "try { rs.status() } catch (err) { rs.initiate({_id:'rs0',members:[{_id:0,host:'host.docker.internal:27017'}]}) }" | mongosh --port 27017 --quiet
test: 'mongosh --port 27017 --eval "try { rs.status() } catch (err) { rs.initiate({_id:\"rs0\",members:[{_id:0,host:\"localhost:27017\"}]}); throw err; }"'
interval: 5s
timeout: 30s
start_period: 0s
start_interval: 1s
retries: 30
volumes:
- 'mongo_data:/data/db'
- 'mongo_config:/data/configdb'

volumes:
mongo_data:
mongo_config:

0 comments on commit 8785ed8

Please sign in to comment.