test(actor): cover shutdown ordering and broker fanout#482
Merged
intendednull merged 1 commit intoApr 28, 2026
Merged
Conversation
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
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 4 inline
#[tokio::test]s tocrates/actor/src/lib.rscovering the behaviors audit issue #232 called out as missing:system_shutdown_terminates_ctx_spawned_child—ctx.spawnchildren 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 aoneshotready-signal, no sleep-for-propagation.broker_delivers_to_many_subscribers— fanout to N=5 withask()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. Usestokio::sync::Notifyfor release coordination.cargo test -p willow-actorcount: 90 → 94 default-runnable (well above issue #232's>10target — 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.rsThe issue prescribed splitting
tests/performance.rsintoactor.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_subscribersinbroker.rsvsperf_broker_fanoutinperformance.rs). Splitting would be churn for no coverage gain.Test plan
cargo fmt --all -- --checkcargo clippy -p willow-actor --all-targets -- -D warnings— cleancargo 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— cleanRefs #232
Generated by Claude Code