Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

test: serialize storage slot tests with a shared lock

Steven Enamakel23a8d6e351db
diff --git a/crates/openhuman-rpc/src/lib.rs b/crates/openhuman-rpc/src/lib.rs
index c92b69e0f2..10864ea2d9 100644
--- a/crates/openhuman-rpc/src/lib.rs
+++ b/crates/openhuman-rpc/src/lib.rs
@@ -77,6 +77,15 @@ pub mod server;
#[cfg(feature = "session-store")]
pub mod session_store;
+/// Serializes tests that touch the process-global storage backend slot.
+///
+/// `session_store` tests install a backend for a moment; any test that
+/// stores a credential meanwhile would route it to storage secrets (which
+/// need a master key CI does not have). Both take this lock.
+#[cfg(test)]
+pub(crate) static STORAGE_SLOT_TEST_LOCK: tokio::sync::Mutex<()> =
+ tokio::sync::Mutex::const_new(());
+
pub use crate::core_host::core::unwrap_rpc;
#[cfg(feature = "http-client")]
pub use client::{bearer_header, post_json_rpc, redact_url_for_log, HttpRpcResponse};
diff --git a/crates/openhuman-rpc/src/server/auth_tests.rs b/crates/openhuman-rpc/src/server/auth_tests.rs
index 47a1f886d0..ec6cc26039 100644
--- a/crates/openhuman-rpc/src/server/auth_tests.rs
+++ b/crates/openhuman-rpc/src/server/auth_tests.rs
@@ -71,6 +71,8 @@ fn is_external_inference_path_matches_only_v1_routes() {
#[test]
fn verify_external_inference_bearer_for_config_accepts_stored_key() {
+ // Keep a session_store test from installing a storage backend mid-test.
+ let _slot = crate::STORAGE_SLOT_TEST_LOCK.blocking_lock();
let tmp = tempfile::tempdir().unwrap();
let config = Config {
config_path: tmp.path().join("config.toml"),
diff --git a/crates/openhuman-rpc/src/session_store/mod_tests.rs b/crates/openhuman-rpc/src/session_store/mod_tests.rs
index d0d1db7d4f..829f870985 100644
--- a/crates/openhuman-rpc/src/session_store/mod_tests.rs
+++ b/crates/openhuman-rpc/src/session_store/mod_tests.rs
@@ -49,8 +49,9 @@ fn recovery_interrupts_turns_left_in_flight() {
);
}
-/// The provider and storage slots are process-wide; these tests take turns.
-static SLOTS: tokio::sync::Mutex<()> = tokio::sync::Mutex::const_new(());
+/// The provider and storage slots are process-wide; these tests take turns
+/// with each other and with any test that stores a credential.
+use crate::STORAGE_SLOT_TEST_LOCK as SLOTS;
/// Puts the process-global storage backend back as a test found it.
fn restore_backend(previous: Option<Arc<dyn crate::core_host::storage::StorageBackend>>) {