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>
107 lines
5.0 KiB
C#
107 lines
5.0 KiB
C#
using Chronos.Core.Model;
|
|
using Chronos.Data.Jobs;
|
|
using Chronos.Testing;
|
|
|
|
namespace Chronos.Data.Tests.Jobs;
|
|
|
|
/// <summary>The priority queue of the settings (owner review 1, R2): levels per kind of job, the claim order and what interrupts.</summary>
|
|
[Category("jobs")]
|
|
public sealed class JobPriorityQueueTests
|
|
{
|
|
private static readonly DateTimeOffset T0 = new(2026, 10, 16, 9, 0, 0, TimeSpan.Zero);
|
|
|
|
[Test]
|
|
public void RendersImportsAndDownloadsComeFirstAndTheLongResumablePassesLast()
|
|
{
|
|
var queue = new JobPriorityQueue();
|
|
Assert.Equal(JobKindPriority.High, queue.LevelOf(JobKind.Render));
|
|
Assert.Equal(JobKindPriority.High, queue.LevelOf(JobKind.Import));
|
|
Assert.Equal(JobKindPriority.High, queue.LevelOf(JobKind.Download));
|
|
Assert.Equal(JobKindPriority.Low, queue.LevelOf(JobKind.Verify));
|
|
Assert.Equal(JobKindPriority.Low, queue.LevelOf(JobKind.Proxies));
|
|
foreach (var kind in new[] { JobKind.Scan, JobKind.Thumbs, JobKind.LightAnalyse, JobKind.DeepAnalyse, JobKind.Maintenance })
|
|
Assert.Equal(JobKindPriority.Normal, queue.LevelOf(kind));
|
|
// A level the user set wins over the default.
|
|
Assert.Equal(JobKindPriority.Low, (queue with { Levels = new Dictionary<JobKind, JobKindPriority> { [JobKind.Render] = JobKindPriority.Low } }).LevelOf(JobKind.Render));
|
|
}
|
|
|
|
[Test]
|
|
public void OnlyAHigherLevelInterruptsAndOnlyWhileTheQueueIsOn()
|
|
{
|
|
var on = new JobPriorityQueue { Enabled = true };
|
|
Assert.True(on.Interrupts(JobKind.Render, JobKind.Scan));
|
|
Assert.True(on.Interrupts(JobKind.Scan, JobKind.Verify));
|
|
Assert.False(on.Interrupts(JobKind.Scan, JobKind.Render));
|
|
Assert.False(on.Interrupts(JobKind.Thumbs, JobKind.Scan));
|
|
Assert.False(on.Interrupts(JobKind.Import, JobKind.Render));
|
|
Assert.False(JobPriorityQueue.Off.Interrupts(JobKind.Render, JobKind.Verify));
|
|
}
|
|
|
|
[Test]
|
|
public void TheQueueOrdersByLevelThenPriorityThenAge()
|
|
{
|
|
var on = new JobPriorityQueue { Enabled = true };
|
|
var oldVerify = Job(JobKind.Verify, JobPriority.User, -30);
|
|
var backgroundScan = Job(JobKind.Scan, JobPriority.Background, -20);
|
|
var userThumbs = Job(JobKind.Thumbs, JobPriority.User, -10);
|
|
var render = Job(JobKind.Render, JobPriority.Normal, 0);
|
|
Job[] jobs = [oldVerify, backgroundScan, userThumbs, render];
|
|
|
|
Assert.SequenceEqual([render, userThumbs, backgroundScan, oldVerify], Sorted(jobs, on));
|
|
// Off, the strict queue of before: priority, then age.
|
|
Assert.SequenceEqual([oldVerify, userThumbs, render, backgroundScan], Sorted(jobs, JobPriorityQueue.Off));
|
|
// Two jobs alike fall back to the id.
|
|
var twin = render with { Id = Guid.CreateVersion7() };
|
|
Assert.True(on.ClaimsBefore(render, twin) != on.ClaimsBefore(twin, render));
|
|
}
|
|
|
|
[Test]
|
|
public void SettingsKeepOnlyTheLevelsThatDifferAndSkipWhatTheyCannotRead()
|
|
{
|
|
var queue = JobPriorityQueue.From(true, new Dictionary<string, string>
|
|
{
|
|
["deep-analyse"] = "high",
|
|
["Scan"] = "LOW",
|
|
["render"] = "high",
|
|
["teleport"] = "high",
|
|
["verify"] = "urgent",
|
|
["99"] = "low",
|
|
});
|
|
Assert.True(queue.Enabled);
|
|
Assert.Equal((JobKindPriority.High, JobKindPriority.Low, JobKindPriority.Low), (queue.LevelOf(JobKind.DeepAnalyse), queue.LevelOf(JobKind.Scan), queue.LevelOf(JobKind.Verify)));
|
|
|
|
var stored = JobPriorityQueue.Changed(Enum.GetValues<JobKind>().ToDictionary(k => k, queue.LevelOf));
|
|
Assert.SequenceEqual(["deep-analyse", "scan"], stored.Keys.Order(StringComparer.Ordinal));
|
|
Assert.Equal(("high", "low"), (stored["deep-analyse"], stored["scan"]));
|
|
var reread = JobPriorityQueue.From(true, stored);
|
|
foreach (var kind in Enum.GetValues<JobKind>()) Assert.Equal(queue.LevelOf(kind), reread.LevelOf(kind));
|
|
Assert.Equal(JobKindPriority.High, JobPriorityQueue.From(false, stored).LevelOf(JobKind.DeepAnalyse));
|
|
Assert.False(JobPriorityQueue.From(false, null).Enabled);
|
|
}
|
|
|
|
[Test]
|
|
public void TheClaimOrderOfTheDatabaseListsOnlyTheLevelsOtherThanNormal()
|
|
{
|
|
var on = new JobPriorityQueue { Enabled = true };
|
|
Assert.Equal(string.Empty, JobPriorityQueue.Off.OrderSql([JobKind.Render, JobKind.Verify]));
|
|
Assert.Equal(string.Empty, on.OrderSql([JobKind.Scan, JobKind.Thumbs]));
|
|
Assert.Equal("CASE WHEN kind IN (7) THEN 2 WHEN kind IN (2) THEN 0 ELSE 1 END DESC, ", on.OrderSql([JobKind.Render, JobKind.Verify, JobKind.Scan, JobKind.Render]));
|
|
}
|
|
|
|
private static Job[] Sorted(Job[] jobs, JobPriorityQueue queue)
|
|
{
|
|
var list = jobs.ToList();
|
|
list.Sort((a, b) => a.Id == b.Id ? 0 : queue.ClaimsBefore(a, b) ? -1 : 1);
|
|
return [.. list];
|
|
}
|
|
|
|
private static Job Job(JobKind kind, JobPriority priority, int minutes) => new()
|
|
{
|
|
Id = Guid.CreateVersion7(),
|
|
Kind = kind,
|
|
Priority = priority,
|
|
State = JobState.Queued,
|
|
Created = T0.AddMinutes(minutes),
|
|
};
|
|
}
|