Akka.test.single-expect-default must be higher than 5s

Hi,
I have a simple test which produces messages to the embedded Kafka ( withEmbeddedKafkaLike) and then uses a probe. request and expectMessages. The test though doesn’t pass without the akka.test.single-expect-default being set to a value higher or equal to 5 seconds. I’ve tried every possible producer and consumer settings but without any success, any value less than 5 seconds just causes a timeout exception: `assertion failed: timeout (4 seconds) during expectMsg while waiting for OnNext(1)
java.lang.AssertionError: assertion failed: timeout (4 seconds) during expectMsg while waiting for OnNext(1)
It’s actually quite annoying as it slows done my whole test suite quite significantly.
Any idea how to speed it up ?
Thanks
Jakub

`

Starting and stopping an embedded Kafka instance for every test should be an even more significant factor to your test runs.
Have you considered using the Alpakka Kafka testkit which helps you to start embedded Kafka per test class instead of per test? See https://doc.akka.io/docs/alpakka-kafka/current/testing.html

Cheers,
Enno.

Hi,

I’m actually using the Alpakka Kafka testkit and starting the embedded kafka per test class. I guess the problem lies somewhere in producing or consuming, as the first message I request never gets through before 5 seconds. I suspect this timeout is somewhere hardcoded but I can’t find where

Ok, great.
Yes, the startup for a consumer is quite slow. In Alpakka Kafka akka.test.single-expect-default is set to 10 seconds.
If you’re interested in testing your flow logic and not the Kafka bit of it, you might use the ConsumerResultFactory to replace the consumer with something else producing the same element types.

I’d rather be interested in the behavior of Kafka and my flow. I was wondering why exactly 5 secs takes for the first message, as it looks like a fixed timeout somewhere