Regole scritte per le puntate prima del modello pronto, backup di account_rewards, partizioni e via DB_PORT e PORT (#49)
Quattro discordanze fra codice, regole e documenti trovate nell'analisi della issue #49, chiuse come ha deciso Alberto. Prima del modello pronto, con valore ignoto e con l'apprendimento spento un'asta in Attiva punta entro i paletti: il codice resta com'è e l'eccezione alla regola dell'unico decisore ora è scritta (ADR 0018, CLAUDE.md, nota all'ADR 0011, commenti di BidStrategy), con la guida che avverte che con paletti e rischio a zero di fabbrica la spesa non ha tetto. Il backup notturno copiava tutte le tabelle non partizionate tranne account_rewards, che Bidoo non garantisce di ridare: ora c'è, e una prova confronta l'elenco con le migrazioni. La partizione del mese dopo nasce a ogni manutenzione, non il giorno 25: si correggono commento, architettura e ADR 0004, il codice non cambia. DB_PORT e PORT non servivano (la porta del database sta in DB_HOST, quella dell'interfaccia nella mappatura di Unraid) e contraddicevano README e docker.md: il programma non le legge più, una variabile rimasta si ignora con una riga di registro all'avvio, e fuori dal container la porta si sceglie con --porta, usato anche dalla sonda --salute e dall'ambiente di release di VS Code (ADR 0019, scostamento dalla specifica §10.1). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit a4889aa2cc99a05ac808f450ed9171aff8a49ff2)
This commit is contained in:
1 parent
1cc52a73c1
commit
edc6362fa5
25 files changed
+352
-66
No files matched your search
@@ -78,19 +78,69 @@ public class EnvConfigTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Predefiniti_e_porta_separata()
|
||||
public void Predefiniti_senza_variabili_tolte()
|
||||
{
|
||||
var env = new Dictionary<string, string?> { ["DB_HOST"] = "db", ["DB_PORT"] = "6000", ["DB_PASSWORD"] = "x" };
|
||||
var env = new Dictionary<string, string?> { ["DB_HOST"] = "db", ["DB_PASSWORD"] = "x" };
|
||||
var cfg = EnvConfig.Read(k => env.GetValueOrDefault(k), Array.Empty<string>());
|
||||
Assert.Equal("db", cfg.DbHost);
|
||||
Assert.Equal(6000, cfg.DbPort);
|
||||
Assert.Equal(5432, cfg.DbPort);
|
||||
Assert.Equal("admin", cfg.DbUser);
|
||||
Assert.Equal("autobidder", cfg.DbName);
|
||||
Assert.Equal(8080, cfg.HttpPort);
|
||||
Assert.False(cfg.HasUiPassword);
|
||||
Assert.Equal("/config", cfg.ConfigDir);
|
||||
Assert.Empty(cfg.IgnoredVariables);
|
||||
Assert.Null(cfg.IgnoredVariablesNotice());
|
||||
Assert.DoesNotContain("x", cfg.ToDbConfig().Describe());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void La_porta_del_database_si_legge_solo_da_DB_HOST()
|
||||
{
|
||||
var env = new Dictionary<string, string?> { ["DB_HOST"] = "db:6000", ["DB_PASSWORD"] = "x" };
|
||||
var cfg = EnvConfig.Read(k => env.GetValueOrDefault(k), Array.Empty<string>());
|
||||
Assert.Equal("db", cfg.DbHost);
|
||||
Assert.Equal(6000, cfg.DbPort);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void DB_PORT_e_PORT_si_ignorano_e_l_avviso_non_ha_valori()
|
||||
{
|
||||
var env = new Dictionary<string, string?> { ["DB_HOST"] = "db", ["DB_PORT"] = "6001", ["PORT"] = "9001", ["DB_PASSWORD"] = "x" };
|
||||
var cfg = EnvConfig.Read(k => env.GetValueOrDefault(k), Array.Empty<string>());
|
||||
Assert.Equal(5432, cfg.DbPort);
|
||||
Assert.Equal(8080, cfg.HttpPort);
|
||||
Assert.Equal(new[] { "DB_PORT", "PORT" }, cfg.IgnoredVariables);
|
||||
|
||||
var notice = cfg.IgnoredVariablesNotice()!;
|
||||
Assert.StartsWith("Variabili ignorate: DB_PORT e PORT.", notice);
|
||||
Assert.Contains("DB_HOST (host:porta)", notice);
|
||||
Assert.Contains("8080", notice);
|
||||
Assert.DoesNotContain("6001", notice);
|
||||
Assert.DoesNotContain("9001", notice);
|
||||
|
||||
var onlyDb = EnvConfig.Read(k => k == "DB_PORT" ? "6001" : null, Array.Empty<string>());
|
||||
Assert.Equal(new[] { "DB_PORT" }, onlyDb.IgnoredVariables);
|
||||
Assert.StartsWith("Variabile ignorata: DB_PORT.", onlyDb.IgnoredVariablesNotice());
|
||||
Assert.DoesNotContain("8080", onlyDb.IgnoredVariablesNotice());
|
||||
|
||||
Assert.Empty(EnvConfig.Read(k => k == "PORT" ? " " : null, Array.Empty<string>()).IgnoredVariables);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(new string[0], 8080)]
|
||||
[InlineData(new[] { "--porta", "8090" }, 8090)]
|
||||
[InlineData(new[] { "--config", "/tmp/x", "--porta", "8091", "--simulatore" }, 8091)]
|
||||
[InlineData(new[] { "--porta", "0" }, 8080)]
|
||||
[InlineData(new[] { "--porta", "65536" }, 8080)]
|
||||
[InlineData(new[] { "--porta", "otto" }, 8080)]
|
||||
[InlineData(new[] { "--porta" }, 8080)]
|
||||
public void La_porta_dell_interfaccia_viene_solo_da_porta(string[] args, int expected)
|
||||
{
|
||||
Assert.Equal(expected, EnvConfig.HttpPortFrom(args));
|
||||
Assert.Equal(expected, EnvConfig.Read(_ => null, args).HttpPort);
|
||||
Assert.Equal(8080, EnvConfig.Read(k => k == "PORT" ? "9001" : null, Array.Empty<string>()).HttpPort);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Avvio senza variabili: schermata d'errore, niente database (ConfigErrorTests della specifica).</summary>
|
||||
|
||||
@@ -39,6 +39,11 @@ public sealed partial class GuideTests
|
||||
{ "aggiornare da Bidoo BidBot", "Installazione-Docker-e-Unraid", ["/mnt/user/appdata/mimante", "pg_dump"] },
|
||||
{ "i tre modi delle aste", "Aste", ["ferma", "osserva", "attiva"] },
|
||||
{ "il modello è l'unico decisore", "Come-decide-il-modello", ["paletti"] },
|
||||
{ "prima del modello pronto si punta entro i paletti (ADR 0018)", "Come-decide-il-modello",
|
||||
["un'eccezione", "non ancora pronto", "valore del prodotto è ignoto", "apprendimento acceso", "la spesa non ha tetto"] },
|
||||
{ "in Attiva presto la spesa non ha tetto (ADR 0018)", "Primo-avvio",
|
||||
["modello non ancora pronto", "valore del prodotto è ignoto", "tutti a zero", "la spesa non ha tetto"] },
|
||||
{ "DB_PORT e PORT non si leggono più (ADR 0019)", "Installazione-Docker-e-Unraid", ["db_port e port", "non si leggono più", "8080"] },
|
||||
{ "l'HALT si toglie a mano", "Paletti-e-rischio", ["halt", "togli il blocco"] },
|
||||
{ "il riscatto è spento di fabbrica", "Puntate-gratis", ["spento di fabbrica"] },
|
||||
{ "Telegram con BotFather", "Telegram", ["@botfather", "/newbot", "chat id"] },
|
||||
|
||||
@@ -447,6 +447,29 @@ public class CsvExportPureTests
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Il backup notturno copia ogni tabella non partizionata delle migrazioni, e solo quelle.</summary>
|
||||
public partial class BackupTablesTests
|
||||
{
|
||||
[Fact]
|
||||
public void Il_backup_notturno_copia_tutte_le_tabelle_non_partizionate()
|
||||
{
|
||||
var created = Migrations.Embedded()
|
||||
.SelectMany(s => CreateTable().Matches(s.Sql).Select(m => m.Groups["name"].Value.ToLowerInvariant()))
|
||||
.Append("schema_migrations")
|
||||
.Except(Partitions.Tables)
|
||||
.ToHashSet();
|
||||
|
||||
Assert.Contains("account_rewards", created);
|
||||
Assert.Equal(created.Order(), Maintenance.BackupTables.Order());
|
||||
Assert.Equal(Maintenance.BackupTables.Length, Maintenance.BackupTables.Distinct().Count());
|
||||
Assert.Empty(Maintenance.BackupTables.Intersect(Partitions.Tables));
|
||||
}
|
||||
|
||||
[System.Text.RegularExpressions.GeneratedRegex(@"CREATE\s+TABLE\s+(?:IF\s+NOT\s+EXISTS\s+)?(?<name>[A-Za-z_][A-Za-z0-9_]*)\s*\(",
|
||||
System.Text.RegularExpressions.RegexOptions.IgnoreCase)]
|
||||
private static partial System.Text.RegularExpressions.Regex CreateTable();
|
||||
}
|
||||
|
||||
[Collection("Database")]
|
||||
public class DataRetentionTests(DatabaseFixture fx)
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user