Correzione: la prova da capo a fondo del server non perde più la prima sessione

«Tempo scaduto: tre file di marta.prova scaricati» era un difetto della prova: l'orologio
compresso sommava le attese dei lavori di sottofondo (circa 34 volte invece di 10, a salti) e
consumava in un attimo i limiti delle pagine vere e la prima sessione; inoltre il motore apriva
la sua sessione a «Ho finito», prima di «Controlla ora», con luca.prova per primo. Finita la
sessione, i file aspettavano la prossima: 120 secondi veri, più dei 90 della prova.

Ora le composizioni intere usano ScaledClock (attese sovrapposte = stesso tempo, 5 volte), la sola
sessione è quella chiesta con «Controlla ora», e un'attesa scaduta dice che cosa faceva Febe.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Alby96andClaude Opus 5.5 committed 2026-12-01 17:00:10 +01:00
1 parent 6d66cf96d3
commit 66a3873554
12 files changed
+242 -83

No files matched your search

+19 -11
View File
@@ -37,7 +37,7 @@ public sealed partial class ServerEndToEndTests
}
[TestMethod]
[Timeout(540_000, CooperativeCancellation = true)]
[Timeout(900_000, CooperativeCancellation = true)]
public async Task TheRealServerCollectsFromTheTestSiteStopsAtTheVerificationAndShowsTheBrowser()
{
var ct = TestContext.CancellationToken;
@@ -95,7 +95,7 @@ public sealed partial class ServerEndToEndTests
Assert.AreEqual("queued", check.GetProperty("status").GetString(), check.GetProperty("message").GetString());
// The engine runs a session: every action toward the site has its Governor's permit in action_log.
await ServerTestBed.WaitUntilAsync(
await bed.WaitUntilAsync(
async () => (await server.Database.ActionLog.ListAsync(DateTimeOffset.UnixEpoch, bed.Clock.Now.AddDays(1), ct)).Any(a => a.AccountId == marta.Id),
TimeSpan.FromSeconds(90),
"un'azione del motore su marta.prova nel registro delle azioni");
@@ -103,11 +103,19 @@ public sealed partial class ServerEndToEndTests
Assert.IsTrue(actions.All(a => a.SessionId is not null), "every counted action belongs to a session");
Assert.IsNotNull(await server.Database.Sessions.GetLastAsync(ct));
// The session is the one Alberto asked for, and starts from his account. Another account first (a session of the
// engine's own that began at «Ho finito») leaves little of these few minutes to marta.prova, and once they end the
// files have to wait for the next session: say it here, not after a wait that cannot succeed.
if (actions.First(a => a.AccountId is not null).AccountId != marta.Id)
{
Assert.Fail($"La prima azione della sessione non è su marta.prova, chiesta con «Controlla ora».\n{await bed.DescribeAsync()}");
}
// Files arrive in the library with the names of the scheme, and their thumbnails.
var library = bed.Library;
var thumbnails = bed.Thumbnails;
List<(Entry Entry, Media Media)> stored = [];
await ServerTestBed.WaitUntilAsync(
await bed.WaitUntilAsync(
async () =>
{
stored = await StoredAsync(server, marta.Id, ct);
@@ -134,7 +142,7 @@ public sealed partial class ServerEndToEndTests
// The site asks for a verification: at its next action toward the site the engine stops and the banner appears
// in /api/engine. Usually still in the first session (two accounts to read in full); if that session already
// ended, in the next one, after the minimum pause (20 minutes at 10×: two real minutes).
// ended, in the next one, after the minimum pause (20 minutes at 5×: four real minutes).
// Alerts on Telegram (M8): token and chat set from Impostazioni ▸ Notifiche; the composition sends through the fake.
const string token = "4839574812:AAF-gettoneDelServerDiProva_123";
var events = """{"verification":true,"disconnection":true,"throttle":true,"backfillDone":true,"diskLow":true,"unknownFormat":true}""";
@@ -142,20 +150,20 @@ public sealed partial class ServerEndToEndTests
var servedBefore = bed.Site.Control.CdnFilesServed;
bed.Site.Control.Set(StopMode.Challenge);
await ServerTestBed.WaitUntilAsync(
await bed.WaitUntilAsync(
async () =>
{
var engine = await bed.JsonAsync(HttpMethod.Get, "/api/engine");
var snapshot = engine.GetProperty("snapshot");
return snapshot.GetProperty("mode").GetString() == "StoppedForVerification" && snapshot.GetProperty("banner").ValueKind == JsonValueKind.Object;
},
TimeSpan.FromSeconds(200),
TimeSpan.FromSeconds(360),
"la striscia di arresto per la verifica in /api/engine");
Assert.AreEqual(ConnectionState.VerificationRequired, (await connection.GetStatusAsync(ct)).State);
TestContext.WriteLine($"CDN: {servedBefore} file prima del fermo, {bed.Site.Control.CdnFilesServed} adesso.");
// The same stop reached Telegram, with the Italian text, and the «Avvisi» list of Attività.
await ServerTestBed.WaitUntilAsync(
await bed.WaitUntilAsync(
() => Task.FromResult(telegram.Requests.Any(r => r.Text.StartsWith("Febe · Instagram chiede una verifica\n", StringComparison.Ordinal))),
TimeSpan.FromSeconds(20),
"il messaggio Telegram della verifica");
@@ -200,7 +208,7 @@ public sealed partial class ServerEndToEndTests
await socket.CloseAsync(WebSocketCloseStatus.NormalClosure, "fine", ct);
}
await ServerTestBed.WaitUntilAsync(() => Task.FromResult(!server.Browser.UserIsDriving), TimeSpan.FromSeconds(10), "la vista chiusa libera il browser");
await bed.WaitUntilAsync(() => Task.FromResult(!server.Browser.UserIsDriving), TimeSpan.FromSeconds(10), "la vista chiusa libera il browser");
}
[TestMethod]
@@ -222,7 +230,7 @@ public sealed partial class ServerEndToEndTests
Assert.IsTrue(server.Browser.IsAvailable, "the browser runs again, with an empty profile");
Assert.AreEqual(ConnectionState.NotConnected, (await connection.GetStatusAsync(ct)).State);
Assert.IsFalse(server.Browser.UserIsDriving);
await ServerTestBed.WaitUntilAsync(
await bed.WaitUntilAsync(
() => Task.FromResult(server.Engine!.Services.Runtime.IsRunning),
TimeSpan.FromSeconds(60),
"il motore di nuovo in funzione, in attesa del collegamento");
@@ -272,7 +280,7 @@ public sealed partial class ServerEndToEndTests
// From the rest page: where the browser starts, and where the engine puts it once nobody is at the browser.
// Page.getFrameTree is answered by the page itself, which DevTools holds back while a navigation is pending:
// «about:blank» here means the engine's rest has committed.
await ServerTestBed.WaitUntilAsync(
await bed.WaitUntilAsync(
async () => await Febe.Browser.Cdp.CdpPageExtensions.GetMainFrameUrlAsync(server.Browser.Cdp, ct) == "about:blank",
TimeSpan.FromSeconds(60),
"la pagina di riposo");
@@ -322,7 +330,7 @@ public sealed partial class ServerEndToEndTests
{
// From the rest page, as in TwoViews…: the previous round ends on a site page, so «about:blank» here means the
// engine's rest after the last view has committed and nothing else navigates.
await ServerTestBed.WaitUntilAsync(
await bed.WaitUntilAsync(
async () => await Febe.Browser.Cdp.CdpPageExtensions.GetMainFrameUrlAsync(browser.Cdp, ct) == "about:blank",
TimeSpan.FromSeconds(60),
"la pagina di riposo");