Files
Chronos/tests/Chronos.Server.Tests/Jobs/PlaybackRoutingTests.cs
T
Alby96andClaude Opus 5.5 03b4d0ef60 feat(P2): videos library, verified video trash and copy job, render hashes and still jobs
Renders now record their SHA-256 and kind, so copies, deletes and restores can
be verified. The new videos library lists every render with paging and
filters, deletes into the archive trash after a dry run whose fingerprint must
still match (journalled, so a crash mid-move is settled on open), restores by id
refusing a tampered file, and a VideoCopy job copies renders hash-verified into
a videos folder outside the archive, never overwriting. A still job saves one
frame as an image through an interim Data-side path until P1's Core still API
lands. Batch exports keep the playback and routing uses the job's own export,
so a playback job needs settings format 3 and an older node never claims it.

Refs #21

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-05 02:27:37 +01:00

40 lines
2.0 KiB
C#

using Chronos.Core.Model;
using Chronos.Core.Project;
using Chronos.Core.Video;
using Chronos.Data.Processing;
using Chronos.Protocol;
using Chronos.Server.Jobs;
using Chronos.Testing;
namespace Chronos.Server.Tests.Jobs;
/// <summary>Owner review 1, phase 5: a job that plays back, or saves a still, goes only to a node that reads settings format 3.</summary>
[Category("server")]
public sealed class PlaybackRoutingTests
{
private static readonly ExportSettings Mjpeg = new()
{
Preset = new Auto<string>().WithManual("mjpeg-avi"),
Overrides = new ExportOverrides { Width = 96, Height = 64 },
};
[Test]
public void APlaybackJobIsNeverGivenToAFormatTwoNode()
{
var sequence = new Sequence { Id = Guid.CreateVersion7(), ArchiveId = Guid.CreateVersion7(), Folder = "Roof", Title = "Roof" };
var playing = ProcessingJobs.ReadRender(ProcessingJobs.Render(sequence, Mjpeg with { Playback = new PlaybackSettings { Loops = 3 } }, 96, 64,
new ProjectSettings()).ParametersJson).Parameters;
var plain = ProcessingJobs.ReadRender(ProcessingJobs.Render(sequence, Mjpeg, 96, 64, new ProjectSettings()).ParametersJson).Parameters;
Assert.Equal((3, 1), (playing.RequiredSettingsFormat, plain.RequiredSettingsFormat));
RegisterNodeRequest Node(int format) => new("node", [new NodeEncoder("mjpeg", "managed", false, false)], 0, 0, format);
Assert.False(RenderNodeService.Renders(Node(2), playing), "a format-2 node would render it forward once");
Assert.True(RenderNodeService.Renders(Node(3), playing));
Assert.True(RenderNodeService.Renders(Node(2), plain));
// A still needs format 3 too (and an image codec no node encodes).
var still = ProcessingJobs.ReadRender(ProcessingJobs.Still(sequence, Mjpeg, VideoCodec.JpegSequence, 0, null, 96, 64, new ProjectSettings()).ParametersJson).Parameters;
Assert.False(RenderNodeService.Renders(Node(2) with { Encoders = [new NodeEncoder(still.Codec, "managed", false, false)] }, still));
}
}