E2: misure del filtro Copie, migrazione 0004 e prove di web e Docker

Il filtro «Copie» con 200.000 elementi stava al limite dei 250 ms
(«Copiati» 249 ms): la migrazione 0004 aggiunge solo l'indice
ix_media_sha256_entry e la finestra scende a 160 ms. Totali e giorni
contano «Copiati» partendo dalle copie e gli altri valori con un solo
passaggio sui file dietro gli elenchi degli SHA-256 copiati (1,5 s ->
0,7 s); hanno un limite loro di 3 s, scritto in decisioni.md con le
misure.

«Copia di nuovo» sceglie un file dell'account che è sul disco: prima
prendeva il primo con quello SHA-256 e, nella demo, a certe ore non
scriveva nulla.

Nuove prove: API delle copie, coerenza della demo, interfaccia nel
browser, opzioni del server, avvio del contenitore con /esporta,
contenuto dell'immagine e modelli, migrazione 4 e scala.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Alby96andClaude Opus 5.5 committed 2026-11-27 15:29:59 +01:00
1 parent 736d241a38
commit 724db13e1b
14 files changed
+1403 -38

No files matched your search

+43 -2
View File
@@ -63,9 +63,11 @@ public sealed partial class PackagingTests
Assert.Inconclusive(reason);
}
// A first start: /dati and /libreria just created by Docker (root), a folder of photos inside the library.
// A first start: /dati and /libreria just created by Docker (root), a folder of photos inside the library, and
// an /esporta mounted with a folder of copies, while the copies are not declared.
using var temp = new TempFolder("avvio-contenitore");
Directory.CreateDirectory(temp.Combine("libreria", "foto"));
Directory.CreateDirectory(temp.Combine("esporta", "usb"));
var whoAmI = temp.Combine("dati", "home", "chi");
var (code, _, errors) = await RunEntrypointAsync(temp, "/bin/sh", "-c", $"id -u > '{whoAmI}'");
Assert.AreEqual(0, code, errors);
@@ -75,12 +77,40 @@ public sealed partial class PackagingTests
Assert.IsFalse(File.Exists(temp.Combine("dati", "seccomp.json")), "the profile Docker reads stays out of /dati");
Assert.AreEqual($"{Nobody}:{Nobody}", (await StatAsync(temp.Combine("libreria"))).Split(' ')[0]);
Assert.AreEqual("0:0", (await StatAsync(temp.Combine("libreria", "foto"))).Split(' ')[0], "the library is never changed recursively");
Assert.AreEqual("0:0", (await StatAsync(temp.Combine("esporta"))).Split(' ')[0], "/esporta is left alone while the copies are not declared");
// A /dati/home left by a start as root (a real folder): given back to the user.
await RunAsync("chown", "0:0", temp.Combine("dati", "home"));
(code, _, errors) = await RunEntrypointAsync(temp, "true");
Assert.AreEqual(0, code, errors);
Assert.AreEqual($"{Nobody}:{Nobody} 700", await StatAsync(temp.Combine("dati", "home")));
Assert.AreEqual("0:0", (await StatAsync(temp.Combine("esporta"))).Split(' ')[0]);
(code, _, errors) = await RunEntrypointAsync(temp, ["true"], ("FEBE_ESPORTA", "no"));
Assert.AreEqual(0, code, errors);
Assert.AreEqual("0:0", (await StatAsync(temp.Combine("esporta"))).Split(' ')[0], "only the values of a switch declare the copies");
// Copie esterne declared (FEBE_ESPORTA=1): the root of /esporta, owned by root, goes to the user; what is inside
// (files of Alberto, other copies) never changes owner.
(code, _, errors) = await RunEntrypointAsync(temp, ["true"], ("FEBE_ESPORTA", "1"));
Assert.AreEqual(0, code, errors);
Assert.AreEqual($"{Nobody}:{Nobody}", (await StatAsync(temp.Combine("esporta"))).Split(' ')[0]);
Assert.AreEqual("0:0", (await StatAsync(temp.Combine("esporta", "usb"))).Split(' ')[0], "/esporta is never changed recursively");
// Declared with --esporta among the arguments of the server: the same. A root of another user stays his.
await RunAsync("chown", "0:0", temp.Combine("esporta"));
(code, _, errors) = await RunEntrypointAsync(temp, "true", "--esporta");
Assert.AreEqual(0, code, errors);
Assert.AreEqual($"{Nobody}:{Nobody}", (await StatAsync(temp.Combine("esporta"))).Split(' ')[0]);
await RunAsync("chown", "1234:1234", temp.Combine("esporta"));
(code, _, errors) = await RunEntrypointAsync(temp, ["true"], ("FEBE_ESPORTA", "1"));
Assert.AreEqual(0, code, errors);
Assert.AreEqual("1234:1234", (await StatAsync(temp.Combine("esporta"))).Split(' ')[0], "only a root owned by root is given to the user");
// A missing /esporta is never created, declared or not.
Directory.Delete(temp.Combine("esporta"), recursive: true);
(code, _, errors) = await RunEntrypointAsync(temp, ["true", "--esporta"], ("FEBE_ESPORTA", "1"));
Assert.AreEqual(0, code, errors);
Assert.IsFalse(Directory.Exists(temp.Combine("esporta")), "the start never creates /esporta");
}
[TestMethod]
@@ -206,7 +236,12 @@ public sealed partial class PackagingTests
}
/// <summary>The real entrypoint, with /dati, /libreria, /esporta and the profile of the image moved into <paramref name="temp"/>.</summary>
private async Task<(int Code, string Output, string Errors)> RunEntrypointAsync(TempFolder temp, params string[] command)
private Task<(int Code, string Output, string Errors)> RunEntrypointAsync(TempFolder temp, params string[] command) =>
RunEntrypointAsync(temp, command, []);
/// <summary>The same, with variables of the container (FEBE_ESPORTA is never taken from the machine of the tests).</summary>
private async Task<(int Code, string Output, string Errors)> RunEntrypointAsync(
TempFolder temp, string[] command, params (string Name, string Value)[] variables)
{
var text = await File.ReadAllTextAsync(Repository.PathOf("docker", "entrypoint.sh"), TestContext.CancellationToken);
var image = temp.Combine("immagine-seccomp.json");
@@ -229,6 +264,12 @@ public sealed partial class PackagingTests
start.Environment["PUID"] = Nobody.ToString(System.Globalization.CultureInfo.InvariantCulture);
start.Environment["PGID"] = Nobody.ToString(System.Globalization.CultureInfo.InvariantCulture);
start.Environment.Remove("FEBE_ESPORTA");
foreach (var (name, value) in variables)
{
start.Environment[name] = value;
}
using var process = Process.Start(start)!;
var output = process.StandardOutput.ReadToEndAsync(TestContext.CancellationToken);
var errors = process.StandardError.ReadToEndAsync(TestContext.CancellationToken);