Skip to content

refactor(updater): expose test seams for polling intervals and SHA detection - #23356

Merged
kubestellar-hive[bot] merged 1 commit into
kubestellar:mainfrom
vjymisal0:fix/updater-test-seams
Sep 13, 2026
Merged

refactor(updater): expose test seams for polling intervals and SHA detection#23356
kubestellar-hive[bot] merged 1 commit into
kubestellar:mainfrom
vjymisal0:fix/updater-test-seams

Conversation

@vjymisal0

Copy link
Copy Markdown
Contributor

Fixes #23341.

Summary

Exposes package-level test seams in \pkg/agent/updater\ to unblock unit testing without altering production behavior:

  • Changes \developerCheckInterval\ and
    eleaseCheckInterval\ from \const\ to package-level \�ar\ in \pkg/agent/updater/checker.go.
  • Adds package-level \�ar initialStartupDelay = 30 * time.Second\ in \pkg/agent/updater/poller.go\ and uses it in the startup delay select arm.
  • Replaces direct calls to \ etchLatestMainSHAWithRepo\ and \detectCurrentSHA\ in \checkDeveloperChannel\ with package-level function variables \ etchLatestMainSHAFn\ and \detectCurrentSHAFn.

This provides the exact seams required by issue #23341 so the quality agent can follow up with additive unit tests for the ticker and developer channel branches.

…tection

Expose developerCheckInterval, releaseCheckInterval, and initialStartupDelay
as package variables to allow shrinking check intervals during unit tests.
Add fetchLatestMainSHAFn and detectCurrentSHAFn package function variables
in poller.go to enable isolated unit testing of checkDeveloperChannel without
requiring a real git remote.

Fixes kubestellar#23341

Signed-off-by: vjymisal0 <misalvijay153@gmail.com>
Copilot AI lite review requested due to automatic review settings September 13, 2026 06:59
@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

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

netlify Bot commented Sep 13, 2026

Copy link
Copy Markdown

Deploy Preview for kubestellarconsole canceled.

Built without sensitive environment variables

Name Link
🔨 Latest commit d48ebff
🔍 Latest deploy log https://app.netlify.com/projects/kubestellarconsole/deploys/6aa649d500dbe000087be94f

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@kubestellar-prow kubestellar-prow Bot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Sep 13, 2026
@kubestellar-hive kubestellar-hive Bot added agent/scanner Filed by the scanner agent hive/hosted-kubestellar-console-4vkt Hive instance hosted-kubestellar-console-4vkt labels Sep 13, 2026
@kubestellar-hive
kubestellar-hive Bot merged commit b6fc0b8 into kubestellar:main Sep 13, 2026
39 of 40 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

⏹️ Post-Merge Verification: cancelled

Commit: b6fc0b89f90e9619f35522e6767c933df72b5be9
Specs run: smoke.spec.ts
Report: https://github.com/kubestellar/console/actions/runs/34745805126

kubestellar-hive Bot pushed a commit that referenced this pull request Sep 13, 2026
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent/scanner Filed by the scanner agent dco-signoff: yes Indicates the PR's author has signed the DCO. hive/hosted-kubestellar-console-4vkt Hive instance hosted-kubestellar-console-4vkt size/S Denotes a PR that changes 10-29 lines, ignoring generated files.

Projects

None yet

2 participants