test: baseline pure-logic tests across manager + agent#15
Merged
kleopasevan merged 2 commits intomainfrom Apr 29, 2026
Merged
Conversation
Plan 2 (iSCSI): generic + TrueNAS REST control-plane backends, agent IscsiHostBackend with iscsiadm shell-out, agent kind() handshake, slow-path rootfs allocator (provision + agent populate + caller-side resize2fs). 14 tasks. Plan 3 (UI): TypeScript types, useStorageBackends hook, BackendSelector component, VM-create + volume-create form integration. 7 tasks. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Adds 70 pure-logic tests covering modules the upcoming pluggable-VMM
refactor will touch: vms, snapshots, templates, hosts, networks (manager)
and vm/{spawn,stop,serial,balloon,entropy,system} (agent). Captures
current behavior so refactors can detect regressions.
Per-module breakdown:
- manager/vms/service.rs: 14 tests (network selection, rate-limiter
normalization, VmPaths, tap-name format, snapshot payloads, query strings)
- manager/snapshots/{routes,repo}.rs: 18 tests (URL building, payload
shapes, name resolution, mem-path handling) + 7 helpers extracted
for testability
- manager/templates/{routes,repo}.rs: 7 tests (TemplateSpec round-trip,
TemplateRow JSON decoding)
- manager/hosts/routes.rs: 8 tests (status thresholds, metrics extraction,
row mapping) + 3 helpers + 2 threshold constants extracted
- manager/networks/{service,routes}.rs: 8 tests (gateway derivation,
DHCP range, host-IP parsing, list-item mapping)
- agent/vm/spawn.rs: 5 tests (unit-name format, SpawnReq serde,
socket connectability)
- agent/vm/{stop,serial,balloon,entropy,system}.rs: 8 tests (request
serde round-trips, config-path layouts)
Test count: 25 → 95 across the workspace. All clippy-clean, fmt-clean,
no new dependencies. Production code changes are limited to extracting
pure helpers from inlined async handlers (snapshots/routes.rs,
hosts/routes.rs); behavior is byte-for-byte identical.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
9f32f3e to
8b9bab1
Compare
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.
Summary
Adds 70 pure-logic tests across modules the upcoming pluggable-VMM
backend refactor will touch. Captures current behavior so refactors
can detect regressions.
Test count: 25 → 95 across the workspace (no integration tests; all
pure logic, no DB, no HTTP, no real VMM).
Per-module breakdown
manager/vms/service.rsmanager/snapshots/{routes,repo}.rsmanager/templates/{routes,repo}.rsTemplateSpecround-trip,TemplateRowJSON decodingmanager/hosts/routes.rsmanager/networks/{service,routes}.rsagent/vm/spawn.rsSpawnReqserde, socket connectabilityagent/vm/{stop,serial,balloon,entropy,system}.rsProduction code refactors (in scope, byte-for-byte equivalent)
snapshots/routes.rs— extracted 7 pure helpers (build_agent_snapshot_urls,resolve_snapshot_name,resolve_snapshot_type,build_create_snapshot_payload,combined_snapshot_size_i64,resolve_storage_mem_path,resolve_instantiate_name) and aAgentSnapshotUrlsstruct. Original behavior preserved includingSome("")override semantics andNonemem path serializing as JSONnull.hosts/routes.rs— extractedcompute_host_status,extract_host_metrics,host_row_to_list_itemplusHEALTHY_THRESHOLD_SECONDS = 30andDEGRADED_THRESHOLD_SECONDS = 300constants. Call sites inheartbeat/list/getrewired to call helpers.No other production code modified. No new dependencies.
Verification
cargo test --workspace --no-fail-fast→ 72 manager + 23 agent passing, 11 ignored (pre-existing)cargo clippy --all-targets --all-features -- -D warnings→ cleancargo fmt -- --check→ cleanWhat this enables
The companion VMM-backend spec (
docs/superpowers/specs/2026-04-28-pluggable-vmm-backend.md, separate PR) refactorsapps/agent/src/features/vm/spawn.rs, snapshot routes, and the manager'sspawn_firecrackerflow into aVmmDrivertrait. With this baseline in place, that refactor can be verified to preserve current behavior — without it, "no regression" is vacuous (only 25 tests existed beforehand, mostly leaf helpers).Test plan
cargo test --workspacecargo clippy --all-targets --all-features -- -D warningscargo fmt -- --checksnapshots/routes.rsandhosts/routes.rspreserve original semantics🤖 Generated with Claude Code