scalatest-embedded-kafka
scalatest-embedded-kafka copied to clipboard
Consumer offsets after restarting
Hi,
I'm using your tool to make some unit test on Kafka. I wrote a test in which I want to assert that if I restart Kafka, a consumer with the same group id retrieves last committed offset. Below my test scenario :
- Dataset in the test is 99 elements to publish in one topic kafka and 9 elements to publish in another topic.
- Kafka configuration is to have 4 partitions per topic
EmbeddedKafka.start()- Publish DataSet
- Check offsets : must be 99 for one topic, 9 for another one (tests are OK)
- Stop Kafka :
EmbeddedKafka.stop() - Wait 5 seconds.
- Restart kafka with
EmbeddedKafka.start() - Check last committed for each topic : must be always 99 for one topic, 9 for another one (tests failed)
My issue start here : when stopping the EmbeddedKafka with function stop, it seems that everything is cleaned, included offsets of a group id. My question here is to know if I can produce a such scenario with Embedded Kafka or I'm missing something in the Kafka broker configuration ?
Note that I'm using the version 0.14.0.
I think this could easily be addressed by adding a restart method. .stop() should clean up always, so I'd rather have a new method. Feel free to submit a PR - I have unfortunately very little time at the moment.
Hi @alifirat - could you share how you are checking the offsets in your test?