forked from makeplane/plane
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose-test.yml
More file actions
151 lines (145 loc) · 4.68 KB
/
Copy pathdocker-compose-test.yml
File metadata and controls
151 lines (145 loc) · 4.68 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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
# Docker Compose for running the API pytest suite in a contained environment.
#
# Prerequisite:
# ./setup.sh # creates apps/api/.env (and the other env files) from .env.example
#
# Usage:
# # Run the full suite (defaults to `pytest`):
# docker compose -f docker-compose-test.yml up --build --abort-on-container-exit --exit-code-from api-tests
#
# # Run a subset by overriding the command:
# docker compose -f docker-compose-test.yml run --rm --build api-tests pytest -m unit
# docker compose -f docker-compose-test.yml run --rm api-tests pytest plane/tests/unit -k "test_workspace"
#
# # Tear down (removes ephemeral volumes and the test network):
# docker compose -f docker-compose-test.yml down -v
#
# Notes:
# - Postgres / Valkey / RabbitMQ / MinIO start with health checks; the test
# runner only starts once each dependency is healthy.
# - Data dirs are tmpfs so every run begins from a clean state.
# - Env vars come from apps/api/.env (the same file the local stack uses); tests
# use plane.settings.test, which inherits from common and reads DATABASE_URL,
# REDIS_URL, RABBITMQ_* etc. from the environment.
services:
test-db:
image: postgres:15.7-alpine
networks:
- test_env
env_file:
- ./apps/api/.env
environment:
POSTGRES_USER: ${POSTGRES_USER:-plane}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-plane}
POSTGRES_DB: ${POSTGRES_DB:-plane}
tmpfs:
- /var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-plane} -d ${POSTGRES_DB:-plane}"]
interval: 5s
timeout: 5s
retries: 10
test-redis:
image: valkey/valkey:7.2.11-alpine
networks:
- test_env
tmpfs:
- /data
healthcheck:
test: ["CMD", "valkey-cli", "ping"]
interval: 5s
timeout: 3s
retries: 10
test-mq:
image: rabbitmq:3.13.6-management-alpine
networks:
- test_env
env_file:
- ./apps/api/.env
environment:
RABBITMQ_DEFAULT_USER: ${RABBITMQ_USER:-plane}
RABBITMQ_DEFAULT_PASS: ${RABBITMQ_PASSWORD:-plane}
RABBITMQ_DEFAULT_VHOST: ${RABBITMQ_VHOST:-plane}
tmpfs:
- /var/lib/rabbitmq
healthcheck:
test: ["CMD", "rabbitmq-diagnostics", "-q", "ping"]
interval: 10s
timeout: 10s
retries: 10
test-minio:
image: minio/minio
networks:
- test_env
env_file:
- ./apps/api/.env
environment:
MINIO_ROOT_USER: ${AWS_ACCESS_KEY_ID:-access-key}
MINIO_ROOT_PASSWORD: ${AWS_SECRET_ACCESS_KEY:-secret-key}
entrypoint: >
/bin/sh -c "
mkdir -p /export/${AWS_S3_BUCKET_NAME:-uploads} &&
minio server /export --console-address ':9090' &
sleep 3 &&
mc alias set local http://localhost:9000 ${AWS_ACCESS_KEY_ID:-access-key} ${AWS_SECRET_ACCESS_KEY:-secret-key} &&
mc mb local/${AWS_S3_BUCKET_NAME:-uploads} -p || true &&
tail -f /dev/null
"
tmpfs:
- /export
healthcheck:
test: ["CMD", "mc", "ready", "local"]
interval: 10s
timeout: 5s
retries: 10
api-tests:
build:
context: ./apps/api
dockerfile: Dockerfile.dev
args:
DOCKER_BUILDKIT: 1
networks:
- test_env
env_file:
- ./apps/api/.env
environment:
DJANGO_SETTINGS_MODULE: plane.settings.test
# Override service hostnames to point at the test-only services above.
POSTGRES_HOST: test-db
DATABASE_URL: postgresql://${POSTGRES_USER:-plane}:${POSTGRES_PASSWORD:-plane}@test-db:5432/${POSTGRES_DB:-plane}
REDIS_HOST: test-redis
REDIS_URL: redis://test-redis:6379/
RABBITMQ_HOST: test-mq
AWS_S3_ENDPOINT_URL: http://test-minio:9000
# Magic-link tests mock the celery delay but the view first checks that
# EMAIL_HOST is configured. Set a placeholder so the check passes.
EMAIL_HOST: test-smtp.invalid
volumes:
- ./apps/api:/code
working_dir: /code
depends_on:
test-db:
condition: service_healthy
test-redis:
condition: service_healthy
test-mq:
condition: service_healthy
test-minio:
condition: service_healthy
# Install test-only requirements (not in local.txt) then exec pytest.
# Any args passed via `docker compose run api-tests <args>` replace the default command.
entrypoint:
- /bin/sh
- -c
- |
set -e
pip install --no-cache-dir -r requirements/test.txt
# STATIC_ROOT must exist or Django's static middleware emits a
# UserWarning on every request (~100 of the warnings in test runs).
mkdir -p plane/static-assets/collected-static
exec "$@"
- --
command: ["pytest"]
networks:
test_env:
driver: bridge