mirror of
https://github.com/azaion/loader.git
synced 2026-04-22 13:26:32 +00:00
Add E2E tests, fix bugs
Made-with: Cursor
This commit is contained in:
@@ -0,0 +1,117 @@
|
||||
# Test Infrastructure
|
||||
|
||||
**Task**: 01_test_infrastructure
|
||||
**Name**: Test Infrastructure
|
||||
**Description**: Scaffold the blackbox test project — pytest runner, mock API server, mock CDN (MinIO), Docker test environment, test data fixtures, CSV reporting
|
||||
**Complexity**: 5 points
|
||||
**Dependencies**: None
|
||||
**Component**: Blackbox Tests
|
||||
**Tracker**: pending
|
||||
**Epic**: pending
|
||||
|
||||
## Test Project Folder Layout
|
||||
|
||||
```
|
||||
e2e/
|
||||
├── conftest.py
|
||||
├── requirements.txt
|
||||
├── mocks/
|
||||
│ └── mock_api/
|
||||
│ ├── Dockerfile
|
||||
│ └── app.py
|
||||
├── fixtures/
|
||||
│ ├── test_resource.bin
|
||||
│ └── test_archive.enc
|
||||
├── tests/
|
||||
│ ├── test_health.py
|
||||
│ ├── test_auth.py
|
||||
│ ├── test_resources.py
|
||||
│ ├── test_unlock.py
|
||||
│ ├── test_security.py
|
||||
│ ├── test_performance.py
|
||||
│ └── test_resilience.py
|
||||
└── docker-compose.test.yml
|
||||
```
|
||||
|
||||
## Mock Services
|
||||
|
||||
| Mock Service | Replaces | Endpoints | Behavior |
|
||||
|-------------|----------|-----------|----------|
|
||||
| mock-api | Azaion Resource API | POST /login, POST /resources/get/{folder}, POST /resources/{folder}, GET /resources/list/{folder}, GET /binary-split/key-fragment | Returns canned JWT, encrypted test resources, key fragment |
|
||||
| mock-cdn (MinIO) | S3 CDN | S3 API (standard) | S3-compatible storage with pre-seeded test .big files |
|
||||
|
||||
## Docker Test Environment
|
||||
|
||||
### docker-compose.test.yml Structure
|
||||
|
||||
| Service | Image / Build | Purpose | Depends On |
|
||||
|---------|--------------|---------|------------|
|
||||
| system-under-test | Build from Dockerfile | Azaion.Loader | mock-api, mock-cdn |
|
||||
| mock-api | Build from e2e/mocks/mock_api/ | Mock Azaion Resource API | — |
|
||||
| mock-cdn | minio/minio | Mock S3 CDN | — |
|
||||
| e2e-consumer | python:3.11-slim + e2e/ | Pytest test runner | system-under-test |
|
||||
|
||||
### Networks and Volumes
|
||||
|
||||
- `e2e-net`: isolated test network connecting all services
|
||||
- `test-data` volume: mounted to e2e-consumer for test fixtures
|
||||
- Docker socket: mounted to system-under-test for unlock flow
|
||||
|
||||
## Test Runner Configuration
|
||||
|
||||
**Framework**: pytest
|
||||
**Plugins**: pytest-csv (reporting), requests (HTTP client)
|
||||
**Entry point**: `pytest tests/ --csv=/results/report.csv -v`
|
||||
|
||||
### Fixture Strategy
|
||||
|
||||
| Fixture | Scope | Purpose |
|
||||
|---------|-------|---------|
|
||||
| base_url | session | URL of the system-under-test |
|
||||
| logged_in_client | function | requests.Session with /login called |
|
||||
| mock_api_url | session | URL of the mock API |
|
||||
|
||||
## Test Data Fixtures
|
||||
|
||||
| Data Set | Source | Format | Used By |
|
||||
|----------|--------|--------|---------|
|
||||
| test_resource.bin | Generated (small binary) | Binary | test_resources.py |
|
||||
| test_archive.enc | Generated (AES-encrypted tar) | Binary | test_unlock.py |
|
||||
| cdn.yaml | Generated (mock CDN config) | YAML | conftest.py (served by mock-api) |
|
||||
|
||||
### Data Isolation
|
||||
|
||||
Fresh container restart per test run. Mock API state is stateless (canned responses). MinIO bucket re-created on startup.
|
||||
|
||||
## Test Reporting
|
||||
|
||||
**Format**: CSV
|
||||
**Columns**: Test ID, Test Name, Execution Time (ms), Result (PASS/FAIL/SKIP), Error Message
|
||||
**Output path**: `/results/report.csv` → mounted to `./e2e-results/report.csv` on host
|
||||
|
||||
## Acceptance Criteria
|
||||
|
||||
**AC-1: Test environment starts**
|
||||
Given the docker-compose.test.yml
|
||||
When `docker compose -f e2e/docker-compose.test.yml up` is executed
|
||||
Then all services start and the system-under-test health endpoint responds
|
||||
|
||||
**AC-2: Mock API responds**
|
||||
Given the test environment is running
|
||||
When the e2e-consumer sends POST /login to the mock API
|
||||
Then the mock API returns a valid JWT response
|
||||
|
||||
**AC-3: Mock CDN operational**
|
||||
Given the test environment is running
|
||||
When the e2e-consumer uploads/downloads a file to MinIO
|
||||
Then S3 operations succeed
|
||||
|
||||
**AC-4: Test runner discovers tests**
|
||||
Given the test environment is running
|
||||
When the e2e-consumer starts
|
||||
Then pytest discovers all test files in e2e/tests/
|
||||
|
||||
**AC-5: Test report generated**
|
||||
Given tests have completed
|
||||
When the test run finishes
|
||||
Then a CSV report exists at /results/report.csv with correct columns
|
||||
Reference in New Issue
Block a user