cluster-api-provider-gcp icon indicating copy to clipboard operation
cluster-api-provider-gcp copied to clipboard

Fix broken `TestGCPClusterTemplate_ValidateUpdate` test

Open omertuc opened this issue 2 years ago • 6 comments

/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

omertuc avatar Aug 14 '22 21:08 omertuc

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:

k8s-ci-robot avatar Aug 14 '22 21:08 k8s-ci-robot

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.

k8s-ci-robot avatar Aug 14 '22 21:08 k8s-ci-robot

/assign @pydctw

cpanato avatar Aug 16 '22 15:08 cpanato

/test pull-cluster-api-provider-gcp-e2e-test

omertuc avatar Aug 16 '22 16:08 omertuc

@omertuc, where did you see the failing tests (not running)? Could you provide before and after?

pydctw avatar Aug 16 '22 22:08 pydctw

@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

omertuc avatar Aug 16 '22 22:08 omertuc

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

omertuc avatar Aug 16 '22 22:08 omertuc

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.

pydctw avatar Aug 16 '22 22:08 pydctw

e2e test shouldn't matter for this change but running it again as it is failing.

/test pull-cluster-api-provider-gcp-e2e-test

pydctw avatar Aug 16 '22 22:08 pydctw

Looks like e2e flake is resolved on other PRs.

/test pull-cluster-api-provider-gcp-e2e-test

pydctw avatar Aug 18 '22 21:08 pydctw

/lgtm

pydctw avatar Aug 19 '22 04:08 pydctw

[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

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 avatar Aug 19 '22 06:08 k8s-ci-robot