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(openhuman-rpc): add host cli, desktop, and tui integration tests
Steven Enamakela2b2536e028a
diff --git a/crates/openhuman-rpc/tests/host_cli.rs b/crates/openhuman-rpc/tests/host_cli.rsnew file mode 100644index 0000000000..d750637961--- /dev/null+++ b/crates/openhuman-rpc/tests/host_cli.rs@@ -0,0 +1,20 @@+//! `host::cli` dispatches a subcommand in-process and returns. Its own test+//! binary: the CLI boot installs process-lifetime seams that are never restored.+#![cfg(feature = "server")]++#[test]+fn cli_host_runs_help_and_returns_ok() {+ let workspace = tempfile::tempdir().expect("workspace tempdir");+ std::env::set_var("OPENHUMAN_WORKSPACE", workspace.path());++ std::thread::Builder::new()+ .stack_size(64 * 1024 * 1024)+ .spawn(|| {+ openhuman_rpc::host::cli(&["--help".to_string()]).expect("--help dispatches and exits Ok");+ openhuman_rpc::host::cli(&["http_host".to_string(), "--help".to_string()])+ .expect("the http_host namespace extension is registered");+ })+ .expect("test thread")+ .join()+ .expect("test thread should not panic");+}diff --git a/crates/openhuman-rpc/tests/host_desktop.rs b/crates/openhuman-rpc/tests/host_desktop.rsnew file mode 100644index 0000000000..c1c329c734--- /dev/null+++ b/crates/openhuman-rpc/tests/host_desktop.rs@@ -0,0 +1,91 @@+//! `host::serve_desktop` booted in-process: ready signal, `GET /health`, then a+//! clean shutdown. Its own test binary because a runtime claims a process-wide+//! slot (the keyring, event bus and domain subscribers are process-scoped).+#![cfg(feature = "server")]++use std::sync::Arc;+use std::time::Duration;++use openhuman_rpc::embed::ServiceSet;+use openhuman_rpc::host::{desktop_builder, serve_desktop, DesktopOptions, EmbeddedReadySignal};+use tokio_util::sync::CancellationToken;++/// HTTP only: no cron, channels, update checker or other background work that+/// could reach beyond loopback.+fn http_only() -> ServiceSet {+ ServiceSet {+ rpc_http: true,+ socketio: false,+ cron: false,+ channels: false,+ login_gated: false,+ update_scheduler: false,+ memory_queue: false,+ harness_init: false,+ skill_catalog_refresh: false,+ mcp_boot: false,+ integrations: false,+ memory_sync: false,+ }+}++fn free_loopback_port() -> u16 {+ std::net::TcpListener::bind("127.0.0.1:0")+ .expect("bind ephemeral port")+ .local_addr()+ .expect("local addr")+ .port()+}++#[test]+fn serve_desktop_signals_ready_serves_health_and_stops_on_shutdown() {+ let workspace = tempfile::tempdir().expect("workspace tempdir");+ std::env::set_var("OPENHUMAN_WORKSPACE", workspace.path());+ std::env::set_var("OPENHUMAN_CORE_HOST", "127.0.0.1");++ std::thread::Builder::new()+ .stack_size(64 * 1024 * 1024)+ .spawn(move || {+ tokio::runtime::Builder::new_multi_thread()+ .enable_all()+ .thread_stack_size(16 * 1024 * 1024)+ .build()+ .expect("tokio runtime")+ .block_on(async {+ let options = DesktopOptions {+ host: Some("127.0.0.1".into()),+ port: Some(free_loopback_port()),+ socketio: false,+ rpc_token: Some(Arc::new("host-desktop-test-bearer".into())),+ };+ let builder = desktop_builder(&options).services(http_only());+ let shutdown = CancellationToken::new();+ let (ready_tx, ready_rx) = tokio::sync::oneshot::channel();+ let server = tokio::spawn(serve_desktop(builder, shutdown.clone(), ready_tx));++ let EmbeddedReadySignal { port, .. } =+ tokio::time::timeout(Duration::from_secs(120), ready_rx)+ .await+ .expect("ready signal within the timeout")+ .expect("ready signal sent");+ assert_eq!(port, options.port.unwrap());++ let health = reqwest::Client::new()+ .get(format!("http://127.0.0.1:{port}/health"))+ .send()+ .await+ .expect("GET /health");+ assert_eq!(health.status(), 200);++ shutdown.cancel();+ let finished = tokio::time::timeout(Duration::from_secs(60), server)+ .await+ .expect("server stops after shutdown")+ .expect("server task joins");+ finished.expect("server exits cleanly");+ });+ })+ .expect("test thread")+ .join()+ .expect("test thread should not panic");+}diff --git a/crates/openhuman-rpc/tests/host_tui.rs b/crates/openhuman-rpc/tests/host_tui.rsnew file mode 100644index 0000000000..b4cfadd4a9--- /dev/null+++ b/crates/openhuman-rpc/tests/host_tui.rs@@ -0,0 +1,34 @@+//! `host::tui()` builds a connected in-process runtime and a controller call+//! works through it. Its own test binary: a runtime claims a process-wide slot.+#![cfg(feature = "session-store")]++#[test]+fn tui_host_builds_a_runtime_that_answers_a_read_rpc() {+ let workspace = tempfile::tempdir().expect("workspace tempdir");+ std::env::set_var("OPENHUMAN_WORKSPACE", workspace.path());++ std::thread::Builder::new()+ .stack_size(64 * 1024 * 1024)+ .spawn(move || {+ tokio::runtime::Builder::new_multi_thread()+ .enable_all()+ .thread_stack_size(16 * 1024 * 1024)+ .build()+ .expect("tokio runtime")+ .block_on(async {+ let runtime = openhuman_rpc::host::tui()+ .await+ .expect("tui host builds a runtime");+ let listed = runtime+ .core_runtime()+ .invoke("openhuman.threads_list", serde_json::json!({}))+ .await+ .expect("threads_list answers in-process");+ assert!(listed.is_object() || listed.is_array(), "{listed}");+ drop(runtime);+ });+ })+ .expect("test thread")+ .join()+ .expect("test thread should not panic");+}