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

🌱 Improve TestReconcileMachinePoolMachines unit test #11124

Merged
merged 1 commit into from
Sep 2, 2024

Conversation

cahillsf
Copy link
Member

@cahillsf cahillsf commented Sep 1, 2024

What this PR does / why we need it:

we can see in the failing test results (i.e. https://prow.k8s.io/view/gs/kubernetes-jenkins/logs/periodic-cluster-api-test-mink8s-main/1830171842158006272) that this line

log.Info("Creating new Machine for infraMachine", "infraMachine", klog.KObj(infraMachine))
is only logging once, whereas in the successful tests (example) , it logs twice as 2 infraMachines are recognized and the 2 machinepool machines are created accordingly

my theory is that a cache sync delay is causing this flake as only 1 of the expected infraMachines is found in the cache when reconcileMachines gets called

this pr updates the method called to Create objects in this set of unit test to the "preferred" method:

"CreateAndWait creates the given object and waits for the cache to be updated accordingly."

instead of Create()

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

/area machinepool

@k8s-ci-robot
Copy link
Contributor

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

@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. area/machinepool Issues or PRs related to machinepools cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Sep 1, 2024
@k8s-ci-robot k8s-ci-robot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Sep 1, 2024
@cahillsf cahillsf marked this pull request as ready for review September 1, 2024 21:45
@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 Sep 1, 2024
Copy link
Member

@fabriziopandini fabriziopandini left a comment

Choose a reason for hiding this comment

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

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Sep 2, 2024
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: 552ec153c4b4c9a253cf1760032ec62f9cc54b74

@sbueringer
Copy link
Member

I don't really get the change from APIReader to Client. APIReader directly accesses the apiserver, Client uses a cache.

So I don't see how switching to Client makes the tests more stable (probably it will make it more flaky)

@cahillsf
Copy link
Member Author

cahillsf commented Sep 2, 2024

I don't really get the change from APIReader to Client. APIReader directly accesses the apiserver, Client uses a cache.

So I don't see how switching to Client makes the tests more stable (probably it will make it more flaky)

I think you’re right, will revert this change

@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Sep 2, 2024
@cahillsf cahillsf force-pushed the improve-mpc-unit-test branch from 762a825 to 35cf278 Compare September 2, 2024 15:52
@sbueringer sbueringer changed the title 🌱 improve mpc unit test 🌱 Improve mpc unit test Sep 2, 2024
@sbueringer sbueringer changed the title 🌱 Improve mpc unit test 🌱 Improve TestReconcileMachinePoolMachines unit test Sep 2, 2024
@sbueringer
Copy link
Member

Thank you!

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Sep 2, 2024
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: 0294a7af8986abdbfef884214036112bd5577758

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: sbueringer

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 k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Sep 2, 2024
@k8s-ci-robot k8s-ci-robot merged commit 7062ab0 into kubernetes-sigs:main Sep 2, 2024
30 checks passed
@k8s-ci-robot k8s-ci-robot added this to the v1.9 milestone Sep 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. area/machinepool Issues or PRs related to machinepools cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

flaking unit test in TestReconcileMachinePoolMachines
4 participants