diff --git a/frontend/cypress.config.ts b/frontend/cypress.config.ts index 8bd806de..686e5ac2 100644 --- a/frontend/cypress.config.ts +++ b/frontend/cypress.config.ts @@ -1,8 +1,8 @@ -import { defineConfig } from "cypress"; +import { defineConfig } from 'cypress'; export default defineConfig({ e2e: { - baseUrl: "https://nginx", - specPattern: "src/test/e2e/**/*.cy.{js,jsx,ts,tsx}", + baseUrl: 'http://test_nginx', + specPattern: 'src/test/e2e/**/*.cy.{js,jsx,ts,tsx}', }, }); diff --git a/test.sh b/test.sh index 0a42e1b6..f4cba183 100755 --- a/test.sh +++ b/test.sh @@ -54,7 +54,7 @@ if [ "$build" = true ]; then fi echo "Starting services..." -docker-compose -f test.yml up -d --scale cypress=0 +docker-compose -f test.yml up -d --scale test_cypress=0 cypress_exit=0 vitest_exit=0 @@ -63,25 +63,25 @@ django_exit=0 if [ "$frontend" = true ]; then echo "Running frontend tests..." echo "Running Cypress tests..." - docker-compose -f test.yml up --exit-code-from cypress --abort-on-container-exit cypress + docker-compose -f test.yml up --exit-code-from test_cypress --abort-on-container-exit test_cypress cypress_exit=$? echo "Running Vitest tests..." - docker exec frontend npm run test + docker exec test_frontend npm run test vitest_exit=$? elif [ "$backend" = true ]; then echo "Running backend tests..." - docker exec backend python manage.py test + docker exec test_backend python manage.py test django_exit=$? else echo "Running backend tests..." - docker exec backend python manage.py test + docker exec test_backend python manage.py test django_exit=$? echo "Running frontend tests..." echo "Running Cypress tests..." - docker-compose -f test.yml up --exit-code-from cypress --abort-on-container-exit cypress + docker-compose -f test.yml up --exit-code-from test_cypress --abort-on-container-exit test_cypress cypress_exit=$? echo "Running Vitest tests..." - docker exec frontend npm run test + docker exec test_frontend npm run test vitest_exit=$? fi @@ -98,6 +98,9 @@ if [ $cypress_exit -ne 0 ] || [ $vitest_exit -ne 0 ] || [ $django_exit -ne 0 ]; echo " - Django" fi echo "-----------------" + echo "Cleaning up..." + docker-compose -f test.yml down + echo "Done." exit 1 else echo "All tests passed!" diff --git a/test.yml b/test.yml index ac716c0f..cd50a19e 100644 --- a/test.yml +++ b/test.yml @@ -3,18 +3,18 @@ version: "3.9" ############################# NETWORKS networks: - selab_network: - name: selab_network + test_selab_network: + name: test_selab_network driver: bridge ipam: config: - - subnet: 192.168.90.0/24 + - subnet: 192.168.91.0/24 ############################# EXTENSIONS x-common-keys-selab: &common-keys-selab networks: - - selab_network + - test_selab_network security_opt: - no-new-privileges:true restart: unless-stopped @@ -28,49 +28,49 @@ x-common-keys-selab: &common-keys-selab ############################# SERVICES services: - nginx: + test_nginx: <<: *common-keys-selab image: nginx:latest - container_name: nginx + container_name: test_nginx expose: - 80 - 443 - 8080 volumes: - - ${DATA_DIR}/nginx/nginx.dev.conf:/etc/nginx/nginx.conf:ro + - ${DATA_DIR}/nginx/nginx.test.conf:/etc/nginx/nginx.conf:ro - ${SSL_DIR}:/etc/nginx/ssl:ro depends_on: - - backend - - frontend + - test_backend + - test_frontend - backend: + test_backend: <<: *common-keys-selab - container_name: backend + container_name: test_backend build: context: $BACKEND_DIR dockerfile: Dockerfile - command: /bin/bash -c "./setup.sh && python manage.py runsslserver 192.168.90.2:8080" + command: /bin/bash -c "./setup.sh && python manage.py runsslserver 192.168.91.2:8080" expose: - 8080 volumes: - $BACKEND_DIR:/code - celery: + test_celery: <<: *common-keys-selab - container_name: celery + container_name: test_celery build: context: $BACKEND_DIR - dockerfile: Dockerfile.dev + dockerfile: Dockerfile command: celery -A ypovoli worker -l DEBUG volumes: - $BACKEND_DIR:/code depends_on: - - backend - - redis + - test_backend + - test_redis - frontend: + test_frontend: <<: *common-keys-selab - container_name: frontend + container_name: test_frontend build: context: $FRONTEND_DIR dockerfile: Dockerfile.dev @@ -80,24 +80,24 @@ services: volumes: - $FRONTEND_DIR:/app depends_on: - - backend + - test_backend - redis: + test_redis: <<: *common-keys-selab - container_name: redis + container_name: test_redis image: redis:latest networks: - selab_network: - ipv4_address: $REDIS_IP + test_selab_network: + ipv4_address: 192.168.91.10 expose: - - $REDIS_PORT + - 6379 entrypoint: redis-server --appendonly yes --maxmemory 512mb --maxmemory-policy allkeys-lru volumes: - ${DATA_DIR}/redis:/data - cypress: + test_cypress: <<: *common-keys-selab - container_name: cypress + container_name: test_cypress image: cypress/included:cypress-12.17.3-node-18.16.0-chrome-114.0.5735.133-1-ff-114.0.2-edge-114.0.1823.51-1 restart: "no" working_dir: /e2e