69e91fd5d0
- Extended health endpoint: DB+Redis+Storage+Worker checks with degraded status - Prometheus metrics endpoint: admin-only, text/plain format - Metrics: http_requests_total, db_pool_connections, arq_jobs_total - Structured JSON logging (structlog): timestamp, level, method, path, status, duration_ms, tenant_id - Performance: page_size max 100 enforced (422), streaming CSV export (StreamingResponse) - Scripts: seed_perf_data.py, check_indexes.py - Docs: admin-guide.md (Deploy, Backup, Restore, Env-Vars, Troubleshooting), api-overview.md - README updated: prod setup, API section, env profiles, admin-guide link - .env.example: added SECRET_KEY, STORAGE_PATH, SMTP_* vars - 38 new tests, full regression 564/564 pass (0 failures) - Ruff: all checks passed
93 lines
3.1 KiB
Markdown
93 lines
3.1 KiB
Markdown
# T10 Test Report — Monitoring, Performance, Documentation & Environment Config
|
|
|
|
**Date**: 2026-07-01
|
|
**Task**: T10
|
|
**Status**: ✅ ALL TESTS PASS
|
|
|
|
---
|
|
|
|
## Test Run
|
|
|
|
```
|
|
cd /a0/usr/workdir/dev-projects/leocrm && python -m pytest tests/test_monitoring.py tests/test_performance.py tests/test_health.py -v --tb=short
|
|
```
|
|
|
|
**Result**: 38 passed, 2 warnings in 24.24s
|
|
|
|
### All 38 Tests Passed:
|
|
|
|
#### test_monitoring.py (17 tests) — AC1-6
|
|
- ✅ test_health_returns_200_with_checks_structure (AC1)
|
|
- ✅ test_health_db_down_returns_degraded (AC2)
|
|
- ✅ test_health_no_auth_required
|
|
- ✅ test_check_database_returns_dict
|
|
- ✅ test_check_redis_returns_dict
|
|
- ✅ test_check_storage_returns_dict
|
|
- ✅ test_check_worker_returns_dict
|
|
- ✅ test_metrics_admin_returns_200_text_plain (AC3)
|
|
- ✅ test_metrics_non_admin_returns_403 (AC3)
|
|
- ✅ test_metrics_unauthenticated_returns_401
|
|
- ✅ test_metrics_include_required_metric_names (AC4)
|
|
- ✅ test_generate_metrics_returns_bytes
|
|
- ✅ test_record_request_increments_counter (AC5)
|
|
- ✅ test_record_request_log_has_required_fields (AC5)
|
|
- ✅ test_record_error_logs_stacktrace_and_context (AC6)
|
|
- ✅ test_record_error_without_traceback
|
|
- ✅ test_record_arq_job_increments_counter
|
|
|
|
#### test_performance.py (15 tests) — AC7-12
|
|
- ✅ test_list_contacts_response_time_under_500ms (AC8)
|
|
- ✅ test_search_contacts_response_time_under_500ms (AC9)
|
|
- ✅ test_list_contacts_returns_correct_pagination
|
|
- ✅ test_page_size_over_100_returns_422 (AC10)
|
|
- ✅ test_page_size_100_accepted
|
|
- ✅ test_page_size_0_returns_422
|
|
- ✅ test_companies_page_size_over_100_returns_422
|
|
- ✅ test_csv_export_streams_content (AC12)
|
|
- ✅ test_csv_export_empty_tenant
|
|
- ✅ test_csv_export_with_search_filter
|
|
- ✅ test_csv_export_companies_streaming
|
|
- ✅ test_csv_export_requires_auth
|
|
- ✅ test_seed_script_exists (AC7)
|
|
- ✅ test_seed_script_has_count_arg
|
|
- ✅ test_check_indexes_script_exists
|
|
|
|
#### test_health.py (6 tests) — AC1
|
|
- ✅ test_health_returns_200_without_auth
|
|
- ✅ test_health_has_database_check
|
|
- ✅ test_health_has_redis_check
|
|
- ✅ test_health_has_storage_check
|
|
- ✅ test_health_has_worker_check
|
|
- ✅ test_health_status_is_valid_value
|
|
|
|
---
|
|
|
|
## Ruff Check
|
|
|
|
```
|
|
python -m ruff check app/core/monitoring.py app/routes/metrics.py app/routes/health.py tests/test_monitoring.py tests/test_performance.py
|
|
```
|
|
|
|
**Result**: All checks passed!
|
|
|
|
---
|
|
|
|
## Docs Check
|
|
|
|
```
|
|
test -f README.md && test -f docs/admin-guide.md && test -f docs/api-overview.md && echo 'Docs OK'
|
|
```
|
|
|
|
**Result**: Docs OK
|
|
|
|
---
|
|
|
|
## Smoke Test
|
|
|
|
- App imports successfully: `from app.main import create_app` → OK
|
|
- Health endpoint returns 200 with all checks (database, redis, storage, worker): verified via direct ASGI client test
|
|
- Prometheus metrics endpoint returns text/plain with required metric names (leocrm_http_requests_total, leocrm_db_pool_connections, leocrm_arq_jobs_total): verified
|
|
- Structured JSON logging produces entries with timestamp, level, event, method, path, status, duration_ms, tenant_id: verified
|
|
- CSV export uses StreamingResponse with own DB session (not buffered): verified
|
|
- page_size > 100 returns 422 for both contacts and companies: verified
|