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
@@ -1,4 +1,3 @@
|
||||
using System.Diagnostics;
|
||||
using Febe.Core.Abstractions;
|
||||
using Febe.Core.Domain;
|
||||
using Febe.Data;
|
||||
@@ -110,27 +109,31 @@ public sealed class SingleWriterTests
|
||||
using var temp = new TempFolder();
|
||||
await using var db = await TestDatabase.OpenAsync(temp);
|
||||
await db.Settings.SetAsync("prima", "1");
|
||||
using var inside = new ManualResetEventSlim(false);
|
||||
using var gate = new ManualResetEventSlim(false);
|
||||
|
||||
// The write holds the writer and its transaction until the gate opens (at most 60 s, only a hang guard).
|
||||
var longWrite = db.WriteAsync(
|
||||
w =>
|
||||
{
|
||||
w.Command("INSERT INTO setting (key, value) VALUES ('durante', '1')").ExecuteNonQuery();
|
||||
gate.Wait(TimeSpan.FromSeconds(10));
|
||||
inside.Set();
|
||||
gate.Wait(TimeSpan.FromSeconds(60));
|
||||
},
|
||||
default);
|
||||
Assert.IsTrue(inside.Wait(TimeSpan.FromSeconds(60)), "La scrittura lunga non è partita.");
|
||||
|
||||
var watch = Stopwatch.StartNew();
|
||||
// An ordering, not a time (#46): the reads end while the write still holds its uncommitted transaction.
|
||||
var value = await db.Settings.GetAsync("prima");
|
||||
var during = await db.Settings.GetAsync("durante");
|
||||
watch.Stop();
|
||||
Assert.IsFalse(longWrite.IsCompleted, "Le letture sono finite solo dopo la scrittura lunga.");
|
||||
gate.Set();
|
||||
await longWrite;
|
||||
|
||||
Assert.AreEqual("1", value);
|
||||
Assert.IsNull(during, "Una lettura non vede una scrittura non ancora confermata.");
|
||||
Assert.IsLessThan(2000L, watch.ElapsedMilliseconds);
|
||||
Assert.AreEqual("1", await db.Settings.GetAsync("durante"));
|
||||
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
|
||||
Reference in new issue
Block a user