Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions cmd/harness/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -744,18 +744,25 @@ func versionCmd() *cobra.Command {
}
}

// applyCasePin overlays a case's subject_image/subject_version pin onto a
// registry-resolved Subject. The global --image/--version CLI flags are applied
// later in runner.applySubjectOverrides, so an explicit CLI flag still wins:
// applyCasePin overlays a case's subject_image/subject_version/subject_entrypoint
// pin onto a registry-resolved Subject. The global --image/--version CLI flags are
// applied later in runner.applySubjectOverrides, so an explicit CLI flag still
// wins:
//
// CLI --image/--version > case subject_image/subject_version > registry default
//
// subject_entrypoint has no CLI counterpart: it is a property of what the case
// tests (see TestCase.SubjectEntrypoint), not of which build is under test.
func applyCasePin(s config.Subject, tc *config.TestCase) config.Subject {
if tc.SubjectImage != "" {
s = s.WithImage(tc.SubjectImage)
}
if tc.SubjectVersion != "" {
s = s.WithVersion(tc.SubjectVersion)
}
if len(tc.SubjectEntrypoint) > 0 {
s = s.WithEntrypoint(tc.SubjectEntrypoint)
}
return s
}

Expand Down
11 changes: 11 additions & 0 deletions internal/config/case.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,17 @@ type TestCase struct {
SubjectImage string `yaml:"subject_image"`
SubjectVersion string `yaml:"subject_version"`

// SubjectEntrypoint replaces the registry's entrypoint for this case, with
// the registry Command still appended as arguments. Same precedence and the
// same non-strict-decode tolerance as SubjectImage.
//
// Needed where the case is about the subject's own process lifecycle: the
// director self-update cases stop and restart the service they are updating,
// which ends the container when the service is PID 1. Pointing the entrypoint
// at a wrapper that runs the service as a CHILD keeps the container alive
// across that restart, so "the service came back" is observable at all.
SubjectEntrypoint []string `yaml:"subject_entrypoint"`

Subjects []string `yaml:"subjects"`
Configurations map[string]Configuration `yaml:"configurations"`
Correctness CorrectnessConfig `yaml:"correctness"`
Expand Down
8 changes: 8 additions & 0 deletions internal/config/subject.go
Original file line number Diff line number Diff line change
Expand Up @@ -336,3 +336,11 @@ func (s Subject) WithImage(img string) Subject {
s.Image = img
return s
}

// WithEntrypoint returns a copy of the Subject with the entrypoint overridden.
// Command is left alone, so the registry's arguments still reach the new
// entrypoint — a wrapper script gets them as "$@".
func (s Subject) WithEntrypoint(entrypoint []string) Subject {
s.Entrypoint = entrypoint
return s
}
Loading