Verify publishing and restore after cleanup
This commit is contained in:
@@ -9,6 +9,7 @@ import (
|
||||
"time"
|
||||
|
||||
"gitea.maximumdirect.net/eric/narratio/internal/adapters/scriptorium"
|
||||
"gitea.maximumdirect.net/eric/narratio/internal/adapters/storage"
|
||||
"gitea.maximumdirect.net/eric/narratio/internal/adapters/whisperx"
|
||||
"gitea.maximumdirect.net/eric/narratio/internal/artifacts"
|
||||
"gitea.maximumdirect.net/eric/narratio/internal/config"
|
||||
@@ -101,4 +102,46 @@ func TestCleanedSessionReusesProductsAndSupportsForcedAnalysis(t *testing.T) {
|
||||
if _, err := os.Stat(filepath.Join(paths.ArtifactsDir, "recap.md")); err != nil {
|
||||
t.Fatalf("canonical output missing: %v", err)
|
||||
}
|
||||
|
||||
// Publish the retained products in another invocation after the old run is gone.
|
||||
cfg.Pipeline.Storage.Backend = config.StorageBackendS3
|
||||
cfg.Pipeline.Publish = &config.PublishConfig{Enabled: boolPtr(true), UploadRun: boolPtr(true), Outputs: []config.PublishOutputRule{
|
||||
{Source: artifacts.ExtractionArtifactSourceID("npc_registry"), Dest: "artifacts/npc_registry.json", Required: boolPtr(true)},
|
||||
{Source: artifacts.ConfiguredArtifactSourceID("recap"), Dest: "artifacts/recap.md", Required: boolPtr(true)},
|
||||
}}
|
||||
cfg.ArtifactCatalog, err = config.DeriveArtifactCatalog(cfg.Pipeline, cfg.Party)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
seed = loadLifecycleManifest(t, cfg)
|
||||
for _, name := range []string{"merge", "polish", "normalize", "render"} {
|
||||
seed.MarkStageSucceeded(name, time.Now().UTC(), nil)
|
||||
}
|
||||
if err := (&manifest.LocalStore{}).Save(context.Background(), paths.ManifestPath, seed); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
remote := &storage.FakeBackend{}
|
||||
env.ObjectStore = remote
|
||||
invoke("publish-again", BoundedPlan{stages: []stage.Stage{mustSelectStage(t, "publish"), selectedCleanupStage(t)}}, false)
|
||||
if _, err := os.Lstat(paths.RunsDir); !errors.Is(err, os.ErrNotExist) {
|
||||
t.Fatalf("second cleanup left runs: %v", err)
|
||||
}
|
||||
prefix := artifacts.S3SessionPrefix("dnd", cfg.Session.Campaign, cfg.Session.SessionID)
|
||||
pointerKey := artifacts.S3CurrentCommitPointerKey(prefix)
|
||||
if len(remote.Uploads) == 0 || remote.Uploads[len(remote.Uploads)-1].Key != pointerKey {
|
||||
t.Fatalf("publication pointer not last: %#v", remote.Uploads)
|
||||
}
|
||||
commit, err := artifacts.DecodeRemoteCommitManifest(remote.Objects[artifacts.S3RunCommitKey(prefix, "publish-again")].Data)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
var found int
|
||||
for _, item := range commit.Artifacts {
|
||||
if item.Type == artifacts.RemoteArtifactTypePublishedOutput {
|
||||
found++
|
||||
}
|
||||
}
|
||||
if found != 2 {
|
||||
t.Fatalf("published product count = %d, commit = %#v", found, commit)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,6 +65,10 @@ func TestRestoreThenForcedAnalyzeUsesRestoredDurableState(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatalf("load restored session manifest: %v", err)
|
||||
}
|
||||
producerRun := filepath.Join(sessionRoot, "runs", "20260519T010203Z-a1b2c3d4")
|
||||
if _, err := os.Stat(producerRun); !os.IsNotExist(err) {
|
||||
t.Fatalf("restore unexpectedly required producer run: %v", err)
|
||||
}
|
||||
upstreamCompletedAt := map[string]time.Time{}
|
||||
for _, stageName := range []string{"prepare", "transcribe", "merge", "polish", "normalize", "trim", "render", "extract"} {
|
||||
rec := beforeAnalyze.Stages[stageName]
|
||||
@@ -262,6 +266,8 @@ func restoreWorkflowManifestJSON(t *testing.T, sessionID, campaign string) []byt
|
||||
for i, stageName := range stages {
|
||||
m.MarkStageSucceeded(stageName, now.Add(time.Duration(i+1)*time.Minute), nil)
|
||||
}
|
||||
m.Stages["trim"].Logs = []string{"/prior/session/runs/old/trim/logs/report.json"}
|
||||
m.Stages["trim"].GeneratedConfigs = []string{"/prior/session/runs/old/trim/config.yml"}
|
||||
transcript := filepath.Join(t.TempDir(), "final.trimmed.json")
|
||||
mustWriteTestFile(t, transcript, `{"segments":[]}`+"\n")
|
||||
setCurrentBuiltInEvidence(t, m, "trim", artifacts.TranscriptOutputKindFinalTrimmed, artifacts.ArtifactTranscriptFinalTrimmed, transcript)
|
||||
|
||||
Reference in New Issue
Block a user