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

test(backend): fix flaky backend test #9079

Merged
merged 1 commit into from
Mar 31, 2023

Conversation

Linchin
Copy link
Contributor

@Linchin Linchin commented Mar 31, 2023

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:

@Linchin Linchin requested review from chensun and gkcalat March 31, 2023 18:52
@google-oss-prow google-oss-prow bot requested a review from zijianjoy March 31, 2023 18:52
@Linchin Linchin removed the request for review from zijianjoy March 31, 2023 18:57
keys := make([]string, 0, len(tasks))
for key := range tasks {
keys = append(keys, key)
}
Copy link
Member

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

Copy link
Member

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

Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Member

@chensun chensun left a 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.

@google-oss-prow google-oss-prow bot added the lgtm label Mar 31, 2023
@google-oss-prow
Copy link

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

@google-oss-prow google-oss-prow bot merged commit 76a7ed2 into kubeflow:master Mar 31, 2023
rd-pong pushed a commit to rd-pong/pipelines that referenced this pull request Apr 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants