From 50f5c8150a2a5bac9fb80bff416c7fc962a6de94 Mon Sep 17 00:00:00 2001 From: Alberto Balbo Date: Tue, 1 Dec 2026 14:17:35 +0100 Subject: [PATCH] CI: le prove ferme si chiudono da sole e si vede lo stato della macchina MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Le esecuzioni 502 e 532 si sono fermate per circa mezz'ora con tutte le prove in corso, anche quelle H.265 che non usano browser: i Chromium paralleli non sono la causa, quindi nessun limite. Ogni dotnet test ha ora --blame-hang-timeout 20m senza dump, e durante le prove .gitea/scripts/macchina.sh scrive carico, memoria, scambio e pressione in macchina.log, caricato con i .trx: alla prossima pausa si vedrà se la macchina del runner era sospesa o che cosa le mancava. Co-Authored-By: Claude Opus 5.5 --- .gitea/scripts/macchina.sh | 40 +++++++++++++++++++ .gitea/workflows/rilascio.yml | 4 ++ .gitea/workflows/verifica.yml | 15 +++++-- docs/decisioni.md | 1 + docs/stato.md | 5 +++ .../Packaging/PipelineTests.Riepilogo.cs | 31 ++++++++++++++ tests/Febe.Tests/Packaging/PipelineTests.cs | 13 +++++- 7 files changed, 105 insertions(+), 4 deletions(-) create mode 100644 .gitea/scripts/macchina.sh diff --git a/.gitea/scripts/macchina.sh b/.gitea/scripts/macchina.sh new file mode 100644 index 0000000..f17f095 --- /dev/null +++ b/.gitea/scripts/macchina.sh @@ -0,0 +1,40 @@ +#!/usr/bin/env bash +# The state of the machine while the tests run: every few seconds one line with the time, the load and the available +# memory and swap of the runner host and, where the kernel offers them, its CPU, memory and disk pressure (PSI). Runs +# 502 and 532 stopped for half an hour with every test in progress, browser or not: a hole in the times of this file +# says the host (or the container) was suspended, lines without holes say what it was short of. +# +# .gitea/scripts/macchina.sh [secondi fra una riga e l'altra] [righe, 0 = senza fine] +# +# It runs in the background of the test step, which ends it. Only numbers of the machine: no names, paths or tokens. +set -euo pipefail + +file="${1:?Indica il file da scrivere.}" +ogni="${2:-15}" +righe="${3:-0}" +[[ "$ogni" =~ ^[0-9]+$ && "$righe" =~ ^[0-9]+$ ]] || { echo "I secondi e le righe devono essere numeri interi." >&2; exit 2; } +mkdir -p "$(dirname "$file")" + +# One value of /proc/meminfo, in MB; nothing where there is no /proc. +memoria() { + awk -v nome="$1:" '$1 == nome { printf "%d", $2 / 1024 }' /proc/meminfo 2> /dev/null || true +} + +# The ten-second average of the «some» line of one PSI file; nothing where the kernel does not offer it. +pressione() { + awk '$1 == "some" { sub(/^avg10=/, "", $2); printf "%s", $2 }' "/proc/pressure/$1" 2> /dev/null || true +} + +fatte=0 +while :; do + carico=$(cut -d ' ' -f 1-3 /proc/loadavg 2> /dev/null || true) + printf '%s carico=%s memoria=%s MB scambio=%s MB psi cpu=%s memoria=%s disco=%s\n' \ + "$(date -u +%Y-%m-%dT%H:%M:%SZ)" "$carico" "$(memoria MemAvailable)" "$(memoria SwapFree)" \ + "$(pressione cpu)" "$(pressione memory)" "$(pressione io)" >> "$file" + fatte=$((fatte + 1)) + if ((righe > 0 && fatte >= righe)); then + break + fi + # With no share in the output of the step: killing the script must not leave the step waiting for this sleep. + sleep "$ogni" > /dev/null 2>&1 +done diff --git a/.gitea/workflows/rilascio.yml b/.gitea/workflows/rilascio.yml index 7a57393..a180c75 100644 --- a/.gitea/workflows/rilascio.yml +++ b/.gitea/workflows/rilascio.yml @@ -103,9 +103,13 @@ jobs: - name: Compilazione (avvisi = errori) run: dotnet build Febe.slnx -c Release -nologo -warnaserror + # As in the verification: twenty minutes without a test that starts or ends (the longest take 2 to 3) end the + # run and name the tests in progress, instead of a job that waits for the runner's own limit; no dump: one of + # the test host, with its managed heap, can take gigabytes in the febe-ci package. - name: Prove run: >- dotnet test tests/Febe.Tests -c Release --no-build --nologo + --blame-hang-timeout 20m --blame-hang-dump-type none --logger "trx;LogFileName=prove.trx" --results-directory out/prove # No skipped test: an inconclusive test (for example without Chromium) stops the release. diff --git a/.gitea/workflows/verifica.yml b/.gitea/workflows/verifica.yml index ca7dc5f..a50fc37 100644 --- a/.gitea/workflows/verifica.yml +++ b/.gitea/workflows/verifica.yml @@ -174,10 +174,17 @@ jobs: - name: Compilazione di tutta la soluzione (avvisi = errori) run: dotnet build Febe.slnx -c Release -nologo -warnaserror + # Twenty minutes without a test that starts or ends (the longest take 2 to 3) end the run and name the tests in + # progress, instead of a job that waits for the runner's own limit; no dump: one of the test host, with its + # managed heap, can take gigabytes in the febe-ci package. - name: Prove, seme 13 - run: >- - dotnet test tests/Febe.Tests -c Release --no-build --nologo - --logger "trx;LogFileName=prove-seme-13.trx" --results-directory out/prove + run: | + bash .gitea/scripts/macchina.sh out/prove/macchina.log & + macchina=$! + trap 'kill "$macchina" 2> /dev/null || true' EXIT + dotnet test tests/Febe.Tests -c Release --no-build --nologo \ + --blame-hang-timeout 20m --blame-hang-dump-type none \ + --logger "trx;LogFileName=prove-seme-13.trx" --results-directory out/prove - name: Prove del sito di prova, seme dell'esecuzione if: ${{ !cancelled() && steps.semi.outputs.seme != '' }} @@ -185,6 +192,7 @@ jobs: FEBE_SEME_PROVA: ${{ steps.semi.outputs.seme }} run: >- dotnet test tests/Febe.Tests -c Release --no-build --nologo --filter "TestCategory=SitoDiProva" + --blame-hang-timeout 20m --blame-hang-dump-type none --logger "trx;LogFileName=prove-seme-$FEBE_SEME_PROVA.trx" --results-directory out/prove - name: Riepilogo delle prove @@ -201,6 +209,7 @@ jobs: shopt -s nullglob risultati=(out/prove/*.trx) ((${#risultati[@]} > 0)) || { echo "::warning::Nessun risultato delle prove da conservare."; exit 0; } + [ ! -f out/prove/macchina.log ] || risultati+=(out/prove/macchina.log) bash .gitea/scripts/artefatti.sh verifica "${risultati[@]}" installatore: diff --git a/docs/decisioni.md b/docs/decisioni.md index fb2f378..2a51cda 100644 --- a/docs/decisioni.md +++ b/docs/decisioni.md @@ -661,3 +661,4 @@ Ogni scelta tecnica presa strada facendo, con data e motivo (specifica §15). | 2026-11-29 | Commenti in inglese anche negli script di shell di `.gitea/scripts/` e `installer/`, nei blocchi `run:` dei flussi di `.gitea/workflows/` e in `docker/entrypoint.sh`; restano in italiano i messaggi che una persona legge (`echo`, `::warning::`/`::error::`, nomi dei passi, note della release, istruzioni d'uso), come nel resto del codice. Decisione di Alberto (#43) | La regola «codice e commenti in inglese; interfaccia, documenti e messaggi in italiano» vale per tutto il repository, script compresi: nessuna eccezione per la CI | | 2026-11-29 | **Subito dopo «Scollega», con l'indirizzo della pagina sconosciuto** (il browser non risponde ancora, `FullUrlAsync` dà `null`), Febe aspetta che il browser risponda, entro un limite; se ancora non risponde apre la pagina di accesso (#67). Fatto così: `BrowserConnectionService` chiede l'indirizzo ogni 200 ms (`AddressPoll`, con `IClock`) per al più 10 s (`AddressWait`), poi apre la pagina di accesso o d'inizio; se anche la navigazione non riesce, la finestra resta su e il registro dice «Alberto usa il browser: … non aperta (il browser non risponde).» | Decisione di Alberto del 29 novembre 2026: senza sapere quale pagina mostra il browser non si può dire se è già quella di accesso; aspettare un poco evita di ricaricare una pagina che sta arrivando, e il limite evita di restare fermi | | 2026-11-29 | **Il motore non rimette a riposo la pagina che Alberto ha appena ripreso**: a fine sessione e dopo la guida di Alberto il riposo (`about:blank`) si dà solo se, ottenuto il turno, Alberto non guida il browser e l'interruttore non è su Verifica o Scollegato (`KeepsPageAfterWaitingForTurn`); `IsRunning` si accende in `StartAsync` prima di avviare il lavoro | Le prove del desktop su #67 cadevano a volte: fra il controllo e il turno Alberto poteva riprendere il browser, e il motore gli toglieva la pagina. Resta una finestra stretta fra il turno e la navigazione, scritta in `docs/stato.md` | +| 2026-12-01 | **Prove ferme nella CI (502 e 532): `--blame-hang-timeout 20m --blame-hang-dump-type none` su ogni `dotnet test` e lo stato della macchina durante le prove** (`.gitea/scripts/macchina.sh`: ogni 15 s ora, carico, memoria, scambio e pressione PSI in `macchina.log`, nel pacchetto `febe-ci` con i `.trx`). Nessun limite ai Chromium paralleli | Nelle due pause si sono fermate insieme tutte le prove in corso, anche le H.265, che non usano browser (aperti solo 5 e 3 Chromium), e tutto è ripartito insieme: un limite a 4 Chromium non le avrebbe evitate e allunga le prove (da 242 a 332 s in una misura sola, nell'immagine della CI in locale). Il quadro fa pensare alla macchina del runner (memoria, disco o sospensione), ma non è verificato: un buco negli orari di `macchina.log` dirà una sospensione, le righe senza buchi che cosa mancava. Venti minuti senza una prova che comincia o finisce chiudono l'esecuzione con i nomi delle prove in corso; niente dump, che può pesare gigabyte nel pacchetto | diff --git a/docs/stato.md b/docs/stato.md index a81dd7f..fa5ef11 100644 --- a/docs/stato.md +++ b/docs/stato.md @@ -51,6 +51,11 @@ fra le sessioni; ciò che è da fare si legge nelle issue aperte. (anche le prove H.265 da 1 s), e due prove d'interfaccia nuove sono scadute in quella pausa; la stessa revisione nell'immagine della CI in locale è verde in 10 m 33 s e nel codice di E3 non c'è nulla che blocchi i thread. Se si ripete, il prossimo passo è limitare i Chromium paralleli nelle prove (`UiBrowser`) e aggiungere `--blame-hang`. + Si è ripetuto nella 532 (29/11, 28 minuti). I `.trx` dicono che **i Chromium non sono la causa**: si sono fermate + insieme anche le prove H.265, con 3 e 5 browser aperti. Perciò nessun limite ai browser; aggiunti (1/12) + `--blame-hang-timeout 20m` e `macchina.log` (carico, memoria e pressione della macchina durante le prove, nel pacchetto + `febe-ci`). La causa resta da trovare: da guardare la macchina del runner, memoria, scambio, disco e sospensione, del + 28/11 11:38–12:20 e del 29/11 12:55–13:23 UTC. La 510 è stata verde alla seconda prova: al primo giro la prova da capo a fondo con il sito di prova (`TheRealServerCollectsFromTheTestSite…`) ha passato i 90 s, come già una volta prima di E3 (2 min 10 s nella 107). Dopo l'unione la 518 di main è caduta nell'immagine su `APreviewPastItsBudgetSaysToUseTheFolderOfTheCopies`: con diff --git a/tests/Febe.Tests/Packaging/PipelineTests.Riepilogo.cs b/tests/Febe.Tests/Packaging/PipelineTests.Riepilogo.cs index 1a5f395..c9de982 100644 --- a/tests/Febe.Tests/Packaging/PipelineTests.Riepilogo.cs +++ b/tests/Febe.Tests/Packaging/PipelineTests.Riepilogo.cs @@ -58,6 +58,37 @@ public sealed partial class PipelineTests } } + /// + /// 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. + /// + [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(); + /// riepilogo-prove.sh with no skipped test allowed, on one .trx file of the given results. private async Task<(int Code, string Output, string Errors, string Report)> RunSummaryAsync(string bash, params (string Outcome, string Name, string? Message)[] results) { diff --git a/tests/Febe.Tests/Packaging/PipelineTests.cs b/tests/Febe.Tests/Packaging/PipelineTests.cs index 609744b..477a53b 100644 --- a/tests/Febe.Tests/Packaging/PipelineTests.cs +++ b/tests/Febe.Tests/Packaging/PipelineTests.cs @@ -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"); } } -- 2.54.1