Repository navigation
test(tenant): anchor the operator-gate absence and refresh a spent reason - #3661
Conversation
📝 WalkthroughWalkthroughThe tenant Helm tests clarify offline rendering scope and strengthen negative assertions by verifying the targeted seaweedfs and gateway HelmRelease names before checking that ChangesTenant Helm test updates
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ 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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/apps/tenant/tests/cleanup_role_watch_test.yaml`:
- Around line 20-23: The comments in both suite-level templates lists must
explain that the list limits rendering so failures in unrelated templates cannot
affect the suite. In packages/apps/tenant/tests/cleanup_role_watch_test.yaml
lines 20-23, identify the cleanup template as the target under test; in
packages/apps/tenant/tests/vmo_webhook_dependson_test.yaml lines 14-17, identify
the listed HelmRelease templates as the render scope and retain the explanation
that offline lookup returns empty.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 83ac279d-42fe-4e31-83a1-1523cb567055
📒 Files selected for processing (2)
packages/apps/tenant/tests/cleanup_role_watch_test.yamlpackages/apps/tenant/tests/vmo_webhook_dependson_test.yaml
| # Render only the cleanup template. The list keeps an unrelated template breaking | ||
| # out of this suite's result, so what reddens here is the hook it guards. | ||
| # (namespace.yaml's `lookup` is not the reason: the lookup returns empty offline | ||
| # and the template renders.) |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Clarify the duplicated templates: rationale.
Both comments use reddens and do not clearly describe the exclusion behavior. State that the suite-level templates: list prevents failures in unrelated templates from affecting the suite.
packages/apps/tenant/tests/cleanup_role_watch_test.yaml#L20-L23: identify the cleanup template as the target under test.packages/apps/tenant/tests/vmo_webhook_dependson_test.yaml#L14-L17: identify the listed HelmRelease templates as the render scope and retain the offlinelookupexplanation.
Proposed wording
-# out of this suite's result, so what reddens here is the hook it guards.
+# templates from affecting this suite; the cleanup hook is the target under test.-# unrelated template breaking out of this suite's result, so what reddens here is
-# the gate it guards. (namespace.yaml's `lookup` is not the reason: the lookup
+# failures in unrelated templates from affecting this suite. (namespace.yaml's
+# `lookup` is not the reason: the lookup📍 Affects 2 files
packages/apps/tenant/tests/cleanup_role_watch_test.yaml#L20-L23(this comment)packages/apps/tenant/tests/vmo_webhook_dependson_test.yaml#L14-L17
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@packages/apps/tenant/tests/cleanup_role_watch_test.yaml` around lines 20 -
23, The comments in both suite-level templates lists must explain that the list
limits rendering so failures in unrelated templates cannot affect the suite. In
packages/apps/tenant/tests/cleanup_role_watch_test.yaml lines 20-23, identify
the cleanup template as the target under test; in
packages/apps/tenant/tests/vmo_webhook_dependson_test.yaml lines 14-17, identify
the listed HelmRelease templates as the render scope and retain the explanation
that offline lookup returns empty.
ee7a4ac to
bee7a2d
Compare
IvanHunters
left a comment
There was a problem hiding this comment.
Overview
This is a test-only change to two helm-unittest suites in packages/apps/tenant/tests/. It does two things:
- Anchors the "no operator gate" negative assertions for the
seaweedfsandgatewayHelmReleases invmo_webhook_dependson_test.yamlby assertingmetadata.namebeforenotExists: spec.dependsOn. - Refreshes stale header comments in both suites that attributed the
templates:allowlist tonamespace.yaml'slookuperroring under helm-unittest.
Verdict: LGTM with non-blocking notes
Why the anchoring is correct, not cosmetic: templates/seaweedfs.yaml and templates/gateway.yaml are both conditionally rendered ({{- if .Values.seaweedfs }} / {{- if eq (include "tenant.gatewayEffective" .) "true" }}). A bare notExists: spec.dependsOn passes just as well when the template renders no document at all as when it renders a document without the field — so if the gating value key were ever renamed or the helper changed, the suite would stay green while silently testing nothing. Pinning metadata.name first closes that hole. This also brings the two remaining suites in the chart in line with no_upgrade_force_test.yaml, which already anchors all seven of its releases the same way — this isn't a new idiom, it's catching up to an existing one.
Why the comment refresh is correct: the old rationale (keycloakgroups.yaml indexing .Values._cluster unguarded, failing a no-values render) is verifiably stale — the current template guards with index (.Values._cluster | default dict) "oidc-enabled". The new rationale (namespace.yaml's lookup returns empty offline rather than erroring, so the template still renders) matches that template's own doc-comment and is independently corroborated by the already-merged no_upgrade_force_test.yaml, which states the same correction.
CI corroborates this statically: "Unit & controller tests" (which executes these exact suites) is green at head, so the new asserts pass against the real templates, not just against the PR's stated reasoning.
Non-blocking notes
- CodeRabbit flagged that the refreshed wording ("...so what reddens here is the hook/gate it guards...") is unusual phrasing that doesn't explicitly spell out the
templates:allowlist's exclusion mechanism. That's still present verbatim at head — worth a small wording pass for a future reader unfamiliar with the term, but it doesn't affect correctness. - The "E2E (in-tree)" check is red on this PR, but the failure is in "Wait for Cluster-API provider deployments" (cluster-api provider readiness/liveness probe failures during install) — an unrelated subsystem from the tenant chart test fixtures this diff touches. Flagging for visibility only; not attributable to this change.
Closing
Small, well-scoped, and the reasoning holds up against the actual templates and sibling test file. Approving with the two notes above for optional follow-up.
bee7a2d to
a0dc1e3
Compare
…ason The two "carries no operator gate" tests asserted only `notExists: spec.dependsOn`. A bare absence assert passes on a template that renders no document, so toggling `seaweedfs` and `gateway` off left both green while the releases they guard were gone. Measured: all 5 tests passed with the templates rendering nothing, and 2 of them fail once the name is pinned alongside the absence. An earlier check on these two asserts injected a `dependsOn` and watched them redden, which proves only that they catch an added gate. That is the other direction; the one that matters for a negative assert is the document disappearing. Both suite headers also justified their `templates:` list with a reason that has expired: keycloakgroups.yaml now guards its `.Values._cluster` index, so a no-values render of the whole chart succeeds. The list is still load-bearing, for the reason the sibling suite already records. It keeps an unrelated template out of this suite's result: with a nil dereference added outside the guard of a template neither suite asserts on, both suites stay green with their list and error without it. Assisted-By: Claude <[email protected]> Signed-off-by: Aleksei Sviridkin <[email protected]>
a0dc1e3 to
c681ae1
Compare
myasnikovdaniil
left a comment
There was a problem hiding this comment.
The absence assertions were genuinely vacuous and the fix closes it in both directions, which I checked rather than took from the description.
Threat A, gate becomes present: adding spec.dependsOn to templates/seaweedfs.yaml reddens asserts[1] notExists fail. Threat B is the vacuity itself, and it is the interesting one. templates/seaweedfs.yaml:1 gates on .Values.seaweedfs and templates/gateway.yaml:1 on tenant.gatewayEffective, so renaming both gating values makes the templates render zero documents. On the pre-PR file that leaves the suite at 5 passed, 5 total, still claiming to police two releases that had vanished from the chart entirely. On this PR it gives 2 failed with Expected to equal: seaweedfs / Actual: no manifest found. Threat C, a second document carrying the gate, also reddens with DocumentIndex: 1, so notExists scopes across all documents of the named template and the fix has no multi-document blind spot.
The spent reason really has expired. packages/apps/tenant/templates/keycloakgroups.yaml:8 now reads index (.Values._cluster | default dict) "oidc-enabled", so the old rationale is dead. I then checked the new comment is not itself an empty claim, by injecting a nil deref into a template neither suite asserts on: with the templates: list both suites pass 13 of 13, without it both fail on index of untyped nil. So the prophylaxis is real rather than decorative.
The package is genuinely exercised, packages/apps/tenant/Makefile has a test: target and hack/helm-unit-tests.sh probes for it, so this suite is not in the silently-skipped class. Full chart run is 10 suites, 43 tests, green.
One thing to know rather than change. The equal: metadata.name pin also asserts that seaweedfs.yaml renders exactly one document, so adding a legitimate second document there reddens this suite. That is arguably the right default since it forces a conscious update, and it matches no_upgrade_force_test.yaml:18-28 which already carries this pattern, so I would leave it. The assertion is just doing two jobs and the name only mentions one.
After this the tenant chart is clean on this class. The other notExists uses are each preceded by a hasDocuments count or a documentIndex equal in the same test.
What this PR does
Two tests in
packages/apps/tenant/tests/vmo_webhook_dependson_test.yamlsay the seaweedfs and gateway HelmReleases deliberately carry no operator gate, and assert that withnotExists: spec.dependsOnand nothing else. A bare absence assert also passes when the template renders no document at all, so both stayed green with those two releases switched off entirely. Withseaweedfs: false, gateway: falsethe suite still reported 5 of 5 passing; pinningmetadata.namenext to the absence turns the same run into 2 failures.An earlier check on these asserts injected a
dependsOnand watched them redden. That proves they catch an added gate, which is the other direction. For a negative assert the direction that matters is the document going away, and that one was never covered.Pairing
equal: metadata.namewith the absence is not a new idiom introduced here.no_upgrade_force_test.yaml, in the same directory, already anchors all seven of its releases that way, and this brings the last two suites in the chart into line with it.Both suite headers also carried a reason for their
templates:list that has expired: that rendering the whole chart fails becausekeycloakgroups.yamlindexes.Values._clusterunguarded. #3636 added the guard, so a no-values render of the chart now succeeds. The list is still load-bearing, for the reasonno_upgrade_force_test.yamlalready records — it keeps an unrelated template breaking out of this suite's result. Checked by adding a nil dereference to a template neither suite asserts on: both suites stay green with their lists and error without them.Screenshots
Not a UI change.
Downstream repositories
Walked the trigger map against the diff. It touches two files, both under
packages/apps/tenant/tests/, and no chart, template, values file or tooling. Nothing in the map keys on test files.Release note