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

Clean up dag_test.go #3230

Merged
merged 1 commit into from
Sep 15, 2020
Merged

Clean up dag_test.go #3230

merged 1 commit into from
Sep 15, 2020

Conversation

imjasonh
Copy link
Member

  • 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

Submitter Checklist

These are the criteria that every PR should meet, please check them off as you
review them:

  • [y] Includes tests (if functionality changed/added)
  • [n] Includes docs (if user facing)
  • [y] Commit messages follow commit message best practices
  • [y] Release notes block has been filled in or deleted (only if no user facing changes)

See the contribution guide for more details.

Double check this list of stuff that's easy to miss:

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

NONE

/kind cleanup
/area testing
#3178

@tekton-robot tekton-robot added release-note-none Denotes a PR that doesnt merit a release note. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. area/testing Issues or PRs related to testing labels Sep 15, 2020
@tekton-robot tekton-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Sep 15, 2020
Copy link
Member

@vdemeester vdemeester left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label Sep 15, 2020
test/dag_test.go Outdated
Comment on lines 223 to 236
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)
Copy link
Member

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?

Copy link
Member

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.

Copy link
Member Author

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 :)

@popcor255
Copy link
Member

/lgtm

@tekton-robot tekton-robot removed the lgtm Indicates that a PR is ready to be merged. label Sep 15, 2020
- 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
Copy link
Collaborator

@bobcatfish bobcatfish left a 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)
})
Copy link
Collaborator

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)
}
Copy link
Collaborator

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)
Copy link
Collaborator

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

@tekton-robot
Copy link
Collaborator

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@tekton-robot tekton-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Sep 15, 2020
@bobcatfish
Copy link
Collaborator

/lgtm

@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label Sep 15, 2020
@tekton-robot tekton-robot merged commit 723fca9 into tektoncd:master Sep 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. area/testing Issues or PRs related to testing kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. lgtm Indicates that a PR is ready to be merged. release-note-none Denotes a PR that doesnt merit a release note. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants