Repository navigation
feat(qbittorrent-e2e): add qBittorrent E2E runner with Docker Compose orchestration - #1707
Conversation
…ion in torrent polling Add --keep-containers flag to runner for post-run debugging (skips automatic RAII teardown) Fix race condition: replace immediate list_torrents with polling loop (500ms intervals, configurable timeout) Both clients now reliably show ≥1 torrent before runner proceeds Update issue spec with completion checklist, pending tasks, and implementation notes All linting checks pass; runner exits code 0 with verified torrent uploads
There was a problem hiding this comment.
Pull request overview
Adds a new qBittorrent-based end-to-end smoke runner intended to validate the seeder→tracker→leecher flow using a Docker Compose stack, alongside reusable compose orchestration utilities and supporting docs/scripts.
Changes:
- Introduces a Rust E2E runner (
qbittorrent_e2e_runner) that builds a local tracker image, starts a Compose stack, authenticates to both qBittorrent WebUIs, uploads a torrent, and polls until it appears. - Adds a reusable
DockerComposewrapper with aRunningComposeRAII guard to ensuredocker compose down --volumesruns on drop (unless--keep-containersis set). - Adds debugging shell scripts + documentation, and wires in the new spec/doc references and dependencies.
Reviewed changes
Copilot reviewed 16 out of 17 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/console/ci/qbittorrent/runner.rs | Main orchestration logic for workspace setup, compose lifecycle, WebUI login, torrent creation/upload, and polling. |
| src/console/ci/qbittorrent/qbittorrent_client.rs | Minimal reqwest client for qBittorrent WebUI API (login, add torrent, list torrents) with CSRF header handling. |
| src/console/ci/qbittorrent/mod.rs | Exposes the qbittorrent CI module. |
| src/console/ci/mod.rs | Registers new compose and qbittorrent CI modules. |
| src/console/ci/compose.rs | New wrapper around docker compose commands + RAII teardown guard. |
| src/bin/qbittorrent_e2e_runner.rs | Tokio-enabled binary entry point with rustdoc usage/behavior documentation. |
| compose.qbittorrent-e2e.yaml | Compose stack definition for tracker + seeder + leecher using bind mounts + ephemeral host ports. |
| contrib/dev-tools/debugging/qbt/qbittorrent-login-probe.sh | Standalone script to probe qBittorrent WebUI login/CSRF header behavior. |
| contrib/dev-tools/debugging/qbt/check-qbittorrent-e2e-compose.sh | Standalone script to validate the compose stack wiring and port publishing. |
| contrib/dev-tools/debugging/qbt/README.md | Readme describing qBittorrent debugging helpers. |
| contrib/dev-tools/debugging/README.md | Top-level debugging tools index/readme. |
| docs/issues/1706-1525-02-qbittorrent-e2e.md | Updates the issue spec with current status, acceptance criteria checkboxes, and follow-up work. |
| docs/issues/1525-overhaul-persistence.md | Updates persistence EPIC doc to point at the renamed spec path. |
| docs/issues/1525-08-add-postgresql-driver.md | Updates references to the renamed spec path. |
| Cargo.toml | Adds dependencies needed by the runner/client (base64, pbkdf2, sha1/sha2, tempfile) and enables reqwest multipart. |
| Cargo.lock | Locks new/updated dependency graph for added crates/features. |
| project-words.txt | Adds new domain/tooling words to the spellchecker dictionary. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## develop #1707 +/- ##
===========================================
- Coverage 86.44% 82.55% -3.90%
===========================================
Files 288 323 +35
Lines 22693 24334 +1641
Branches 22693 24334 +1641
===========================================
+ Hits 19617 20088 +471
- Misses 2842 3987 +1145
- Partials 234 259 +25 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 18 out of 19 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…rackerConfigBuilder
…ketAddr bind addresses
… artifact builder
…download_completes
…nctions in filesystem_setup
… to enforce tracker-only peer discovery
- Add `label()` accessor to `QbittorrentClient` - Remove `client_name: &str` parameter from step functions; steps now derive the label from `client.label()` internally - Convert all log calls to structured tracing fields (client=, torrent=, progress=, state=, torrent_count=, bytes=, torrent_file=) - Add structured milestone events in `seeder_to_leecher_transfer`: scenario_start, seeder_ready, download_started, download_finished, scenario_passed
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 61 out of 62 changed files in this pull request and generated 7 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…ce URL handling - Add InvalidFileName error type and TryFrom<String> impl for FileName to reject path separators and '..' at construction time - Simplify WebUiBaseUrl by dropping host/scheme fields; use hardcoded localhost constants (WEBUI_HEADER_HOST, WEBUI_HEADER_SCHEME) - Change webui_headers() to associated fn (no longer needs &self) - Remove stale /announce suffix from udp_announce_url_for_compose_service - Remove stale --tracker-config-template flag doc from binary header - Fix typo 'Continuos' -> 'Continuous' in ci module doc - Update issue spec: mark GitHub Actions integration criteria as done - Fix leecher credentials in qBittorrent debugging README
|
ACK d9fa45c |
da2ce7
left a comment
There was a problem hiding this comment.
This is a post-merge review of the change as it stands at a94c3ced8 on the default branch.
Nearly all of #1707 still runs. The Compose wrapper (src/console/ci/compose.rs) and the src/console/ci/qbittorrent_e2e/ tree are still at their original paths. The runner binary moved to packages/e2e-tools/src/bin/qbittorrent_e2e_runner.rs in c47173f. The single compose file became compose.qbittorrent-e2e.{sqlite3,mysql,postgresql}.yaml in 74f5c8a. The runner now runs for all three database drivers in .github/workflows/testing.yaml:321-331 and .github/workflows/container.yaml:145-155, including on the persistent self-hosted runner. Three claims in the description do not match the merged code. The automatic cleanup "even on failure" does not cover a failed start (see below). The paths src/console/ci/qbittorrent/ and qbittorrent_client.rs are actually src/console/ci/qbittorrent_e2e/qbittorrent/client.rs. And the prerequisite docker-compose is really the docker compose plugin the code calls.
[Minor] Every published port binds all host interfaces, and the credentials are in the source. compose.qbittorrent-e2e.sqlite3.yaml:22-25, :47 and :69 use the "0:PORT" form, and so do compose.qbittorrent-e2e.mysql.yaml:27-30,68,90 and compose.qbittorrent-e2e.postgresql.yaml:27-30,65,87. Docker publishes that form on 0.0.0.0 and [::], and its forwarding rules bypass host firewalls such as ufw. The WebUI logins are admin/seeder-pass and admin/leecher-pass (src/console/ci/qbittorrent_e2e/filesystem_setup.rs:44-46), and the tracker API token is MyAccessToken (src/console/ci/qbittorrent_e2e/tracker/config_builder.rs:23). On a developer machine on a shared network, anyone who finds the ephemeral port while a run is in progress can log into either qBittorrent instance and drive it: add torrents that the host then downloads and seeds, or change its preferences. With --keep-containers, that stays open until someone removes the stack. The self-hosted CI host is covered by its cloud firewall, which allows inbound SSH only (docs/self-hosted-runner.md:52), so CI is not the exposed case. The runner connects only through loopback (src/console/ci/qbittorrent_e2e/services_setup.rs:106, src/console/ci/qbittorrent_e2e/tracker/client.rs:30). Prefixing each mapping with 127.0.0.1: (for example "127.0.0.1:0:8080") closes the exposure without a code change. Switching services_setup.rs:106 from localhost to 127.0.0.1 would match the tracker client.
[Minor] A failed start leaves the whole stack running. DockerCompose::up (src/console/ci/compose.rs:73-94) returns the RunningCompose guard only when docker compose up --wait --detach succeeds. When the tracker never becomes healthy or a database service fails, up returns an error and no guard, and src/console/ci/qbittorrent_e2e/services_setup.rs:47 propagates it, so the containers, network and volumes stay. On the persistent runner, each such failure leaves a tracker, seeder, leecher and database running, and the prune script does not remove them because it removes only stopped containers. The binary's documentation promises teardown "even on failure" (packages/e2e-tools/src/bin/qbittorrent_e2e_runner.rs:15). #2908 already tracks this with a design and is still open at a94c3ced8. The smallest fix is to run down --volumes on the error branch of up, or to create the guard before calling up.
[Minor] A failed scenario destroys its own evidence, even with --keep-containers. src/console/ci/qbittorrent_e2e/runner.rs:129 returns early through ? before the keep() call at :132-144, so RunningCompose::drop (src/console/ci/compose.rs:22-35) runs down --volumes. Take a --keep-containers run whose leecher download times out: the containers the flag promised to keep are removed, and only the workspace under storage/qbt-e2e/ is left. In CI, no seeder, leecher or tracker log is printed before teardown, because logs is called only inside wait_for_port_mapping (src/console/ci/compose.rs:201-235). A scenario failure therefore shows only the runner's own tracing. Smallest fix: match on the scenario result, and on Err print logs for all services and call keep() when the flag is set, then return the error. This needs a small logs accessor on RunningCompose.
[Minor] The fast-fail check for an exited service never matches. compose_service_has_exited (src/console/ci/compose.rs:323-328) looks for lowercase exited, dead, created or removing in the table output of docker compose ps -a. That table's STATUS column prints Docker's status text, which is capitalised (Exited (1) 3 seconds ago, Created, Dead, Removal In Progress). The lowercase state names appear only with --format json. So when a seeder or leecher exits after up --wait has returned, wait_for_port_mapping keeps retrying docker compose port until its deadline (600 s per wait in CI) instead of failing at once with the logs. Smallest fix: read docker compose ps -a --format json (or --format '{{.Service}} {{.State}}') and compare the State of the exact service instead of matching substrings anywhere in the line. A unit test over captured output would pin the behaviour.
[Minor] The login probe script turns WebUI authentication off for every address. contrib/dev-tools/debugging/qbt/qbittorrent-login-probe.sh:102-103 writes WebUI\AuthSubnetWhitelistEnabled=true with WebUI\AuthSubnetWhitelist=0.0.0.0/0,::/0. :108-111 and :122 publish the WebUI on all interfaces, on a fixed port when --host-port 8080 is used as the help text suggests (:30-31), and with --keep (:32) the container stays up. Anyone on the network can then use the whole API without a password. qBittorrent also opens a session for whitelisted clients without checking credentials, so the probe's password results may not tell a right password from a wrong one. Smallest fix: drop the two whitelist lines, or limit them to 127.0.0.1/32, and publish with -p "127.0.0.1:${PORT_MAPPING}".
[Nit] The tracker swarm check reads once, without retry. verify_tracker_swarm (src/console/ci/qbittorrent_e2e/scenario_steps/tracker/verify_tracker_swarm.rs:17-21) runs as soon as the leecher's WebUI reports 100 % (src/console/ci/qbittorrent_e2e/scenarios/seeder_to_leecher_transfer.rs:286). It asserts completed >= 1 on a single REST read, but the leecher sends its completed announce asynchronously, and over UDP that announce is a connect plus an announce. The window is narrow but not zero. Polling with the existing Poller until completed >= 1 or the deadline removes this source of flakes.
[Nit] The seeder's state is never checked, and terminal states end no wait. The run waits on the seeder only until the torrent appears in its list (src/console/ci/qbittorrent_e2e/scenarios/seeder_to_leecher_transfer.rs:205-211). If the seeder's recheck of the payload fails (missingFiles or error), the run waits out the full deadline in wait_until_download_completes (src/console/ci/qbittorrent_e2e/scenario_steps/qbittorrent/wait_until_download_completes.rs:23-43) and reports a leecher timeout. That loop also never exits on the leecher's own error or missingFiles state. A single transient WebUI error at :24 aborts it through ?, even though the torrent's absence is retried. Waiting for an *UP state on the seeder before adding the torrent to the leecher, and failing on terminal states, would make these failures name their cause.
[Nit] Several docs are stale at a94c3ced8. The usage cargo run --bin qbittorrent_e2e_runner at packages/e2e-tools/src/bin/qbittorrent_e2e_runner.rs:27 and src/console/ci/qbittorrent_e2e/runner.rs:6 fails, because torrust-tracker-e2e-tools is not a default member (Cargo.toml:198-220); CI passes -p torrust-tracker-e2e-tools. In the same file, items 6 and 7 of the overview (:14-15) describe a torrent count and an unconditional teardown that the code does not perform. :38 calls --timeout-seconds an HTTP timeout, but it also bounds every polling loop and port wait. src/console/ci/qbittorrent_e2e/mod.rs:10 still names src/bin/qbittorrent_e2e_runner.rs. mod.rs:26 says the seeder creates the torrent, but the runner builds it on the host (src/console/ci/qbittorrent_e2e/scenarios/seeder_to_leecher_transfer.rs:113-150).
[Nit] Crates used only by the E2E harness are dependencies of the tracker package. base64, pbkdf2, sha1, sha2 and the multipart feature of reqwest (Cargo.toml:95,102,105,109,110) are used only under src/console/ci/qbittorrent_e2e/. That module is public in the tracker library (src/console/ci/mod.rs:4), so every tracker build compiles it and these crates are in the tracker package's dependency tree. c47173f moved the binary to packages/e2e-tools but left the modules and dependencies behind. Moving src/console/ci/compose.rs and src/console/ci/qbittorrent_e2e/, with these dependencies, into packages/e2e-tools would confine them to the tool.
Checked and found sound:
- the bencode encoder's key ordering and the two-pass info-hash construction (
src/console/ci/qbittorrent_e2e/bencode.rs,src/console/ci/qbittorrent_e2e/torrent_artifacts.rs); - the PBKDF2-SHA512
@ByteArray(salt:hash)format that qBittorrent expects (src/console/ci/qbittorrent_e2e/qbittorrent/config_builder.rs:119-129); - URL-encoding of the login body and extraction of the
SIDcookie (src/console/ci/qbittorrent_e2e/qbittorrent/client.rs:78-119,:330-343); - the byte-for-byte payload comparison;
- peer discovery restricted to the tracker, with DHT, LSD and PeX disabled;
- per-run project names and ephemeral host ports;
- the guard being dropped before the temporary workspace;
- the database URL parsing in
src/console/ci/qbittorrent_e2e/tracker/config_builder.rs:155-184.
Summary
Completes the qBittorrent end-to-end smoke test implementation.
Closes #1706.
What Was Delivered
compose.qbittorrent-e2e.yaml: Docker Compose configuration for a complete tracker-seeder-leecher stack.src/console/ci/compose.rs: A robust Rust wrapper for Docker Compose operations with automatic cleanup.src/console/ci/qbittorrent/:runner.rs: Full E2E orchestration (build, start, verify, cleanup).qbittorrent_client.rs: WebUI API client with CSRF and authentication handling.src/bin/qbittorrent_e2e_runner.rs: CLI tool to run the E2E tests.contrib/dev-tools/debugging/qbt/: Diagnostic scripts for manual debugging.How to Test
Run the full end-to-end test using Cargo:
To keep containers alive after the run for debugging:
Prerequisites: Docker and
docker-composemust be installed and running.