| doc-type | issue | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| issue-type | enhancement | ||||||||||||
| status | draft | ||||||||||||
| priority | p3 | ||||||||||||
| github-issue | |||||||||||||
| spec-path | docs/issues/drafts/increase-main-app-integration-test-coverage.md | ||||||||||||
| branch | |||||||||||||
| related-pr | |||||||||||||
| last-updated-utc | 2026-07-27 12:00 | ||||||||||||
| semantic-links |
|
Systematically expand integration test coverage at the main application level (tests/) to verify
application-level behaviors that can only be tested with the complete Torrust Tracker application
and multiple coordinated services.
The Torrust Tracker project uses a three-layer testing strategy:
- Unit tests (
packages/*/tests/) — Fast, isolated tests for individual components - Integration tests (
tests/) — Main application-level tests with full app context - E2E tests (
packages/e2e-tools/,src/console/ci/e2e/,src/console/ci/qbittorrent_e2e/) — Container-based tests with Docker Compose
After implementing issue #1419 (parallel integration test infrastructure), the project has a
foundation for writing independent, concurrent integration tests at the main application level.
Currently, only one test suite exists (tests/servers/api/contract/stats/), which verifies global
metrics aggregation across multiple tracker instances.
This issue tracks the expansion of integration test coverage (layer 2) for application-level concerns that cannot be tested at the package level:
- Multiple tracker instances running simultaneously
- Cross-service coordination and metrics aggregation
- Application container lifecycle and job orchestration
- Health check aggregation across all services
- Bootstrap and configuration integration
- Graceful shutdown coordination
This issue complements EPIC #1347 - Increase unit testing for workspace packages.
| Layer | Location | Focus | EPIC/Issue |
|---|---|---|---|
| Unit tests | packages/*/tests/ |
Individual component behavior | EPIC #1347 |
| Integration | tests/ (main app-level) |
Application-level coordination | This issue |
| E2E tests | packages/e2e-tools/, src/console/ci/e2e/, qbittorrent_e2e/ |
Container-based cross-process validation | (separate) |
All three layers are part of a broader effort to improve overall test coverage and reliability.
- Integration tests that require the full application context (
app::run()) - Tests that verify behavior across multiple coordinated services
- Tests that verify application container initialization and lifecycle
- Tests that verify job manager orchestration and background tasks
- Tests for global metrics, health checks, and cross-service coordination
- Tests that run in parallel without port conflicts (using port
0and temp config)
- Package-level unit tests — belongs in
packages/*/tests/(covered by EPIC #1347) - E2E tests using Docker Compose — belongs in
packages/e2e-tools/,src/console/ci/e2e/, andsrc/console/ci/qbittorrent_e2e/(runs against containerized tracker with external clients) - Protocol parsing tests — belongs in
packages/http-protocol/tests/orpackages/udp-protocol/tests/ - Single-service behavior tests — belongs in corresponding server package tests
- Database-only tests — belongs in
packages/swarm-coordination-registry/tests/
Guideline: If a test can be written at the package level, it should be. Only add integration tests when the full application context is genuinely required. If a test requires Docker Compose orchestration or external BitTorrent clients, it belongs in the E2E layer.
-
Multiple trackers with different protocols
Verify HTTP and UDP trackers run simultaneously, handle announces independently, and contribute to separate metrics. -
Health check aggregates all services
Verify health check API returns status for all registered services (HTTP API, HTTP trackers, UDP trackers). -
Torrent cleanup job with active trackers
Run the cleanup job while trackers are handling announces; verify it removes inactive peers without interfering with active announces. -
Global scrape across multiple trackers
Send scrape requests to multiple HTTP tracker instances and verify the responses reflect the correct swarm state. -
Metrics counters across HTTP and UDP
Verify that announce counters aggregate correctly when requests come to both HTTP and UDP trackers.
-
Graceful shutdown coordination
Start all services, send requests, trigger shutdown, verify all services stop cleanly without dropping active connections. -
Job manager handles job failures
Trigger a job failure; verify the job manager restarts or reports the failure without crashing the application. -
Concurrent announce load across multiple trackers
Send simultaneous announces to multiple tracker instances; verify correct peer aggregation and no race conditions. -
Activity metrics updater job
Verify the activity metrics updater job correctly processes peer activity and updates global stats across all running services. -
Event listener coordination
Verify event listeners for different services process events without interference when multiple services emit events simultaneously.
-
Container dependency validation
Verify the application refuses to start with invalid service combinations or detects configuration conflicts at bootstrap. -
Application bootstrap with minimal configuration
Start the application with minimal required config; verify all default services initialize correctly. -
Multiple database backends
Start the application with SQLite, MySQL, and PostgreSQL configurations; verify the bootstrap process correctly initializes each database backend and all services start without errors. -
Service registration completeness
Verify all configured services register correctly in the Registrar with their actual bound addresses and metadata.
This is a tracking issue. Each test case should be implemented as a subtask or separate small issue.
Suggested approach:
- Start with high-priority tests (tests 1-5)
- Implement one test per PR to keep changes reviewable
- Follow the test pattern established in issue #1419
- Use test utilities from
tests/helpers.rs(temp config, port extraction) - Ensure all tests use port
0and temporary configuration files - Document test purpose with clear doc comments
- AC1: All high-priority tests (tests 1-5) are implemented and passing
- AC2: Test utilities in
tests/helpers.rsare expanded as needed for common patterns - AC3: All new tests run in parallel without conflicts (port
0, temp config) - AC4: Each test has clear documentation explaining what application-level behavior is verified
- AC5:
linter allpasses - AC6: All tests pass in CI
linter allexits with code0cargo test --test statspasses all new integration testscargo test --workspacepasses (no regressions)- CI pipeline passes with new tests running in parallel
| ID | Check | Expected Outcome |
|---|---|---|
| M1 | Run cargo test --test stats |
All integration tests pass, no port conflicts or config collisions |
| M2 | Run with RUST_LOG=debug |
Verify multiple services log startup without errors |
| M3 | Review test execution time | Integration tests complete faster than equivalent E2E tests |
- Issue #1419 must be completed (infrastructure for parallel integration tests)
- Issue #1419 - Allow multiple integration tests at the main app level - Infrastructure foundation
- EPIC #1347 - Increase unit testing for workspace packages - Package-level unit test coverage
- tests/AGENTS.md - Guidelines for main-level vs package-level tests
- tests/stats.rs - Integration test scaffolding
- tests/servers/api/contract/stats/ - Current global stats test example
- .github/skills/dev/testing/write-unit-test/SKILL.md - Unit testing conventions and Test Desiderata principles
- docs/adrs/20260603000000_keep_unit_tests_inside_container_build.md - ADR documenting the three-layer testing strategy (GHA unit tests, in-container unit tests, E2E tests)
- packages/e2e-tools/README.md - E2E test runners
(
e2e_tests_runner,qbittorrent_e2e_runner)
Note: There is currently no comprehensive testing strategy document in docs/. Testing
guidance is distributed across skills, ADRs, and package README files. A future improvement
could consolidate this into a canonical docs/testing.md document.
High-priority tests:
- Test 1: Multiple trackers with different protocols
- Test 2: Health check aggregates all services
- Test 3: Torrent cleanup job with active trackers
- Test 4: Global scrape across multiple trackers
- Test 5: Metrics counters across HTTP and UDP
Medium-priority tests:
- Test 6: Graceful shutdown coordination
- Test 7: Job manager handles job failures
- Test 8: Concurrent announce load across multiple trackers
- Test 9: Activity metrics updater job
- Test 10: Event listener coordination
Low-priority tests tracked separately when high/medium priorities are complete.
- 2026-07-27 12:00 UTC - agent - Created draft issue to track integration test coverage expansion after #1419 infrastructure implementation.