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

🌱 Setup separate context for test files to avoid flaky errors #2462

Closed
wants to merge 1 commit into from

Conversation

zhanggbj
Copy link
Contributor

What this PR does / why we need it:
Setup separate context for test files under /controllers instead of using the test-package context, this is to avoid flaky errors we found in CI.

Please find more details in #2295

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Part of #2295

@k8s-ci-robot k8s-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Oct 25, 2023
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign neolit123 for approval. For more information see the Kubernetes Code Review Process.

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

@k8s-ci-robot k8s-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Oct 25, 2023
@codecov
Copy link

codecov bot commented Oct 25, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 63.34%. Comparing base (a4eef1b) to head (08f5135).
Report is 543 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2462      +/-   ##
==========================================
- Coverage   63.63%   63.34%   -0.29%     
==========================================
  Files         122      122              
  Lines        8753     8753              
==========================================
- Hits         5570     5545      -25     
- Misses       2773     2791      +18     
- Partials      410      417       +7     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@zhanggbj zhanggbj changed the title [WIP] 🌱 Setup separate context for test files to avoid flaky errors 🌱 Setup separate context for test files to avoid flaky errors Oct 26, 2023
@k8s-ci-robot k8s-ci-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 26, 2023
Copy link
Contributor

@killianmuldoon killianmuldoon left a comment

Choose a reason for hiding this comment

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

/retest

@@ -17,6 +17,7 @@ limitations under the License.
package controllers
Copy link
Member

Choose a reason for hiding this comment

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

Let's move the package-level ctx in controllers_suite_test.go into the setup func.

This way we ensure nobody is reusing it

Copy link
Member

@sbueringer sbueringer Oct 26, 2023

Choose a reason for hiding this comment

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

Btw, I'm not sure I understand how the package-level context can lead to flaky tests. It should be only canceled when the test process is killed. Are there more details on this?

Copy link
Member

Choose a reason for hiding this comment

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

One state of @zhanggbj 's PR #2431 had constantly failing tests in CI. the changes after the following comment fixed it.

#2431 (comment)

Copy link
Member

Choose a reason for hiding this comment

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

Interesting. If I find the time I try to reproduce. Would be just interesting to understand why. I'm not sure but could be that we should re-think the pattern of using a package-level ctx. I think we use it in a bunch of places in core CAPI (but not sure)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It only can be reproduced in prow test, I cannot reproduce it locally, so not sure about the root cause.

Copy link
Member

Choose a reason for hiding this comment

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

If it's okay I would hold this PR for now. I'm hesitant to make this change if we don't know why we need it and tests are stable without this PR

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's OK for me to hold it until we reproduce it, this PR is just to make test cases more isolated considering the context staff.

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 10, 2023
@k8s-ci-robot
Copy link
Contributor

PR needs rebase.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@zhanggbj zhanggbj mentioned this pull request Nov 15, 2023
18 tasks
@sbueringer
Copy link
Member

sbueringer commented Nov 15, 2023

Related to #2506 (I think)

@chrischdi
Copy link
Member

Let's hold this work until we are sure about why it happened in https://github.com/kubernetes-sigs/cluster-api-provider-vsphere/compare/269023424b03a8c029ad95b605f0b6bf9431f9a3..b00e9811fd246af7a9e03676d9577b8ef56106d0 and if this would bring a benefit at all

/hold

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Dec 6, 2023
@k8s-ci-robot
Copy link
Contributor

@zhanggbj: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
pull-cluster-api-provider-vsphere-e2e-blocking-main 08f5135 link true /test pull-cluster-api-provider-vsphere-e2e-blocking-main
pull-cluster-api-provider-vsphere-e2e-supervisor-blocking-main 08f5135 link true /test pull-cluster-api-provider-vsphere-e2e-supervisor-blocking-main
pull-cluster-api-provider-vsphere-e2e-govmomi-blocking-main 08f5135 link true /test pull-cluster-api-provider-vsphere-e2e-govmomi-blocking-main

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

@chrischdi
Copy link
Member

I think we don't need this anymore.

/close

@k8s-ci-robot
Copy link
Contributor

@chrischdi: Closed this PR.

In response to this:

I think we don't need this anymore.

/close

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. 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.

5 participants