Skip to content

test: stabilize customresourcesgate TestReconcile [release-2.1 backport]#978

Merged
phisco merged 1 commit intocrossplane:release-2.1from
phisco:fix/customresourcesgate-flake-release-2.1
Apr 17, 2026
Merged

test: stabilize customresourcesgate TestReconcile [release-2.1 backport]#978
phisco merged 1 commit intocrossplane:release-2.1from
phisco:fix/customresourcesgate-flake-release-2.1

Conversation

@phisco
Copy link
Copy Markdown
Contributor

@phisco phisco commented Apr 17, 2026

Backports the flaky-test fix from main (originally part of 552d14c, "Upgrade controller-runtime to v0.21.0") to release-2.1.

The normaliser in TestReconcile sorted recorded gate.True/gate.False calls by Kind only. The EstablishedCRDCallsGateTrue fixture contains two GVKs with identical Kind="TestResource" differing only in Version, so the sort could not disambiguate them — combined with the reconciler's nondeterministic map[schema.GroupVersionKind]bool iteration, the assertion was order-dependent and flaked intermittently in CI (also flaked on unrelated runs before the current security-bump PRs).

Replaces the comparator with a full GVK sort (Group, Version, Kind), matching what main and release-2.2 already have.

Test plan

  • `go test -count=10 -race ./pkg/reconciler/customresourcesgate/...` → 10/10 pass locally.

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>
@phisco phisco requested a review from a team as a code owner April 17, 2026 15:40
@phisco phisco requested review from jbw976 and removed request for a team April 17, 2026 15:40
@phisco phisco merged commit 2a5192e into crossplane:release-2.1 Apr 17, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants