feat: owner review 2 phase 4a: Reorganize sequences after import (#12)
CI / Build and test (push) Successful in 9m15s
CI / Windows tests and installer (push) Skipped
CI / YAML check (push) Successful in 6s
Release / Build, test and publish (push) Successful in 15m35s
CI / PostgreSQL 16 integration (push) Successful in 7m26s
CI / PostgreSQL 17 integration (push) Successful in 6m47s
CI / Docker image (push) Successful in 59s
Release / Server image (push) Successful in 1m24s
CI / Build and test (push) Successful in 9m15s
CI / Windows tests and installer (push) Skipped
CI / YAML check (push) Successful in 6s
Release / Build, test and publish (push) Successful in 15m35s
CI / PostgreSQL 16 integration (push) Successful in 7m26s
CI / PostgreSQL 17 integration (push) Successful in 6m47s
CI / Docker image (push) Successful in 59s
Release / Server image (push) Successful in 1m24s
- Reorganize… on the web panel and the desktop: folder, file and title templates applied to existing sequences, with a dry run and an explicit Apply that runs as a job. - One naming rule (FrameNaming) for import, upload and Reorganize. - Crash-safe plan and file journals, held plans, stale-plan refusal; exports move with their folder. - Writers refuse a folder another program moved or gave to another sequence. - Server: POST /api/v1/archive/reorganize with a bounded plan cache; template rules. - Phase 3 docs and translations merged; strings in all 38 languages. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Alberto Balbo <alberto.balbo.96@gmail.com>
This commit was merged in pull request #12.
This commit is contained in:
1 parent
9aa818ed47
commit
7e4a3b481d
416 files changed
+15304
-1572
No files matched your search
@@ -2,9 +2,13 @@ using System.Net;
|
||||
using System.Net.Http.Json;
|
||||
using System.Text.Json;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Chronos.Core.Archiving;
|
||||
using Chronos.Data;
|
||||
using Chronos.Data.Archiving;
|
||||
using Chronos.Protocol;
|
||||
using Chronos.Protocol.Client;
|
||||
using Chronos.Server.Jobs;
|
||||
using Chronos.Server.Storage;
|
||||
using Chronos.Testing;
|
||||
|
||||
namespace Chronos.Server.Tests.Jobs;
|
||||
@@ -120,6 +124,99 @@ public sealed class RenderNodeTests(TestContext context)
|
||||
Assert.Equal(render.Id, (await renders.ReadAsync(ProtocolJson.Default.ListRenderDto)).Single().Id);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task ARenderThatCannotBeFiledForNowIsCompletedAgain()
|
||||
{
|
||||
// The archive engine with a short lease wait: a sequence another writer holds refuses the filing at once.
|
||||
await using var server = await TestServer.StartAsync(context, o => o.ChunkSizeBytes = 64 * 1024, s => s.AddSingleton(sp =>
|
||||
new ArchiveService(sp.GetRequiredService<ChronosDatabase>(), new ArchiveServiceOptions { Owner = ArchiveModule.Owner, LeaseWait = TimeSpan.FromMilliseconds(200) })));
|
||||
var (editor, _, _) = await server.UserAsync("alberto", "editor", renderNode: true);
|
||||
var frame = await Uploads.UploadAsync(editor, Uploads.Photo(5000, 54), "IMG_0001.CR3");
|
||||
var job = await JobApiTests.CreateAsync(editor, "render", frame.SequenceId, HevcJob);
|
||||
var node = await RegisterAsync(editor, "studio-pc", "hevc", 8192);
|
||||
using (var claim = await editor.PostAsync($"/api/v1/nodes/{node.Id}/claim", null)) await claim.ExpectAsync(HttpStatusCode.OK);
|
||||
|
||||
// A render node's output, and a render a client sends of the same sequence, both fully received.
|
||||
var output = Uploads.Photo(3000, 55);
|
||||
var result = new RenderResultRequest("Roof - 4K HEVC.mp4", output.Length, Uploads.Sha(output), "4K HEVC", "hevc", 3840, 2160, 25, 120);
|
||||
Guid fromNode;
|
||||
using (var started = await editor.PostAsJsonAsync($"/api/v1/nodes/{node.Id}/jobs/{job.Id}/result", result, ProtocolJson.Default.RenderResultRequest))
|
||||
{
|
||||
await started.ExpectAsync(HttpStatusCode.Created);
|
||||
fromNode = Assert.NotNull((await started.ReadAsync(ProtocolJson.Default.StartUploadResponse)).UploadId);
|
||||
}
|
||||
using (var put = await Uploads.PutChunkAsync(editor, fromNode, 0, output)) await put.ExpectAsync(HttpStatusCode.OK);
|
||||
var sent = Uploads.Photo(2000, 56);
|
||||
var offered = new RenderUploadRequest(Guid.CreateVersion7(), "Roof.mp4", sent.Length, Uploads.Sha(sent), "1080p", "h264", 1920, 1080, 30, 10, null);
|
||||
Guid fromClient;
|
||||
using (var started = await editor.PostAsJsonAsync($"/api/v1/sequences/{frame.SequenceId}/renders", offered, ProtocolJson.Default.RenderUploadRequest))
|
||||
{
|
||||
await started.ExpectAsync(HttpStatusCode.Created);
|
||||
fromClient = Assert.NotNull((await started.ReadAsync(ProtocolJson.Default.StartUploadResponse)).UploadId);
|
||||
}
|
||||
using (var put = await Uploads.PutChunkAsync(editor, fromClient, 0, sent)) await put.ExpectAsync(HttpStatusCode.OK);
|
||||
|
||||
var completions = new[] { $"/api/v1/nodes/{node.Id}/jobs/{job.Id}/result/complete", $"/api/v1/sequences/{frame.SequenceId}/renders/{fromClient}/complete" };
|
||||
var paths = new ArchivePaths(server.Options.ArchivePath);
|
||||
async Task RefusedAsync(string code)
|
||||
{
|
||||
foreach (var complete in completions)
|
||||
{
|
||||
using var refused = await editor.PostAsync(complete, null);
|
||||
await refused.ExpectErrorAsync(HttpStatusCode.ServiceUnavailable, code);
|
||||
}
|
||||
// Nothing filed, nothing staged: both uploads receive again with their chunks, and the node keeps its job.
|
||||
foreach (var upload in new[] { fromNode, fromClient })
|
||||
{
|
||||
Assert.Equal(Chronos.Data.Repositories.UploadState.Receiving, (await server.Database.Uploads.GetAsync(upload))!.State);
|
||||
Assert.True(server.Services.GetRequiredService<UploadStore>().Exists(upload));
|
||||
}
|
||||
Assert.False(Directory.Exists(server.Options.StagingPath) && Directory.EnumerateFiles(server.Options.StagingPath).Any());
|
||||
Assert.Equal(0, (await server.Database.Sequences.GetAsync(frame.SequenceId))!.RenderedCount);
|
||||
var waiting = await JobApiTests.GetAsync(editor, job.Id);
|
||||
Assert.Equal(("running", node.Id.ToString()), (waiting.State, waiting.NodeId));
|
||||
}
|
||||
|
||||
// Another writer holds the sequence past the lease wait (a Reorganize step, a photo deletion).
|
||||
using (Assert.NotNull(LeaseFile.TryAcquire(paths.LocksDirectory, $"seq-{frame.SequenceId:N}", "tests")))
|
||||
await RefusedAsync("sequence_busy");
|
||||
// The archive drive is gone.
|
||||
File.Move(paths.ManifestPath, paths.ManifestPath + ".away");
|
||||
try
|
||||
{
|
||||
await RefusedAsync("archive_offline");
|
||||
}
|
||||
finally
|
||||
{
|
||||
File.Move(paths.ManifestPath + ".away", paths.ManifestPath);
|
||||
}
|
||||
// A desktop sharing the archive moved the sequence's folder: this server's index has it at the old place until its
|
||||
// next scan, and nothing is filed there meanwhile.
|
||||
var folder = (await server.Database.Sequences.GetAsync(frame.SequenceId))!.Folder;
|
||||
var left = paths.FromRelative(folder);
|
||||
Directory.Move(left, paths.FromRelative(folder + " moved"));
|
||||
await RefusedAsync("folder_moved");
|
||||
Assert.False(Directory.Exists(left), "the folder it left is not created again");
|
||||
// The next scan finds it where it is now (moved here as a scan moves it: this composition writes no sidecars), and the
|
||||
// renders are filed there.
|
||||
await using (var tx = await server.Database.BeginAsync(context.Cancellation))
|
||||
{
|
||||
await tx.Sequences.RelocateAsync(frame.SequenceId, folder + " moved", null, context.Cancellation);
|
||||
await tx.CommitAsync(context.Cancellation);
|
||||
}
|
||||
|
||||
foreach (var complete in completions)
|
||||
{
|
||||
using var filed = await editor.PostAsync(complete, null);
|
||||
await filed.ExpectAsync(HttpStatusCode.OK);
|
||||
}
|
||||
Assert.Equal("done", (await JobApiTests.GetAsync(editor, job.Id)).State);
|
||||
var sequence = (await server.Database.Sequences.GetAsync(frame.SequenceId))!;
|
||||
Assert.Equal(2, sequence.RenderedCount);
|
||||
await Http.BytesEqualAsync(output, File.ReadAllBytesAsync(Path.Combine(server.Options.ArchivePath, sequence.Folder, "exports", "Roof - 4K HEVC.mp4")));
|
||||
await Http.BytesEqualAsync(sent, File.ReadAllBytesAsync(Path.Combine(server.Options.ArchivePath, sequence.Folder, "exports", "Roof.mp4")));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task NodesReportFailuresAndNeedTheRight()
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user