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:
1 parent
736d241a38
commit
724db13e1b
14 files changed
+1403
-38
No files matched your search
@@ -154,6 +154,45 @@ public sealed partial class ImageContentsTests
|
||||
handovers);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Copie esterne (spec §4.10, §11): /esporta is never made by the image. A VOLUME or a mkdir would give an anonymous
|
||||
/// volume or a folder of the image disk that looks like a mounted folder; Compose and Unraid offer it commented out
|
||||
/// or empty, with FEBE_ESPORTA.
|
||||
/// </summary>
|
||||
[TestMethod]
|
||||
public void TheImageNeverMakesTheExportFolderAndTheTemplatesOfferItOff()
|
||||
{
|
||||
var code = Code(Dockerfile());
|
||||
var volume = code.Split('\n').Single(line => line.StartsWith("VOLUME ", StringComparison.Ordinal));
|
||||
Assert.DoesNotContain("esporta", volume);
|
||||
foreach (var line in code.Split('\n').Where(line => line.Contains("mkdir", StringComparison.Ordinal)))
|
||||
{
|
||||
Assert.DoesNotContain("esporta", line);
|
||||
}
|
||||
|
||||
Assert.DoesNotContain("FEBE_ESPORTA", code, "export is off unless the container declares it");
|
||||
StringAssert.Contains(Dockerfile(), "Niente /esporta qui", "the reason stays next to VOLUME");
|
||||
|
||||
var lines = File.ReadAllText(Repository.PathOf("docker", "compose.yml")).Replace("\r\n", "\n", StringComparison.Ordinal).Split('\n');
|
||||
var mount = lines.Single(line => line.Contains(":/esporta", StringComparison.Ordinal) && line.Contains("FEBE_CARTELLA_ESPORTA", StringComparison.Ordinal));
|
||||
StringAssert.StartsWith(mount.TrimStart(), "# - ", "the mount of /esporta is commented out in compose.yml");
|
||||
var variable = lines.Single(line => line.TrimStart().TrimStart('#').TrimStart().StartsWith("FEBE_ESPORTA:", StringComparison.Ordinal));
|
||||
StringAssert.StartsWith(variable.TrimStart(), "# ", "FEBE_ESPORTA is commented out in compose.yml");
|
||||
var active = lines.Where(line => !line.TrimStart().StartsWith('#') && line.Contains("esporta", StringComparison.OrdinalIgnoreCase)).ToList();
|
||||
Assert.IsEmpty(active, string.Join('\n', active));
|
||||
|
||||
var template = System.Xml.Linq.XDocument.Load(Repository.PathOf("docker", "unraid", "febe.xml")).Root!;
|
||||
var folder = template.Elements("Config").Single(c => (string?)c.Attribute("Target") == "/esporta");
|
||||
Assert.AreEqual("Path", (string?)folder.Attribute("Type"));
|
||||
Assert.AreEqual("false", (string?)folder.Attribute("Required"));
|
||||
Assert.AreEqual(string.Empty, (string?)folder.Attribute("Default"));
|
||||
Assert.AreEqual(string.Empty, folder.Value.Trim(), "no folder of the server by default");
|
||||
var flag = template.Elements("Config").Single(c => (string?)c.Attribute("Target") == "FEBE_ESPORTA");
|
||||
Assert.AreEqual("Variable", (string?)flag.Attribute("Type"));
|
||||
Assert.AreEqual(string.Empty, (string?)flag.Attribute("Default"));
|
||||
Assert.AreEqual(string.Empty, flag.Value.Trim());
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TheToolsTheStartUsesComeWithTheBaseImageAndTheBuildChecksThem()
|
||||
{
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in new issue
Block a user