-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Clean up dag_test.go #3230
Clean up dag_test.go #3230
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
test/dag_test.go
Outdated
if !strings.HasPrefix(taskRuns[0].Name, "dag-pipeline-run-pipeline-task-1") { | ||
t.Errorf("Expected first task to execute first, but %q was first", taskRuns[0].Name) | ||
} | ||
if !strings.HasPrefix(times[1].name, "dag-pipeline-run-pipeline-task-2") { | ||
t.Errorf("Expected parallel tasks to run second & third, but %q was second", times[1].name) | ||
if !strings.HasPrefix(taskRuns[1].Name, "dag-pipeline-run-pipeline-task-2") { | ||
t.Errorf("Expected parallel tasks to run second & third, but %q was second", taskRuns[1].Name) | ||
} | ||
if !strings.HasPrefix(times[2].name, "dag-pipeline-run-pipeline-task-2") { | ||
t.Errorf("Expected parallel tasks to run second & third, but %q was third", times[2].name) | ||
if !strings.HasPrefix(taskRuns[2].Name, "dag-pipeline-run-pipeline-task-2") { | ||
t.Errorf("Expected parallel tasks to run second & third, but %q was third", taskRuns[2].Name) | ||
} | ||
if !strings.HasPrefix(times[3].name, "dag-pipeline-run-pipeline-task-3") { | ||
t.Errorf("Expected third task to execute third, but %q was third", times[3].name) | ||
if !strings.HasPrefix(taskRuns[3].Name, "dag-pipeline-run-pipeline-task-3") { | ||
t.Errorf("Expected third task to execute third, but %q was third", taskRuns[3].Name) | ||
} | ||
if !strings.HasPrefix(times[4].name, "dag-pipeline-run-pipeline-task-4") { | ||
t.Errorf("Expected fourth task to execute fourth, but %q was fourth", times[4].name) | ||
if !strings.HasPrefix(taskRuns[4].Name, "dag-pipeline-run-pipeline-task-4") { | ||
t.Errorf("Expected fourth task to execute fourth, but %q was fourth", taskRuns[4].Name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is dag-pipeline-run-pipeline-task-2
supposed to be there twice on line 226 and 229?
Also, can we put this in a loop?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh, I see what this is doing. 🤦 nvm.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah it confused me too, and even after I "got" it I had a moment of panic when I read your comment that this test wasn't correct. I think we could use better names :)
/lgtm |
- don't use test builders - use script mode instead of command+args - sort start times using sort.Slice - compare parallel task start times using math.Abs in case s1 starts >5s before s2 -- only the other case was checked before - then copy test/dag_test.go -> test/v1alpha1/dag_test.go and fix incompatibilities
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
full disclosure i didnt look at the v1alpha1 version very closely but anyway thanks for updating both! and for this cleanup :D
/approve
it := taskRuns[i].Status.StartTime.Time | ||
jt := taskRuns[j].Status.StartTime.Time | ||
return it.Before(jt) | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice!!
for i, wp := range wantPrefixes { | ||
if !strings.HasPrefix(taskRuns[i].Name, wp) { | ||
t.Errorf("Expected task %q to execute first, but %q was first", wp, taskRuns[0].Name) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 👍 👍
s2 := taskRuns[2].Status.StartTime.Time | ||
absDiff := time.Duration(math.Abs(float64(s2.Sub(s1)))) | ||
if absDiff > (time.Second * 5) { | ||
t.Errorf("Expected parallel tasks to execute more or less at the same time, but they were %v apart", absDiff) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well this test is a lot easier to understand now :D
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: bobcatfish The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/lgtm |
Submitter Checklist
These are the criteria that every PR should meet, please check them off as you
review them:
See the contribution guide for more details.
Double check this list of stuff that's easy to miss:
cmd
dir, please updatethe release Task to build and release this image.
Reviewer Notes
If API changes are included, additive changes must be approved by at least two OWNERS and backwards incompatible changes must be approved by more than 50% of the OWNERS, and they must first be added in a backwards compatible way.
Release Notes
/kind cleanup
/area testing
#3178