Test `caf.flow.generation` unstable on CI
I've seen this test fail on a couple of runs recently. We need to figure out whether it's an issue with the test or an actual bug in CAF.
Tried recreating the fail locally and couldn't bring it to fail. I think the test fails on fedora-39:no-exceptions, I'll try setting up the runner locally.
The test fails with this check (link):
Scenario: asynchronous buffers can generate flow items
Given: a background thread writing into an async buffer
When: canceling the subscription to the buffer
Then: the producer receives a cancel event
error: check failed
loc: /actors/libcaf_core/caf/flow/generation.test.cpp:248
check: should be true
pass /actors/libcaf_core/caf/flow/generation.test.cpp:250
I was able to reproduce this using GCC 11.4 and GCC 13.2 running the test infinitely for a minute or two. Had no success with clang.
I've recorded and analyzed a test run that fails and one that succeeds. The vector res witch is a sink from the observable has 128 values in the failing run (expected empty).
The test setup starts a new thread with a producer, and immediately calls dispose on the observable. In both runs the disposable is valid and schedules an action that calls from_steps::on_dispose. Since the default demand for from_steps is 128, my guess is that the producer thread will manage to squeeze in one step from the flow first and then call the scheduled action (from_steps::on_dispose). I've added a small delay to the producer thread and let the test run in an infinite loop for 15 minutes and I can't reproduce the issue anymore.
FYI: @Neverlord