test: stabilize customresourcesgate TestReconcile#976
Merged
phisco merged 1 commit intocrossplane:release-2.0from Apr 17, 2026
Merged
Conversation
The TestReconcile subtests normalized recorded gate calls by sorting only on GVK.Kind. Several fixtures contain multiple GVKs with identical Kind but different Version (e.g. "TestResource" at v1alpha1 and v1beta1). Combined with the nondeterministic map iteration in the reconciler, this made the assertion order-dependent and the test intermittently flaky (notably TestReconcile/EstablishedCRDCallsGateTrue). Sort on the full GroupVersionKind (Group, Version, Kind) so the comparison is stable regardless of the reconciler's iteration order. This mirrors the fix already on main (552d14c), backported here for release-2.0. Signed-off-by: Philippe Scorsolini <5697904+phisco@users.noreply.github.com>
Contributor
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
lsviben
approved these changes
Apr 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of your changes
Fixes a flake in
TestReconcile/EstablishedCRDCallsGateTrue(and other subtests with multi-version fixtures) inpkg/reconciler/customresourcesgate.The test normaliser sorted recorded
gate.True/gate.Falsecalls byGroupVersionKind.Kindonly. Several fixtures contain multiple GVKs that share the sameKindbut differ inVersion(e.g.TestResourceatv1alpha1andv1beta1). Because the reconciler iterates amap[schema.GroupVersionKind]bool— whose iteration order is nondeterministic in Go — the resulting slice order is not stable, and the Kind-only sort cannot disambiguate entries, so the assertion becomes order-dependent and intermittently fails.Sort on the full GVK (Group, Version, Kind) so the comparison is stable regardless of reconciler iteration order. This is a test-only change; reconciler behaviour is unchanged.
This has been blocking PRs #919 and #972 (and caused an unrelated flake observed in run #955, which predates the recent dep bumps).
This mirrors the fix already on
mainas part of 552d14c ("Upgrade controller-runtime to v0.21.0"), backported here forrelease-2.0.I have:
earthly +reviewableto ensure this PR is ready for review.How has this code been tested
Ran
go test -count=10 -race ./pkg/reconciler/customresourcesgate/...and the fullTestReconcile/EstablishedCRDCallsGateTruesubtest 10/10 times under-race— all passing.