-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
test(backend): fix flaky backend test #9079
Conversation
keys := make([]string, 0, len(tasks)) | ||
for key := range tasks { | ||
keys = append(keys, key) | ||
} |
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.
I think this chunk can be just
keys := dagSpec.GetTasks().Keys()
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.
It seems that golang's map
doesn't have Keys()
methods. A more concise way of gett all keys is:
keys := reflect.ValueOf(dagSpec.GetTasks()).MapKeys()
We can still remove tasks := dagSpec.GetTasks()
and use keys := make([]string, 0, len(dagSpec.GetTasks()))
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.
My bad, ignore me then.
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.
With
keys := reflect.ValueOf(dagSpec.GetTasks()).MapKeys()
It doesn't feel very readable? it also introduces a new package. The variable tasks
is used again at line #58 so I don't think it makes a huge difference.
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
/approve
Thanks for the quick fix.
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: chensun 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 |
Description of your changes:
Since #9059, the backend test has been rather flaky. After some investigation, it turned out that the tasks inside the root dag had a random order, and an added unit test in #9059 exposed this issue. This PR fixed the issue by ordering the tasks alphabetically.
Checklist: