-
Couldn't load subscription status.
- Fork 1.1k
Harden Akka.TestKit.Tests.TestEventListenerTests.CustomEventFilterDebugTests.Make_sure_async_works #7828
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Harden Akka.TestKit.Tests.TestEventListenerTests.CustomEventFilterDebugTests.Make_sure_async_works #7828
Conversation
…ugTests.Make_sure_async_works
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Skeptical about the AI assessment of this
| await _testingEventFilter.ForLogLevel(LogLevel).ExpectAsync(1, TimeSpan.FromSeconds(2), () => | ||
| { | ||
| #pragma warning disable CS4014 // intentionally fire-and-forget to verify filter after action returns | ||
| _ = Task.Run(async () => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is the ConfigureAwait(false) the only meaningful change here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no, its the Task.Run()
…Arkatufus/akka.net into tests/TestKit-TestEventListenerTests_01
|
Separate test that failed: Akka.TestKit.Tests.TestKitBaseTests.WithinTests.Within_should_respect_minimum_time Failed: Block took 00:00:01.3719852, exceeding 00:00:01. |
…Arkatufus/akka.net into tests/TestKit-TestEventListenerTests_01
…Arkatufus/akka.net into tests/TestKit-TestEventListenerTests_01
Fix: Deflake
Make_sure_async_worksin TestEventListener testsSummary
Akka.TestKit.Tests.TestEventListenerTests.CustomEventFilterDebugTests.Make_sure_async_worksobserved on resource‑constrained CI VMs.Theory / Root Cause
Task.Delay(...).ContinueWith(...)to emit a log after the ExpectAsync action returned. Under constrained CI environments:ContinueWithschedules ontoTaskScheduler.Current, which can be bound to the TestKit’sSynchronizationContextand is sensitive to thread pool starvation.EventFilter.ExpectAsynctimes out.ExpectAsync/InterceptAsyncnow properly await async delegates. The flake is a test design fragility, not a production code defect.Mutebefore wiringEventMatchedhandlers), but it is not the primary cause here since the log is scheduled “later”.Assumptions (Test Intent)
Change
Task.Delay(...).ContinueWith(...)with a fire‑and‑forget .NET async task decoupled from the current context:Task.Run(async () => { await Task.Delay(10).ConfigureAwait(false); LogMessage("whatever"); });ExpectAsync(1, TimeSpan.FromSeconds(2), action)and returns immediately fromaction.Why This Preserves Intent and Fixes Flakiness
ContinueWith+ ambientSynchronizationContexttiming/pumping issues; reduces susceptibility to thread pool starvation in CI.