feat: expose measured model loading phases in overview and chat (#1095)
This commit is contained in:
@ -3002,3 +3002,72 @@ async fn engine_oberflaeche_braucht_admin_und_bleibt_bei_unsicherem_praefix_gesc
|
||||
let (_, _, body) = ui_get(&gw, "/ui/engines", Some(&user)).await;
|
||||
assert!(!body.contains("href=\"/ui/engine/"));
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn ladephase_ist_im_chat_und_in_der_uebersicht_sichtbar_und_behaelt_letzte_dauer() {
|
||||
let gw = Arc::new(gateway(600, false).await);
|
||||
let cookie = ui_cookie(&gw).await;
|
||||
assert_eq!(
|
||||
ui_get(&gw, "/ui/chat/status?modell=bonsai", None).await.0,
|
||||
303
|
||||
);
|
||||
assert_eq!(
|
||||
ui_get(&gw, "/ui/chat/status?modell=gesperrt", Some(&cookie))
|
||||
.await
|
||||
.0,
|
||||
404
|
||||
);
|
||||
let running = {
|
||||
let gw = gw.clone();
|
||||
tokio::spawn(async move {
|
||||
gw.chat(Some(&gw.key), None, &chat_body("bonsai", false))
|
||||
.await
|
||||
.text()
|
||||
.await
|
||||
.unwrap()
|
||||
})
|
||||
};
|
||||
wait_until("Start läuft", || starts(&gw) == 1).await;
|
||||
let (status, _, body) = ui_get(&gw, "/ui/chat/status?modell=bonsai", Some(&cookie)).await;
|
||||
assert_eq!(status, 200);
|
||||
let phase: Value = serde_json::from_str(&body).unwrap();
|
||||
assert_eq!(phase["phase"], "Engine startet");
|
||||
assert!(phase["elapsed_ms"].is_u64());
|
||||
assert!(phase["last_load_ms"].is_null());
|
||||
let (_, _, overview) = ui_get(&gw, "/ui", Some(&cookie)).await;
|
||||
assert!(overview.contains("Engine startet"));
|
||||
assert!(!overview.contains("Modelldateien werden gelesen"));
|
||||
running.await.unwrap();
|
||||
let (_, _, body) = ui_get(&gw, "/ui/chat/status?modell=bonsai", Some(&cookie)).await;
|
||||
let phase: Value = serde_json::from_str(&body).unwrap();
|
||||
assert_eq!(phase["phase"], "bereit");
|
||||
assert!(phase["last_load_ms"].as_u64().unwrap() >= 600);
|
||||
gw.state.runtime.unload("bonsai").unwrap();
|
||||
wait_until("Entladen", || {
|
||||
gw.state.runtime.scheduler_view().instances.is_empty()
|
||||
})
|
||||
.await;
|
||||
let (_, _, body) = ui_get(&gw, "/ui/chat/status?modell=bonsai", Some(&cookie)).await;
|
||||
let unloaded: Value = serde_json::from_str(&body).unwrap();
|
||||
assert_eq!(unloaded["phase"], "nicht geladen");
|
||||
assert_eq!(unloaded["last_load_ms"], phase["last_load_ms"]);
|
||||
assert!(!body.contains("/m/"));
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn ladephase_meldet_fehlstart_ohne_engine_fehlertext() {
|
||||
let gw = gateway(0, true).await;
|
||||
let cookie = ui_cookie(&gw).await;
|
||||
assert_eq!(
|
||||
gw.chat(Some(&gw.key), None, &chat_body("bonsai", false))
|
||||
.await
|
||||
.status(),
|
||||
503
|
||||
);
|
||||
let (status, _, body) = ui_get(&gw, "/ui/chat/status?modell=bonsai", Some(&cookie)).await;
|
||||
assert_eq!(status, 200);
|
||||
let phase: Value = serde_json::from_str(&body).unwrap();
|
||||
assert_eq!(phase["phase"], "Start fehlgeschlagen");
|
||||
assert!(phase["last_load_ms"].is_null());
|
||||
assert!(!body.contains("geheimes-detail"));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user