feat(dl): replace Transmission with qBittorrent
qBittorrent's add call answers `Ok.` and nothing else — no hash, no name, no duplicate signal — so arr derives the v1 infohash from the magnet or the `.torrent` bytes before the call and looks the torrent up by it. That also drops Transmission's numeric torrent id: the hash is the only identity now. The reaper needs "stopped because a share limit was reached", and qBittorrent's state field cannot tell that apart from a hand-paused torrent. So the ratio and idle counters are checked against the limits arr set, and a torrent stopped by a global limit reads as still seeding rather than being deleted. The WebUI needs a login, so `ARR_QBITTORRENT_USERNAME` and `ARR_QBITTORRENT_PASSWORD` join the env-only secrets; leaving both unset is valid for an instance that whitelists arr's subnet. Verified against qBittorrent 5 (WebAPI 2.15.1) in a container: it rejects `setShareLimits` without `shareLimitAction`, which 4.x ignores, so it is always sent. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
afe167ca7b
commit
ab4f95b166
+10
-11
@@ -1,6 +1,6 @@
|
||||
//! arr-e2e — cross-process integration test harness. See DESIGN.md §12.
|
||||
//!
|
||||
//! Tests built on this harness talk to a real Transmission container and to
|
||||
//! Tests built on this harness talk to a real qBittorrent container and to
|
||||
//! `wiremock` fakes serving recorded responses for Prowlarr and TMDB. Never a
|
||||
//! live tracker: trackers rate-limit and it would leak credentials into CI.
|
||||
//!
|
||||
@@ -55,13 +55,12 @@ pub const INDEXER_ID: i64 = 3;
|
||||
/// The movie in [`fixtures::TMDB_MOVIE_DUNE`].
|
||||
pub const TMDB_MOVIE_ID: u32 = 693_134;
|
||||
|
||||
/// The Transmission RPC endpoint tests should use: `TRANSMISSION_RPC_URL`
|
||||
/// when set (CI points it at the service container), a local container's
|
||||
/// default port otherwise. Never the production LXC.
|
||||
/// The qBittorrent `WebUI` base URL tests should use: `QBITTORRENT_URL` when
|
||||
/// set (CI points it at the service container), a local container's default
|
||||
/// port otherwise. Never the production instance.
|
||||
#[must_use]
|
||||
pub fn transmission_url() -> String {
|
||||
std::env::var("TRANSMISSION_RPC_URL")
|
||||
.unwrap_or_else(|_| "http://127.0.0.1:9091/transmission/rpc".into())
|
||||
pub fn qbittorrent_url() -> String {
|
||||
std::env::var("QBITTORRENT_URL").unwrap_or_else(|_| "http://127.0.0.1:8080".into())
|
||||
}
|
||||
|
||||
/// A `wiremock` Prowlarr: the REST indexer enumeration plus one enabled
|
||||
@@ -197,8 +196,8 @@ impl Daemon {
|
||||
///
|
||||
/// Panics when the binary cannot be built or spawned, or when the health
|
||||
/// endpoint does not answer within the boot timeout.
|
||||
pub async fn spawn(prowlarr_url: &str, tmdb_url: &str, transmission_url: &str) -> Self {
|
||||
Self::spawn_with_env(prowlarr_url, tmdb_url, transmission_url, &[]).await
|
||||
pub async fn spawn(prowlarr_url: &str, tmdb_url: &str, qbittorrent_url: &str) -> Self {
|
||||
Self::spawn_with_env(prowlarr_url, tmdb_url, qbittorrent_url, &[]).await
|
||||
}
|
||||
|
||||
/// Same as [`Self::spawn`], plus extra environment variables for the
|
||||
@@ -212,7 +211,7 @@ impl Daemon {
|
||||
pub async fn spawn_with_env(
|
||||
prowlarr_url: &str,
|
||||
tmdb_url: &str,
|
||||
transmission_url: &str,
|
||||
qbittorrent_url: &str,
|
||||
extra_env: &[(&str, &str)],
|
||||
) -> Self {
|
||||
let dir = tempfile::tempdir().expect("create daemon tempdir");
|
||||
@@ -232,7 +231,7 @@ impl Daemon {
|
||||
.env("ARR_PROWLARR_API_KEY", API_KEY)
|
||||
.env("ARR_TMDB_URL", tmdb_url)
|
||||
.env("ARR_TMDB_API_KEY", API_KEY)
|
||||
.env("ARR_TRANSMISSION_URL", transmission_url)
|
||||
.env("ARR_QBITTORRENT_URL", qbittorrent_url)
|
||||
.stdin(Stdio::null());
|
||||
for (key, value) in extra_env {
|
||||
command.env(key, value);
|
||||
|
||||
+26
-21
@@ -1,5 +1,5 @@
|
||||
//! Cross-process end-to-end tests over the DESIGN.md §12 seams: the real
|
||||
//! `arr` binary, a real Transmission container, and `wiremock` fakes serving
|
||||
//! `arr` binary, a real qBittorrent container, and `wiremock` fakes serving
|
||||
//! recorded Prowlarr and TMDB responses. Never a live tracker.
|
||||
//!
|
||||
//! The full add-to-imported run lands here once the reconcile loop (#21),
|
||||
@@ -12,28 +12,28 @@ use {arr_db as _, sqlx as _, tempfile as _, wiremock as _};
|
||||
|
||||
use std::path::PathBuf;
|
||||
|
||||
use arr_dl::{AddTorrent, TorrentSource, TransmissionClient};
|
||||
use arr_dl::{AddTorrent, QbitClient, TorrentSource};
|
||||
use arr_e2e::{
|
||||
transmission_url, Daemon, FakeProwlarr, FakeTmdb, API_KEY, INDEXER_ID, TMDB_MOVIE_ID,
|
||||
qbittorrent_url, Daemon, FakeProwlarr, FakeTmdb, API_KEY, INDEXER_ID, TMDB_MOVIE_ID,
|
||||
};
|
||||
use arr_indexer::{ProwlarrClient, SearchRequest};
|
||||
use arr_meta::TmdbClient;
|
||||
use chrono::NaiveDate;
|
||||
|
||||
/// The daemon boots as its own process against faked Prowlarr and TMDB plus a
|
||||
/// real Transmission, reports every upstream healthy, and serves the movie
|
||||
/// real qBittorrent, reports every upstream healthy, and serves the movie
|
||||
/// API over the wire.
|
||||
#[tokio::test]
|
||||
async fn daemon_runs_against_fakes_and_a_real_transmission() {
|
||||
async fn daemon_runs_against_fakes_and_a_real_qbittorrent() {
|
||||
let prowlarr = FakeProwlarr::start().await;
|
||||
let tmdb = FakeTmdb::start().await;
|
||||
let daemon = Daemon::spawn(&prowlarr.url(), &tmdb.url(), &transmission_url()).await;
|
||||
let daemon = Daemon::spawn(&prowlarr.url(), &tmdb.url(), &qbittorrent_url()).await;
|
||||
let base = daemon.base_url();
|
||||
|
||||
let health = daemon.health().await;
|
||||
assert_eq!(health["status"], "ok", "health report: {health}");
|
||||
assert_eq!(health["prowlarr"]["status"], "ok");
|
||||
assert_eq!(health["transmission"]["status"], "ok");
|
||||
assert_eq!(health["qbit"]["status"], "ok");
|
||||
assert_eq!(health["tmdb"]["status"], "ok");
|
||||
|
||||
// Movie CRUD across the process boundary, against the migrated seed data.
|
||||
@@ -134,11 +134,13 @@ async fn recorded_fixtures_satisfy_the_real_clients() {
|
||||
assert!(movie.is_digitally_released(after_digital));
|
||||
}
|
||||
|
||||
/// Torrent lifecycle against the real Transmission container: RPC semantics
|
||||
/// are the seam most likely to surprise (DESIGN.md §12).
|
||||
/// Torrent lifecycle against the real qBittorrent container: the `WebUI` API's
|
||||
/// semantics are the seam most likely to surprise (DESIGN.md §12). In
|
||||
/// particular `torrents/add` answers `Ok.` and nothing else, so the infohash
|
||||
/// arr derived locally has to be the one qBittorrent went on to list.
|
||||
#[tokio::test]
|
||||
async fn transmission_add_list_and_remove() {
|
||||
let client = TransmissionClient::new(&transmission_url()).expect("valid endpoint");
|
||||
async fn qbittorrent_add_list_and_remove() {
|
||||
let client = QbitClient::new(&qbittorrent_url()).expect("valid endpoint");
|
||||
let name = format!("arr-e2e-{}", uuid::Uuid::new_v4());
|
||||
let metainfo = torrent_with_name(&name);
|
||||
let download_dir = PathBuf::from("/tmp/arr-e2e");
|
||||
@@ -156,34 +158,37 @@ async fn transmission_add_list_and_remove() {
|
||||
let torrents = client.list_torrents().await.expect("list torrents");
|
||||
let listed = torrents
|
||||
.iter()
|
||||
.find(|torrent| torrent.id == first.id)
|
||||
.find(|torrent| torrent.hash == first.hash)
|
||||
.expect("added torrent is authoritative in list");
|
||||
assert_eq!(listed.name, name);
|
||||
assert_eq!(listed.hash, first.hash);
|
||||
assert_eq!(listed.download_dir, download_dir);
|
||||
assert_eq!(listed.labels, ["movies-main"]);
|
||||
assert!((0.0..=1.0).contains(&listed.progress));
|
||||
|
||||
client
|
||||
.remove_torrent(first.id, false)
|
||||
.remove_torrent(&first.hash, false)
|
||||
.await
|
||||
.expect("remove without data");
|
||||
|
||||
let second = client.add_torrent(request()).await.expect("add again");
|
||||
assert_eq!(
|
||||
second.hash, first.hash,
|
||||
"the same file is the same infohash"
|
||||
);
|
||||
client
|
||||
.remove_torrent(second.id, true)
|
||||
.remove_torrent(&second.hash, true)
|
||||
.await
|
||||
.expect("remove with data");
|
||||
|
||||
let torrents = client.list_torrents().await.expect("list after remove");
|
||||
assert!(torrents.iter().all(|torrent| torrent.id != second.id));
|
||||
assert!(torrents.iter().all(|torrent| torrent.hash != second.hash));
|
||||
}
|
||||
|
||||
/// Transmission, not arr's import state, owns the done-seeding boundary. The
|
||||
/// qBittorrent, not arr's import state, owns the done-seeding boundary. The
|
||||
/// real service must report an unfinished torrent before its seed limit clears.
|
||||
#[tokio::test]
|
||||
async fn transmission_reports_done_only_after_its_seed_limit() {
|
||||
let client = TransmissionClient::new(&transmission_url()).expect("valid endpoint");
|
||||
async fn qbittorrent_reports_done_only_after_its_seed_limit() {
|
||||
let client = QbitClient::new(&qbittorrent_url()).expect("valid endpoint");
|
||||
let name = format!("arr-e2e-reaper-{}", uuid::Uuid::new_v4());
|
||||
let download_dir = PathBuf::from("/tmp/arr-e2e");
|
||||
let metainfo = torrent_with_name(&name);
|
||||
@@ -204,7 +209,7 @@ async fn transmission_reports_done_only_after_its_seed_limit() {
|
||||
.await
|
||||
.expect("list before limit")
|
||||
.into_iter()
|
||||
.find(|torrent| torrent.id == added.id)
|
||||
.find(|torrent| torrent.hash == added.hash)
|
||||
.expect("torrent before limit");
|
||||
assert!(
|
||||
!before.is_finished,
|
||||
@@ -212,7 +217,7 @@ async fn transmission_reports_done_only_after_its_seed_limit() {
|
||||
);
|
||||
|
||||
client
|
||||
.remove_torrent(added.id, true)
|
||||
.remove_torrent(&added.hash, true)
|
||||
.await
|
||||
.expect("cleanup");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user