Skip to content

Commit

Permalink
Improve DAG validation for pipelines with hundreds of tasks - v1beta1…
Browse files Browse the repository at this point in the history
… tests

Add pipeline validation tests for `v1beta1`.

Related to: #5420
  • Loading branch information
rafalbigaj authored and tekton-robot committed Sep 9, 2022
1 parent 666cc8f commit edbca30
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions pkg/apis/pipeline/v1beta1/pipeline_validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -733,9 +733,11 @@ func TestPipelineSpec_Validate_Failure_CycleDAG(t *testing.T) {
name := "invalid pipeline spec with DAG having cyclic dependency"
ps := &PipelineSpec{
Tasks: []PipelineTask{{
Name: "foo", TaskRef: &TaskRef{Name: "foo-task"}, RunAfter: []string{"bar"},
Name: "foo", TaskRef: &TaskRef{Name: "foo-task"}, RunAfter: []string{"baz"},
}, {
Name: "bar", TaskRef: &TaskRef{Name: "bar-task"}, RunAfter: []string{"foo"},
}, {
Name: "baz", TaskRef: &TaskRef{Name: "baz-task"}, RunAfter: []string{"bar"},
}},
}
err := ps.Validate(context.Background())
Expand Down Expand Up @@ -1139,9 +1141,15 @@ func TestValidateGraph_Failure(t *testing.T) {
}, {
Name: "bar", TaskRef: &TaskRef{Name: "bar-task"}, RunAfter: []string{"foo"},
}}
if err := validateGraph(tasks); err == nil {
expectedError := apis.FieldError{
Message: `invalid value: cycle detected; task "bar" depends on "foo"`,
Paths: []string{"tasks"},
}
err := validateGraph(tasks)
if err == nil {
t.Error("Pipeline.validateGraph() did not return error for invalid DAG of pipeline tasks:", desc)

} else if d := cmp.Diff(expectedError.Error(), err.Error(), cmpopts.IgnoreUnexported(apis.FieldError{})); d != "" {
t.Errorf("Pipeline.validateGraph() errors diff %s", diff.PrintWantGot(d))
}
}

Expand Down

0 comments on commit edbca30

Please sign in to comment.