chore: 부하테스트 시나리오 개선 및 성능 분석 문서화 #40
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Test | |
| on: | |
| push: | |
| branches: [develop] | |
| pull_request: | |
| branches: [develop] | |
| concurrency: | |
| group: test-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| test: | |
| name: pytest | |
| runs-on: ubuntu-latest | |
| services: | |
| mysql: | |
| image: mysql:8.0 | |
| env: | |
| MYSQL_ROOT_PASSWORD: testpass | |
| MYSQL_DATABASE: speedcam | |
| ports: | |
| - 3306:3306 | |
| options: >- | |
| --health-cmd="mysqladmin ping -h 127.0.0.1 --silent" | |
| --health-interval=10s | |
| --health-timeout=5s | |
| --health-retries=5 | |
| --health-start-period=30s | |
| env: | |
| DJANGO_SETTINGS_MODULE: config.settings.dev | |
| DB_HOST: 127.0.0.1 | |
| DB_PORT: 3306 | |
| DB_USER: root | |
| DB_PASSWORD: testpass | |
| DB_NAME: speedcam | |
| DB_NAME_VEHICLES: speedcam_vehicles | |
| DB_NAME_DETECTIONS: speedcam_detections | |
| DB_NAME_NOTIFICATIONS: speedcam_notifications | |
| CELERY_BROKER_URL: memory:// | |
| SECRET_KEY: ci-test-secret-key | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Set up Python 3.12 | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.12" | |
| - name: Cache pip | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.cache/pip | |
| key: ${{ runner.os }}-pip-test-${{ hashFiles('requirements/test.txt') }} | |
| restore-keys: | | |
| ${{ runner.os }}-pip-test- | |
| - name: Install system dependencies | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y default-libmysqlclient-dev pkg-config | |
| - name: Install Python dependencies | |
| run: pip install -r requirements/test.txt | |
| - name: Create MSA databases | |
| run: | | |
| mysql -h 127.0.0.1 -u root -ptestpass -e " | |
| CREATE DATABASE IF NOT EXISTS speedcam_vehicles CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; | |
| CREATE DATABASE IF NOT EXISTS speedcam_detections CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; | |
| CREATE DATABASE IF NOT EXISTS speedcam_notifications CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; | |
| ALTER DATABASE speedcam CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; | |
| " | |
| - name: Run migrations | |
| run: | | |
| python manage.py migrate --database=default | |
| python manage.py migrate --database=vehicles_db | |
| python manage.py migrate --database=detections_db | |
| python manage.py migrate --database=notifications_db | |
| - name: Run tests | |
| run: | | |
| pytest \ | |
| --cov=apps \ | |
| --cov-report=term-missing \ | |
| --cov-report=xml:coverage.xml \ | |
| --junitxml=test-results.xml \ | |
| -v --tb=short | |
| - name: Upload coverage report | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: coverage-report | |
| path: coverage.xml | |
| - name: Upload test results | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: test-results | |
| path: test-results.xml |