Two classes with @EmbeddedKafka fail sporadicallly

64 Views Asked by At

I have two test classes both annotated with @EmbeddedKafka. They use a @TestConfiguration class for creating ConsumerFactory, because the code under test is using Containers instead of classes annotated with @KafkaListener. When the tests run, methods in the test class executed as second sometimes fail, sometimes pass with following note:

WARN org.apache.kafka.clients.NetworkClient -- [Consumer clientId=consumer-topic-1, groupId=topic] Connection to node 0 (localhost/127.0.0.1:55678) could not be established. Broker may not be available.

Experiments with setting bootstrap-servers to ${spring.embedded.kafka.brokers} in many locations haven't helped. Adding Thread.sleep(xxx) seems to change the behaviour by changing the test method that fails.

0

There are 0 best solutions below