[quality] cover updater executeBinaryUpdateFlow backup-failure branch (45.5% → 51.0%) - #23353
Conversation
…Flow 45.5% → 51.0%)
TestExecuteBinaryUpdateFlow_BackupFailure exercises three previously
uncovered consecutive branches inside executeBinaryUpdateFlow after the
extract gate succeeds:
1. exec.LookPath("console") failure fallback to "./bin/console"
2. renameOrCopy(consolePath, backupPath) failure (source missing)
3. "Failed to back up current binary" failed-status broadcast
The test forces LookPath to fail by clearing PATH and chdirs to a fresh
tempdir so the "./bin/console" fallback resolves against a directory
that provably has no binary. The subsequent renameOrCopy call fails
cleanly, and the flow must broadcast failed / Failed to back up current
binary and populate lastUpdateError via recordError.
Both t.Chdir and t.Setenv auto-restore on teardown. Skipped on Windows
because the fallback path and renameOrCopy semantics differ there — the
Unix runners already exercise the branch in CI.
Refs #23160 (issue tracks additional post-extract arms: chmod fail,
rename fail with rollback, restartBackend fail with rollback, and
health-check-fail with rollback — each needs its own targeted fixture).
Verified locally: pkg/agent/updater coverage 83.0% → 83.6%,
executeBinaryUpdateFlow 45.5% → 51.0%.
Signed-off-by: quality <noreply@github.com>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
✅ Deploy Preview for kubestellarconsole canceled.
|
|
👋 Hey @kubestellar-hive[bot] — thanks for opening this PR!
This is an automated message. |
|
Thank you for your contribution! Your PR has been merged. Check out what's new:
Stay connected: Slack #kubestellar-dev | Multi-Cluster Survey |
|
Post-merge build verification passed ✅ Both Go and frontend builds compiled successfully against merge commit |
⏹️ Post-Merge Verification: cancelledCommit: |
Test Improvement
Adds
pkg/agent/updater/execute_binary_flow_backup_test.go— one focusedtest (
TestExecuteBinaryUpdateFlow_BackupFailure) that closes the nextgap after the existing
Extract/PostExtractCancellationcoverage inexecute_binary_flow_more_test.go.Branches covered
Three consecutive previously-uncovered branches inside
executeBinaryUpdateFlow(
download.go):exec.LookPath("console")err arm — fallback to./bin/consolerenameOrCopy(consolePath, backupPath)err arm (source missing)"Failed to back up current binary"failed-status broadcast +recordErrorpathApproach:
newRecordingUpdateChecker/serveTarballAndChecksums/releaseWith/buildValidTarGzhelpers — no test infra churn.t.Setenv("PATH", "")forcesexec.LookPathto fail;t.Chdir(t.TempDir())makes the
./bin/consolefallback resolve against a directory thatprovably has no binary. Both auto-restore on teardown.
safeTarExtract, so we hit thepost-extract backup step cleanly.
renameOrCopysemantics differ);Linux + macOS runners exercise the branch.
Verified locally
Coverage delta on
pkg/agent/updater:executeBinaryUpdateFlowpkg/agent/updatertotalSince the issue was filed (
executeBinaryUpdateFlow@ 13.3%), cumulativeprogress across all landed tests is 13.3% → 51.0%.
Not addressed here (intentional)
The remaining ~49% of
executeBinaryUpdateFlowsits past the backup stepand each subsequent branch needs its own controlled fixture:
ChmodIfSupportedfailure + rollback via backup restorerenameOrCopy(stagedBinary, consolePath)failure + rollbackrestartBackend()failure + rollback + rollback-restarthealthCheckFn()false + rollback + rollback-restart"done"/currentVersionupdateEach of those follows the same pattern (drive to the branch, assert the
broadcast +
lastUpdateError, assert norestarting/done), so theycan land as follow-up PRs stacked on this one. Not bundling them here
keeps the diff scoped to a single mechanically-verified branch.
Refs #23160 (issue tracker for the whole flow — remaining post-backup
arms listed above are still open).
Filed by quality agent (ACMM L4/L6 — full mode)
— hive: agent=quality backend=copilot model=claude-opus-4.7