Verify preflight recovery and cleanup interactions
This commit is contained in:
@@ -158,3 +158,48 @@ func TestNotariusPreflightFailurePreservesCompletedExtraction(t *testing.T) {
|
||||
t.Fatalf("completed extraction changed: before=%#v after=%#v error=%v", before.Stages["extract"], after.Stages["extract"], err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestPreflightUsesSyntheticInputWhenTranscriptWorkWouldRerun(t *testing.T) {
|
||||
pipeline, campaign, session := writeValidConfigFiles(t, t.TempDir())
|
||||
cfg, err := config.LoadWithSessionOptions(pipeline, campaign, session, config.SessionLoadOptions{})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
configureNotariusProbe(t, cfg)
|
||||
deps := fakeCommandDependencies(&storage.FakeBackend{}, nil)
|
||||
native := ¬arius.FakeRunner{}
|
||||
deps.newNotarius = func() notarius.Runner { return native }
|
||||
if _, err := inspectConfiguredForTest(context.Background(), cfg, deps); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
paths := artifacts.NewLocalStore(cfg.Pipeline.Workspace.Root).SessionPathsFor(cfg.Session.Campaign, cfg.Session.SessionID)
|
||||
path := filepath.Join(paths.Root, "transcripts", "final.trimmed.json")
|
||||
mustWriteTestFile(t, path, `{"segments":[]}`)
|
||||
checksum, err := artifacts.SHA256File(path)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
store := &manifest.LocalStore{}
|
||||
m, err := store.Load(context.Background(), paths.ManifestPath)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for _, name := range []string{"transcribe", "merge", "polish", "normalize", "trim"} {
|
||||
m.MarkStageSucceeded(name, time.Now().UTC(), nil)
|
||||
}
|
||||
m.Stages["trim"].Outputs = []manifest.ArtifactRecord{{Kind: "transcript_final_trimmed", SourceID: "narratio.transcript.final_trimmed", LocalPath: path, ProducerRunID: "prior-run", Checksum: checksum, Size: int64(len(`{"segments":[]}`))}}
|
||||
if _, err := artifacts.ResolveExtractionInputIdentity(paths, m); err != nil {
|
||||
t.Fatalf("test transcript is not independently usable: %v", err)
|
||||
}
|
||||
if err := store.Save(context.Background(), paths.ManifestPath, m); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
report, err := inspectConfiguredForTest(context.Background(), cfg, deps)
|
||||
if err != nil || !report.Ready || report.Preparation.Outcome != "reused" || len(native.PreflightRequests) != 2 {
|
||||
t.Fatalf("report=%+v requests=%d error=%v", report, len(native.PreflightRequests), err)
|
||||
}
|
||||
request := native.PreflightRequests[1]
|
||||
if !strings.Contains(request.InputDescription, "synthetic") || request.InputPath == path {
|
||||
t.Fatalf("stale transcript selected: %+v", request)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user