diff --git a/crates/api/tests/backups_writer_link.rs b/crates/api/tests/backups_writer_link.rs index 71373434..9431dfdb 100644 --- a/crates/api/tests/backups_writer_link.rs +++ b/crates/api/tests/backups_writer_link.rs @@ -120,6 +120,14 @@ async fn dual_process_readonly_api_delegates_backup_pause_and_restore_to_bot_wri api_state.install_session_store((*store).clone()); let router = jmodguard_api::web::router(Arc::clone(&api_state)); + // Direct cargo test runs have no outer CI watchdog. + tokio::time::timeout( + std::time::Duration::from_secs(180), + bot_state.activation.wait_for_recovery_finish(), + ) + .await + .expect("bot startup recovery stalled before backup export"); + // 1. Export from read-only API (pauses bot writes via WriterLink, reads, resumes). let (st, body) = send( &router, diff --git a/crates/bot/src/activation.rs b/crates/bot/src/activation.rs index 138e2054..e2a82796 100644 --- a/crates/bot/src/activation.rs +++ b/crates/bot/src/activation.rs @@ -102,7 +102,7 @@ pub struct Activation { moderation_depth: std::sync::atomic::AtomicUsize, recovery: AtomicU8, backup_paused: AtomicBool, - #[cfg(test)] + #[cfg(any(test, feature = "test-support"))] recovery_finished: tokio::sync::Notify, #[cfg(test)] recovery_read_pause: Mutex>, @@ -180,7 +180,7 @@ impl Activation { moderation_depth: std::sync::atomic::AtomicUsize::new(0), recovery: AtomicU8::new(RecoveryState::Idle as u8), backup_paused: AtomicBool::new(false), - #[cfg(test)] + #[cfg(any(test, feature = "test-support"))] recovery_finished: tokio::sync::Notify::new(), #[cfg(test)] recovery_read_pause: Mutex::new(None), @@ -241,7 +241,7 @@ impl Activation { RecoveryState::Idle }; self.recovery.store(state as u8, Ordering::Release); - #[cfg(test)] + #[cfg(any(test, feature = "test-support"))] if !active { self.recovery_finished.notify_waiters(); } @@ -269,8 +269,8 @@ impl Activation { } } - #[cfg(test)] - pub(crate) async fn wait_for_recovery_finish(&self) { + #[cfg(any(test, feature = "test-support"))] + pub async fn wait_for_recovery_finish(&self) { loop { let finished = self.recovery_finished.notified(); tokio::pin!(finished);