Skip to content

test(actor): cover shutdown ordering and broker fanout#482

Merged
intendednull merged 1 commit into
claude/friendly-maxwell-bVlpWfrom
auto-fix/issue-232-actor-tests
Apr 28, 2026
Merged

test(actor): cover shutdown ordering and broker fanout#482
intendednull merged 1 commit into
claude/friendly-maxwell-bVlpWfrom
auto-fix/issue-232-actor-tests

Conversation

@intendednull
Copy link
Copy Markdown
Owner

Summary

Adds 4 inline #[tokio::test]s to crates/actor/src/lib.rs covering the behaviors audit issue #232 called out as missing:

  • system_shutdown_terminates_ctx_spawned_childctx.spawn children are tracked by the system and stopped on shutdown.
  • system_shutdown_awaits_in_flight_handler — shutdown blocks until every actor's mailbox loop runs to completion (parent waits for child). Uses a oneshot ready-signal, no sleep-for-propagation.
  • broker_delivers_to_many_subscribers — fanout to N=5 with ask() round-trips per subscriber as a deterministic FIFO barrier. Also asserts no replay to late subscribers.
  • broker_slow_subscriber_does_not_block_others — a blocked handler on one subscriber must not delay delivery to another. Uses tokio::sync::Notify for release coordination.

cargo test -p willow-actor count: 90 → 94 default-runnable (well above issue #232's >10 target — the inline-test-coverage gap was actually closed by PR #78 before this issue's auto-PR landed; the audit body was outdated by the time it was filed). Existing inline coverage already exists for mailbox bounded capacity and basic broker delivery; these 4 tests fill the remaining ordering / multi-subscriber gaps.

Tradeoff: did NOT split tests/performance.rs

The issue prescribed splitting tests/performance.rs into actor.rs (correctness) + performance.rs (timing). On audit, every one of the 15 cases in that file is a genuine throughput/timing test (assert!(ops_per_sec > 5_000.0), 10 000-iteration loops, propagation-latency assertions, multi-source benchmarks). There are no correctness-only cases lurking in there. Their correctness counterparts already exist as inline tests (e.g. broker_publish_to_subscribers in broker.rs vs perf_broker_fanout in performance.rs). Splitting would be churn for no coverage gain.

Test plan

  • cargo fmt --all -- --check
  • cargo clippy -p willow-actor --all-targets -- -D warnings — clean
  • cargo test -p willow-actor — 94 passed, 0 failed, 15 ignored (perf gated). Run 8x consecutively, deterministic.
  • cargo check -p willow-actor --target wasm32-unknown-unknown — clean

Refs #232


Generated by Claude Code

Add 4 inline #[tokio::test]s to crates/actor/src/lib.rs covering
behaviors the audit (issue #232) called out as missing:

- system_shutdown_terminates_ctx_spawned_child: ctx.spawn children
  are tracked by the system and stopped on shutdown.
- system_shutdown_awaits_in_flight_handler: shutdown blocks until
  every actor's mailbox loop runs to completion (parent waits for
  child). Uses a oneshot ready-signal — no sleep-for-propagation.
- broker_delivers_to_many_subscribers: fanout to N=5 subscribers,
  with ask() round-trips on each subscriber as a deterministic
  FIFO barrier. Also asserts no replay to late subscribers.
- broker_slow_subscriber_does_not_block_others: a blocked Handler
  on one subscriber must not delay delivery to another. Uses
  tokio::sync::Notify for release coordination.

Test count: 90 -> 94 (well above the issue's >10 default-run target).

Note on the issue's other prescription — splitting tests/performance.rs
into actor.rs (correctness) + performance.rs (timing): every test
in the file is a genuine performance/throughput case (assert
ops_per_sec > 5_000.0, 10k-iteration loops, propagation-latency
thresholds, multi-source benchmarks). There are no correctness-only
tests lurking in there to extract; splitting would be churn without
benefit. Inline tests in src/ already cover the correctness
counterparts (e.g. broker_publish_to_subscribers in broker.rs vs
perf_broker_fanout in performance.rs).

Refs #232
@intendednull intendednull merged commit e805a83 into claude/friendly-maxwell-bVlpW Apr 28, 2026
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