You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix flaky TestProbe supervision test by preventing restart storm (#688)
* Fix flaky TestProbe supervision test by preventing restart storm
The test was sending a new message on each AwaitAssert retry (every 100ms for 3 seconds), creating a restart storm that could exceed the supervisor's restart limit and cause the child actor to be stopped permanently. This resulted in the restart counter remaining at 0.
Changes:
- Send exactly 2 messages before AwaitAssert to trigger exactly 2 restarts
- Move the message sending outside the assertion loop to avoid accumulating messages
- Fix FailingActor.PostRestart to call base.PostRestart() to maintain proper actor lifecycle
This eliminates the race condition and makes the test deterministic.
* Use message-passing for deterministic restart verification
Replaced counter-based polling with direct message verification using TestProbe.
Now the actor sends a "restarted" message on each PostRestart, and the test
uses ExpectMsg to block until both restart notifications arrive.
This is more idiomatic Akka.NET testing and eliminates all timing assumptions:
- No AwaitAssert polling
- No AtomicCounter shared state
- Direct synchronization via message passing
- ExpectMsg blocks until message arrives or times out
The test is now truly deterministic and clearly expresses its intent.
* Convert test to use async/await pattern
Changed ExpectMsg to ExpectMsgAsync for modern async test patterns.
Test still passes reliably in ~43ms.
0 commit comments