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 access in fixture tests

Steven Enamakel107e4b3fcb51
diff --git a/crates/openhuman-core/src/channels/module_fixture_tests.rs b/crates/openhuman-core/src/channels/module_fixture_tests.rs
index ab19065624..39d16f0226 100644
--- a/crates/openhuman-core/src/channels/module_fixture_tests.rs
+++ b/crates/openhuman-core/src/channels/module_fixture_tests.rs
@@ -12,7 +12,7 @@ use crate::config::schema::ModuleSourceMode;
use crate::config::Config;
use crate::modules::linked::register_linked;
use crate::modules::{ops, runtime};
-use std::sync::Arc;
+use std::sync::{Arc, MutexGuard};
use tinybus::module::ModuleClient;
#[cfg(feature = "e2e-test-support")]
use tinychannels_bus::methods;
@@ -41,13 +41,16 @@ pub(crate) async fn client() -> ModuleClient {
/// Temporarily install in-memory storage for module callbacks in isolated tests.
pub(crate) struct MemoryStorageGuard {
+ _slot_lock: MutexGuard<'static, ()>,
previous: Option<Arc<dyn crate::storage::StorageBackend>>,
}
/// Give the linked module a writable backend for storage-backed fixture calls.
pub(crate) fn install_memory_storage() -> MemoryStorageGuard {
+ let slot_lock = crate::storage::test_support::lock_storage_slot();
MemoryStorageGuard {
- previous: crate::storage::install(Arc::new(crate::storage::MemoryStorage::new())),
+ _slot_lock: slot_lock,
+ previous: crate::storage::install(crate::storage::test_support::memory_backend()),
}
}
diff --git a/crates/openhuman-core/src/profiles/cron_tests.rs b/crates/openhuman-core/src/profiles/cron_tests.rs
index fb4a6e4823..b29b333e4f 100644
--- a/crates/openhuman-core/src/profiles/cron_tests.rs
+++ b/crates/openhuman-core/src/profiles/cron_tests.rs
@@ -82,6 +82,7 @@ async fn hosted_cron_sweep_runs_trusted_memory_jobs_in_agent_only_profiles() {
}
async fn hosted_memory_cron_sweep_child() {
+ let _storage_slot = crate::storage::test_support::lock_storage_slot();
let registry = crate::storage::fence::registry();
let backend: Arc<dyn crate::storage::StorageBackend> =
Arc::new(crate::storage::fenced_backend::FencedBackend::new(