CI / Build and test (push) Successful in 8m14s
CI / Windows tests and installer (push) Skipped
CI / YAML check (push) Successful in 7s
Release / Build, test and publish (push) Successful in 13m19s
CI / PostgreSQL 16 integration (push) Successful in 4m49s
CI / PostgreSQL 17 integration (push) Successful in 5m28s
CI / Docker image (push) Successful in 53s
Release / Server image (push) Failing after 10s
The owner renamed the product and moved the repository to the self-hosted Gitea (https://gitea.encke-hake.ts.net/BalboSoft/Chronos) for more control, and asked for Actions and a first automatic release with the server package and the Windows exe (docs/requests/2026-10-23-chronos-gitea.md). - Chronos everywhere: a byte-exact rename of contents and paths, then a per-language review of the forms the old name's ending had dictated. - Gitea instead of GitHub: the update check, licence, issue and support links read ChronosReleasesUrl; the update check takes the highest stable version, offers a pre-release build its final release and reports a repository it cannot see as a failed check. EULA, security policy and Gitea issue forms live at the repository root. - Gitea Actions for the Linux act_runner (.gitea/workflows): CI, release, nightly image and performance gates in the .NET SDK container with git checkout and the system SQLite. The release cross-compiles the Windows programs, checks their icon, version and DPI manifest, packs installers and zips, publishes the Gitea release and pushes the server image (REGISTRY_TOKEN). Windows-only tests run in an opt-in job on a Windows runner (WINDOWS_RUNNER). - New Chronos.Tools commands: zip, gitea-release, postgres-ci (replaces the docker-exec script, which Gitea's service containers do not allow; the throw-away server runs without durability) and pe-check. - Timed tests take their budget from TestTiming (CHRONOS_TEST_TIME_FACTOR, 3 on the shared runner; the weekly performance gates keep theirs). BREAKING CHANGE: programs, settings, data folders, file types, environment variables and the Docker image use the new name; nothing is migrated from Titano, which never had a release. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Alberto Balbo <alberto.balbo.96@gmail.com>
164 lines
8.0 KiB
C#
164 lines
8.0 KiB
C#
using System.Net;
|
|
using System.Text.RegularExpressions;
|
|
using Chronos.Data;
|
|
using Chronos.Server.Configuration;
|
|
using Chronos.Server.Hosting;
|
|
using Chronos.Testing;
|
|
|
|
namespace Chronos.Server.Tests.Hosting;
|
|
|
|
[Category("server")]
|
|
public sealed class StartupTests(TestContext context)
|
|
{
|
|
[Test]
|
|
public void TheServerRefusesToStartWithoutTheArchiveModule()
|
|
{
|
|
var root = context.CreateTempDirectory("bare");
|
|
var options = new ServerOptions
|
|
{
|
|
DataPath = Path.Combine(root, "data"),
|
|
ArchivePath = Path.Combine(root, "archive"),
|
|
HttpPort = 0,
|
|
HttpsPort = 0,
|
|
Database = DatabaseKind.Sqlite,
|
|
Discovery = false,
|
|
};
|
|
var error = Assert.Throws<InvalidOperationException>(() => ServerHost.Build(options, []));
|
|
Assert.Contains("IArchiveIngest", error.Message);
|
|
Assert.Contains("IFrameAssetLocator", error.Message);
|
|
}
|
|
|
|
[Test]
|
|
public void ChronosDbAcceptsAConnectionString()
|
|
{
|
|
var root = context.CreateTempDirectory("env");
|
|
var options = ServerOptions.Load(new Dictionary<string, string?>
|
|
{
|
|
["CHRONOS_DATA_PATH"] = root,
|
|
["CHRONOS_DB"] = "Host=db.lan;Port=6543;Database=archive;Username=chronos;Password=secret",
|
|
});
|
|
Assert.Equal(DatabaseKind.Postgres, options.Database);
|
|
var database = options.ToDatabaseOptions();
|
|
Assert.Equal(Dialect.Postgres, database.Dialect);
|
|
Assert.Equal(6543, Chronos.Data.Postgres.PostgresSettings.Parse(database.ConnectionString).Port);
|
|
}
|
|
|
|
[Test]
|
|
public void PartsBuildAQuotedPostgresConnectionString()
|
|
{
|
|
var options = new ServerOptions
|
|
{
|
|
Database = DatabaseKind.Postgres, // the Windows default is SQLite
|
|
DbHost = "postgres",
|
|
DbName = "chronos",
|
|
DbUser = "chronos",
|
|
DbPassword = "it's;secret",
|
|
DbSslMode = "disable",
|
|
};
|
|
var settings = Chronos.Data.Postgres.PostgresSettings.Parse(options.ToDatabaseOptions().ConnectionString);
|
|
Assert.Equal(("postgres", "chronos", "it's;secret"), (settings.Host, settings.Database, settings.Password));
|
|
Assert.Equal(Chronos.Data.Postgres.SslMode.Disable, settings.SslMode);
|
|
}
|
|
|
|
[Test]
|
|
public void EnvironmentVariablesLockTheirSettings()
|
|
{
|
|
var root = context.CreateTempDirectory("locked");
|
|
var options = ServerOptions.Load(new Dictionary<string, string?>
|
|
{
|
|
["CHRONOS_DATA_PATH"] = root,
|
|
["CHRONOS_DB"] = "postgres",
|
|
["CHRONOS_HTTP_PORT"] = "9090",
|
|
["CHRONOS_DISCOVERY"] = "false",
|
|
});
|
|
Assert.SequenceEqual(["Database", "HttpPort", "Discovery"], options.Locked);
|
|
Assert.Throws<InvalidOperationException>(() => ServerOptions.Load(new Dictionary<string, string?> { ["CHRONOS_DATA_PATH"] = root, ["CHRONOS_DB"] = "postgres", ["CHRONOS_WORKERS"] = "many" }));
|
|
}
|
|
|
|
[Test]
|
|
public void TheFormerWorkersSettingStillSetsTheParallelism()
|
|
{
|
|
// Owner review 1: "workers" (jobs at once) became the parallelism (photos the running job processes at once).
|
|
var root = context.CreateTempDirectory("workers");
|
|
File.WriteAllText(Path.Combine(root, "server.json"), """{ "Workers": 6 }""");
|
|
Assert.Equal(6, ServerOptions.Load(new Dictionary<string, string?> { ["CHRONOS_DATA_PATH"] = root, ["CHRONOS_DB"] = "postgres" }).Parallelism);
|
|
|
|
var former = ServerOptions.Load(new Dictionary<string, string?> { ["CHRONOS_DATA_PATH"] = root, ["CHRONOS_DB"] = "postgres", ["CHRONOS_WORKERS"] = "5" });
|
|
Assert.Equal((5, true), (former.Parallelism, former.FormerWorkersVariable));
|
|
Assert.SequenceEqual(["Database", "Parallelism"], former.Locked);
|
|
var both = ServerOptions.Load(new Dictionary<string, string?>
|
|
{
|
|
["CHRONOS_DATA_PATH"] = root,
|
|
["CHRONOS_DB"] = "postgres",
|
|
["CHRONOS_WORKERS"] = "5",
|
|
["CHRONOS_PARALLELISM"] = "7",
|
|
["CHRONOS_PRIORITY_QUEUE"] = "true",
|
|
});
|
|
Assert.Equal((7, true), (both.Parallelism, both.PriorityQueue));
|
|
Assert.SequenceEqual(["Database", "Parallelism", "PriorityQueue"], both.Locked);
|
|
Assert.False(ServerOptions.Load(new Dictionary<string, string?> { ["CHRONOS_DATA_PATH"] = root, ["CHRONOS_DB"] = "postgres", ["CHRONOS_PARALLELISM"] = "2" })
|
|
.FormerWorkersVariable);
|
|
Assert.Throws<InvalidOperationException>(() => ServerOptions.Load(new Dictionary<string, string?> { ["CHRONOS_DATA_PATH"] = root, ["CHRONOS_DB"] = "postgres", ["CHRONOS_PRIORITY_QUEUE"] = "often" }));
|
|
// A value the admin panel would refuse is brought within its range, so the panel can still save the other settings.
|
|
Assert.Equal(ServerOptions.MaxParallelism,
|
|
ServerOptions.Load(new Dictionary<string, string?> { ["CHRONOS_DATA_PATH"] = root, ["CHRONOS_DB"] = "postgres", ["CHRONOS_PARALLELISM"] = "96" }).Parallelism);
|
|
Assert.Equal(1, ServerOptions.Load(new Dictionary<string, string?> { ["CHRONOS_DATA_PATH"] = root, ["CHRONOS_DB"] = "postgres", ["CHRONOS_WORKERS"] = "0" }).Parallelism);
|
|
Assert.InRange(new ServerOptions().Parallelism, 1, ServerOptions.MaxParallelism);
|
|
}
|
|
|
|
[Test]
|
|
public void TrustedProxiesAreAddressesOrNetworks()
|
|
{
|
|
var root = context.CreateTempDirectory("proxies");
|
|
// Loopback only: machines of the home network reach the HTTP port directly from private addresses.
|
|
var defaults = ServerOptions.Load(new Dictionary<string, string?> { ["CHRONOS_DATA_PATH"] = root, ["CHRONOS_DB"] = "postgres" }).TrustedProxyNetworks();
|
|
foreach (var address in new[] { "127.0.0.1", "127.0.0.53", "::1" })
|
|
Assert.True(defaults.Any(n => n.Contains(IPAddress.Parse(address))), address);
|
|
foreach (var address in new[] { "10.20.30.40", "172.18.0.3", "192.168.1.2", "fd00::7", "203.0.113.5" })
|
|
Assert.False(defaults.Any(n => n.Contains(IPAddress.Parse(address))), address);
|
|
|
|
var options = ServerOptions.Load(new Dictionary<string, string?>
|
|
{
|
|
["CHRONOS_DATA_PATH"] = root,
|
|
["CHRONOS_DB"] = "postgres",
|
|
["CHRONOS_TRUSTED_PROXIES"] = "10.1.2.3, 2001:db8::/32;172.20.0.5/16",
|
|
});
|
|
Assert.Contains("TrustedProxies", options.Locked);
|
|
Assert.SequenceEqual(["10.1.2.3/32", "2001:db8::/32", "172.20.0.0/16"], options.TrustedProxyNetworks().Select(n => n.ToString()));
|
|
foreach (var invalid in new[] { "proxy.lan", "10.0.0.0/33", "fe80::1%2" })
|
|
{
|
|
var error = Assert.Throws<InvalidOperationException>(() => ServerOptions.Load(new Dictionary<string, string?>
|
|
{
|
|
["CHRONOS_DATA_PATH"] = root,
|
|
["CHRONOS_DB"] = "postgres",
|
|
["CHRONOS_TRUSTED_PROXIES"] = "127.0.0.1," + invalid,
|
|
}));
|
|
Assert.Contains(invalid, error.Message);
|
|
}
|
|
}
|
|
|
|
[Test]
|
|
public void PublicPortsComeFromTheEnvironment()
|
|
{
|
|
var root = context.CreateTempDirectory("public");
|
|
var options = ServerOptions.Load(new Dictionary<string, string?>
|
|
{
|
|
["CHRONOS_DATA_PATH"] = root,
|
|
["CHRONOS_DB"] = "postgres",
|
|
["CHRONOS_PUBLIC_HTTP_PORT"] = "18080",
|
|
["CHRONOS_PUBLIC_HTTPS_PORT"] = "18443",
|
|
});
|
|
Assert.Equal((18080, 18443), (options.PublicHttpPort, options.PublicHttpsPort));
|
|
Assert.Null(ServerOptions.Load(new Dictionary<string, string?> { ["CHRONOS_DATA_PATH"] = root, ["CHRONOS_DB"] = "postgres" }).PublicHttpsPort);
|
|
foreach (var invalid in new[] { "0", "70000", "https" })
|
|
Assert.Throws<InvalidOperationException>(() => ServerOptions.Load(new Dictionary<string, string?> { ["CHRONOS_DATA_PATH"] = root, ["CHRONOS_DB"] = "postgres", ["CHRONOS_PUBLIC_HTTPS_PORT"] = invalid }));
|
|
}
|
|
|
|
[Test]
|
|
public void HelpListsEveryVariable()
|
|
{
|
|
foreach (var variable in ServerOptions.EnvironmentVariables.Concat(["PUID", "PGID", "TZ"]))
|
|
Assert.True(Regex.IsMatch(ServerCommandLine.Usage, $@"\b{variable}\b"), variable);
|
|
}
|
|
}
|