Merge remote-tracking branch 'origin/main' into correzione/prova-da-capo-a-fondo
Revisione: la causa è l'orologio che somma le attese, e «Controlla ora» si chiede di nuovo prima di aspettare la verifica, perché a sessione finita la pausa può arrivare a 90 minuti. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
commit
4dc3a83a51
9 files changed
+125
-18
No files matched your search
@@ -58,6 +58,37 @@ public sealed partial class PipelineTests
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The state of the machine sampled while the tests run (runs 502 and 532 stopped with every test in progress): the
|
||||
/// test step starts it, ends it and keeps the result of the tests; the log goes up with the .trx files.
|
||||
/// </summary>
|
||||
[TestMethod]
|
||||
public async Task TheVerificationKeepsTheStateOfTheMachineDuringTheTests()
|
||||
{
|
||||
var tests = Code(Workflow("verifica.yml"));
|
||||
StringAssert.Contains(tests, "bash .gitea/scripts/macchina.sh out/prove/macchina.log &");
|
||||
StringAssert.Contains(tests, "trap 'kill \"$macchina\" 2> /dev/null || true' EXIT");
|
||||
StringAssert.Contains(tests, "risultati+=(out/prove/macchina.log)");
|
||||
|
||||
CiPath("scripts", "macchina.sh");
|
||||
var bash = RequireBash();
|
||||
using var folder = new TempFolder("febe-macchina");
|
||||
var log = folder.Combine("prove", "macchina.log");
|
||||
var run = await RunProcessAsync(bash, ["--noprofile", "--norc", ".gitea/scripts/macchina.sh", log.Replace('\\', '/'), "0", "3"]);
|
||||
Assert.AreEqual(0, run.Code, run.Errors);
|
||||
var lines = await File.ReadAllLinesAsync(log, TestContext.CancellationToken);
|
||||
Assert.HasCount(3, lines);
|
||||
foreach (var line in lines)
|
||||
{
|
||||
StringAssert.Matches(line, MachineLine());
|
||||
}
|
||||
|
||||
Assert.AreEqual(2, (await RunProcessAsync(bash, ["--noprofile", "--norc", ".gitea/scripts/macchina.sh", log.Replace('\\', '/'), "presto"])).Code);
|
||||
}
|
||||
|
||||
[System.Text.RegularExpressions.GeneratedRegex(@"^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\dZ carico=[\d. ]* memoria=\d* MB scambio=\d* MB psi cpu=[\d.]* memoria=[\d.]* disco=[\d.]*$")]
|
||||
private static partial System.Text.RegularExpressions.Regex MachineLine();
|
||||
|
||||
/// <summary>riepilogo-prove.sh with no skipped test allowed, on one .trx file of the given results.</summary>
|
||||
private async Task<(int Code, string Output, string Errors, string Report)> RunSummaryAsync(string bash, params (string Outcome, string Name, string? Message)[] results)
|
||||
{
|
||||
|
||||
@@ -122,12 +122,23 @@ public sealed partial class PipelineTests
|
||||
}
|
||||
|
||||
// tests/Febe.Tests.Windows runs only on Windows: never «dotnet test» on the solution or without a project.
|
||||
// Every run of the tests ends, naming the culprit, when a test is stuck for 20 minutes (no dump of the test host).
|
||||
foreach (var name in new[] { "verifica.yml", "rilascio.yml" })
|
||||
{
|
||||
foreach (Match test in DotnetTest().Matches(Code(Workflow(name))))
|
||||
var code = Code(Workflow(name));
|
||||
var runs = 0;
|
||||
foreach (Match test in DotnetTest().Matches(code))
|
||||
{
|
||||
Assert.AreEqual("tests/Febe.Tests", test.Groups["target"].Value, $"{name}: {test.Value}");
|
||||
var end = code.IndexOf("--results-directory", test.Index, StringComparison.Ordinal);
|
||||
if (code.AsSpan(test.Index + test.Length).StartsWith(" -c Release") && end > test.Index)
|
||||
{
|
||||
runs++;
|
||||
StringAssert.Contains(code[test.Index..end], "--blame-hang-timeout 20m --blame-hang-dump-type none", $"{name}: {test.Value}");
|
||||
}
|
||||
}
|
||||
|
||||
Assert.AreEqual(name == "verifica.yml" ? 2 : 1, runs, $"{name}: le esecuzioni delle prove");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -86,12 +86,7 @@ public sealed partial class ServerEndToEndTests
|
||||
Assert.AreEqual(ConnectionState.Connected, (await connection.GetStatusAsync(ct)).State);
|
||||
|
||||
// «Controlla ora».
|
||||
var check = await bed.JsonAsync(HttpMethod.Post, $"/api/accounts/{marta.Id}/check-now");
|
||||
if (check.GetProperty("status").GetString() == "needsConfirmation")
|
||||
{
|
||||
check = await bed.JsonAsync(HttpMethod.Post, $"/api/accounts/{marta.Id}/check-now", $$"""{"token":"{{check.GetProperty("token").GetString()}}"}""");
|
||||
}
|
||||
|
||||
var check = await CheckNowAsync(bed, marta.Id);
|
||||
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.
|
||||
@@ -103,9 +98,8 @@ 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.
|
||||
// The session is the one Alberto asked for, and starts from the account he chose: not a session of the engine's
|
||||
// own that began at «Ho finito», before his request.
|
||||
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()}");
|
||||
@@ -141,8 +135,9 @@ public sealed partial class ServerEndToEndTests
|
||||
TestContext.WriteLine($"Ricette: {string.Join(", ", recipes.Select(r => r.Code).Distinct())}; file di marta.prova: {stored.Count}.");
|
||||
|
||||
// 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 5×: four real minutes).
|
||||
// in /api/engine. Usually still in the first session (two accounts to read in full). Were that session over, or
|
||||
// ending right now, the next one would come 20 to 90 minutes later (4 to 18 real ones at 5×): «Controlla ora» again
|
||||
// brings it to the minimum pause, 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}""";
|
||||
@@ -150,6 +145,7 @@ public sealed partial class ServerEndToEndTests
|
||||
|
||||
var servedBefore = bed.Site.Control.CdnFilesServed;
|
||||
bed.Site.Control.Set(StopMode.Challenge);
|
||||
await CheckNowAsync(bed, marta.Id);
|
||||
await bed.WaitUntilAsync(
|
||||
async () =>
|
||||
{
|
||||
@@ -385,6 +381,16 @@ public sealed partial class ServerEndToEndTests
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>«Controlla ora», confirmed when Febe asks for it.</summary>
|
||||
private static async Task<JsonElement> CheckNowAsync(ServerTestBed bed, long accountId)
|
||||
{
|
||||
var path = $"/api/accounts/{accountId}/check-now";
|
||||
var check = await bed.JsonAsync(HttpMethod.Post, path);
|
||||
return check.GetProperty("status").GetString() == "needsConfirmation"
|
||||
? await bed.JsonAsync(HttpMethod.Post, path, $$"""{"token":"{{check.GetProperty("token").GetString()}}"}""")
|
||||
: check;
|
||||
}
|
||||
|
||||
private static async Task<List<(Entry Entry, Media Media)>> StoredAsync(Febe.Server.FebeServer server, long accountId, CancellationToken ct)
|
||||
{
|
||||
var list = new List<(Entry, Media)>();
|
||||
|
||||
@@ -21,8 +21,8 @@ namespace Febe.Tests.Server.Support;
|
||||
/// in a temporary Data/Library/Import folder, on free ports and a free display. Never Instagram: the browser only ever
|
||||
/// sees 127.0.0.1. Time runs five times faster (<see cref="ScaledClock"/>) in a time zone where it is around noon now, so
|
||||
/// that the engine is inside its active window whatever the hour of the test. Five and not more: the engine's few minutes
|
||||
/// and pauses stay short, and the limits of a real page (30 seconds to load, 20 for its data) stay seconds on a loaded
|
||||
/// runner.
|
||||
/// and pauses stay short, and the limits of a real page (30 seconds to load, 20 for its data) are six and four real
|
||||
/// seconds.
|
||||
/// </summary>
|
||||
internal sealed class ServerTestBed : IAsyncDisposable
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user