test: Startfehler belegt nichts und der nächste Start gelingt (engine2betrieb.3)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GmHhg6sxZ8wsKZAVLQ6Xj5
This commit is contained in:
@ -37,7 +37,7 @@ struct FixedEngine {
|
||||
health_timeout: std::sync::atomic::AtomicBool,
|
||||
measured_vram: std::sync::atomic::AtomicU64,
|
||||
delay: Duration,
|
||||
fail: bool,
|
||||
fail: std::sync::atomic::AtomicBool,
|
||||
/// Lässt `stop` scheitern, während die Instanz weiterläuft (→ #1166).
|
||||
stop_fails: std::sync::atomic::AtomicBool,
|
||||
}
|
||||
@ -73,7 +73,7 @@ impl Engine for FixedEngine {
|
||||
async fn start(&self, _p: &ProfileSpec) -> Result<InstanceHandle, AdapterError> {
|
||||
self.starts.fetch_add(1, Ordering::SeqCst);
|
||||
tokio::time::sleep(self.delay).await;
|
||||
if self.fail {
|
||||
if self.fail.load(Ordering::SeqCst) {
|
||||
return Err(AdapterError::Spawn("geheimes-detail".to_string()));
|
||||
}
|
||||
Ok(InstanceHandle {
|
||||
@ -363,7 +363,7 @@ async fn gateway_with(
|
||||
health_timeout: std::sync::atomic::AtomicBool::new(false),
|
||||
measured_vram: std::sync::atomic::AtomicU64::new(0),
|
||||
delay: Duration::from_millis(delay_ms),
|
||||
fail,
|
||||
fail: std::sync::atomic::AtomicBool::new(fail),
|
||||
stop_fails: std::sync::atomic::AtomicBool::new(false),
|
||||
});
|
||||
|
||||
@ -1117,6 +1117,34 @@ async fn logs_tragen_die_correlation_id_und_enthalten_keine_geheimnisse() {
|
||||
}
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn startfehler_belegt_nichts_und_der_naechste_start_gelingt() {
|
||||
// engine2betrieb.3: Defekter Start sichtbar (503, Fehlerblock im Audit/Log), danach keine Buchung und keine
|
||||
// Instanz übrig; nach der Korrektur startet dasselbe Modell erneut.
|
||||
let gw = gateway(0, true).await;
|
||||
let body = chat_body("bonsai", false);
|
||||
for _ in 0..2 {
|
||||
assert_eq!(gw.chat(Some(&gw.key), None, &body).await.status(), 503);
|
||||
}
|
||||
assert_eq!(
|
||||
gw.engine.starts.load(Ordering::SeqCst),
|
||||
2,
|
||||
"jeder Versuch startet neu"
|
||||
);
|
||||
let view = gw.state.runtime.scheduler_view();
|
||||
assert!(
|
||||
view.instances.is_empty(),
|
||||
"nichts bleibt belegt: {:?}",
|
||||
view.instances
|
||||
);
|
||||
gw.engine.fail.store(false, Ordering::SeqCst);
|
||||
assert_eq!(gw.chat(Some(&gw.key), None, &body).await.status(), 200);
|
||||
assert_eq!(gw.engine.starts.load(Ordering::SeqCst), 3);
|
||||
let view = gw.state.runtime.scheduler_view();
|
||||
assert_eq!(view.instances.len(), 1);
|
||||
assert_eq!(view.instances[0].state, "ready");
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn startfehler_steht_als_error_im_log_der_anfrage() {
|
||||
let (logs, _guard) = capture_logs();
|
||||
|
||||
Reference in New Issue
Block a user