CI / Build and test (pull_request) Failing after 2m3s
CI / PostgreSQL 16 integration (pull_request) Skipped
CI / PostgreSQL 17 integration (pull_request) Skipped
CI / Docker image (pull_request) Skipped
CI / Windows tests and installer (pull_request) Skipped
CI / YAML check (pull_request) Successful in 4s
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. 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) and pe-check. 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>
103 lines
4.8 KiB
C#
103 lines
4.8 KiB
C#
using System.Net;
|
|
using System.Net.Http.Json;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Chronos.Core.Model;
|
|
using Chronos.Data;
|
|
using Chronos.Data.Jobs;
|
|
using Chronos.Protocol;
|
|
using Chronos.Server.Configuration;
|
|
using Chronos.Server.Tests.Jobs;
|
|
using Chronos.Testing;
|
|
|
|
namespace Chronos.Server.Tests.Postgres;
|
|
|
|
/// <summary>The server on PostgreSQL (<c>CHRONOS_TEST_PG</c>), each test in a private schema.</summary>
|
|
[Category("server")]
|
|
[RequiresEnvironment("CHRONOS_TEST_PG")]
|
|
public sealed class PostgresServerTests(TestContext context)
|
|
{
|
|
[Test]
|
|
public async Task SignInUploadSyncAndJobsWorkOnPostgres()
|
|
{
|
|
await using var schema = await Schema.CreateAsync(context);
|
|
var handler = new BlockingJobHandler(JobKind.Thumbs);
|
|
await using var server = await TestServer.StartAsync(context, o =>
|
|
{
|
|
o.Database = DatabaseKind.Postgres;
|
|
o.DbConnectionString = schema.ConnectionString;
|
|
o.ChunkSizeBytes = 64 * 1024;
|
|
}, s => s.AddSingleton<IJobHandler>(handler));
|
|
Assert.Equal(Dialect.Postgres, server.Database.Dialect);
|
|
|
|
var (editor, _, _) = await server.UserAsync("alberto", "editor", quotaBytes: 10_000_000);
|
|
var data = Uploads.Photo(150_000, 71);
|
|
var frame = await Uploads.UploadAsync(editor, data, sessionKey: "pg");
|
|
using (var manifest = await editor.GetAsync($"/api/v1/sequences/{frame.SequenceId}/manifest"))
|
|
Assert.Equal(Uploads.Sha(data), (await manifest.ReadAsync(ProtocolJson.Default.SequenceManifest)).Frames.Single().Sha256);
|
|
using (var me = await editor.GetAsync("/api/v1/auth/me")) Assert.Equal(data.Length, (await me.ReadAsync(ProtocolJson.Default.UserDto)).UsedBytes);
|
|
|
|
using (var stale = await editor.PatchAsJsonAsync($"/api/v1/sequences/{frame.SequenceId}", new UpdateSequenceRequest(null, ["pg"], null, null, "{}", 99),
|
|
ProtocolJson.Default.UpdateSequenceRequest))
|
|
await stale.ExpectErrorAsync(HttpStatusCode.Conflict, "settings_conflict");
|
|
|
|
// Uploading queued a background thumbnail job for the sequence; it runs on the server's engine.
|
|
using var queued = await editor.GetAsync("/api/v1/jobs?kind=thumbs");
|
|
var job = (await queued.ReadAsync(ProtocolJson.Default.PageJobDto)).Items.Single();
|
|
await JobApiTests.WaitForAsync(editor, job.Id, "running");
|
|
handler.Release();
|
|
await JobApiTests.WaitForAsync(editor, job.Id, "done");
|
|
|
|
var admin = await server.AdminAsync();
|
|
using var dashboard = await admin.GetAsync("/api/v1/server/dashboard");
|
|
Assert.True((await dashboard.ReadAsync(ProtocolJson.Default.DashboardDto)).Database.StartsWith("PostgreSQL ", StringComparison.Ordinal));
|
|
using var health = await server.Client.GetAsync("/health");
|
|
Assert.Equal("ok", (await health.ReadAsync(ProtocolJson.Default.HealthStatus)).Checks["database"]);
|
|
}
|
|
|
|
[Test]
|
|
public async Task TheManifestListsTheFramesOfOneFramesVersionOnPostgres()
|
|
{
|
|
await using var schema = await Schema.CreateAsync(context);
|
|
await using var server = await TestServer.StartAsync(context, o =>
|
|
{
|
|
o.Database = DatabaseKind.Postgres;
|
|
o.DbConnectionString = schema.ConnectionString;
|
|
});
|
|
Assert.Equal(Dialect.Postgres, server.Database.Dialect);
|
|
await Api.SequenceTests.FramesOfOneVersionAsync(server);
|
|
}
|
|
|
|
/// <summary>A throw-away schema on the test server, selected through <c>Search Path</c>.</summary>
|
|
private sealed class Schema : IAsyncDisposable
|
|
{
|
|
private readonly IDatabase _admin;
|
|
private readonly string _name;
|
|
|
|
private Schema(IDatabase admin, string name, string connectionString)
|
|
{
|
|
_admin = admin;
|
|
_name = name;
|
|
ConnectionString = connectionString;
|
|
}
|
|
|
|
public string ConnectionString { get; }
|
|
|
|
public static async Task<Schema> CreateAsync(TestContext context)
|
|
{
|
|
var baseConnection = Environment.GetEnvironmentVariable("CHRONOS_TEST_PG")!;
|
|
var admin = DatabaseFactory.Open(DatabaseOptions.Postgres(baseConnection));
|
|
var name = "chronos_s_" + Guid.NewGuid().ToString("N")[..16];
|
|
await using (var session = await admin.OpenAsync(context.Cancellation))
|
|
await session.ExecuteScriptAsync($"CREATE SCHEMA {name}", context.Cancellation);
|
|
return new Schema(admin, name, baseConnection.TrimEnd(';', ' ') + $";Search Path={name}");
|
|
}
|
|
|
|
public async ValueTask DisposeAsync()
|
|
{
|
|
await using (var session = await _admin.OpenAsync(CancellationToken.None))
|
|
await session.ExecuteScriptAsync($"DROP SCHEMA IF EXISTS {_name} CASCADE", CancellationToken.None);
|
|
await _admin.DisposeAsync();
|
|
}
|
|
}
|
|
}
|