Skip to content

test(submit): cover Run non-detach watch path (root-cause #4) - #259

Merged
saadqbal merged 1 commit into
developfrom
test/submit-nondetach
Jul 14, 2026
Merged

test(submit): cover Run non-detach watch path (root-cause #4)#259
saadqbal merged 1 commit into
developfrom
test/submit-nondetach

Conversation

@LukasWodka

@LukasWodkaLukasWodka commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Summary

Closes the last structural root-cause from the coverage audit (#4): all six pre-existing submit.Run tests set Detach:true and returned before WatchJob, so the entire non-detach post-watch surface — the WatchError wrap, the per-DetachReason switch, and the summary-render branch — was unexecuted.

Adds a watchJobFn seam over WatchJob (same pattern as doctorRunFn / listDatasetsFn) so Run's non-detach path is exercisable with a canned WatchResult/error — no live Job to watch. Pure seam routing — the package var defaults to the real WatchJob, so no production behavior change.

Coverage

internal/submit own-coverage 76.2% → 80.4%; submit.Run→ 97.3%.

New tests:

  • Watch failure is tagged WatchError (so the orchestrator maps it to exit 9, not 8) and Result.Submit still survives (the run was already accepted server-side).
  • The per-DetachReason switch renders each timeout's distinct diagnostic + the same kubectl logs reconnect hint — with a mutation guard that the pod-wait-timeout path must not read as a Ctrl-C stop (the exact Bugbot PR feat(dataset): Phase 4 — submit to jobs-manager + watch + summary (#152) #10 r7 regression).
  • A completed run renders the summary panel; a nil summary skips it (the wr.Summary != nil false branch).

Test plan

  • make ci green (build, vet, gofmt -s, go test -race -cover, errcheck/ineffassign/misspell, schema-check).
  • Uses the existing fakeSubmitter harness + the new watchJobFn seam — no real cluster, no watch mechanics (those stay covered by watch_test.go).

🤖 Generated with Claude Code


Note

Low Risk
Test-only changes plus a package-level indirection that still defaults to the real WatchJob; no runtime behavior change.

Overview
Adds a watchJobFn test seam (defaults to WatchJob) so Run with Detach:false can be tested without a live cluster Job. Run now invokes watchJobFn instead of calling WatchJob directly; production behavior is unchanged.

New tests in run_watch_test.go exercise the post-submit watch path that prior Detach:true tests skipped: WatchError wrapping (exit-9 mapping) with Result.Submit preserved, per-DetachReason user messages plus the kubectl logs hint (including a guard that pod-wait-timeout is not worded like Ctrl-C), and summary panel rendering vs skipping when Summary is nil.

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

All six pre-existing submit.Run tests set Detach:true and returned before
WatchJob, leaving the entire post-watch surface — the WatchError wrap, the
per-DetachReason switch, and the summary-render branch — unexecuted (the last
structural root cause from the coverage audit).
Add a watchJobFn seam over WatchJob (same pattern as doctorRunFn/listDatasetsFn)
so Run's non-detach path is exercisable with a canned WatchResult/error, no live
Job needed. Pure seam routing — the package var defaults to the real WatchJob, so
there is no production behavior change.
Coverage: submit.Run 97.3%, package own-coverage 76.2% -> 80.4%. New tests:
- a watch failure is tagged WatchError (exit-9 mapping) and Result.Submit survives;
- the per-DetachReason switch renders each timeout's distinct diagnostic + the
reconnect hint (mutation guard: pod-wait-timeout must not read as a Ctrl-C stop);
- a completed run renders the summary panel, and a nil summary skips it.
make ci green.
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 3686351. 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 👍 One-line seam, and it unlocks the whole post-watch surface the Detach:true tests never reached. Verified all four DetachReason arms + the WatchError→exit-9 wrap match Run, and the PodWaitTimeout mutation guard (must not read as a Ctrl-C stop) is a good pin given the Bugbot PR#10 history.

@saadqbal
saadqbal merged commit b51b5c1 into developJul 14, 2026
22 checks passed
@saadqbal
saadqbal deleted the test/submit-nondetach branch July 14, 2026 08:55
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