Skip to content

test(547): restore the daemon slot regression suite and structure slot custody (slices 1–2) - #650

Merged
mengmengmengqiang merged 2 commits into
layerfs_v2_0_0from
fix/547-slice-12
Nov 12, 2026
Merged

mengmengmengqiang merged 2 commits into
layerfs_v2_0_0from
fix/547-slice-12

Conversation

@mengmengmengqiang

Copy link
Copy Markdown
Contributor

Summary

Slices 1–2 of #547, rebased onto layerfs_v2_0_0 (e9b903eac, #543 merged). Slice 1 restores the daemon-slot regression suite that #543 deleted; slice 2 puts the slot-custody state machine into the shape the recovery work needs, with no behavior change.

17 files, +862 −147. Two commits, authorship kept.

What this does

Slice 1 — restore the regression suite (test-only) — 4a0c3bd01

  • engine/crates/layerfs-daemon/tests/daemon_slots.rs: the four real-daemon custody assertions over TCP — an undecodable record frees its slot, a full pool writes the capacity notice, and a concurrent failure storm neither deadlocks nor leaks.
  • engine/crates/layerfs-daemon/tests/slot_state.rs: the deleted owner/retained unit assertions plus the guard-drop release, driven through the published state machine.
  • Slots/RetainedFailures and their methods are now pub, re-exported behind a #[doc(hidden)] application::internals module so tests/ can exercise them.

Slice 2 — structure, no behavior change — 50243b9c4

  • RetainedFailures moves out of Slots into State; Slots keeps only the slot table.
  • The pure disposition() classifier and the capacity_report() read model are extracted. disposition(&ConnectionFailure, SlotTicket, &str, Instant) builds the bounded record outside the lock and Slots::finish applies it; capacity_report(SlotCounts, RetainedSnapshot) is the read model.
  • SlotClass replaces the reserved slot: usize that control_operation/hello took.
  • AdmissionClass::Lease, AdmissionReason::ReservedBusy and the CAPACITY_OPERATION aliases are deleted: layerfs_bridge::control::OPERATION is now the one name for the operator capacity/retained-failure read.

Rebase

Rebased from d788cc0a onto e9b903eac. One conflict, control/crates/layerfs-control/src/doctor/capacity.rs: #543 moved that query into layerfs_sandbox::daemon::capacity, so that file takes the base version and the slice's local OPERATION const duplication stays deleted. Slice 2's CAPACITY_OPERATION → OPERATION rename was carried into the four call sites #543 added (daemon/capacity.rs, host/call.rs, api/tests/sandbox_capacity.rs, sandbox/tests/capacity_read.rs), so the rename does not resurrect the alias. No commits squashed.

Test evidence

Dell aluminium (x86_64, 88 cores), rustc 1.85.1:

cargo +1.85.1 fmt --all -- --check                                              # rc=0
cargo +1.85.1 clippy --workspace --exclude layerfs-node --all-targets -- -D warnings   # rc=0
cargo +1.85.1 test -p layerfs-daemon --lib                                      # ok, 0 tests (same as base)
cargo +1.85.1 test -p layerfs-daemon --test daemon_slots --test slot_state      # ok
    daemon_slots.rs: 3 passed, 0 failed
    slot_state.rs:  10 passed, 0 failed
cargo +1.85.1 test -p layerfs-api -p layerfs-control -p layerfs-sandbox --no-fail-fast
    # 11 failures — all pre-existing, see below

The 11 failures are not from this branch. I built and ran the same -p layerfs-api -p layerfs-control -p layerfs-sandbox suite on unmodified e9b903eac: base fails 12 of those tests (including one this branch fixes), and this branch's failing set is a strict subset of base's — zero new failures.

They are a host limitation of the test machine, not of the code: the kernel-mount suites need /dev/fuse owned by the test user and fail as a normal user with kernel attach Mount: Operation not permitted (os error 1) / FUSE device ownership/type. Run as root they pass, but the daemon refuses to start when the command uid equals the owner uid, so daemon_slots/slot_state need a non-root user. The suite therefore cannot be green in one configuration on that host.

Refs #547, #540 — not closing either.

…sh the state machine (#547)

Slice 1: restore the four deleted daemon assertions (the pre-#543 connection
tests) as package integration tests, and make the pure Slots/RetainedFailures
state machine public behind the #[doc(hidden)] internals module so it is
unit-testable from tests/. No behavior change.

- engine/crates/layerfs-daemon/tests/daemon_slots.rs: the four real-daemon
  custody assertions over TCP (undecodable records free their slot, the
  capacity notice on a full pool, and a concurrent failure storm).
- engine/crates/layerfs-daemon/tests/slot_state.rs: the deleted owner/retained
  unit assertions plus the guard-drop release, via the public state machine.
- application/internals.rs: #[doc(hidden)] re-export of the pub'd state-machine
  values; application/{owner,retained}.rs: Slots/RetainedFailures and their
  methods are now pub.
#547)

Slice 2 (no behavior change): move RetainedFailures out of Slots into State,
extract the pure disposition() classifier and capacity_report() read model,
pass SlotClass instead of the reserved slot index to control_operation/hello,
and delete the dead AdmissionClass::Lease, AdmissionReason::ReservedBusy and
the three CAPACITY_OPERATION aliases (the bridge canonical OPERATION now
stands alone).

- owner.rs: Slots keeps only the slot table; State gains the retained store.
  A free disposition(&ConnectionFailure, SlotTicket, &str, Instant) ->
  Disposition builds the bounded record outside the lock; Slots::finish
  applies it.
- connection.rs: SlotGuard records the retained record into state.retained;
  capacity_report(SlotCounts, RetainedSnapshot) -> CapacityModel is extracted;
  control_operation/hello take SlotClass; the CONNECTION_FAILURES alias is gone.
- bridge/control/sandbox/control: AdmissionReason::ReservedBusy and the
  CAPACITY_OPERATION aliases are deleted; callers use OPERATION.
- tests/slot_state.rs updated to the split Slots + RetainedFailures API.
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