Prove che cadevano con il runner carico (#46)
verifica / controlli (push) Successful in 25s
verifica / prove (push) Successful in 25m9s
verifica / installatore (push) Successful in 7m37s
verifica / immagine (push) Successful in 20m21s

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:
Alby96andClaude Opus 5.5 committed 2026-11-13 19:50:40 +01:00
1 parent e2e64c09e8
commit 0775a1460f
34 files changed
+875 -245

No files matched your search

@@ -13,6 +13,7 @@ using Febe.Browser.Targets;
using Febe.Core.Abstractions;
using Febe.Core.Collection;
using Febe.Tests.Browser.TestSupport;
using Febe.Tests.Support;
namespace Febe.Tests.Browser;
@@ -139,7 +140,11 @@ public sealed class BrowserIntegrationTests
var requested = await gestures.ScrollBurstAsync();
requested += await gestures.ScrollBurstAsync();
await Task.Delay(600);
// The scroll runs in the compositor after the events: by condition, not after a fixed time (#46).
await TestWait.UntilAsync(
async () => await Browser.EvalAsync<double>("window.scrollY") > 200 && await Browser.EvalAsync<int>("(window.__wheel && window.__wheel.count) || 0") >= 6,
"la pagina scesa con la rotella");
var scrolled = await Browser.EvalAsync<double>("window.scrollY");
var wheel = await Browser.Cdp.EvaluateAsync("window.__wheel");
@@ -149,7 +154,7 @@ public sealed class BrowserIntegrationTests
Assert.IsTrue(wheel.GetProperty("trusted").GetBoolean(), "Wheel events are trusted, as real ones.");
await gestures.ScrollBackAsync();
await Task.Delay(400);
await TestWait.UntilAsync(async () => await Browser.EvalAsync<double>("window.scrollY") < scrolled, "la pagina risalita");
Assert.IsTrue(await Browser.EvalAsync<double>("window.scrollY") < scrolled, "A scroll back goes up.");
}
@@ -225,7 +230,8 @@ public sealed class BrowserIntegrationTests
// S4 locally: click into a field through the remote view and type.
await view.NavigateAsync(Browser.Site.Url("/modulo"));
await Browser.Cdp.WaitForLoadAsync(Browser.Clock, TimeSpan.FromSeconds(10));
Assert.IsTrue(await Browser.Cdp.WaitForLoadAsync(Browser.Clock, TimeSpan.FromSeconds(60)), "La pagina del modulo non ha finito di caricare.");
await Browser.WaitForPaintAsync();
await Task.Delay(RealBrowser.SettleAfterLoad);
var field = await new TargetResolver(Browser.Cdp, TargetMap.Parse(Targets)).ResolveAsync("campo");
Assert.IsTrue(field.Found, field.Message);
+3 -9
View File
@@ -11,6 +11,7 @@ using Febe.Core.Collection;
using Febe.Core.Collection.Readers;
using Febe.Core.Collection.Recipes;
using Febe.Tests.Browser.TestSupport;
using Febe.Tests.Support;
namespace Febe.Tests.Browser;
@@ -418,15 +419,8 @@ public sealed class CaptureUnitTests
["response"] = new JsonObject { ["url"] = url, ["status"] = 200, ["mimeType"] = "text/html; charset=utf-8" },
};
private static async Task WaitUntilAsync(Func<bool> condition)
{
for (var i = 0; i < 300 && !condition(); i++)
{
await Task.Delay(10);
}
Assert.IsTrue(condition(), "Condition not reached in time.");
}
// By condition until a deadline, not a count of polls: bodies and acks run on pool continuations (#46).
private static Task WaitUntilAsync(Func<bool> condition) => TestWait.UntilAsync(condition, "condizione della prova");
/// <summary>The body of a cleaned Instagram sample (<c>tests/campioni/instagram</c>), as JSON text.</summary>
private static string SampleBody(string name)
+4 -9
View File
@@ -7,6 +7,7 @@ using System.Text.Json;
using System.Text.Json.Nodes;
using Febe.Browser.Cdp;
using Febe.Browser.Diagnostics;
using Febe.Tests.Support;
namespace Febe.Tests.Browser;
@@ -161,15 +162,9 @@ public sealed class CdpClientTests
Assert.IsFalse(all.Contains("segret", StringComparison.Ordinal), "Parameters, events and results never reach the log.");
}
private static async Task WaitUntilAsync(Func<bool> condition)
{
for (var i = 0; i < 200 && !condition(); i++)
{
await Task.Delay(10);
}
Assert.IsTrue(condition());
}
// By condition until a deadline, not a count of polls: the receive loop runs on the pool, which the parallel tests may
// keep busy for seconds (#46).
private static Task WaitUntilAsync(Func<bool> condition) => TestWait.UntilAsync(condition, "condizione della prova");
/// <summary>A CdpClient connected to a server-side WebSocket over a loopback TCP connection.</summary>
private sealed class SocketPair : IAsyncDisposable
+13 -7
View File
@@ -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"));
}
}
@@ -145,16 +145,38 @@ public sealed class RealBrowser : IAsyncDisposable
throw new InvalidOperationException($"Navigazione fallita: {result.ErrorText}");
}
if (!await Cdp.WaitForLoadAsync(Clock, TimeSpan.FromSeconds(15)))
// The limit only bounds a hang: the wait ends with the load (#46).
if (!await Cdp.WaitForLoadAsync(Clock, TimeSpan.FromSeconds(60)))
{
throw new TimeoutException("La pagina non ha finito di caricare.");
}
// Like the post-load wait of the recipes (1–6 s, shortened here): Chromium ignores input that arrives
// right after a navigation, before the page has painted.
// right after a navigation, before the page has painted. On a loaded runner the first paint comes later.
await WaitForPaintAsync();
await Task.Delay(SettleAfterLoad);
}
/// <summary>
/// Waits until the page reports its first paint (a read-only look at the paint entries), up to 15 s. Not reported
/// in time is not an error: the settle after it stays as before.
/// </summary>
public async Task<bool> WaitForPaintAsync()
{
var watch = System.Diagnostics.Stopwatch.StartNew();
while (watch.Elapsed < TimeSpan.FromSeconds(15))
{
if (await EvalAsync<bool>("performance.getEntriesByType('paint').length > 0"))
{
return true;
}
await Task.Delay(50);
}
return false;
}
public static TimeSpan SettleAfterLoad { get; } = TimeSpan.FromMilliseconds(500);
public async Task<T> EvalAsync<T>(string expression) =>