Skip to content

[quality] cover poller run() ticker + checkDeveloperChannel branches via #23356 seams - #23357

Open
kubestellar-hive[bot] wants to merge 1 commit into
mainfrom
quality/poller-seams-tests
Open

[quality] cover poller run() ticker + checkDeveloperChannel branches via #23356 seams#23357
kubestellar-hive[bot] wants to merge 1 commit into
mainfrom
quality/poller-seams-tests

Conversation

@kubestellar-hive

Copy link
Copy Markdown
Contributor

Test Improvement

Adds pkg/agent/updater/poller_seams_test.go — 4 tests exploiting the test seams introduced by #23356 to cover previously-unreachable branches in poller.go.

Refs #23341. Depends on #23356 landing first — that PR flipped developerCheckInterval from const to var, introduced initialStartupDelay / fetchLatestMainSHAFn / detectCurrentSHAFn. This PR uses those seams; if #23356 is not merged first, this branch will not compile.

Coverage delta (pkg/agent/updater)

Function Before After
poller.go run 40.9% 100.0%
poller.go checkDeveloperChannel 44.4% 92.6%
package total 83.6% 85.6%

Tests added

  • TestRun_TickerFiresAndCanUpdate — first test to reach the case <-ticker.C: arm of run(). TestRun_StopsOnContextCancel only covered the context-cancel arm.

  • TestCheckDeveloperChannel_FetchLatestSHAError — locks the fetch-failure return path. A regression that dropped the return after slog.Error(...) would fall through with latestSHA="", compare equal to a fresh currentSHA of "", and silently emit a bogus "already up to date" broadcast — hiding the fetch failure from the frontend.

  • TestCheckDeveloperChannel_AlreadyUpToDate — locks the Progress=100 "no changes on main" broadcast and asserts detectCurrentSHAFn is invoked exactly once and its result is stored on the checker.

  • TestCheckDeveloperChannel_FreshSHANotDetected — locks the if freshSHA := ...; freshSHA != "" guard. Without it an empty detectCurrentSHA result would clobber uc.currentSHA on every tick.

Seam etiquette

withSwappedSeams(t, ...) at the top of the file saves the original vars and registers a t.Cleanup to restore them, so parallel test runs and later tests are unaffected.

Not covered (intentional)

  • The final checkDeveloperChannel branch that dispatches executeDeveloperUpdate when SHAs differ — that's the heavy path (git operations, npm build, restart) that already has extensive coverage in checker_test.go.

Filed by quality agent (ACMM L4/L6 — full mode)

— hive: agent=quality backend=copilot model=claude-opus-4.7

@kubestellar-prow kubestellar-prow Bot added the dco-signoff: yes Indicates the PR's author has signed the DCO. label Sep 13, 2026
@kubestellar-prow

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign mikespreitzer for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@netlify

netlify Bot commented Sep 13, 2026

Copy link
Copy Markdown

Deploy Preview for kubestellarconsole canceled.

Name Link
🔨 Latest commit 2a042e6
🔍 Latest deploy log https://app.netlify.com/projects/kubestellarconsole/deploys/6aa65a7c30dd9b0008ce49d5

@github-actions

Copy link
Copy Markdown
Contributor

👋 Hey @kubestellar-hive[bot] — thanks for opening this PR!

🤖 This project is developed exclusively using AI coding assistants.

Please do not attempt to code anything for this project manually.
All contributions should be authored using an AI coding tool such as:

This ensures consistency in code style, architecture patterns, test coverage,
and commit quality across the entire codebase.


This is an automated message.

@github-actions github-actions Bot added the ai-generated Pull request generated by AI label Sep 13, 2026
@kubestellar-prow kubestellar-prow Bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Sep 13, 2026
@kubestellar-hive kubestellar-hive Bot added the hold Blocked — do not touch label Sep 13, 2026
@kubestellar-hive

Copy link
Copy Markdown
Contributor Author

Important

Held for human sign-off on the direction, not on the code.

This PR's only tracked rationale is #23341, which the hive filed itself — issue #23341 was filed by kubestellar-hive[bot] and no human has acknowledged it. An agent-filed issue does not, on its own, establish that anyone agreed to the direction (hivecommons/hive#5117).

The change may well be right; nothing here is a review of it. To release the hold, acknowledge the direction on that issue — comment on it, assign yourself, or add the approved-direction label — and remove the hold label here.

Refs #23341.

Uses the fetchLatestMainSHAFn / detectCurrentSHAFn function-var seams
landed by PR #23356 to add three unit tests in poller_seams_test.go
that cover previously-unreachable branches in checkDeveloperChannel:

  - TestCheckDeveloperChannel_FetchLatestSHAError — locks the fetch-
    failure return path so a dropped 'return' after slog.Error can't
    silently emit a bogus 'already up to date' broadcast.

  - TestCheckDeveloperChannel_AlreadyUpToDate — locks the Progress=100
    'no changes on main' broadcast and asserts detectCurrentSHAFn is
    invoked exactly once with its result stored on the checker.

  - TestCheckDeveloperChannel_FreshSHANotDetected — locks the guard
    that keeps an empty detectCurrentSHA result from clobbering
    uc.currentSHA.

Coverage on pkg/agent/updater:
  poller.go checkDeveloperChannel   44.4% ->  92.6%

A previous version of this file also had a TestRun_TickerFiresAndCanUpdate
that shrank the developerCheckInterval / initialStartupDelay interval
seams to force run()'s ticker arm to fire. The race detector caught a
legitimate data race between that write and the read of
initialStartupDelay done by run() goroutines that pre-existing tests
(TestStart_Stop in lifecycle_checksum_test.go) leave dangling in
time.After(initialStartupDelay) even after they cancel their contexts.
Covering the ticker arm safely needs run() to atomic-load the interval
seams — a coder-lane change, not a quality-lane one — so run()
coverage stays at 40.9% for now.

Signed-off-by: kubestellar-hive[bot] <223556219+Copilot@users.noreply.github.com>
@kubestellar-hive

Copy link
Copy Markdown
Contributor Author

Update — dropped racy TestRun_TickerFiresAndCanUpdate, kept 3 SHA-fn tests

The original push added a 4th test that shrank initialStartupDelay and developerCheckInterval to force run()'s ticker arm to fire. The race detector caught a legitimate data race between that write and reads of initialStartupDelay from run() goroutines that pre-existing tests (TestStart_Stop in lifecycle_checksum_test.go) leave dangling in time.After(initialStartupDelay) even after they cancel their contexts.

Force-pushed a new HEAD (2a042e6) that:

  • removes TestRun_TickerFiresAndCanUpdate
  • keeps the three tests that only swap the two function-var seams fetchLatestMainSHAFn / detectCurrentSHAFn and never write to the interval vars — those can't race with anything run() only reads.

Revised coverage delta

function before after
poller.go checkDeveloperChannel 44.4% 92.6%

run() coverage stays at 40.9%. Covering the ticker arm safely requires run() to atomic-load the interval seams — a coder-lane change on top of #23356, not a quality-lane one. Will file a follow-up issue once this lands.

Also removed the now-unused context and time imports and the atomic scaffolding for the deleted test.

The commit-message body of 2a042e6 records all of the above; nothing was silently changed.

— hive: agent=quality backend=copilot model=claude-opus-4.7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-generated Pull request generated by AI dco-signoff: yes Indicates the PR's author has signed the DCO. hold Blocked — do not touch size/L Denotes a PR that changes 100-499 lines, ignoring generated files. tier/1-lightweight

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant