docker-compose.test.yml 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. services:
  2. # Backend unit tests
  3. backend-test:
  4. build:
  5. context: .
  6. dockerfile: Dockerfile.test
  7. target: backend-test
  8. container_name: bambuddy-backend-test
  9. # Reaps orphaned processes: pytest would otherwise be PID 1 and leave the
  10. # children some tests kill as zombies that still answer kill(pid, 0).
  11. init: true
  12. # Some backend tests also read the frontend sources and scripts/.
  13. volumes:
  14. - ./backend:/app/backend:ro
  15. - ./frontend/src:/app/frontend/src:ro
  16. - ./scripts:/app/scripts:ro
  17. environment:
  18. - TESTING=1
  19. - PYTHONUNBUFFERED=1
  20. # Frontend unit tests
  21. frontend-test:
  22. build:
  23. context: .
  24. dockerfile: Dockerfile.test
  25. target: frontend-test
  26. container_name: bambuddy-frontend-test
  27. volumes:
  28. - ./frontend/src:/app/frontend/src:ro
  29. - ./frontend/tests:/app/frontend/tests:ro
  30. # Integration test - full application
  31. integration:
  32. build:
  33. context: .
  34. dockerfile: Dockerfile
  35. container_name: bambuddy-integration-test
  36. ports:
  37. - "8001:8000"
  38. environment:
  39. - TESTING=1
  40. - DATA_DIR=/app/data
  41. healthcheck:
  42. test: ["CMD", "python", "-c", "import urllib.request; urllib.request.urlopen('http://localhost:8000/health')"]
  43. interval: 5s
  44. timeout: 5s
  45. retries: 10
  46. start_period: 10s
  47. volumes:
  48. - integration_test_data:/app/data
  49. # Integration test runner
  50. integration-test-runner:
  51. build:
  52. context: .
  53. dockerfile: Dockerfile.test
  54. target: backend-test
  55. container_name: bambuddy-integration-runner
  56. depends_on:
  57. integration:
  58. condition: service_healthy
  59. environment:
  60. - BAMBUDDY_TEST_URL=http://integration:8000
  61. - TESTING=1
  62. # -v dropped + -n 30 so integration tests inherit the same noise /
  63. # parallelism profile as the backend-test image (see Dockerfile.test CMD).
  64. command: ["pytest", "backend/tests/integration/", "--tb=short", "-p", "no:cacheprovider", "-n", "30"]
  65. init: true
  66. volumes:
  67. - ./backend:/app/backend:ro
  68. - ./frontend/src:/app/frontend/src:ro
  69. - ./scripts:/app/scripts:ro
  70. volumes:
  71. integration_test_data: