From 273f1b6c959db61a26b4e68fe751eea6ea07453c Mon Sep 17 00:00:00 2001 From: Leynos Date: Sun, 14 Sep 2025 13:14:21 +0100 Subject: [PATCH 1/5] Reapply "Remove unnecessary await and lint expectation" This reverts commit 8dd43a5732e21f18db751915ee7ca78fcdd202a9. --- crates/comenqd/tests/daemon.rs | 8 ++++---- crates/comenqd/tests/util.rs | 1 - 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/crates/comenqd/tests/daemon.rs b/crates/comenqd/tests/daemon.rs index 77057d1..ec846a4 100644 --- a/crates/comenqd/tests/daemon.rs +++ b/crates/comenqd/tests/daemon.rs @@ -283,7 +283,7 @@ mod worker_tests { let ctx = ctx.await; let server = Arc::new(ctx.server); let drained = Arc::new(Notify::new()); - let mut drained_notified = drained.notified(); + let drained_notified = drained.notified(); let (shutdown_tx, shutdown_rx) = watch::channel(()); let control = WorkerControl { shutdown: shutdown_rx, @@ -299,7 +299,7 @@ mod worker_tests { DRAINED_NOTIFICATION, "worker drained notification", || async { - (&mut drained_notified).await; + drained_notified.await; Ok(()) }, ) @@ -354,7 +354,7 @@ mod worker_tests { let server = Arc::new(ctx.server); let (shutdown_tx, shutdown_rx) = watch::channel(()); let enqueued = Arc::new(Notify::new()); - let mut enqueued_notified = enqueued.notified(); + let enqueued_notified = enqueued.notified(); let control = WorkerControl { shutdown: shutdown_rx, hooks: WorkerHooks { @@ -366,7 +366,7 @@ mod worker_tests { let h = tokio::spawn(run_worker(ctx.cfg.clone(), ctx.rx, ctx.octo, control)); timeout_with_retries(WORKER_SUCCESS, "worker enqueued", || async { - (&mut enqueued_notified).await; + enqueued_notified.await; Ok(()) }) .await diff --git a/crates/comenqd/tests/util.rs b/crates/comenqd/tests/util.rs index bca4d96..9357d07 100644 --- a/crates/comenqd/tests/util.rs +++ b/crates/comenqd/tests/util.rs @@ -13,7 +13,6 @@ pub const PROGRESSIVE_RETRY_PERCENTS: [u64; 3] = [50, 100, 150]; #[derive(Debug, Clone, Copy)] pub enum TestComplexity { - #[expect(dead_code, reason = "Constructed in integration tests but unused here")] Simple, Moderate, Complex, From bcffa256aa52c061a26b7f83ff76081d7ef000cf Mon Sep 17 00:00:00 2001 From: Leynos Date: Sun, 14 Sep 2025 14:44:45 +0100 Subject: [PATCH 2/5] Clone notify handles in tests --- crates/comenqd/src/daemon.rs | 4 +++- crates/comenqd/tests/daemon.rs | 33 +++++++++++++++++---------------- 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/crates/comenqd/src/daemon.rs b/crates/comenqd/src/daemon.rs index 434cd24..5d5c20a 100644 --- a/crates/comenqd/src/daemon.rs +++ b/crates/comenqd/src/daemon.rs @@ -28,5 +28,7 @@ pub use crate::util::is_metadata_file; /// can exercise socket preparation and client handling without exposing the /// entire module as part of the public API. pub mod listener { - pub use crate::listener::{handle_client, prepare_listener, run_listener}; + pub use crate::listener::{ + CLIENT_READ_TIMEOUT_SECS, MAX_REQUEST_BYTES, handle_client, prepare_listener, run_listener, + }; } diff --git a/crates/comenqd/tests/daemon.rs b/crates/comenqd/tests/daemon.rs index ec846a4..7272c7f 100644 --- a/crates/comenqd/tests/daemon.rs +++ b/crates/comenqd/tests/daemon.rs @@ -283,27 +283,26 @@ mod worker_tests { let ctx = ctx.await; let server = Arc::new(ctx.server); let drained = Arc::new(Notify::new()); - let drained_notified = drained.notified(); let (shutdown_tx, shutdown_rx) = watch::channel(()); let control = WorkerControl { shutdown: shutdown_rx, hooks: WorkerHooks { enqueued: None, idle: None, - drained: Some(drained), + drained: Some(drained.clone()), }, }; let h = tokio::spawn(run_worker(ctx.cfg.clone(), ctx.rx, ctx.octo, control)); - if let Err(e) = timeout_with_retries( - DRAINED_NOTIFICATION, - "worker drained notification", - || async { - drained_notified.await; - Ok(()) - }, - ) - .await + if let Err(e) = + timeout_with_retries(DRAINED_NOTIFICATION, "worker drained notification", || { + let drained = drained.clone(); + async move { + drained.notified().await; + Ok(()) + } + }) + .await { let diagnostics = diagnose_queue_state(&ctx.cfg, &server, 0).await; tracing::error!("Timeout waiting for worker drained notification: {e}"); @@ -354,20 +353,22 @@ mod worker_tests { let server = Arc::new(ctx.server); let (shutdown_tx, shutdown_rx) = watch::channel(()); let enqueued = Arc::new(Notify::new()); - let enqueued_notified = enqueued.notified(); let control = WorkerControl { shutdown: shutdown_rx, hooks: WorkerHooks { - enqueued: Some(enqueued), + enqueued: Some(enqueued.clone()), idle: None, drained: None, }, }; let h = tokio::spawn(run_worker(ctx.cfg.clone(), ctx.rx, ctx.octo, control)); - timeout_with_retries(WORKER_SUCCESS, "worker enqueued", || async { - enqueued_notified.await; - Ok(()) + timeout_with_retries(WORKER_SUCCESS, "worker enqueued", || { + let enqueued = enqueued.clone(); + async move { + enqueued.notified().await; + Ok(()) + } }) .await .expect("worker picked up job"); From 2a432d7562cbe25206d738ebaf66e4f83e4e6a60 Mon Sep 17 00:00:00 2001 From: Leynos Date: Sun, 14 Sep 2025 16:54:59 +0100 Subject: [PATCH 3/5] Test all TestComplexity variants --- crates/comenqd/tests/util.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/crates/comenqd/tests/util.rs b/crates/comenqd/tests/util.rs index 9357d07..f3bebe7 100644 --- a/crates/comenqd/tests/util.rs +++ b/crates/comenqd/tests/util.rs @@ -91,6 +91,13 @@ where Err(format!("{operation_name} exhausted all retry attempts")) } +#[test] +fn uses_all_test_complexity_variants() { + let _ = TimeoutConfig::new(1, TestComplexity::Simple); + let _ = TimeoutConfig::new(1, TestComplexity::Moderate); + let _ = TimeoutConfig::new(1, TestComplexity::Complex); +} + /// Map a task [`JoinError`] into a concise diagnostic message. /// /// ```ignore From 4be2ee990868f6032cc27b3b79c1d3a3cdfa42ee Mon Sep 17 00:00:00 2001 From: Leynos Date: Mon, 15 Sep 2025 01:44:48 +0100 Subject: [PATCH 4/5] Document listener constants and parameterise test --- crates/comenqd/src/daemon.rs | 6 +++--- crates/comenqd/tests/util.rs | 11 ++++++----- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/crates/comenqd/src/daemon.rs b/crates/comenqd/src/daemon.rs index 5d5c20a..bcdb37b 100644 --- a/crates/comenqd/src/daemon.rs +++ b/crates/comenqd/src/daemon.rs @@ -24,9 +24,9 @@ pub use crate::util::is_metadata_file; /// Listener utilities for accepting client connections. /// -/// Re-exports functions from the internal `listener` module so integration tests -/// can exercise socket preparation and client handling without exposing the -/// entire module as part of the public API. +/// Re-exports selected listener APIs (functions and constants) so integration +/// tests can exercise socket preparation, client handling, and read limits +/// without exposing the entire `listener` module publicly. pub mod listener { pub use crate::listener::{ CLIENT_READ_TIMEOUT_SECS, MAX_REQUEST_BYTES, handle_client, prepare_listener, run_listener, diff --git a/crates/comenqd/tests/util.rs b/crates/comenqd/tests/util.rs index f3bebe7..9a7a1e3 100644 --- a/crates/comenqd/tests/util.rs +++ b/crates/comenqd/tests/util.rs @@ -91,11 +91,12 @@ where Err(format!("{operation_name} exhausted all retry attempts")) } -#[test] -fn uses_all_test_complexity_variants() { - let _ = TimeoutConfig::new(1, TestComplexity::Simple); - let _ = TimeoutConfig::new(1, TestComplexity::Moderate); - let _ = TimeoutConfig::new(1, TestComplexity::Complex); +#[rstest] +#[case(TestComplexity::Simple)] +#[case(TestComplexity::Moderate)] +#[case(TestComplexity::Complex)] +fn uses_all_test_complexity_variants(#[case] complexity: TestComplexity) { + let _ = TimeoutConfig::new(1, complexity); } /// Map a task [`JoinError`] into a concise diagnostic message. From 717de17b47da1098e82b88dbac30fd102c6d15cd Mon Sep 17 00:00:00 2001 From: Leynos Date: Mon, 15 Sep 2025 17:16:25 +0100 Subject: [PATCH 5/5] Drop TimeoutConfig explicitly in complexity test --- crates/comenqd/tests/util.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/comenqd/tests/util.rs b/crates/comenqd/tests/util.rs index 9a7a1e3..30c084f 100644 --- a/crates/comenqd/tests/util.rs +++ b/crates/comenqd/tests/util.rs @@ -11,14 +11,14 @@ pub const COVERAGE_MULTIPLIER: u64 = 5; pub const CI_MULTIPLIER: u64 = 2; pub const PROGRESSIVE_RETRY_PERCENTS: [u64; 3] = [50, 100, 150]; -#[derive(Debug, Clone, Copy)] +#[derive(Debug, Clone)] pub enum TestComplexity { Simple, Moderate, Complex, } -#[derive(Debug, Clone, Copy)] +#[derive(Debug, Clone)] pub struct TimeoutConfig { base_seconds: u64, complexity: TestComplexity, @@ -96,7 +96,7 @@ where #[case(TestComplexity::Moderate)] #[case(TestComplexity::Complex)] fn uses_all_test_complexity_variants(#[case] complexity: TestComplexity) { - let _ = TimeoutConfig::new(1, complexity); + drop(TimeoutConfig::new(1, complexity)); } /// Map a task [`JoinError`] into a concise diagnostic message. @@ -117,7 +117,7 @@ pub(crate) fn join_err(name: &str, e: JoinError) -> String { } } -#[derive(Debug, Clone, Copy)] +#[derive(Debug, Clone)] enum JoinScenario { Cancelled, Panicked,