The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
test(profiles): use sqlite backend and storage slot lock in tests
Steven Enamakel1f5f005653ca
diff --git a/crates/openhuman-core/src/flows/catalog_storage_tests.rs b/crates/openhuman-core/src/flows/catalog_storage_tests.rsindex aa833d13ca..c8dfbb445b 100644--- a/crates/openhuman-core/src/flows/catalog_storage_tests.rs+++ b/crates/openhuman-core/src/flows/catalog_storage_tests.rs@@ -284,6 +284,8 @@ async fn catalog_storage_resolves_the_current_backend_and_confines_graph_namespaCatalogStorageReply, DocDeleteWhereRequest,};+ let _slot_lock = crate::storage::test_support::lock_storage_slot();+let workspace = tempfile::tempdir().expect("isolated workspace");let config = Config {workspace_dir: workspace.path().to_path_buf(),@@ -293,7 +295,7 @@ async fn catalog_storage_resolves_the_current_backend_and_confines_graph_namespalet registration = register(&context, &config).await.unwrap();let proxy = callback_proxy(®istration).await;- let backend_a: Arc<dyn StorageBackend> = Arc::new(crate::storage::MemoryStorage::new());+ let backend_a = crate::storage::test_support::memory_backend();let previous = crate::storage::install(Arc::clone(&backend_a));struct RestoreBackend(Option<Arc<dyn StorageBackend>>);impl Drop for RestoreBackend {@@ -486,7 +488,7 @@ async fn catalog_storage_resolves_the_current_backend_and_confines_graph_namespaCatalogStorageReply::Value { ref value } if value == &Value::Bool(true)));- let backend_b: Arc<dyn StorageBackend> = Arc::new(crate::storage::MemoryStorage::new());+ let backend_b = crate::storage::test_support::memory_backend();crate::storage::install(Arc::clone(&backend_b));let ensured: CatalogStorageReply = proxy.call(diff --git a/crates/openhuman-core/src/profiles/lease_tests.rs b/crates/openhuman-core/src/profiles/lease_tests.rsindex e651f74600..1880e1ee9f 100644--- a/crates/openhuman-core/src/profiles/lease_tests.rs+++ b/crates/openhuman-core/src/profiles/lease_tests.rs@@ -1,6 +1,7 @@+#![cfg(feature = "storage-sqlite")]+use super::*;use crate::core::runtime::{CoreContext, DomainSet, SaasConfig};-use crate::storage::MemoryStorage;const TTL_SECS: u64 = 30;@@ -29,8 +30,8 @@ fn node()}-fn shared() -> Arc<dyn StorageBackend> {- Arc::new(MemoryStorage::new())+fn shared() -> crate::storage::test_support::SqliteBackend {+ crate::storage::test_support::sqlite_backend().unwrap()}fn profile(name: &str) -> ProfileId {@@ -54,8 +55,8 @@ async fn a_profile_open_on_one_node_is_refused_on_another_naming_the_holder() {let tmp = tempfile::tempdir().unwrap();let backend = shared();let (a, b) = (- node(tmp.path(), "node-a", Some(&backend)),- node(tmp.path(), "node-b", Some(&backend)),+ node(tmp.path(), "node-a", Some(&backend.backend)),+ node(tmp.path(), "node-b", Some(&backend.backend)),);let alice = profile("alice");assert!(a.provision(&alice).await.unwrap());@@ -92,8 +93,8 @@ async fn release_hands_a_profile_to_another_node_at_once() {let tmp = tempfile::tempdir().unwrap();let backend = shared();let (a, b) = (- node(tmp.path(), "node-a", Some(&backend)),- node(tmp.path(), "node-b", Some(&backend)),+ node(tmp.path(), "node-a", Some(&backend.backend)),+ node(tmp.path(), "node-b", Some(&backend.backend)),);let alice = profile("alice");a.provision(&alice).await.unwrap();@@ -125,10 +126,10 @@ async fn eviction_and_shutdown_release_the_lease() {let a = ProfileHost::with_backend(config,CoreContext::for_test(DomainSet::full(), None),- Some(Arc::clone(&backend)),+ Some(Arc::clone(&backend.backend)),).unwrap();- let b = node(tmp.path(), "node-b", Some(&backend));+ let b = node(tmp.path(), "node-b", Some(&backend.backend));let (alice, bob) = (profile("alice"), profile("bob"));a.provision(&alice).await.unwrap();a.provision(&bob).await.unwrap();@@ -154,7 +155,7 @@ async fn eviction_and_shutdown_release_the_lease() {async fn renewal_keeps_the_lease_and_a_lost_lease_fences_the_profile() {let tmp = tempfile::tempdir().unwrap();let backend = shared();- let a = node(tmp.path(), "node-a", Some(&backend));+ let a = node(tmp.path(), "node-a", Some(&backend.backend));let alice = profile("alice");a.provision(&alice).await.unwrap();let state = a.open(&alice).await.unwrap();@@ -305,7 +306,7 @@ async fn a_release_during_a_heartbeat_renewal_releases_the_renewed_grant() {let mut a = ProfileHost::with_backend(saas(tmp.path(), "node-a"),CoreContext::for_test(DomainSet::full(), None),- Some(Arc::clone(&backend)),+ Some(Arc::clone(&backend.backend)),).unwrap();let pausing = Arc::new(PausingRenewals {@@ -316,7 +317,7 @@ async fn a_release_during_a_heartbeat_renewal_releases_the_renewed_grant() {});a.leases = Arc::clone(&pausing) as Arc<dyn LeaseStore>;let a = Arc::new(a);- let b = node(tmp.path(), "node-b", Some(&backend));+ let b = node(tmp.path(), "node-b", Some(&backend.backend));let alice = profile("alice");a.provision(&alice).await.unwrap();drop(a.open(&alice).await.unwrap());