Read publication inventory without execution snapshots
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
@@ -533,3 +534,71 @@ func addSecretsToPipelineConfig(t *testing.T, pipelinePath, secretsDir, accessKe
|
||||
}
|
||||
configureTestSecrets(t, pipelinePath, secretsDir)
|
||||
}
|
||||
|
||||
func TestPublicationInspectionAndSessionConfigIgnoreExecutionSnapshot(t *testing.T) {
|
||||
for _, tc := range []struct {
|
||||
name string
|
||||
omit bool
|
||||
body []byte
|
||||
}{
|
||||
{"no snapshot", true, nil}, {"missing snapshot", false, nil}, {"malformed snapshot", false, []byte("not json")}, {"unsupported snapshot", false, []byte(`{"schema_version":"unsupported"}`)},
|
||||
} {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
cfg := restorePlanConfig(t)
|
||||
fake := &storage.FakeBackend{}
|
||||
current := seedCommittedRestoreSnapshot(t, cfg, fake, "20260519T010203Z-a1b2c3d4", map[string][]byte{"transcripts/final.trimmed.json": []byte(`{"segments":[]}`)})
|
||||
sessionKey := artifacts.S3RunRelativeDestinationKey(artifacts.S3RunPrefix(current.SessionPrefix, current.RunID), "prepare/inputs/session.yml")
|
||||
fake.SeedObject(storage.FakeObject{Key: sessionKey, Data: []byte("session_id: 2026-05-03\ntitle: Inventory\n")})
|
||||
current.Commit.Artifacts = append(current.Commit.Artifacts, remoteRestoreArtifact(fake, artifacts.RemoteArtifactTypeRunFile, "run:prepare/inputs/session.yml", sessionKey))
|
||||
if tc.omit {
|
||||
filtered := current.Commit.Artifacts[:0]
|
||||
for _, item := range current.Commit.Artifacts {
|
||||
if item.Type != artifacts.RemoteArtifactTypeSessionManifest {
|
||||
filtered = append(filtered, item)
|
||||
}
|
||||
}
|
||||
current.Commit.Artifacts = filtered
|
||||
}
|
||||
if tc.body == nil {
|
||||
delete(fake.Objects, current.CurrentManifestKey)
|
||||
} else {
|
||||
fake.SeedObject(storage.FakeObject{Key: current.CurrentManifestKey, Data: tc.body})
|
||||
}
|
||||
commitData, err := artifacts.EncodeRemoteCommitManifest(*current.Commit)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
commitKey := artifacts.S3RunCommitKey(current.SessionPrefix, current.RunID)
|
||||
fake.SeedObject(storage.FakeObject{Key: commitKey, Data: commitData})
|
||||
pointer, err := artifacts.EncodeCurrentCommitPointer(artifacts.CurrentCommitPointer{FormatVersion: artifacts.RemoteCommitFormatVersion, Campaign: cfg.Session.Campaign, SessionID: cfg.Session.SessionID, RunID: current.RunID, CommitKey: commitKey, CommitSHA256: restoreCommitSHA256(commitData), CommitSize: int64(len(commitData)), CommitGeneration: fake.Objects[commitKey].ETag})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
fake.SeedObject(storage.FakeObject{Key: artifacts.S3CurrentCommitPointerKey(current.SessionPrefix), Data: pointer})
|
||||
fake.Reads = nil
|
||||
publication, err := discoverRemotePublication(context.Background(), cfg, fake)
|
||||
if err != nil || publication.RunID != current.RunID {
|
||||
t.Fatalf("publication %+v %v", publication, err)
|
||||
}
|
||||
_, _, body, err := findRemoteSessionConfig(context.Background(), fake, current.SessionPrefix, current.SessionPrefix+"session.yml", cfg.Session.Campaign, cfg.Session.SessionID)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
data, err := io.ReadAll(body)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := body.Close(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !strings.Contains(string(data), "title: Inventory") {
|
||||
t.Fatalf("session %s", data)
|
||||
}
|
||||
for _, read := range fake.Reads {
|
||||
if read.Key == current.CurrentManifestKey {
|
||||
t.Fatal("execution snapshot was read")
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user