Skip to content

Commit

Permalink
Update fan in / fan out test (no automatic copy) 📋
Browse files Browse the repository at this point in the history
Now that we don't automatically copy the content of an input to an
output (when the same resource is used as both an input and an output),
this means that:
- Our fan-in / fan-out test will need to explicitly write to the output
  path, instead of writing to the input path and assuming it would get
  copied over (the very behaviour we're changing in #1188)
- Data previously written to an output that is used as an input, and
  then an output later on, will be lost unless explicitly copied. In the
  update to the examples this was handled by symlinking the input to the
  output, I decided to instead update the test to no longer expect to
  see a file that was written by the first task in the graph and to not
  copy it explicitly.

Note that there is actually a race between the two tasks fanning out -
if the were writing the same file we would not be able to reliably
predict which would win.

Part of fixing #1188
  • Loading branch information
bobcatfish authored and tekton-robot committed Sep 13, 2019
1 parent f5ff8a6 commit 5e3276d
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions test/pipelinerun_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,12 +251,12 @@ func getFanInFanOutTasks(namespace string) []*v1alpha1.Task {
)),
tb.TaskOutputs(outWorkspaceResource),
tb.Step("write-data-task-0-step-0", "ubuntu", tb.StepCommand("/bin/bash"),
tb.StepArgs("-c", "echo stuff > $(inputs.resources.workspace.path)/stuff"),
tb.StepArgs("-c", "echo stuff > $(outputs.resources.workspace.path)/stuff"),
),
tb.Step("write-data-task-0-step-1", "ubuntu", tb.StepCommand("/bin/bash"),
// TODO(#1170): This test is using a mix of ${} and $() syntax to make sure both work.
// In the next release we will remove support for $() entirely.
tb.StepArgs("-c", "echo other > ${inputs.resources.workspace.path}/other"),
tb.StepArgs("-c", "echo other > ${outputs.resources.workspace.path}/other"),
),
)),
tb.Task("check-create-files-exists", namespace, tb.TaskSpec(
Expand All @@ -268,7 +268,7 @@ func getFanInFanOutTasks(namespace string) []*v1alpha1.Task {
tb.StepArgs("-c", "[[ stuff == $(cat ${inputs.resources.workspace.path}/stuff) ]]"),
),
tb.Step("write-data-task-1", "ubuntu", tb.StepCommand("/bin/bash"),
tb.StepArgs("-c", "echo something > $(inputs.resources.workspace.path)/something"),
tb.StepArgs("-c", "echo something > $(outputs.resources.workspace.path)/something"),
),
)),
tb.Task("check-create-files-exists-2", namespace, tb.TaskSpec(
Expand All @@ -278,20 +278,17 @@ func getFanInFanOutTasks(namespace string) []*v1alpha1.Task {
tb.StepArgs("-c", "[[ other == $(cat $(inputs.resources.workspace.path)/other) ]]"),
),
tb.Step("write-data-task-1", "ubuntu", tb.StepCommand("/bin/bash"),
tb.StepArgs("-c", "echo else > $(inputs.resources.workspace.path)/else"),
tb.StepArgs("-c", "echo else > $(outputs.resources.workspace.path)/else"),
),
)),
tb.Task("read-files", namespace, tb.TaskSpec(
tb.TaskInputs(tb.InputsResource("workspace", v1alpha1.PipelineResourceTypeGit,
tb.ResourceTargetPath("readingspace"),
)),
tb.Step("read-from-task-0", "ubuntu", tb.StepCommand("/bin/bash"),
tb.StepArgs("-c", "[[ stuff == $(cat $(inputs.resources.workspace.path)/stuff) ]]"),
),
tb.Step("read-from-task-1", "ubuntu", tb.StepCommand("/bin/bash"),
tb.StepArgs("-c", "[[ something == $(cat $(inputs.resources.workspace.path)/something) ]]"),
),
tb.Step("read-from-task-2", "ubuntu", tb.StepCommand("/bin/bash"),
tb.Step("read-from-task-1", "ubuntu", tb.StepCommand("/bin/bash"),
// TODO(#1170): This test is using a mix of ${} and $() syntax to make sure both work.
// In the next release we will remove support for $() entirely.
tb.StepArgs("-c", "[[ else == $(cat ${inputs.resources.workspace.path}/else) ]]"),
Expand Down

0 comments on commit 5e3276d

Please sign in to comment.