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(storage): drop file and mongodb driver test cases
Steven Enamakel79671df79a5b
diff --git a/crates/openhuman-rpc/src/session_store/mod_tests.rs b/crates/openhuman-rpc/src/session_store/mod_tests.rsindex 144ff0bfd6..62c10ec96e 100644--- a/crates/openhuman-rpc/src/session_store/mod_tests.rs+++ b/crates/openhuman-rpc/src/session_store/mod_tests.rs@@ -53,108 +53,6 @@ async fn a_storage_url_installs_the_driver_backed_store() {crate::core_host::agent::session_store::restore(previous);}-/// A storage URL installs the driver-backed store, and two agents on the one-/// backend keep their turn states apart. Run once per driver the build has.-async fn driver_backed_store_keeps_agents_apart(url: String, driver: &str) {- let _turn = SLOTS.lock().await;- let previous = crate::core_host::agent::session_store::installed();- let previous_backend = crate::core_host::storage::installed();- install_for_url(Some(url)).await.unwrap();-- assert_eq!(- crate::core_host::storage::installed().map(|b| b.driver()),- Some(driver)- );- let provider = crate::core_host::agent::session_store::installed().unwrap();- let alice = provider.for_agent("alice");- alice- .turn_states- .put(&TurnState::started("t", "r", 8, "2026-01-01T00:00:00Z"))- .unwrap();- assert!(alice.turn_states.get("t").unwrap().is_some());- assert!(provider- .for_agent("bob")- .turn_states- .get("t")- .unwrap()- .is_none());-- restore_backend(previous_backend);- crate::core_host::agent::session_store::restore(previous);-}--#[cfg(feature = "storage-sqlite")]-#[tokio::test(flavor = "multi_thread")]-async fn the_sqlite_backend_keeps_agents_apart() {- let dir = tempfile::tempdir().unwrap();- let url = format!("sqlite:{}", dir.path().join("sessions").display());- driver_backed_store_keeps_agents_apart(url, "sqlite").await;-}--#[cfg(feature = "storage-file")]-#[tokio::test(flavor = "multi_thread")]-async fn the_file_backend_keeps_agents_apart() {- let dir = tempfile::tempdir().unwrap();- let url = format!("file:{}", dir.path().join("files").display());- driver_backed_store_keeps_agents_apart(url, "file").await;-}--/// Whether every seed host of a MongoDB URL is exactly the local machine-/// (`localhost`, `127.0.0.1` or `::1`); a prefix match would accept-/// `127.0.0.1.example.com`. Same rule as the root suites' helper-/// (`tests/support/storage_drivers.rs`).-#[cfg(feature = "storage-mongodb")]-fn is_loopback_mongo_url(url: &str) -> bool {- let rest = url.split_once("://").map_or(url, |(_, rest)| rest);- let authority = rest.split(['/', '?']).next().unwrap_or_default();- let hosts = authority.rsplit_once('@').map_or(authority, |(_, h)| h);- !hosts.is_empty()- && !url.starts_with("mongodb+srv://")- && hosts.split(',').all(|host| {- let name = if let Some(v6) = host.strip_prefix('[') {- v6.split(']').next().unwrap_or_default()- } else {- host.rsplit_once(':').map_or(host, |(name, _)| name)- };- matches!(name, "localhost" | "127.0.0.1" | "::1")- })-}--/// Runs against `TSD_MONGO_URL` (a throwaway local replica set, as the-/// `Storage (MongoDB)` workflow starts) in a database of its own; skipped-/// when it is unset or names a host other than this machine.-#[cfg(feature = "storage-mongodb")]-#[tokio::test(flavor = "multi_thread")]-async fn the_mongodb_backend_keeps_agents_apart() {- let Some(base) = std::env::var("TSD_MONGO_URL")- .ok()- .filter(|url| !url.trim().is_empty())- else {- eprintln!("skipped mongodb: TSD_MONGO_URL is not set");- return;- };- if !is_loopback_mongo_url(&base) {- eprintln!("skipped mongodb: TSD_MONGO_URL must name a local server");- return;- }- let (head, query) = match base.split_once('?') {- Some((head, query)) => (head, format!("?{query}")),- None => (base.as_str(), String::new()),- };- let authority_end = head[head.find("://").map_or(0, |at| at + 3)..]- .find('/')- .map_or(head.len(), |at| head.find("://").map_or(0, |i| i + 3) + at);- let nanos = std::time::SystemTime::now()- .duration_since(std::time::UNIX_EPOCH)- .map_or(0, |d| d.as_nanos());- let url = format!(- "{}/oh_rpc_{nanos:x}_{}{query}",- &head[..authority_end],- std::process::id()- );- driver_backed_store_keeps_agents_apart(url, "mongodb").await;-}-#[tokio::test]async fn an_unusable_url_fails_the_boot() {let _turn = SLOTS.lock().await;diff --git a/tests/support/storage_drivers.rs b/tests/support/storage_drivers.rsindex bab9179ba9..3024df153a 100644--- a/tests/support/storage_drivers.rs+++ b/tests/support/storage_drivers.rs@@ -55,8 +55,7 @@ impl Driver {}/// The storage URL for this driver, using `dir` for the on-disk drivers.- /// `None` when the driver cannot run here: not compiled in, or MongoDB- /// without [`MONGO_URL_VAR`].+ /// `None` when the driver is not compiled in.pub fn url(self, dir: &std::path::Path) -> Option<String> {if !self.compiled_in() {return None;@@ -68,17 +67,6 @@ impl Driver {}}-/// A short unique token for database and scope names.-fn uuid_like() -> String {- use std::time::{SystemTime, UNIX_EPOCH};- static COUNTER: std::sync::atomic::AtomicU64 = std::sync::atomic::AtomicU64::new(0);- let nanos = SystemTime::now()- .duration_since(UNIX_EPOCH)- .map_or(0, |d| d.as_nanos());- let n = COUNTER.fetch_add(1, std::sync::atomic::Ordering::Relaxed);- format!("{nanos:x}_{}_{n}", std::process::id())-}-/// The slot is process-wide, so cases of one binary take turns.static SLOT_LOCK: Mutex<()> = Mutex::new(());@@ -106,11 +94,7 @@ impl Case {eprintln!("skipped {}: {}",driver.name(),- if driver.compiled_in() {- format!("{MONGO_URL_VAR} is not set")- } else {- "driver not compiled in".to_string()- }+ "driver not compiled in");return None;};@@ -156,13 +140,13 @@ pub struct UrlCase {/// Runs a body that only needs the driver's URL (`driver_cases!(url body)`).pub fn run_url(driver: Driver, body: fn(UrlCase)) {// Same lock as the in-process cases: the spawned cores and this process- // share the environment and, for MongoDB, one server.+ // share the process-wide test setup.let _lock = SLOT_LOCK.lock().unwrap_or_else(std::sync::PoisonError::into_inner);let data_dir = tempfile::tempdir().expect("temp dir");let Some(url) = driver.url(data_dir.path()) else {- eprintln!("skipped {}: {MONGO_URL_VAR} is not set", driver.name());+ eprintln!("skipped {}: driver not compiled in", driver.name());return;};body(UrlCase {@@ -198,9 +182,8 @@ where}/// Declares one test case per driver for each `body`, in a module named after-/// the driver (`memory::body`, `sqlite::body`, ...). Drivers the build lacks-/// are not declared at all; MongoDB is declared when compiled in and skips-/// itself without `TSD_MONGO_URL`.+/// the driver (`memory`, `sqlite`). SQLite is declared only when its feature+/// is compiled in.#[allow(unused_macros)]macro_rules! driver_cases {(sync $($body:ident),+ $(,)?) => {@@ -236,29 +219,5 @@ macro_rules! driver_cases {})+}- #[cfg(feature = "storage-file")]- mod file {- $(- #[test]- fn $body() {- $crate::storage_drivers::$runner(- $crate::storage_drivers::Driver::File,- super::$body,- );- }- )+- }- #[cfg(feature = "storage-mongodb")]- mod mongodb {- $(- #[test]- fn $body() {- $crate::storage_drivers::$runner(- $crate::storage_drivers::Driver::Mongo,- super::$body,- );- }- )+- }};}