Files
Chronos/tests/Chronos.Data.Tests/Processing/ProjectStoreTests.cs
T
Alby96andClaude Opus 5.5 fca6c8dfea feat(server): route renders by settings format and adapted size; gate older servers
Owner review 1, phase 4 (P5). A render job now carries the output size its
settings give (RenderSize, proportions win) and the settings format it needs,
resolved on the server before the job is split, so only nodes that read that
format and whose encoder takes the frame claim it, and a job no online node
can read no longer waits for one. Nodes and the server announce the format
they read; settings of a newer Chronos fail saying so.

Encoder size limits are read as long edge x short edge: Media Foundation's
software H.264 encoder, announced as 4096x2304, accepts portrait 2160x3840
(probed on this PC), so EncoderSelector and the provider take either
orientation and cap a portrait frame against the turned limit.

On the desktop, Sync and Send-and-render are disabled with the
NeedsNewerServer tooltip while the server reads an older format than the
working settings need.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-04 19:48:23 +01:00

55 lines
3.3 KiB
C#

using Chronos.Core.Diagnostics.Synthetic;
using Chronos.Core.Localization;
using Chronos.Core.Project;
using Chronos.Data.Archiving;
using Chronos.Data.Processing;
using Chronos.Testing;
namespace Chronos.Data.Tests.Processing;
/// <summary>
/// The project of a sequence as the engine reads and writes it (owner review 1, phase 4): a format-1 project stays format 1
/// through every edit that uses nothing newer, a transform raises it to 2 and its removal brings it back, and settings of
/// a newer Chronos are refused saying so in the user's language.
/// </summary>
[Category("processing")]
public sealed class ProjectStoreTests(TestContext context)
{
[Test]
public async Task AnEditNeverRaisesTheFormatOfAProjectThatUsesNothingNewer()
{
await using var fixture = await ProcessingFixture.CreateAsync(context);
var sequence = await fixture.AddAsync(SyntheticSequence.Create(new SyntheticSequenceOptions { Width = 64, Height = 48, FrameCount = 4 }));
var store = new ProjectStore(fixture.Db, new SequenceWriter(new ArchiveServiceOptions { Owner = "test", LeaseWait = TimeSpan.FromSeconds(20) }));
async Task<int> StoredFormatAsync()
{
var row = (await fixture.Db.Sequences.GetAsync(sequence.Id, fixture.Ct))!;
var file = await File.ReadAllTextAsync(fixture.Folder(sequence).ProjectPath, fixture.Ct);
Assert.Equal(row.SettingsJson, file, "the index and project.json hold the same text");
return ProjectContent.FormatOf(file);
}
Assert.True(await store.UpdateAsync(fixture.Archive.Paths, sequence, p => p with { Exposure = p.Exposure with { ExposureOffsetEv = 0.5 } }, fixture.Ct));
Assert.Equal(ProjectSettings.BaseVersion, await StoredFormatAsync());
// A read project of the base format is never stamped higher, even when it says the highest this Chronos reads.
Assert.True(await store.UpdateAsync(fixture.Archive.Paths, sequence, p => p with { Version = ProjectSettings.CurrentVersion, HeroFrame = 2 }, fixture.Ct));
Assert.Equal(ProjectSettings.BaseVersion, await StoredFormatAsync());
Assert.True(await store.UpdateAsync(fixture.Archive.Paths, sequence, p => p with { Camera = p.Camera with { Rotate = 90 } }, fixture.Ct));
Assert.Equal(2, await StoredFormatAsync());
Assert.True(await store.UpdateAsync(fixture.Archive.Paths, sequence, p => p with { Camera = p.Camera with { Rotate = 0 } }, fixture.Ct));
Assert.Equal(ProjectSettings.BaseVersion, await StoredFormatAsync());
Assert.False(await store.UpdateAsync(fixture.Archive.Paths, sequence, p => p with { Version = ProjectSettings.BaseVersion }, fixture.Ct), "nothing changed");
}
[Test]
public void SettingsOfANewerChronosAreRefusedSayingSo()
{
var refused = Assert.Throws<InvalidDataException>(() => ProjectStore.Parse("""{"version":3,"camera":{"rotate":90}}"""));
Assert.Equal(Loc.L("Errors.Render.NewerSettings"), refused.Message);
Assert.Equal(90, ProjectStore.Parse("""{"version":2,"camera":{"rotate":90}}""").Camera.Rotate);
// Text that is not a project keeps its own reason.
Assert.NotEqual(Loc.L("Errors.Render.NewerSettings"), Assert.Throws<InvalidDataException>(() => ProjectStore.Parse("[1]")).Message);
}
}