Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TEP-0090: Matrix - implement isRunning for Runs #5062

Merged
merged 1 commit into from
Jul 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions pkg/reconciler/pipelinerun/resources/pipelinerunresolution.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ func (t ResolvedPipelineTask) isDone(facts *PipelineRunFacts) bool {
// isRunning returns true only if the task is neither succeeded, cancelled nor failed
func (t ResolvedPipelineTask) isRunning() bool {
switch {
case t.IsCustomTask() && t.IsMatrixed():
if len(t.Runs) == 0 {
return false
}
case t.IsCustomTask():
if t.Run == nil {
return false
Expand Down
135 changes: 135 additions & 0 deletions pkg/reconciler/pipelinerun/resources/pipelinerunresolution_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4052,118 +4052,253 @@ func TestIsRunning(t *testing.T) {
PipelineTask: matrixedPipelineTask,
},
want: false,
}, {
name: "matrixed runs not started",
rpt: ResolvedPipelineTask{
CustomTask: true,
PipelineTask: matrixedPipelineTask,
},
want: false,
}, {
name: "matrixed taskruns running",
rpt: ResolvedPipelineTask{
PipelineTask: matrixedPipelineTask,
TaskRuns: []*v1beta1.TaskRun{makeStarted(trs[0]), makeStarted(trs[1])},
},
want: true,
}, {
name: "matrixed runs running",
rpt: ResolvedPipelineTask{
CustomTask: true,
PipelineTask: matrixedPipelineTask,
Runs: []*v1alpha1.Run{makeRunStarted(runs[0]), makeRunStarted(runs[1])},
},
want: true,
}, {
name: "one matrixed taskrun running",
rpt: ResolvedPipelineTask{
PipelineTask: matrixedPipelineTask,
TaskRuns: []*v1beta1.TaskRun{makeStarted(trs[0]), makeSucceeded(trs[1])},
},
want: true,
}, {
name: "one matrixed run running",
rpt: ResolvedPipelineTask{
CustomTask: true,
PipelineTask: matrixedPipelineTask,
Runs: []*v1alpha1.Run{makeRunStarted(runs[0]), makeRunSucceeded(runs[1])},
},
want: true,
}, {
name: "matrixed taskruns succeeded",
rpt: ResolvedPipelineTask{
PipelineTask: matrixedPipelineTask,
TaskRuns: []*v1beta1.TaskRun{makeSucceeded(trs[0]), makeSucceeded(trs[1])},
},
want: false,
}, {
name: "matrixed runs succeeded",
rpt: ResolvedPipelineTask{
CustomTask: true,
PipelineTask: matrixedPipelineTask,
Runs: []*v1alpha1.Run{makeRunSucceeded(runs[0]), makeRunSucceeded(runs[1])},
},
want: false,
}, {
name: "matrixed taskruns failed",
rpt: ResolvedPipelineTask{
PipelineTask: matrixedPipelineTask,
TaskRuns: []*v1beta1.TaskRun{makeFailed(trs[0]), makeFailed(trs[1])},
},
want: false,
}, {
name: "matrixed runs failed",
rpt: ResolvedPipelineTask{
CustomTask: true,
PipelineTask: matrixedPipelineTask,
Runs: []*v1alpha1.Run{makeRunFailed(runs[0]), makeRunFailed(runs[1])},
},
want: false,
}, {
name: "one matrixed taskrun failed, one matrixed taskrun running",
rpt: ResolvedPipelineTask{
PipelineTask: matrixedPipelineTask,
TaskRuns: []*v1beta1.TaskRun{makeFailed(trs[0]), makeStarted(trs[1])},
},
want: true,
}, {
name: "one matrixed run failed, one matrixed run running",
rpt: ResolvedPipelineTask{
CustomTask: true,
PipelineTask: matrixedPipelineTask,
Runs: []*v1alpha1.Run{makeRunFailed(runs[0]), makeRunStarted(runs[1])},
},
want: true,
}, {
name: "matrixed taskruns failed: retries remaining",
rpt: ResolvedPipelineTask{
PipelineTask: withPipelineTaskRetries(*matrixedPipelineTask, 1),
TaskRuns: []*v1beta1.TaskRun{makeFailed(trs[0]), makeFailed(trs[1])},
},
want: true,
}, {
name: "matrixed runs failed: retries remaining",
rpt: ResolvedPipelineTask{
CustomTask: true,
PipelineTask: withPipelineTaskRetries(*matrixedPipelineTask, 1),
Runs: []*v1alpha1.Run{makeRunFailed(runs[0]), makeRunFailed(runs[1])},
},
want: true,
}, {
name: "matrixed taskruns failed: one taskrun with retries remaining",
rpt: ResolvedPipelineTask{
PipelineTask: withPipelineTaskRetries(*matrixedPipelineTask, 1),
TaskRuns: []*v1beta1.TaskRun{makeFailed(trs[0]), withRetries(makeFailed(trs[1]))},
},
want: true,
}, {
name: "matrixed runs failed: one run with retries remaining",
rpt: ResolvedPipelineTask{
CustomTask: true,
PipelineTask: withPipelineTaskRetries(*matrixedPipelineTask, 1),
Runs: []*v1alpha1.Run{makeRunFailed(runs[0]), withRunRetries(makeRunFailed(runs[1]))},
},
want: true,
}, {
name: "matrixed taskruns failed: no retries remaining",
rpt: ResolvedPipelineTask{
PipelineTask: withPipelineTaskRetries(*matrixedPipelineTask, 1),
TaskRuns: []*v1beta1.TaskRun{withRetries(makeFailed(trs[0])), withRetries(makeFailed(trs[1]))},
},
want: false,
}, {
name: "matrixed runs failed: no retries remaining",
rpt: ResolvedPipelineTask{
CustomTask: true,
PipelineTask: withPipelineTaskRetries(*matrixedPipelineTask, 1),
Runs: []*v1alpha1.Run{withRunRetries(makeRunFailed(runs[0])), withRunRetries(makeRunFailed(runs[1]))},
},
want: false,
}, {
name: "matrixed taskruns cancelled",
rpt: ResolvedPipelineTask{
PipelineTask: matrixedPipelineTask,
TaskRuns: []*v1beta1.TaskRun{withCancelled(makeFailed(trs[0])), withCancelled(makeFailed(trs[1]))},
},
want: false,
}, {
name: "matrixed runs cancelled",
rpt: ResolvedPipelineTask{
CustomTask: true,
PipelineTask: matrixedPipelineTask,
Runs: []*v1alpha1.Run{withRunCancelled(makeRunFailed(runs[0])), withRunCancelled(makeRunFailed(runs[1]))},
},
want: false,
}, {
name: "one matrixed taskrun cancelled, one matrixed taskrun running",
rpt: ResolvedPipelineTask{
PipelineTask: matrixedPipelineTask,
TaskRuns: []*v1beta1.TaskRun{withCancelled(makeFailed(trs[0])), makeStarted(trs[1])},
},
want: true,
}, {
name: "one matrixed run cancelled, one matrixed run running",
rpt: ResolvedPipelineTask{
CustomTask: true,
PipelineTask: matrixedPipelineTask,
Runs: []*v1alpha1.Run{withRunCancelled(makeRunFailed(runs[0])), makeRunStarted(runs[1])},
},
want: true,
}, {
name: "matrixed taskruns cancelled but not failed",
rpt: ResolvedPipelineTask{
PipelineTask: matrixedPipelineTask,
TaskRuns: []*v1beta1.TaskRun{withCancelled(newTaskRun(trs[0])), withCancelled(newTaskRun(trs[1]))},
},
want: true,
}, {
name: "matrixed runs cancelled but not failed",
rpt: ResolvedPipelineTask{
CustomTask: true,
PipelineTask: matrixedPipelineTask,
Runs: []*v1alpha1.Run{withRunCancelled(newRun(runs[0])), withRunCancelled(newRun(runs[1]))},
},
want: true,
}, {
name: "one matrixed taskrun cancelled but not failed",
rpt: ResolvedPipelineTask{
PipelineTask: matrixedPipelineTask,
TaskRuns: []*v1beta1.TaskRun{withCancelled(newTaskRun(trs[0])), makeStarted(trs[1])},
},
want: true,
}, {
name: "one matrixed run cancelled but not failed",
rpt: ResolvedPipelineTask{
CustomTask: true,
PipelineTask: matrixedPipelineTask,
Runs: []*v1alpha1.Run{withRunCancelled(newRun(runs[0])), makeRunStarted(runs[1])},
},
want: true,
}, {
name: "matrixed taskruns cancelled: retries remaining",
rpt: ResolvedPipelineTask{
PipelineTask: withPipelineTaskRetries(*matrixedPipelineTask, 1),
TaskRuns: []*v1beta1.TaskRun{withCancelled(makeFailed(trs[0])), withCancelled(makeFailed(trs[1]))},
},
want: false,
}, {
name: "matrixed runs cancelled: retries remaining",
rpt: ResolvedPipelineTask{
CustomTask: true,
PipelineTask: withPipelineTaskRetries(*matrixedPipelineTask, 1),
Runs: []*v1alpha1.Run{withRunCancelled(makeRunFailed(runs[0])), withRunCancelled(makeRunFailed(runs[1]))},
},
want: false,
}, {
name: "one matrixed taskrun cancelled: retries remaining, one matrixed taskrun running",
rpt: ResolvedPipelineTask{
PipelineTask: withPipelineTaskRetries(*matrixedPipelineTask, 1),
TaskRuns: []*v1beta1.TaskRun{withCancelled(makeFailed(trs[0])), makeStarted(trs[1])},
},
want: true,
}, {
name: "one matrixed run cancelled: retries remaining, one matrixed run running",
rpt: ResolvedPipelineTask{
CustomTask: true,
PipelineTask: withPipelineTaskRetries(*matrixedPipelineTask, 1),
Runs: []*v1alpha1.Run{withRunCancelled(makeRunFailed(runs[0])), makeRunStarted(runs[1])},
},
want: true,
}, {
name: "matrixed taskruns cancelled: no retries remaining",
rpt: ResolvedPipelineTask{
PipelineTask: withPipelineTaskRetries(*matrixedPipelineTask, 1),
TaskRuns: []*v1beta1.TaskRun{withCancelled(withRetries(makeFailed(trs[0]))), withCancelled(withRetries(makeFailed(trs[1])))},
},
want: false,
}, {
name: "matrixed runs cancelled: no retries remaining",
rpt: ResolvedPipelineTask{
CustomTask: true,
PipelineTask: withPipelineTaskRetries(*matrixedPipelineTask, 1),
Runs: []*v1alpha1.Run{withRunCancelled(withRunRetries(makeRunFailed(runs[0]))), withRunCancelled(withRunRetries(makeRunFailed(runs[1])))},
},
want: false,
}, {
name: "one matrixed taskrun cancelled: no retries remaining, one matrixed taskrun running",
rpt: ResolvedPipelineTask{
PipelineTask: withPipelineTaskRetries(*matrixedPipelineTask, 1),
TaskRuns: []*v1beta1.TaskRun{withCancelled(withRetries(makeFailed(trs[0]))), makeStarted(trs[1])},
},
want: true,
}, {
name: "one matrixed run cancelled: no retries remaining, one matrixed run running",
rpt: ResolvedPipelineTask{
CustomTask: true,
PipelineTask: withPipelineTaskRetries(*matrixedPipelineTask, 1),
Runs: []*v1alpha1.Run{withRunCancelled(withRunRetries(makeRunFailed(runs[0]))), makeRunStarted(runs[1])},
},
want: true,
}} {
t.Run(tc.name, func(t *testing.T) {
if got := tc.rpt.isRunning(); got != tc.want {
Expand Down