Drain-Test: eine Sekunde Frist statt 300 ms bei 250-ms-Takt (#722)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Richard
2026-10-02 12:11:35 +02:00
co-authored by Claude Opus 5.5
parent 7ce5e219cf
commit 31eac2f7c0
@@ -307,22 +307,24 @@ public sealed class InstanceSupervisorTests : IDisposable
{ {
_kanal.Answer = Test; _kanal.Answer = Test;
// #722: Viel Luft bis MaxDrainWait — unter Parallellast kam die Verzoegerung von 700 ms // #722: Die Aufsicht fragt alle 250 ms und schiebt die Frist nur bei "raeume auf" weiter.
// sonst erst nach den 2 s an, und der Test sah einen Abschuss, wo keiner hingehoert. // Mit 300 ms Frist kam unter Parallellast die naechste Frage zu spaet, und der Test sah
await using var aufsicht = Aufsicht(Options with { MaxDrainWait = TimeSpan.FromSeconds(20) }); // einen Abschuss, wo keiner hingehoert. Eine Sekunde Frist laesst dem Takt Luft; die
// Instanz raeumt trotzdem deutlich laenger auf, als die Frist allein erlaubt.
await using var aufsicht = Aufsicht(Options with { StopGrace = TimeSpan.FromSeconds(1), MaxDrainWait = TimeSpan.FromSeconds(20) });
await aufsicht.StartAsync(); await aufsicht.StartAsync();
var prozess = _launcher.Last.ShouldNotBeNull(); var prozess = _launcher.Last.ShouldNotBeNull();
// Sie antwortet und meldet: Ich raeume auf. Laenger als StopGrace (300ms), aber // Sie antwortet und meldet: Ich raeume auf. Laenger als StopGrace (1 s), aber
// kuerzer als MaxDrainWait. // kuerzer als MaxDrainWait.
_kanal.Answer = Test with { Phase = ShutdownPhase.Draining, OpenWork = 1 }; _kanal.Answer = Test with { Phase = ShutdownPhase.Draining, OpenWork = 1 };
_kanal.OnStopRequest = _ => Task.Run(async () => _kanal.OnStopRequest = _ => Task.Run(async () =>
{ {
await Task.Delay(700); await Task.Delay(2500);
_kanal.Answer = null;
prozess.Exit(0); prozess.Exit(0);
_kanal.Answer = null;
}); });
(await aufsicht.StopAsync()).ShouldBeTrue(); (await aufsicht.StopAsync()).ShouldBeTrue();