Prove che cadevano con il runner carico (#46)
Le prove cadevano a ogni carico della CI, ogni volta prove diverse. Dietro alcune c'erano difetti veri: FebeDatabase lasciava i file aperti dopo DisposeAsync (comandi SQLite non chiusi, pool di lettura chiuso dopo lo scrittore), e il WAL spariva durante lo spostamento della cartella Dati; la scheda dell'account senza statistiche leggeva i file di tutta la libreria; l'arresto di FebeApp non aspettava i lavori aggiunti da un avvio in corso. Chromium ha 120 s per avviarsi e aprire la prima scheda, e il ricollegamento smette appena il processo cambia. Nelle prove i limiti di tempo diventano protezioni contro un blocco: attese per condizione con un aiuto comune, limiti per classe nella prova di scala con il tempo migliore, porta 0 e stderr di Chromium nel browser delle prove, e la prova di «Scollega» di WebView2 controlla che il processo esca davvero. Provato su Windows con tutti i core occupati. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e2e64c09e8
commit
0775a1460f
34 files changed
+875
-245
No files matched your search
@@ -106,20 +106,25 @@ public sealed class HostingTests
|
||||
}
|
||||
|
||||
var restarted = 0;
|
||||
var twice = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
await using var supervisor = new SupervisedProcess(
|
||||
"prova",
|
||||
() => new ProcessStartInfo("/bin/sleep", "0.2"),
|
||||
(_, _) => Task.CompletedTask,
|
||||
new SystemClock(),
|
||||
policy: new RestartPolicy(TimeSpan.FromMilliseconds(50), TimeSpan.FromMilliseconds(200), TimeSpan.FromMinutes(1)));
|
||||
supervisor.Restarted += (_, _) => Interlocked.Increment(ref restarted);
|
||||
supervisor.Restarted += (_, _) =>
|
||||
{
|
||||
if (Interlocked.Increment(ref restarted) >= 2)
|
||||
{
|
||||
twice.TrySetResult();
|
||||
}
|
||||
};
|
||||
|
||||
await supervisor.StartAsync(CancellationToken.None);
|
||||
for (var i = 0; i < 100 && Volatile.Read(ref restarted) < 2; i++)
|
||||
{
|
||||
await Task.Delay(50);
|
||||
}
|
||||
|
||||
// By condition; the limit only bounds a supervisor that never restarts (process starts are slow under load, #46).
|
||||
await twice.Task.WaitAsync(TimeSpan.FromSeconds(30));
|
||||
Assert.IsTrue(Volatile.Read(ref restarted) >= 2, "The process was restarted after exiting.");
|
||||
await supervisor.StopAsync(TimeSpan.FromSeconds(2));
|
||||
Assert.AreEqual(SupervisedState.Stopped, supervisor.State);
|
||||
@@ -145,9 +150,10 @@ public sealed class HostingTests
|
||||
var pid = supervisor.ProcessId;
|
||||
Assert.IsNotNull(pid);
|
||||
|
||||
// The kill would come only after 120 s: any stop well before that was SIGTERM, with room for a loaded runner (#46).
|
||||
var watch = Stopwatch.StartNew();
|
||||
await supervisor.StopAsync(TimeSpan.FromSeconds(5));
|
||||
Assert.IsTrue(watch.Elapsed < TimeSpan.FromSeconds(4), "SIGTERM ends sleep at once; no need to wait for the kill.");
|
||||
await supervisor.StopAsync(TimeSpan.FromSeconds(120));
|
||||
Assert.IsLessThan(TimeSpan.FromSeconds(30), watch.Elapsed, "SIGTERM ends sleep at once; no need to wait for the kill.");
|
||||
Assert.IsFalse(Process.GetProcesses().Any(p => p.Id == pid && !p.HasExited && p.ProcessName == "sleep"));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user