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
@@ -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 <file> [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
|
||||||
@@ -103,9 +103,13 @@ jobs:
|
|||||||
- name: Compilazione (avvisi = errori)
|
- name: Compilazione (avvisi = errori)
|
||||||
run: dotnet build Febe.slnx -c Release -nologo -warnaserror
|
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
|
- name: Prove
|
||||||
run: >-
|
run: >-
|
||||||
dotnet test tests/Febe.Tests -c Release --no-build --nologo
|
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
|
--logger "trx;LogFileName=prove.trx" --results-directory out/prove
|
||||||
|
|
||||||
# No skipped test: an inconclusive test (for example without Chromium) stops the release.
|
# No skipped test: an inconclusive test (for example without Chromium) stops the release.
|
||||||
|
|||||||
@@ -174,10 +174,17 @@ jobs:
|
|||||||
- name: Compilazione di tutta la soluzione (avvisi = errori)
|
- name: Compilazione di tutta la soluzione (avvisi = errori)
|
||||||
run: dotnet build Febe.slnx -c Release -nologo -warnaserror
|
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
|
- name: Prove, seme 13
|
||||||
run: >-
|
run: |
|
||||||
dotnet test tests/Febe.Tests -c Release --no-build --nologo
|
bash .gitea/scripts/macchina.sh out/prove/macchina.log &
|
||||||
--logger "trx;LogFileName=prove-seme-13.trx" --results-directory out/prove
|
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
|
- name: Prove del sito di prova, seme dell'esecuzione
|
||||||
if: ${{ !cancelled() && steps.semi.outputs.seme != '' }}
|
if: ${{ !cancelled() && steps.semi.outputs.seme != '' }}
|
||||||
@@ -185,6 +192,7 @@ jobs:
|
|||||||
FEBE_SEME_PROVA: ${{ steps.semi.outputs.seme }}
|
FEBE_SEME_PROVA: ${{ steps.semi.outputs.seme }}
|
||||||
run: >-
|
run: >-
|
||||||
dotnet test tests/Febe.Tests -c Release --no-build --nologo --filter "TestCategory=SitoDiProva"
|
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
|
--logger "trx;LogFileName=prove-seme-$FEBE_SEME_PROVA.trx" --results-directory out/prove
|
||||||
|
|
||||||
- name: Riepilogo delle prove
|
- name: Riepilogo delle prove
|
||||||
@@ -201,6 +209,7 @@ jobs:
|
|||||||
shopt -s nullglob
|
shopt -s nullglob
|
||||||
risultati=(out/prove/*.trx)
|
risultati=(out/prove/*.trx)
|
||||||
((${#risultati[@]} > 0)) || { echo "::warning::Nessun risultato delle prove da conservare."; exit 0; }
|
((${#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[@]}"
|
bash .gitea/scripts/artefatti.sh verifica "${risultati[@]}"
|
||||||
|
|
||||||
installatore:
|
installatore:
|
||||||
|
|||||||
+2
-1
@@ -661,4 +661,5 @@ 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 | 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 | **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-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 da capo a fondo: il tempo scorre cinque volte più in fretta con un orologio che non somma le attese** (`ScaledClock`, uno solo per `ServerTestBed` e `DesktopBed`: `Now` dipende solo dal tempo vero) **e l'unica sessione è quella chiesta con «Controlla ora»** (la prima di suo è oltre la durata della prova). `CompressedClock` resta per le prove di raccolta, con un flusso per volta. Quando un'attesa scade, la prova dice che cosa faceva Febe (motore, interruttore, sessioni, coda, azioni, eventi, stato dei file, coda del registro; mai corpi, cookie o indirizzi dei file). Sostituisce per queste prove la riga del 13 ottobre (10×) | `TheRealServerCollectsFromTheTestSite…` cadeva a volte dopo 90 s senza dire perché. `CompressedClock` sommava le attese dei lavori di sottofondo (misurato: circa 34× invece di 10×, a salti di decine di secondi): i 30 s di una pagina vera e i pochi minuti della prima sessione finivano subito; in più il motore apriva la sua sessione a «Ho finito», prima di «Controlla ora», con un altro account per primo. Dopo la sessione i file aspettano la prossima, 20 minuti (120 s veri): allungare il limite non bastava |
|
| 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 |
|
||||||
|
| 2026-12-01 | **Prove da capo a fondo: il tempo scorre cinque volte più in fretta con un orologio che non somma le attese** (`ScaledClock`, uno solo per `ServerTestBed` e `DesktopBed`: `Now` dipende solo dal tempo vero) **e l'unica sessione è quella chiesta con «Controlla ora»** (la prima di suo è oltre la durata della prova). `CompressedClock` resta per le prove di raccolta, con un flusso per volta. Quando un'attesa scade, la prova dice che cosa faceva Febe (motore, interruttore, sessioni, coda, azioni, eventi, stato dei file, coda del registro; mai corpi, cookie o indirizzi dei file). Sostituisce per queste prove la riga del 13 ottobre (10×) | `TheRealServerCollectsFromTheTestSite…` cadeva a volte dopo 90 s senza dire perché. `CompressedClock` sommava le attese dei lavori di sottofondo (misurato: circa 34× invece di 10×, a salti di decine di secondi): i 30 s di una pagina vera e i pochi minuti della prima sessione finivano subito, e il controllo di marta.prova falliva (riprovato un'ora dopo) o i suoi file restavano in coda. Dopo la sessione i file aspettano la prossima, almeno 20 minuti (120 s veri): allungare il limite non bastava. La causa è l'orologio: con quello nuovo, anche lasciando al motore la sua sessione a «Ho finito» (un altro account per primo in 35 giri su 40), 40 giri su 40 sono passati; la sola sessione chiesta rende certo l'ordine. Senza più la sessione del motore, «Controlla ora» si chiede di nuovo prima di aspettare la verifica: altrimenti, a sessione finita, la pausa è fra 20 e 90 minuti |
|
||||||
@@ -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
|
(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
|
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`.
|
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
|
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).
|
(`TheRealServerCollectsFromTheTestSite…`) ha passato i 90 s, come già una volta prima di E3 (2 min 10 s nella 107).
|
||||||
Riaccaduto il 1º dicembre (551): era la prova, non Febe. Corretta con un orologio che non somma le attese e con la
|
Riaccaduto il 1º dicembre (551): era la prova, non Febe. Corretta con un orologio che non somma le attese e con la
|
||||||
|
|||||||
@@ -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>
|
/// <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)
|
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.
|
// 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 (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}");
|
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);
|
Assert.AreEqual(ConnectionState.Connected, (await connection.GetStatusAsync(ct)).State);
|
||||||
|
|
||||||
// «Controlla ora».
|
// «Controlla ora».
|
||||||
var check = await bed.JsonAsync(HttpMethod.Post, $"/api/accounts/{marta.Id}/check-now");
|
var check = await CheckNowAsync(bed, marta.Id);
|
||||||
if (check.GetProperty("status").GetString() == "needsConfirmation")
|
|
||||||
{
|
|
||||||
check = await bed.JsonAsync(HttpMethod.Post, $"/api/accounts/{marta.Id}/check-now", $$"""{"token":"{{check.GetProperty("token").GetString()}}"}""");
|
|
||||||
}
|
|
||||||
|
|
||||||
Assert.AreEqual("queued", check.GetProperty("status").GetString(), check.GetProperty("message").GetString());
|
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.
|
// 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.IsTrue(actions.All(a => a.SessionId is not null), "every counted action belongs to a session");
|
||||||
Assert.IsNotNull(await server.Database.Sessions.GetLastAsync(ct));
|
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
|
// The session is the one Alberto asked for, and starts from the account he chose: not a session of the engine's
|
||||||
// engine's own that began at «Ho finito») leaves little of these few minutes to marta.prova, and once they end the
|
// own that began at «Ho finito», before his request.
|
||||||
// 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)
|
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()}");
|
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}.");
|
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
|
// 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
|
// in /api/engine. Usually still in the first session (two accounts to read in full). Were that session over, or
|
||||||
// ended, in the next one, after the minimum pause (20 minutes at 5×: four real minutes).
|
// 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.
|
// Alerts on Telegram (M8): token and chat set from Impostazioni ▸ Notifiche; the composition sends through the fake.
|
||||||
const string token = "4839574812:AAF-gettoneDelServerDiProva_123";
|
const string token = "4839574812:AAF-gettoneDelServerDiProva_123";
|
||||||
var events = """{"verification":true,"disconnection":true,"throttle":true,"backfillDone":true,"diskLow":true,"unknownFormat":true}""";
|
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;
|
var servedBefore = bed.Site.Control.CdnFilesServed;
|
||||||
bed.Site.Control.Set(StopMode.Challenge);
|
bed.Site.Control.Set(StopMode.Challenge);
|
||||||
|
await CheckNowAsync(bed, marta.Id);
|
||||||
await bed.WaitUntilAsync(
|
await bed.WaitUntilAsync(
|
||||||
async () =>
|
async () =>
|
||||||
{
|
{
|
||||||
@@ -385,6 +381,16 @@ public sealed partial class ServerEndToEndTests
|
|||||||
return false;
|
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)
|
private static async Task<List<(Entry Entry, Media Media)>> StoredAsync(Febe.Server.FebeServer server, long accountId, CancellationToken ct)
|
||||||
{
|
{
|
||||||
var list = new List<(Entry, Media)>();
|
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
|
/// 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
|
/// 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
|
/// 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
|
/// and pauses stay short, and the limits of a real page (30 seconds to load, 20 for its data) are six and four real
|
||||||
/// runner.
|
/// seconds.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal sealed class ServerTestBed : IAsyncDisposable
|
internal sealed class ServerTestBed : IAsyncDisposable
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in new issue
Block a user