E5: il lavoratore delle copie automatiche, all'avvio e ogni ora
AutoExportWorker copia da solo nelle cartelle con «Automatica» accesa: il giro di recupero all'avvio e ogni ora (IClock), una passata due minuti dopo l'ultima riga di _febe.jsonl (il segnale parte da LibraryIngest, anche per le righe scritte in ritardo), subito con un segnale urgente. Mai durante una sessione del motore: aspetta e dice perché; i lavori di Alberto vengono prima e, finiti, il lavoro automatico spostato riprende da solo (risposta 49). Al giro riprova le cartelle in pausa (una copia manuale «In pausa» resta di Alberto, risposta 48) e tutti i «Non riuscito» (risposta 50b); «Interrompi» lo ferma fino alla fine della sosta (risposta 53). Un lavoro finito non ne fa partire un altro da solo, così un file che non cambia torna solo al giro. La composizione lo avvia solo nell'avvio normale (mai nella dimostrazione) e lo ferma per primo alla chiusura. Prove: AutoExportWorkerTests (le prove di accettazione di §15: «Tolto» e «Superato» non si ricopiano, una cartella irraggiungibile va in pausa e un giro dopo riprende, nessuna copia durante una sessione), il segnale del giornale, la composizione. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
0ff4a0d632
commit
e66e322d35
12 files changed
+1821
-5
No files matched your search
@@ -0,0 +1,54 @@
|
||||
using System.Diagnostics;
|
||||
using Febe.Core.Export;
|
||||
using Febe.Tests.Desktop.Support;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace Febe.Tests.Desktop;
|
||||
|
||||
/// <summary>
|
||||
/// The automatic export in the composition (tappa E5, D8): the worker runs only in a normal start (never with a
|
||||
/// configuration problem; the demo never starts it), runs its start-up round at once, and the stop ends it first.
|
||||
/// </summary>
|
||||
[TestClass]
|
||||
public sealed class AutoExportCompositionTests
|
||||
{
|
||||
public TestContext TestContext { get; set; } = null!;
|
||||
|
||||
[TestMethod]
|
||||
[Timeout(60_000, CooperativeCancellation = true)]
|
||||
public async Task TheWorkerRunsInANormalStartAndTheStopEndsIt()
|
||||
{
|
||||
var ct = TestContext.CancellationToken;
|
||||
AutoExportWorker worker;
|
||||
await using (var bed = await DesktopTestBed.StartAsync())
|
||||
{
|
||||
Assert.IsEmpty(bed.App.Problems);
|
||||
worker = bed.App.Web.Services.GetRequiredService<AutoExportWorker>();
|
||||
var watch = Stopwatch.StartNew();
|
||||
while ((await worker.StatusAsync(ct)).LastRound is null)
|
||||
{
|
||||
Assert.IsLessThan(TimeSpan.FromSeconds(30), watch.Elapsed, "the start-up round did not run");
|
||||
await Task.Delay(20, ct);
|
||||
}
|
||||
|
||||
var status = await worker.StatusAsync(ct);
|
||||
Assert.IsTrue(status.Running);
|
||||
Assert.IsFalse(status.AnyAutomatic, "«Automatica» is off by default");
|
||||
Assert.AreEqual(status.LastRound + TimeSpan.FromHours(1), status.NextRound);
|
||||
}
|
||||
|
||||
Assert.IsFalse(worker.Running, "the stop ends the worker");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Timeout(60_000, CooperativeCancellation = true)]
|
||||
public async Task WithAStartupProblemTheWorkerDoesNotRun()
|
||||
{
|
||||
await using var bed = await DesktopTestBed.StartAsync(shell: new FakeDesktopShell { RuntimeVersion = null });
|
||||
Assert.IsNotEmpty(bed.App.Problems);
|
||||
var worker = bed.App.Web.Services.GetRequiredService<AutoExportWorker>();
|
||||
await Task.Delay(200, TestContext.CancellationToken);
|
||||
Assert.IsFalse(worker.Running);
|
||||
Assert.IsNull((await worker.StatusAsync(TestContext.CancellationToken)).LastRound);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user