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

fix cloud event flacky unit tests by adding waitgroup #5672

Closed

Conversation

Yongxuanzhang
Copy link
Member

@Yongxuanzhang Yongxuanzhang commented Oct 21, 2022

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

func (c FakeClient) Send(ctx context.Context, event cloudevents.Event) protocol.Result {

related PR:
#5313
Recent failing tests:

Submitter Checklist

As the author of this PR, please check off the items in this checklist:

  • Has Docs included if any changes are user facing
  • Has Tests included if any functionality added or changed
  • Follows the commit message standard
  • Meets the Tekton contributor standards (including
    functionality, content, code)
  • Has a kind label. You can add one by adding a comment on this PR that contains /kind <type>. Valid types are bug, cleanup, design, documentation, feature, flake, misc, question, tep
  • Release notes block below has been updated with any user facing changes (API changes, bug fixes, changes requiring upgrade notices or deprecation warnings)
  • Release notes contains the string "action required" if the change requires additional action from users switching to the new release

Release Notes

Fix cloud event flacky unit tests by adding waitgroup

@tekton-robot
Copy link
Collaborator

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@tekton-robot tekton-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. release-note-none Denotes a PR that doesnt merit a release note. kind/flake Categorizes issue or PR as related to a flakey test labels Oct 21, 2022
@tekton-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
To complete the pull request process, please assign afrittoli after the PR has been reviewed.
You can assign the PR to them by writing /assign @afrittoli in a comment when ready.

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

@tekton-robot tekton-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Oct 21, 2022
@Yongxuanzhang
Copy link
Member Author

cc @lbernick @abayer

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.

@Yongxuanzhang
Copy link
Member Author

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]
@Yongxuanzhang Yongxuanzhang force-pushed the fix-cloud-events-tests branch from bd048de to 61a9321 Compare October 25, 2022 21:28
@Yongxuanzhang Yongxuanzhang marked this pull request as ready for review October 25, 2022 21:28
@tekton-robot tekton-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Oct 25, 2022
@Yongxuanzhang
Copy link
Member Author

/hold for more reviews

@tekton-robot tekton-robot added do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed release-note-none Denotes a PR that doesnt merit a release note. labels Oct 25, 2022
@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/reconciler/events/cloudevent/cloud_event_controller.go 88.2% 88.6% 0.3

@lbernick
Copy link
Member

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!

@tekton-robot
Copy link
Collaborator

The following Tekton test failed:

Test name Commit Details Required Rerun command
check-pr-has-kind-label 70fcf0e link true /test check-pr-has-kind-label

@Yongxuanzhang
Copy link
Member Author

we may want to use #5690

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. kind/flake Categorizes issue or PR as related to a flakey test release-note Denotes a PR that will be considered when it comes time to generate release notes. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants