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
chore(tests): remove obsolete streaming and lifecycle tests
Steven Enamakelf0af8f1244cc
diff --git a/crates/openhuman-core/src/voice/streaming_tests.rs b/crates/openhuman-core/src/voice/streaming_tests.rsdeleted file mode 100644index b5cd437127..0000000000--- a/crates/openhuman-core/src/voice/streaming_tests.rs+++ /dev/null@@ -1,91 +0,0 @@-use super::*;--#[test]-fn append_stream_samples_keeps_full_audio_and_trims_window() {- let mut audio = vec![0; MAX_STREAM_BUFFER_SAMPLES - 2];- let mut full = vec![1, 2];- let ok = append_stream_samples(&mut audio, &mut full, &[3, 4, 5, 6]);-- assert!(ok, "should succeed when under cap");- assert_eq!(full, vec![1, 2, 3, 4, 5, 6]);- assert_eq!(audio.len(), MAX_STREAM_BUFFER_SAMPLES);- assert_eq!(&audio[audio.len() - 4..], &[3, 4, 5, 6]);-}--/// Feed enough samples to hit the full-audio cap and verify:-/// 1. The buffer does NOT grow past `MAX_FULL_AUDIO_SAMPLES`.-/// 2. `append_stream_samples` returns `false` (cap-exceeded signal) when the next-/// chunk would overflow.-#[test]-fn append_stream_samples_enforces_full_audio_cap() {- let chunk_size = 1_024usize;- let mut audio = Vec::new();- let mut full = Vec::new();-- // Fill up to exactly the cap in chunks.- let full_chunks = MAX_FULL_AUDIO_SAMPLES / chunk_size;- let chunk = vec![0i16; chunk_size];- for _ in 0..full_chunks {- let ok = append_stream_samples(&mut audio, &mut full, &chunk);- assert!(ok, "should succeed while under cap");- }-- // The buffer may now be at or just below MAX_FULL_AUDIO_SAMPLES (depending on- // whether MAX_FULL_AUDIO_SAMPLES is an exact multiple of chunk_size).- assert!(- full.len() <= MAX_FULL_AUDIO_SAMPLES,- "full_audio_buf must not exceed cap before overflow chunk"- );-- // One more chunk must be rejected.- let extra = vec![1i16; chunk_size];- let ok = append_stream_samples(&mut audio, &mut full, &extra);- assert!(- !ok,- "must return false (cap exceeded) when appending would overflow"- );-- // The buffer must not have grown.- assert!(- full.len() <= MAX_FULL_AUDIO_SAMPLES,- "full_audio_buf must not exceed MAX_FULL_AUDIO_SAMPLES after cap is hit"- );-}--/// A single oversized chunk that would exceed the cap on its own must also be rejected.-#[test]-fn append_stream_samples_rejects_single_oversized_chunk() {- let mut audio = Vec::new();- let mut full = Vec::new();-- // Pre-fill to near the cap (1 sample short).- let near_full = vec![0i16; MAX_FULL_AUDIO_SAMPLES - 1];- let ok = append_stream_samples(&mut audio, &mut full, &near_full);- assert!(ok, "pre-fill should succeed");-- // A 2-sample chunk would push us 1 sample over the cap.- let ok = append_stream_samples(&mut audio, &mut full, &[7, 8]);- assert!(!ok, "must return false when chunk crosses the cap boundary");- assert!(- full.len() <= MAX_FULL_AUDIO_SAMPLES,- "full_audio_buf must not exceed cap"- );-}--#[test]-fn append_stream_samples_returns_false_when_full_audio_cap_reached() {- let mut audio = vec![];- let mut full = vec![0i16; MAX_FULL_AUDIO_SAMPLES];- let ok = append_stream_samples(&mut audio, &mut full, &[1, 2, 3]);-- assert!(!ok, "should return false once cap is reached");- assert_eq!(- full.len(),- MAX_FULL_AUDIO_SAMPLES,- "full buf must not grow past cap"- );- assert!(- audio.is_empty(),- "sliding window must not receive new samples"- );-}diff --git a/tests/inference_provider_e2e.rs b/tests/inference_provider_e2e.rsindex e38eba18a3..1cdf6ae14c 100644--- a/tests/inference_provider_e2e.rs+++ b/tests/inference_provider_e2e.rs@@ -1,9 +1,8 @@//! Inference provider end-to-end tests using wiremock.//!-//! These tests spin up a wiremock HTTP server on a random port and verify-//! that TinyAgents' crate-native `OpenAiModel` sends correct request bodies-//! and correctly interprets responses for the major provider shapes (OpenAI-compat,-//! Anthropic auth, streaming, temperature suppression, Ollama endpoint).+//! Non-streaming request/response, auth-header and temperature wire behavior of+//! `OpenAiModel` is covered in tinyinference-llm (`providers/openai/wire_test.rs`);+//! the streaming test below drives the SSE path over a real wiremock socket.//!//! The `/v1/chat/completions` and `/v1/models` HTTP endpoint tests verify the//! full axum router layer (auth middleware + provider routing) end-to-end.@@ -57,23 +56,6 @@ fn ensure_rpc_auth() {});}-// ── Canned OpenAI-compatible response body ────────────────────────────────────--fn openai_chat_response(content: &str) -> Value {- json!({- "id": "chatcmpl-test",- "object": "chat.completion",- "created": 1_700_000_000_u64,- "model": "gpt-4o-mini",- "choices": [{- "index": 0,- "message": { "role": "assistant", "content": content },- "finish_reason": "stop"- }],- "usage": { "prompt_tokens": 5, "completion_tokens": 10, "total_tokens": 15 }- })-}-fn openai_model(provider: &str, endpoint: &str, api_key: &str, auth: AuthStyle) -> OpenAiModel {OpenAiModel::new(api_key).with_provider(provider)@@ -81,25 +63,6 @@ fn openai_model(provider: &str, endpoint: &str, api_key: &str, auth: AuthStyle).with_auth_style(auth)}-fn model_request(prompt: &str, model: &str, temperature: f64) -> ModelRequest {- ModelRequest::new(vec![Message::user(prompt)])- .with_model(model)- .with_temperature(temperature)-}--async fn invoke_text(- model_client: &OpenAiModel,- prompt: &str,- model: &str,- temperature: f64,-) -> String {- model_client- .invoke(&(), model_request(prompt, model, temperature))- .await- .expect("model invocation should succeed")- .text()-}-// ── Helper: build an env-isolated Config pointing at tempdir ─────────────────/// Sets OPENHUMAN_WORKSPACE to `dir` and returns an `EnvVarGuard` thatdiff --git a/tests/ollama_lifecycle_e2e.rs b/tests/ollama_lifecycle_e2e.rsdeleted file mode 100644index 3e46423c42..0000000000--- a/tests/ollama_lifecycle_e2e.rs+++ /dev/null@@ -1,262 +0,0 @@-//! Integration tests for the Ollama daemon lifecycle contract (issue #1622 / pr #1638).-//!-//! These tests exercise the ownership model through the public `LocalAiService`-//! API without launching a real Ollama binary. Three flows are covered:-//!-//! 1. **Owned-spawn → graceful exit**: covered upstream by-//! `shutdown_owned_ollama_clears_marker_and_kills_child` in tinyinference-local.-//! 2. **External adoption → graceful exit**: when the daemon on `:11434` was not-//! spawned by openhuman (`owned_ollama == None`), `shutdown_owned_ollama` is-//! a no-op; a substitute long-running process stands in for the "external"-//! daemon and survives the call.-//! 3. **Crash recovery (stale marker + dead PID)**: `diagnostics` completes-//! successfully even when a leftover marker file references a PID that is no-//! longer alive, demonstrating that the reclaim guard in-//! `reclaim_orphan_if_ours` (called inside the production bootstrap) handles-//! the dead-marker case gracefully.-//!-//! # What requires a real Ollama binary-//!-//! Flows that exercise `start_and_wait_for_server` (i.e. the actual daemon-//! spawn loop with health polling) cannot be fully tested without a live-//! `ollama serve` process. The three scenarios above are covered at the-//! helper/shutdown level which is both necessary and sufficient to lock-//! the ownership contract. The spawn loop itself is tested indirectly via-//! `ensure_ollama_server_requires_external_runtime_when_unreachable` in-//! `ollama_admin_tests.rs`.--use std::sync::{Mutex, OnceLock};--use openhuman_core::config::Config;-use openhuman_core::inference::host_runtime::LocalAiService;--// ── Environment serialization lock ───────────────────────────────────────────-//-// Each test temporarily sets OPENHUMAN_WORKSPACE to redirect the marker path-// away from ~/.openhuman/. The mutex prevents parallel tests from stomping-// each other's env state.--static ENV_LOCK: OnceLock<Mutex<()>> = OnceLock::new();--fn env_lock() -> std::sync::MutexGuard<'static, ()> {- let m = ENV_LOCK.get_or_init(|| Mutex::new(()));- match m.lock() {- Ok(g) => g,- Err(p) => p.into_inner(),- }-}--// ── RAII env-var guard ────────────────────────────────────────────────────────-//-// Restores the previous env-var value (or removes it) when dropped.-// This ensures cleanup runs even if an assertion panics early, preventing-// env-var leakage that could destabilise subsequent tests.--struct EnvVarGuard {- key: &'static str,- prev: Option<std::ffi::OsString>,-}--impl EnvVarGuard {- fn set(key: &'static str, value: &std::ffi::OsStr) -> Self {- let prev = std::env::var_os(key);- std::env::set_var(key, value);- Self { key, prev }- }-}--impl Drop for EnvVarGuard {- fn drop(&mut self) {- match &self.prev {- Some(v) => std::env::set_var(self.key, v),- None => std::env::remove_var(self.key),- }- }-}--// ── Marker path helper ────────────────────────────────────────────────────────-//-// Mirrors the logic of `paths::ollama_spawn_marker_path`: when-// OPENHUMAN_WORKSPACE is set, the marker lives under config_path.parent()-// (i.e. the directory containing config.toml).--fn marker_path_for(config: &Config) -> std::path::PathBuf {- config- .config_path- .parent()- .expect("config_path must have a parent")- .join("local-ai")- .join("ollama.spawn")-}--/// Write a minimal spawn marker JSON directly (avoids needing pub(crate) helpers).-fn write_marker(path: &std::path::Path, pid: u32) {- if let Some(parent) = path.parent() {- std::fs::create_dir_all(parent).expect("create marker dir");- }- let json = format!(- r#"{{"pid":{pid},"started_at_unix":1700000000,"binary_path":"test-stub","openhuman_pid":{my_pid}}}"#,- pid = pid,- my_pid = std::process::id(),- );- let tmp = path.with_extension("spawn.tmp");- std::fs::write(&tmp, &json).expect("write marker tmp");- std::fs::rename(&tmp, path).expect("rename marker");-}--// ── Test 2: external adoption — shutdown leaves external daemon untouched ─────--/// When openhuman adopted an external Ollama (owned_ollama is None),-/// `shutdown_owned_ollama` must be a no-op: the external daemon must not be-/// killed. We simulate the external daemon with a second stub process whose-/// PID we track directly and assert is still alive after the call.-#[tokio::test]-async fn external_adoption_shutdown_leaves_external_process_running() {- let _guard = env_lock();- let tmp = tempfile::tempdir().unwrap();-- let _ws_guard = EnvVarGuard::set("OPENHUMAN_WORKSPACE", tmp.path().as_os_str());- let mut config = Config::default();- config.workspace_dir = tmp.path().to_path_buf();- config.config_path = tmp.path().join("config.toml");-- let runtime = openhuman_core::inference::local_runtime_config(&config);- let service = LocalAiService::new(&runtime);-- // `owned_ollama` starts as None — external daemon was adopted, not spawned.- assert!(- !service.has_owned_ollama(),- "fresh service must have no owned child"- );-- // Spawn a separate stub to represent the "external" daemon so we can- // check it is NOT killed by shutdown. Keep it alive for >2 s.- let mut ext_cmd = if cfg!(windows) {- let mut c = tokio::process::Command::new("powershell");- c.args(["-NoProfile", "-Command", "Start-Sleep -Seconds 30"]);- c- } else {- let mut c = tokio::process::Command::new("sleep");- c.arg("30");- c- };- ext_cmd- .stdout(std::process::Stdio::null())- .stderr(std::process::Stdio::null());- let mut ext_child = ext_cmd.spawn().expect("spawn external stub");- let ext_pid = ext_child.id().expect("external stub pid");-- // No marker file — we never wrote one because we adopted, not spawned.- let marker_path = marker_path_for(&config);-- // Call shutdown with no owned child.- service.shutdown_owned_ollama(&runtime).await;-- // Marker was never written, so it remains absent.- assert!(- !marker_path.exists(),- "no marker should appear when adopting an external daemon"- );-- // The external stub must still be running.- let still_alive = {- let mut sys = sysinfo::System::new();- let target = sysinfo::Pid::from_u32(ext_pid);- sys.refresh_processes(sysinfo::ProcessesToUpdate::Some(&[target]), true);- sys.process(target).is_some()- };- assert!(- still_alive,- "external daemon pid {ext_pid} must still be running after no-op shutdown"- );-- // Clean up the external stub ourselves.- let _ = ext_child.kill().await;- let _ = ext_child.wait().await;- // _ws_guard restores OPENHUMAN_WORKSPACE when it drops.-}--// ── Test 3: crash recovery — stale marker with dead PID ───────────────────────--/// Simulate a previous crash: a marker file exists on disk referencing a PID-/// that is no longer alive. On the next launch the service must handle this-/// gracefully. We test via `diagnostics` (a public, purely-read call that-/// triggers `reclaim_orphan_if_ours` indirectly through the bootstrap path-/// when a real server is present). Here we assert that `diagnostics` succeeds-/// even with a stale dead-PID marker present and without a live Ollama server —-/// the call must not panic or propagate the stale marker as an error.-///-/// NOTE: `reclaim_orphan_if_ours` is invoked inside `start_and_wait_for_server`-/// (the full bootstrap path), which requires a real Ollama binary to be-/// reachable. We test the marker-handling invariant through the path available-/// without a binary: `diagnostics` simply reports that the server is not-/// reachable, while the stale marker on disk is harmless. The dead-marker-/// clearing branch is already exercised by the inline `spawn_marker` unit-/// tests in `ollama_admin_tests.rs` (`pid_is_alive_rejects_dead_pid` +-/// `reclaim_orphan_if_ours` logic). What we add here is an integration-level-/// confirmation that the overall service stays functional when a stale marker-/// is present.-#[tokio::test]-async fn crash_recovery_stale_marker_does_not_break_service() {- let _guard = env_lock();- let tmp = tempfile::tempdir().unwrap();-- let _ws_guard = EnvVarGuard::set("OPENHUMAN_WORKSPACE", tmp.path().as_os_str());- // Redirect Ollama health checks to a dead port so no real daemon is needed.- let _ollama_url_guard = EnvVarGuard::set(- "OPENHUMAN_OLLAMA_BASE_URL",- std::ffi::OsStr::new("http://127.0.0.1:1"),- );-- let mut config = Config::default();- config.workspace_dir = tmp.path().to_path_buf();- config.config_path = tmp.path().join("config.toml");-- // Write a stale marker with a PID that was recycled from a short-lived child.- let zombie = if cfg!(windows) {- std::process::Command::new("cmd")- .args(["/C", "exit 0"])- .spawn()- .expect("spawn cmd /C exit")- } else {- std::process::Command::new("true")- .spawn()- .expect("spawn /usr/bin/true")- };- let dead_pid = zombie.id();- let mut zombie = zombie;- let _ = zombie.wait();- // Brief settle so the OS fully reaps the zombie before we write the marker.- std::thread::sleep(std::time::Duration::from_millis(250));-- let marker_path = marker_path_for(&config);- write_marker(&marker_path, dead_pid);- assert!(- marker_path.exists(),- "stale marker must be present to simulate a crash"- );-- // A freshly constructed service must not panic and diagnostics must succeed.- let runtime = openhuman_core::inference::local_runtime_config(&config);- let service = LocalAiService::new(&runtime);- let diag = service- .diagnostics(&runtime)- .await- .expect("diagnostics must succeed even with a stale spawn marker");-- // Without a live Ollama server, diagnostics reports not running.- assert_eq!(- diag["ollama_running"], false,- "ollama_running must be false when port is unreachable"- );- let issues = diag["issues"].as_array().cloned().unwrap_or_default();- assert!(- !issues.is_empty(),- "diagnostics must surface issues when server is unreachable"- );-- // The stale marker on disk is harmless at this level — it is consumed- // only during the bootstrap path (start_and_wait_for_server). The test- // confirms the service remains operational despite it.- // _ws_guard and _ollama_url_guard restore the env vars when they drop.-}