Skip to content

Commit ec69272

Browse files
rafalbigajafrittoli
authored andcommitted
Improve DAG validation for pipelines with hundreds of tasks - v1beta1 tests
Add pipeline validation tests for `v1beta1`. Related to: tektoncd#5420
1 parent eeb0760 commit ec69272

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

pkg/apis/pipeline/v1beta1/pipeline_validation_test.go

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -733,9 +733,11 @@ func TestPipelineSpec_Validate_Failure_CycleDAG(t *testing.T) {
733733
name := "invalid pipeline spec with DAG having cyclic dependency"
734734
ps := &PipelineSpec{
735735
Tasks: []PipelineTask{{
736-
Name: "foo", TaskRef: &TaskRef{Name: "foo-task"}, RunAfter: []string{"bar"},
736+
Name: "foo", TaskRef: &TaskRef{Name: "foo-task"}, RunAfter: []string{"baz"},
737737
}, {
738738
Name: "bar", TaskRef: &TaskRef{Name: "bar-task"}, RunAfter: []string{"foo"},
739+
}, {
740+
Name: "baz", TaskRef: &TaskRef{Name: "baz-task"}, RunAfter: []string{"bar"},
739741
}},
740742
}
741743
err := ps.Validate(context.Background())
@@ -1139,9 +1141,15 @@ func TestValidateGraph_Failure(t *testing.T) {
11391141
}, {
11401142
Name: "bar", TaskRef: &TaskRef{Name: "bar-task"}, RunAfter: []string{"foo"},
11411143
}}
1142-
if err := validateGraph(tasks); err == nil {
1144+
expectedError := apis.FieldError{
1145+
Message: `invalid value: cycle detected; task "bar" depends on "foo"`,
1146+
Paths: []string{"tasks"},
1147+
}
1148+
err := validateGraph(tasks)
1149+
if err == nil {
11431150
t.Error("Pipeline.validateGraph() did not return error for invalid DAG of pipeline tasks:", desc)
1144-
1151+
} else if d := cmp.Diff(expectedError.Error(), err.Error(), cmpopts.IgnoreUnexported(apis.FieldError{})); d != "" {
1152+
t.Errorf("Pipeline.validateGraph() errors diff %s", diff.PrintWantGot(d))
11451153
}
11461154
}
11471155

0 commit comments

Comments
 (0)