cluster-api-provider-gcp
cluster-api-provider-gcp copied to clipboard
Fix broken `TestGCPClusterTemplate_ValidateUpdate` test
/kind failing-test
More like "not running" test rather than failing
What this PR does / why we need it:
Parallel test closures execute in a goroutine, possibly after the next loop iteration has already began. As a result, the loop var they capture changes before the test execute, leading to all of them executing just the last test in the list.
This fixes that by making the closure capture a local variable rather than the loop variable
Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...)
format, will close the issue(s) when PR gets merged):
None
Special notes for your reviewer:
- [ ] squashed commits
- [ ] includes documentation
- [ ] adds unit tests
NONE
Welcome @omertuc!
It looks like this is your first PR to kubernetes-sigs/cluster-api-provider-gcp 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.
You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.
You can also check if kubernetes-sigs/cluster-api-provider-gcp has its own contribution guidelines.
You may want to refer to our testing guide if you run into trouble with your tests not passing.
If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!
Thank you, and welcome to Kubernetes. :smiley:
Hi @omertuc. Thanks for your PR.
I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test
on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.
Once the patch is verified, the new status will be reflected by the ok-to-test
label.
I understand the commands that are listed here.
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.
/assign @pydctw
/test pull-cluster-api-provider-gcp-e2e-test
@omertuc, where did you see the failing tests (not running)? Could you provide before and after?
@omertuc, where did you see the failing tests (not running)? Could you provide before and after?
I haven't literally seen it happen in this particular instance, I just know they're not running due to a known issue. I wrote a linter that searches for this issue and it was triggered for this particular test
See similar k8s PR https://github.com/kubernetes/kubernetes/pull/111846
In practice what happens is that it seems like all these tests are running, while in reality they're all using the same parameters, which are the parameters of the last test in the loop. So it's enough for just the last test in the loop to pass to make it seem like all loop tests are passsing
This short recording demonstrates that: https://asciinema.org/a/0rMFOEAtFdh0fb5Va743VVBKN
before the fix, no matter what the parameters of the first loop iteration are, the test is passing.
after the fix, the test parameters actually make a difference
Thanks so much for the explanation and the video. Understand the problem. I wonder why we use t.Parallel()
in the unit tests but that is a different conversation.
e2e test shouldn't matter for this change but running it again as it is failing.
/test pull-cluster-api-provider-gcp-e2e-test
Looks like e2e flake is resolved on other PRs.
/test pull-cluster-api-provider-gcp-e2e-test
/lgtm
[APPROVALNOTIFIER] This PR is APPROVED
This pull-request has been approved by: cpanato, omertuc
The full list of commands accepted by this bot can be found here.
The pull request process is described here
- ~~OWNERS~~ [cpanato]
Approvers can indicate their approval by writing /approve
in a comment
Approvers can cancel approval by writing /approve cancel
in a comment