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: tektoncd#5420
  • Loading branch information
rafalbigaj committed Sep 6, 2022
1 parent 062ffcb commit fbf79c0
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 @@ -701,9 +701,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"},
}},
}
ctx := config.SkipValidationDueToPropagatedParametersAndWorkspaces(context.Background(), false)
Expand Down Expand Up @@ -1089,9 +1091,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 fbf79c0

Please sign in to comment.