Skip to content

client: add seamed unit tests for onboarding loop#5958

Draft
eriknordmark wants to merge 4 commits into
lf-edge:masterfrom
eriknordmark:client-phase2-tests
Draft

client: add seamed unit tests for onboarding loop#5958
eriknordmark wants to merge 4 commits into
lf-edge:masterfrom
eriknordmark:client-phase2-tests

Conversation

@eriknordmark
Copy link
Copy Markdown
Contributor

@eriknordmark eriknordmark commented May 13, 2026

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/client combined
block 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

  • 16.0-stable: No.
  • 14.5-stable: No.
  • 13.4-stable: No.

Checklist

  • I've provided a proper description
  • I've written the test verification instructions

eriknordmark and others added 4 commits May 13, 2026 23:26
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
Copy link
Copy Markdown

codecov Bot commented May 14, 2026

Codecov Report

❌ Patch coverage is 50.94340% with 78 lines in your changes missing coverage. Please review.
✅ Project coverage is 21.24%. Comparing base (d093be1) to head (42f74c7).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
pkg/pillar/cmd/client/client.go 64.51% 38 Missing and 6 partials ⚠️
pkg/pillar/cmd/client/adapters.go 2.85% 34 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to 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.

1 participant