when using Akka Streams (2.5.9) I've recently bumped into a problem when testing a stream with a mapAsync stage. It unexpectedly ends with an assertion failing on "timeout (3 seconds) during expectMsg while waiting for OnComplete"
To demonstrate it I've created a simple example.
The code below works as expected.
val sourceUnderTest = Source(1 to 2).mapAsync(2)(i => Future.successful(i * 2))
val c = TestSubscriber.manualProbe[Int]()
val p = sourceUnderTest.to(Sink.fromSubscriber(c)).run()
val sub = c.expectSubscription()
sub.request(2)
c.expectNextN(2) // List(2,4)
c.expectComplete() // akka.stream.testkit.TestSubscriber$ManualProbe@fc258b1
However, when I add another mapping function (bold code), the test fails with a timeout. When I call additional c.request(1) (commented code) it ends correctly. So it looks like the mapping function adds an additional item into the stream, which seems strange.
val sourceUnderTest = Source(1 to 2).mapAsync(2)(i => Future.successful(i * 2).map(identity))
val c = TestSubscriber.manualProbe[Int]()
val p = sourceUnderTest.to(Sink.fromSubscriber(c)).run()
val sub = c.expectSubscription()
sub.request(2)
c.expectNextN(2) // List(2,4)
// c.request(1)
c.expectComplete() // ends with java.lang.AssertionError: assertion failed: timeout (3 seconds) during expectMsg while waiting for OnComplete
Can anyone explain this strange behaviour ?
Thanks
Jakub
--
>>>>>>>>>> Read the docs: http://akka.io/docs/
>>>>>>>>>> Check the FAQ: http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user
---
You received this message because you are subscribed to the Google Groups "Akka User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to akka-user+...@googlegroups.com.
To post to this group, send email to akka...@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.
To unsubscribe from this group and stop receiving emails from it, send an email to akka-user+unsubscribe@googlegroups.com.
To post to this group, send email to akka...@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.
You received this message because you are subscribed to a topic in the Google Groups "Akka User List" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/akka-user/KXFPDLE4jpI/unsubscribe.
To unsubscribe from this group and all its topics, send an email to akka-user+unsubscribe@googlegroups.com.