client: add seamed unit tests for onboarding loop#5958
Draft
eriknordmark wants to merge 4 commits into
Draft
Conversation
A comment claimed zedclient would fall back to the legacy /config endpoint when the /uuid endpoint fails. The fallback was never wired up — the /uuid path is the only one taken at runtime. Remove the unreachable helpers and the comment. No behavior change. Signed-off-by: eriknordmark <erik@zededa.com> Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Refactor zedclient so the onboarding loop is testable in isolation. Runtime state previously held in package globals — server URL, the onboard and device TLS configs, the UUID/hardwaremodel output paths — moves onto the clientContext. The post-loop publishing logic (hostname, UUID file, hardwaremodel file, OnboardingStatus) becomes a method. Four small interfaces front the runtime boundaries the loop crosses: the controller request/verify surface, the controller-cert checkpoint store, ledmanager pattern updates, and the /bin/hostname call. The existing implementations move into adapter types. Production wiring in Run is unchanged at the behavior level; tests can swap any seam. No behavior change. Signed-off-by: eriknordmark <erik@zededa.com> Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Cover the pure helpers in cmd/client with table-driven tests: UUID response parsing, /uuid request generation, the controller-cert key extraction and set-comparison used to decide whether to rewrite the on-disk checkpoint, and the CLI argument validator. Each targeted function reaches 100% statement coverage. Package statement coverage from unit tests alone goes from 0 to ~10%; the remaining gap is the onboarding loop itself, which is covered in a follow-up that drives the seamed paths. Signed-off-by: eriknordmark <erik@zededa.com> Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Cover the network-facing and side-effect-bearing parts of the onboarding loop using the seams introduced earlier: HTTP request classification and LED transitions, the register/UUID-fetch outcomes, controller-cert prefetch with checkpoint comparison, the post-loop hostname/UUID/hardwaremodel publishing, and the DNS-status handler's state-transition + proxy-cert propagation paths. Package statement coverage rises from ~10% to ~54%. Each function the new tests target reaches 80-100%; the remaining dark code is the top-level event loop and adapter wiring, reached by Eden e2e tests in a follow-up. Signed-off-by: eriknordmark <erik@zededa.com> Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #5958 +/- ##
==========================================
+ Coverage 20.50% 21.24% +0.74%
==========================================
Files 487 498 +11
Lines 90131 91797 +1666
==========================================
+ Hits 18482 19505 +1023
- Misses 70095 70545 +450
- Partials 1554 1747 +193 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This was referenced May 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Cover the network-facing and side-effect-bearing parts of the
onboarding loop using the seams introduced earlier: HTTP request
classification and LED transitions, the register/UUID-fetch outcomes,
controller-cert prefetch with checkpoint comparison, the post-loop
hostname/UUID/hardwaremodel publishing, and the DNS-status handler's
state-transition + proxy-cert propagation paths.
Package statement coverage rises from 0 % to 53.66 % (242/451)
across the Phase-1 (#5957) and Phase-2 sets combined. Each function the
new tests target reaches 80-100%; the remaining dark code is the
top-level event loop and adapter wiring, reached by Eden e2e tests in
lf-edge/eden#1178.
With the Eden e2e suite included,
pkg/pillar/cmd/clientcombinedblock coverage reaches 85.59 % (386/451, dedup'd across unit and
e2e profiles).
Depends on #5957.
How to test and validate this PR
go test -count=1 -cover ./pkg/pillar/cmd/client/...from the pillar module.Changelog notes
No user-facing changes.
PR Backports
Checklist