title: Integration test does not wait for Kafka consumer client to retrieve all the events
body: <p>I have an integration test which calls the original service A. This service A only produces events for other services in the Kafka broker with topic: &quot;X&quot; and consumer group: &quot;Y&quot;. One of the objective of my integration test is just to verify the events published by the service A. For this, I created another consumer group: &quot;Y-test&quot; and the same topic: &quot;X&quot;.
  Integration test wont be producing any events but it just tries to consume the events created by Service A in topic:&quot;X&quot;. The issue i am facing is my integration test is erratic. Sometimes it waits for the kafka streamListener in integration test for all the events in the broker or sometimes it does not wait to consume the events, instead goes with next steps, kind of like skipping the steps for messages/events to be consumed.
  The expiry period for the events are around 7 days and i also verified in the kafka, if the produced events are still there and its still there.</p>
  <p>Is there a way for me to make my tests wait until all the events are consumed by my streamlistener in integration test before proceeding with rest of steps. The only way i think is by creating some kind of ListenableFuture or something similar using threads, but i am not sure if there are any simpler way to do it.</p>