Skip to content

test(tenant): anchor the operator-gate absence and refresh a spent reason - #3661

Merged
Aleksei Sviridkin (lexfrei) merged 1 commit into
mainfrom
test/tenant-vmo-anchor
Aug 14, 2026
Merged

Aleksei Sviridkin (lexfrei) merged 1 commit into
mainfrom
test/tenant-vmo-anchor

Conversation

@lexfrei

@lexfrei Aleksei Sviridkin (lexfrei) commented Aug 8, 2026 •

Copy link
Copy Markdown
Contributor

What this PR does

Two tests in packages/apps/tenant/tests/vmo_webhook_dependson_test.yaml say the seaweedfs and gateway HelmReleases deliberately carry no operator gate, and assert that with notExists: spec.dependsOn and 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. With seaweedfs: false, gateway: false the suite still reported 5 of 5 passing; pinning metadata.name next to the absence turns the same run into 2 failures.

An earlier check on these asserts injected a dependsOn and 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.name with 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 because keycloakgroups.yaml indexes .Values._cluster unguarded. #3636 added the guard, so a no-values render of the chart now succeeds. The list is still load-bearing, for the reason no_upgrade_force_test.yaml already 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

NONE

@github-actions github-actions Bot added area/tenant Issues or PRs related to the tenant chart and multi-tenancy size/S This PR changes 10-29 lines, ignoring generated files labels Aug 8, 2026
@coderabbitai

coderabbitai Bot commented Aug 8, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The tenant Helm tests clarify offline rendering scope and strengthen negative assertions by verifying the targeted seaweedfs and gateway HelmRelease names before checking that spec.dependsOn is absent.

Changes

Tenant Helm test updates

Layer / File(s) Summary
Clarify offline rendering scope
packages/apps/tenant/tests/cleanup_role_watch_test.yaml, packages/apps/tenant/tests/vmo_webhook_dependson_test.yaml
Comments now document excluded unrelated template failures and successful offline lookup rendering.
Anchor negative HelmRelease assertions
packages/apps/tenant/tests/vmo_webhook_dependson_test.yaml
The seaweedfs and gateway checks first assert each metadata.name, then assert that spec.dependsOn is absent.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Suggested labels: area/testing

Suggested reviewers: ivanhunters

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the test assertions and rationale updates in the pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch test/tenant-vmo-anchor

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

📥 Commits

Reviewing files that changed from the base of the PR and between d956536 and ee7a4ac.

📒 Files selected for processing (2)
  • packages/apps/tenant/tests/cleanup_role_watch_test.yaml
  • packages/apps/tenant/tests/vmo_webhook_dependson_test.yaml

Comment on lines +20 to +23
# 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.)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

📐 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 offline lookup explanation.
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.

@IvanHunters IvanHunters left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Overview

This is a test-only change to two helm-unittest suites in packages/apps/tenant/tests/. It does two things:

  1. Anchors the "no operator gate" negative assertions for the seaweedfs and gateway HelmReleases in vmo_webhook_dependson_test.yaml by asserting metadata.name before notExists: spec.dependsOn.
  2. Refreshes stale header comments in both suites that attributed the templates: allowlist to namespace.yaml's lookup erroring 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

  1. 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.
  2. 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.

…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]>

@myasnikovdaniil myasnikovdaniil left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

@lexfrei
Aleksei Sviridkin (lexfrei) merged commit 3d4e8c0 into main Aug 14, 2026
16 of 18 checks passed
@lexfrei
Aleksei Sviridkin (lexfrei) deleted the test/tenant-vmo-anchor branch August 14, 2026 07:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/tenant Issues or PRs related to the tenant chart and multi-tenancy size/S This PR changes 10-29 lines, ignoring generated files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants