-
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
fix cloud event flacky unit tests by adding waitgroup #5672
Conversation
Skipping CI for Draft Pull Request. |
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
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.
/cc @afrittoli
This is one approach we may use to fix the cloud event flacky test. Please take a look 🙏 |
This commit adds waitgroup to reconciler, so can be used when creating goroutines to send cloud events. waitgroup.Wait() can be called during unit tests to make sure all goroutines are completed and avoid the case that some events are not written into channel before checking. This change shouldn't have influence on current hebaviour since we don't call Wait to block the code. Signed-off-by: Yongxuan Zhang [email protected]
bd048de
to
61a9321
Compare
/hold for more reviews |
The following is the coverage report on the affected files.
|
Chatting with @Yongxuanzhang, he is exploring an alternative solution where more of the waitgroup logic is contained to the events/cloudevents packages. I think it would be preferable for the events/cloudevents fakes to be able to test events by waiting until all of them are done being sent, but if that solution doesn't work out, this will be a great fix to have in! |
we may want to use #5690 |
Changes
This commit adds waitgroup to reconciler, so can be used when creating goroutines to send cloud events. waitgroup.Wait() can be called during unit tests to make sure all goroutines are completed and avoid the case that some events are not written into channel before checking. This change shouldn't have influence on current hebaviour since we don't call Wait to block the code. This should be able to fix flacky cloud event tests and we don't have to add time.sleep() before collecting events.
Signed-off-by: Yongxuan Zhang [email protected]
/kind flake
related issues:
#5160
to reproduce this issue, adding time.Sleep() to
pipeline/pkg/reconciler/events/cloudevent/cloudeventsfakeclient.go
Line 53 in b648a5b
related PR:
#5313
Recent failing tests:
Submitter Checklist
As the author of this PR, please check off the items in this checklist:
functionality, content, code)
/kind <type>
. Valid types are bug, cleanup, design, documentation, feature, flake, misc, question, tepRelease Notes