Skip to content

tests: add onboarding e2e suite#1178

Merged
eriknordmark merged 3 commits into
lf-edge:masterfrom
eriknordmark:client-onboarding-e2e
May 29, 2026
Merged

tests: add onboarding e2e suite#1178
eriknordmark merged 3 commits into
lf-edge:masterfrom
eriknordmark:client-onboarding-e2e

Conversation

@eriknordmark

@eriknordmark eriknordmark commented May 13, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds an onboarding e2e suite under tests/onboarding/ that exercises
the cmd/client agent in EVE against a live device booted by the
standard eden setup. Four scenarios:

  • onboarding_status — happy path. After eden eve onboard, asserts
    /persist/status/uuid parses, the kernel hostname matches that UUID,
    and /persist/status/hardwaremodel is non-empty.
  • server_changes_at_runtime — writes a deliberately-wrong controller
    URL into the CONFIG partition via eve config mount, reboots, and
    verifies the boot exercises cmd/client's wrong-cert-fetch path
    (LedBlinkInvalidControllerCert escalation). Recovers via an in-VM
    reboot since EVE cannot reach adam to receive a controller-side
    reboot directive once the bad URL is active.
  • pre_provisioned_uuid — uses the same wrong-server lever to keep
    nim's DPC state at FailWithIPAndDNS while cmd/client's 5-second t1
    timer fires, exercising the "already have UUID + checkpoint; declare
    success" shortcut branch in Run().
  • server_returns_403 — drives the un-onboard flow: removes the
    device's adam-side onboard cert + device record via the admin
    endpoints, wipes /persist/status/uuid + /persist/checkpoint/controllercerts
    on EVE, reboots, asserts LedBlinkOnboardingFailureNotFound (=18),
    POSTs the onboard cert back, reboots again, asserts re-onboarding
    succeeds. Requires lf-edge/adam ≥ 0.0.79 (the first release that
    includes server: return 403 on unregistered onboarding cert/serial adam#155, which brings /register in line with
    the eve-api spec: 403 for cert/serial that isn't pre-registered).
    Paired with defaults: bump DefaultAdamTag from 0.0.75 to 0.0.79 #1180 which bumps DefaultAdamTag so the
    default eden setup pulls the right adam.

Complements the cmd/client Go unit tests in lf-edge/eve#5957 and
lf-edge/eve#5958. Combined with the unit tests this suite raised
pkg/pillar/cmd/client block coverage from 0 % to 87.36 %
(eden e2e alone gets 71.18 %; unit-only is 53.66 %).

Two further scenarios from the original plan were left out of this
PR; both need an un-onboarding harness that's now built into
server_returns_403, so they become follow-ups:

  • wrong_server_url (un-onboarded variant) — overlaps with
    server_changes_at_runtime so the marginal coverage is small.
  • register_then_getuuid_interleave — needs adam to know the device
    UUID but reject the onboard cert (a contrived state).

The original cert_miss_refetch scenario was found unreachable from
e2e during analysis: cmd/client's fetchCertChain refreshes the
in-memory cert hash before doGetUUID ever runs, so SenderStatusCertMiss
cannot fire in the same Run(); the branch is already covered by the
unit test TestDoGetUUID_CertMissSchedulesTimer.

Test plan

  • eden setup && eden start && eden test ./tests/onboarding/ -v
    from a clean eden workspace passes all four scenarios.
  • Same on a coverage-instrumented EVE; eden eve collect-coverage
    after the run shows the cmd/client coverage numbers above
    (verified locally against an EVE built with make COVER=y).

eden eve onboard
stdout 'onboarded'

# Wait for the artefacts; zedclient writes them shortly after the

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.

artefacts -> artifacts

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apparently Anthropic has been inflitrated by some Brit (but I haven't seen other odd spelling) ;-)

@rene rene 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.

LGTM other than the typo to be fixed

eriknordmark and others added 3 commits May 29, 2026 22:24
Adds a new test directory that exercises EVE's onboarding flow against
a live device booted by the standard eden setup. The initial test
verifies the on-device artefacts produced by the onboarding loop —
the kernel hostname matches the controller-issued UUID, the UUID file
under /persist/status is parseable, and a hardwaremodel string was
written. Together they cover the post-onboard publishing path and the
full event loop that Go unit tests in the eve repo cannot reach.

Signed-off-by: eriknordmark <erik@zededa.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Adds two more scenarios to the onboarding e2e suite that target the
dark code paths in pkg/pillar/cmd/client that the initial happy-path
test cannot reach.

`server_changes_at_runtime` writes a deliberately-wrong controller URL
into the CONFIG partition via `eve config mount`, reboots, and verifies
the boot brings up cmd/client against the bad URL (exercising the
LedBlinkInvalidControllerCert escalation in tryRegister), then restores
the original URL via an in-VM reboot — controller-side reboots cannot
recover the device once it is pointing at an unreachable controller.

`pre_provisioned_uuid` reuses the same wrong-server lever to keep nim's
DPC state at FailWithIPAndDNS while cmd/client's 5-second t1 timer
fires, so the "already have UUID + checkpoint; declare success" shortcut
branch in Run() is exercised. The witness is the unique log line at
client.go:433, searched in /persist/newlog (active + gzipped archives).

Both tests use a small retry_ssh helper to ride out the ~minute of ssh
banner-exchange flakiness that follows a reboot, and rely on
`eden controller edge-node reboot` for the first reboot (EVE still
reaches adam at that point) and an in-VM `reboot` for the recovery.

Signed-off-by: eriknordmark <erik@zededa.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Covers the dark `case http.StatusForbidden` branch in selfRegister
(pkg/pillar/cmd/client/client.go:671-672) that raises
LedBlinkOnboardingFailureNotFound when the controller rejects an
onboarding cert that the device cryptographically possesses but that
is not present in the controller's pre-registration set. The branch
was effectively unreachable until lf-edge/adam#155 brought adam in
line with the eve-api spec (APIv2.md §/register: "Valid credentials
without authorization: 403").

The scenario captures every onboard-cert + device record that matches
this device's serial, DELETEs them via adam's /admin/onboard and
/admin/device admin endpoints, wipes /persist/status/uuid and
/persist/checkpoint/controllercerts on EVE, in-VM reboots, asserts
LedBlinkCounter=18 (OnboardingFailureNotFound), POSTs the saved
onboard cert back, reboots again, and verifies the device reaches
LedBlinkCounter=4 (Onboarded) with a fresh UUID on disk.

A short retry_ssh wrapper rides out the ~minute of ssh banner-exchange
flakiness right after each reboot, mirroring the pattern in the
existing server_changes_at_runtime and pre_provisioned_uuid scenarios.
The admin curl uses 127.0.0.1:adam.port (host-side docker port
mapping) because adam.ip in the eden config is the EVE-side IP, not
the host side.

Signed-off-by: eriknordmark <erik@zededa.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@eriknordmark
eriknordmark force-pushed the client-onboarding-e2e branch from 91871a1 to 9a932cc Compare May 29, 2026 20:24
@eriknordmark
eriknordmark merged commit 3361187 into lf-edge:master May 29, 2026
16 of 18 checks passed
@eriknordmark
eriknordmark deleted the client-onboarding-e2e branch July 10, 2026 23:51
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.

2 participants