feat: schedule persistent archive jobs with console management

This commit is contained in:
2026-09-23 11:29:32 +08:00
parent 6eb429e21f
commit 0140c78ea7
32 changed files with 2077 additions and 20 deletions

View File

@@ -259,3 +259,33 @@ func TestArchiveJobWriteFailureDoesNotAdvance(t *testing.T) {
t.Fatalf("write recovery=%+v err=%v", final, err)
}
}
func TestManagedArchiveChecksDatabasePrefixAndMissingVolume(t *testing.T) {
ctx := context.Background()
dir := filepath.Join(t.TempDir(), "job")
id, _ := core.NewID()
calls := 0
options := testJobOptions()
options.JobID = id
options.MaxBatches = 1
first, err := RunArchive(ctx, dir, testJobSpec(), options, testJobExporter(t, &calls))
if err != nil || first.JobID != id {
t.Fatal(first, err)
}
options.Checkpoint = &first
options.RequireExisting = true
forged := first
forged.LastSHA256 = strings.Repeat("0", 64)
options.Checkpoint = &forged
if _, err = RunArchive(ctx, dir, testJobSpec(), options, testJobExporter(t, &calls)); err == nil || calls != 1 {
t.Fatal("untrusted prefix accepted")
}
options.Checkpoint = &first
if _, err = RunArchive(ctx, filepath.Join(t.TempDir(), "missing"), testJobSpec(), options, testJobExporter(t, &calls)); err == nil || calls != 1 {
t.Fatal("missing volume silently recreated")
}
second, err := RunArchive(ctx, dir, testJobSpec(), options, testJobExporter(t, &calls))
if err != nil || !second.Completed || second.JobID != id {
t.Fatal(second, err)
}
}