Create run workspaces only when needed
This commit is contained in:
@@ -927,7 +927,7 @@ func TestExecuteStagesLoadsExistingManifest(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestExecuteStagesCreatesRunDirectoryPerInvocation(t *testing.T) {
|
||||
func TestExecuteStagesCreatesRunDirectoryForEachExecutedInvocation(t *testing.T) {
|
||||
cfg := testConfig(t)
|
||||
cfg.Pipeline.Spool.Root = t.TempDir()
|
||||
cfg.Pipeline.Storage.S3 = &config.StorageS3Config{
|
||||
@@ -972,6 +972,30 @@ func TestExecuteStagesCreatesRunDirectoryPerInvocation(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestExecuteStagesDoesNotCreateRunDirectoryWhenAllSelectedStagesAreReusable(t *testing.T) {
|
||||
cfg := testConfig(t)
|
||||
selected := []stage.Stage{resultStage{name: "notify"}}
|
||||
first, err := executeStages(context.Background(), cfg, selected, RunOptions{})
|
||||
if err != nil {
|
||||
t.Fatalf("first executeStages() error = %v", err)
|
||||
}
|
||||
second, err := executeStages(context.Background(), cfg, selected, RunOptions{})
|
||||
if err != nil {
|
||||
t.Fatalf("second executeStages() error = %v", err)
|
||||
}
|
||||
if !reflect.DeepEqual(second.Skipped, []string{"notify"}) {
|
||||
t.Fatalf("second skipped stages = %#v, want notify", second.Skipped)
|
||||
}
|
||||
firstWorkDir := artifacts.SessionRunRootForCampaign(cfg.Pipeline.Workspace.Root, cfg.Session.Campaign, cfg.Session.SessionID, first.RunID)
|
||||
if info, statErr := os.Stat(firstWorkDir); statErr != nil || !info.IsDir() {
|
||||
t.Fatalf("executed invocation work directory %q = %#v, %v; want directory", firstWorkDir, info, statErr)
|
||||
}
|
||||
skippedWorkDir := artifacts.SessionRunRootForCampaign(cfg.Pipeline.Workspace.Root, cfg.Session.Campaign, cfg.Session.SessionID, second.RunID)
|
||||
if _, statErr := os.Lstat(skippedWorkDir); !errors.Is(statErr, os.ErrNotExist) {
|
||||
t.Fatalf("skipped invocation work directory stat error = %v, want absent", statErr)
|
||||
}
|
||||
}
|
||||
|
||||
func TestExecuteStagesRejectsPersistedManifestIdentityMismatch(t *testing.T) {
|
||||
for _, tc := range []struct {
|
||||
name string
|
||||
|
||||
Reference in New Issue
Block a user