Preserve partial run results and terminal failure causes
This commit is contained in:
@@ -18,10 +18,11 @@ type terminalSessionStore struct {
|
||||
}
|
||||
|
||||
type successfulStageSaveFailingStore struct {
|
||||
delegate manifest.Store
|
||||
stageName string
|
||||
dependent string
|
||||
failed bool
|
||||
delegate manifest.Store
|
||||
stageName string
|
||||
failStatus manifest.StageStatus
|
||||
dependent string
|
||||
failed bool
|
||||
}
|
||||
|
||||
func (s *successfulStageSaveFailingStore) Create(ctx context.Context, sessionID string) (*manifest.Manifest, error) {
|
||||
@@ -34,7 +35,11 @@ func (s *successfulStageSaveFailingStore) Load(ctx context.Context, path string)
|
||||
|
||||
func (s *successfulStageSaveFailingStore) Save(ctx context.Context, path string, m *manifest.Manifest) error {
|
||||
record := m.Stages[s.stageName]
|
||||
if !s.failed && record != nil && record.Status == manifest.StatusSucceeded {
|
||||
status := s.failStatus
|
||||
if status == "" {
|
||||
status = manifest.StatusSucceeded
|
||||
}
|
||||
if !s.failed && record != nil && record.Status == status {
|
||||
s.failed = true
|
||||
m.MarkStageSucceeded(s.dependent, time.Now().UTC(), nil)
|
||||
return errors.New("injected successful-stage save failure")
|
||||
@@ -166,3 +171,19 @@ func TestExecuteStagesSuccessfulSaveFailureMarksStageFailedAndInvalidatesDepende
|
||||
t.Fatalf("normalize stage = %#v, want stale", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestExecuteStagesSelfSkipSaveFailureIsNotReportedComplete(t *testing.T) {
|
||||
cfg := testConfig(t)
|
||||
store := &successfulStageSaveFailingStore{delegate: &manifest.LocalStore{}, stageName: "polish", dependent: "normalize", failStatus: manifest.StatusSkipped}
|
||||
summary, err := executeStages(context.Background(), cfg, []stage.Stage{resultStage{name: "polish", result: &stage.StageResult{Disposition: stage.StageDispositionSkipped, SkipReason: "disabled"}}}, RunOptions{Env: &Env{ManifestStore: store}})
|
||||
if err == nil || summary == nil || summary.Complete || len(summary.Skipped) != 0 || summary.StageResults[0].Outcome != "failed" {
|
||||
t.Fatalf("summary=%#v error=%v", summary, err)
|
||||
}
|
||||
saved, err := store.Load(context.Background(), summary.ManifestPath)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if saved.Stages["polish"].Status != manifest.StatusFailed || saved.Stages["normalize"].Status != manifest.StatusStale {
|
||||
t.Fatalf("unpersisted skip preserved as completion: %#v", saved.Stages)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user