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: relocate #6032 ollama health tests to part_03 (file-layout limit)\n\nThe four new health-status/degraded-diagnostics tests pushed\nollama_admin_tests_part_01_tests.rs to 761 lines, over the repo's 750-line\nper-file layout limit (Enforce OpenHuman Rust file layout gate). Moved them to\nthe sibling part_03 file (386 → 510 lines); no test logic changed.\n
shanu4ab17ce96655
diff --git a/src/openhuman/inference/local/service/ollama_admin_tests_part_01_tests.rs b/src/openhuman/inference/local/service/ollama_admin_tests_part_01_tests.rsindex 83ede4110c..e7169dd6ff 100644--- a/src/openhuman/inference/local/service/ollama_admin_tests_part_01_tests.rs+++ b/src/openhuman/inference/local/service/ollama_admin_tests_part_01_tests.rs@@ -100,130 +100,6 @@ async fn ollama_healthy_returns_false_on_unreachable_url() {}}-// #6032 — two-phase health probe classification. `ollama_health_status_at`-// returns `Running` on a fast 200, `Degraded` when the 2s fast probe times out-// but the 8s retry succeeds, and `Stopped` otherwise.--#[tokio::test]-async fn ollama_health_status_running_on_fast_200() {- use super::super::health::OllamaHealthStatus;- let _guard = crate::openhuman::inference::inference_test_guard();-- let app = Router::new().route("/api/tags", get(|| async { Json(json!({ "models": [] })) }));- let base = spawn_mock(app).await;- let config = Config::default();- let service = LocalAiService::new(&config);- assert_eq!(- service.ollama_health_status_at(&base).await,- OllamaHealthStatus::Running- );-}--#[tokio::test]-async fn ollama_health_status_stopped_when_unreachable() {- use super::super::health::OllamaHealthStatus;- let _guard = crate::openhuman::inference::inference_test_guard();-- // Unbound port → connect refused (not a timeout) → Stopped.- let config = Config::default();- let service = LocalAiService::new(&config);- assert_eq!(- service.ollama_health_status_at("http://127.0.0.1:1").await,- OllamaHealthStatus::Stopped- );-}--#[tokio::test]-async fn ollama_health_status_degraded_on_slow_then_fast() {- use std::sync::atomic::{AtomicUsize, Ordering};- use std::sync::Arc;-- use axum::extract::State;-- use super::super::health::OllamaHealthStatus;- let _guard = crate::openhuman::inference::inference_test_guard();-- // Stateful mock: the FIRST /api/tags call sleeps past the 2s fast-probe- // timeout; every later call answers instantly. This is exactly a- // momentarily-busy daemon — the fast probe times out, the 8s retry- // succeeds → Degraded.- let calls: Arc<AtomicUsize> = Arc::new(AtomicUsize::new(0));- let app = Router::new()- .route(- "/api/tags",- get(|State(calls): State<Arc<AtomicUsize>>| async move {- if calls.fetch_add(1, Ordering::SeqCst) == 0 {- tokio::time::sleep(std::time::Duration::from_millis(3000)).await;- }- Json(json!({ "models": [] }))- }),- )- .with_state(calls);- let base = spawn_mock(app).await;- let config = Config::default();- let service = LocalAiService::new(&config);- assert_eq!(- service.ollama_health_status_at(&base).await,- OllamaHealthStatus::Degraded- );-}--#[tokio::test]-async fn diagnostics_degraded_ollama_stays_running_and_lists_models() {- use std::sync::atomic::{AtomicUsize, Ordering};- use std::sync::Arc;-- use axum::extract::State;- use axum::routing::post;-- let _guard = crate::openhuman::inference::inference_test_guard();-- // Same slow-first-call mock, but returns a real model so we can prove that- // model discovery still succeeds under the degraded (8s) timeout — the- // whole point of #6032: a slow-but-alive daemon must keep its models- // selectable rather than collapsing to an empty catalog.- let tags_calls: Arc<AtomicUsize> = Arc::new(AtomicUsize::new(0));- let app = Router::new()- .route(- "/api/tags",- get(|State(calls): State<Arc<AtomicUsize>>| async move {- if calls.fetch_add(1, Ordering::SeqCst) == 0 {- tokio::time::sleep(std::time::Duration::from_millis(3000)).await;- }- Json(json!({- "models": [- {"name": "llama3:latest", "modified_at": "", "size": 1u64, "digest": "d"}- ]- }))- }),- )- .route("/api/show", post(|| async { Json(json!({})) }))- .with_state(tags_calls);- let base = spawn_mock(app).await;-- let mut config = Config::default();- config.local_ai.provider = "ollama".to_string();- config.local_ai.base_url = Some(base);- let service = LocalAiService::new(&config);-- let report = service.diagnostics(&config).await.expect("diagnostics ok");- assert_eq!(- report["ollama_status"], "degraded",- "a slow-but-alive daemon must report degraded, not stopped"- );- assert_eq!(- report["ollama_running"], true,- "degraded still counts as running so local models stay selectable"- );- let models = report["installed_models"]- .as_array()- .expect("installed_models array");- assert!(- !models.is_empty(),- "model discovery must survive the degraded timeout window (non-empty catalog)"- );-}-#[tokio::test]async fn ensure_ollama_server_requires_external_runtime_when_unreachable() {let _guard = crate::openhuman::inference::inference_test_guard();diff --git a/src/openhuman/inference/local/service/ollama_admin_tests_part_03_tests.rs b/src/openhuman/inference/local/service/ollama_admin_tests_part_03_tests.rsindex 97ab7ec17c..d6cff5fc0c 100644--- a/src/openhuman/inference/local/service/ollama_admin_tests_part_03_tests.rs+++ b/src/openhuman/inference/local/service/ollama_admin_tests_part_03_tests.rs@@ -384,3 +384,127 @@ async fn a_later_preload_does_not_bury_the_vision_failure_reason() {"the embedding pull's progress text must not have buried it: {warning}");}++// #6032 — two-phase health probe classification. `ollama_health_status_at`+// returns `Running` on a fast 200, `Degraded` when the 2s fast probe times out+// but the 8s retry succeeds, and `Stopped` otherwise.++#[tokio::test]+async fn ollama_health_status_running_on_fast_200() {+ use super::super::health::OllamaHealthStatus;+ let _guard = crate::openhuman::inference::inference_test_guard();++ let app = Router::new().route("/api/tags", get(|| async { Json(json!({ "models": [] })) }));+ let base = spawn_mock(app).await;+ let config = Config::default();+ let service = LocalAiService::new(&config);+ assert_eq!(+ service.ollama_health_status_at(&base).await,+ OllamaHealthStatus::Running+ );+}++#[tokio::test]+async fn ollama_health_status_stopped_when_unreachable() {+ use super::super::health::OllamaHealthStatus;+ let _guard = crate::openhuman::inference::inference_test_guard();++ // Unbound port → connect refused (not a timeout) → Stopped.+ let config = Config::default();+ let service = LocalAiService::new(&config);+ assert_eq!(+ service.ollama_health_status_at("http://127.0.0.1:1").await,+ OllamaHealthStatus::Stopped+ );+}++#[tokio::test]+async fn ollama_health_status_degraded_on_slow_then_fast() {+ use std::sync::atomic::{AtomicUsize, Ordering};+ use std::sync::Arc;++ use axum::extract::State;++ use super::super::health::OllamaHealthStatus;+ let _guard = crate::openhuman::inference::inference_test_guard();++ // Stateful mock: the FIRST /api/tags call sleeps past the 2s fast-probe+ // timeout; every later call answers instantly. This is exactly a+ // momentarily-busy daemon — the fast probe times out, the 8s retry+ // succeeds → Degraded.+ let calls: Arc<AtomicUsize> = Arc::new(AtomicUsize::new(0));+ let app = Router::new()+ .route(+ "/api/tags",+ get(|State(calls): State<Arc<AtomicUsize>>| async move {+ if calls.fetch_add(1, Ordering::SeqCst) == 0 {+ tokio::time::sleep(std::time::Duration::from_millis(3000)).await;+ }+ Json(json!({ "models": [] }))+ }),+ )+ .with_state(calls);+ let base = spawn_mock(app).await;+ let config = Config::default();+ let service = LocalAiService::new(&config);+ assert_eq!(+ service.ollama_health_status_at(&base).await,+ OllamaHealthStatus::Degraded+ );+}++#[tokio::test]+async fn diagnostics_degraded_ollama_stays_running_and_lists_models() {+ use std::sync::atomic::{AtomicUsize, Ordering};+ use std::sync::Arc;++ use axum::extract::State;+ use axum::routing::post;++ let _guard = crate::openhuman::inference::inference_test_guard();++ // Same slow-first-call mock, but returns a real model so we can prove that+ // model discovery still succeeds under the degraded (8s) timeout — the+ // whole point of #6032: a slow-but-alive daemon must keep its models+ // selectable rather than collapsing to an empty catalog.+ let tags_calls: Arc<AtomicUsize> = Arc::new(AtomicUsize::new(0));+ let app = Router::new()+ .route(+ "/api/tags",+ get(|State(calls): State<Arc<AtomicUsize>>| async move {+ if calls.fetch_add(1, Ordering::SeqCst) == 0 {+ tokio::time::sleep(std::time::Duration::from_millis(3000)).await;+ }+ Json(json!({+ "models": [+ {"name": "llama3:latest", "modified_at": "", "size": 1u64, "digest": "d"}+ ]+ }))+ }),+ )+ .route("/api/show", post(|| async { Json(json!({})) }))+ .with_state(tags_calls);+ let base = spawn_mock(app).await;++ let mut config = Config::default();+ config.local_ai.provider = "ollama".to_string();+ config.local_ai.base_url = Some(base);+ let service = LocalAiService::new(&config);++ let report = service.diagnostics(&config).await.expect("diagnostics ok");+ assert_eq!(+ report["ollama_status"], "degraded",+ "a slow-but-alive daemon must report degraded, not stopped"+ );+ assert_eq!(+ report["ollama_running"], true,+ "degraded still counts as running so local models stay selectable"+ );+ let models = report["installed_models"]+ .as_array()+ .expect("installed_models array");+ assert!(+ !models.is_empty(),+ "model discovery must survive the degraded timeout window (non-empty catalog)"+ );+}