Skip to content

test(home): cover realProbeEnv discovery (live/degraded/no-release) via the cluster-load seam - #250

Merged
saadqbal merged 1 commit into
developfrom
test/cluster-load-seam
Jul 14, 2026
Merged

test(home): cover realProbeEnv discovery (live/degraded/no-release) via the cluster-load seam#250
saadqbal merged 1 commit into
developfrom
test/cluster-load-seam

Conversation

@LukasWodka

@LukasWodkaLukasWodka commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Summary

Fourth increment from the CLI test-coverage audit — the home-screen environment probe's discovery paths. realProbeEnv was 35%: it called cluster.Load / cluster.NewClientset directly, so a test could only reach the ownership-gate and load-failure returns — the actual release discovery (the core of the default bare-tracebloc screen) was dark.

Production change (seam — zero behavior change)

realProbeEnv now routes through the existing loadClusterFn / newClientsetFn seam instead of calling cluster.Load / cluster.NewClientset directly (both default to the real helpers, so production is unchanged). This lets a fake clientset drive discovery.

Test

  • TestRealProbeEnv_Discovery (new) — drives the three discovered states with a fake clientset:
    • live (ready jobs-manager + a Ready node) → localLive, release name resolved, compute surfaced;
    • degraded (jobs-manager present, ReadyReplicas 0) → localDegraded;
    • no release (reachable, empty cluster) → localNoRelease.
    • The ownership-gate + load-failure paths stay covered by the existing TestRealProbeEnv_OwnershipGate.
  • withClusterSeams now sets RestConfigrealProbeEnv does resolved.RestConfig.Timeout = …, so the seam's fake ResolvedConfig needed a non-nil RestConfig. Additive; its existing resolveClusterTarget users don't read it (all their tests still pass).

Not in this PR (follow-up)

runClusterInfo (cluster.go:134) and runClusterDoctor (doctor.go:99) still call cluster.Load directly. Their routing + post-discovery tests (which also need a MintIngestorToken reactor + printing assertions) are the next increment.

Test plan

  • make ci green (build, -race, gofmt, lint, schema). New probe tests + the existing resolveClusterTarget tests (which share withClusterSeams) all pass.

🤖 Generated with Claude Code


Note

Low Risk
Test-only seam wiring with production defaults unchanged; no auth, data, or user-facing behavior changes.

Overview
Adds test coverage for the home screen’s realProbeEnvrelease discovery paths, which were previously hard to exercise because kubeconfig load went straight to cluster.Load / cluster.NewClientset.

realProbeEnv now calls the same loadClusterFn / newClientsetFn hooks as resolveClusterTarget (still defaulting to the real helpers in production). TestRealProbeEnv_Discovery drives a fake clientset through live (ready jobs-manager + node → localLive + compute), degraded (jobs-manager not ready → localDegraded), and no release (localNoRelease).

withClusterSeams now supplies a non-nil RestConfig on the fake ResolvedConfig so tests don’t panic when the probe sets RestConfig.Timeout.

Reviewed by Cursor Bugbot for commit 4ef436e. Bugbot is set up for automated code reviews on this repo. Configure here.

realProbeEnv was 35% — it called cluster.Load / cluster.NewClientset
directly, so tests could only reach the ownership-gate and load-failure
returns; the release discovery (the core of the bare-`tracebloc` screen)
was dark. Route it through the existing loadClusterFn / newClientsetFn
seam (both default to the real helpers → zero behavior change) so a fake
clientset can drive discovery.
- TestRealProbeEnv_Discovery: live (ready jobs-manager + Ready node ->
localLive + compute), degraded (jobs-manager ReadyReplicas 0 ->
localDegraded), no-release (empty cluster -> localNoRelease). Ownership
gate + load failure stay covered by TestRealProbeEnv_OwnershipGate.
- withClusterSeams now sets RestConfig (realProbeEnv sets
RestConfig.Timeout); additive, its resolveClusterTarget users don't read
it (all pass).
make ci green. Follow-up: runClusterInfo/runClusterDoctor still call
cluster.Load directly — their routing + post-discovery tests next.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@LukasWodka

Copy link
Copy Markdown
ContributorAuthor

bugbot run

@cursorcursorBot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 4ef436e. Configure here.

@LukasWodkaLukasWodka self-assigned this Jul 14, 2026

@saadqbalsaadqbal 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.

LGTM 👍 Clean seam routing — and good that you set RestConfig: &rest.Config{} in withClusterSeams, since realProbeEnv now sets .Timeout on it through the seam. The live/degraded/no-release split is asserted right.

@saadqbal
saadqbal merged commit a998ef2 into developJul 14, 2026
22 checks passed
@saadqbal
saadqbal deleted the test/cluster-load-seam branch July 14, 2026 08:49
Sign up for freeto 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

@LukasWodka@saadqbal