scalatest-embedded-kafka icon indicating copy to clipboard operation
scalatest-embedded-kafka copied to clipboard

Consumer offsets after restarting

Open alifirat opened this issue 7 years ago • 2 comments

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 :

  1. Dataset in the test is 99 elements to publish in one topic kafka and 9 elements to publish in another topic.
  2. Kafka configuration is to have 4 partitions per topic
  3. EmbeddedKafka.start()
  4. Publish DataSet
  5. Check offsets : must be 99 for one topic, 9 for another one (tests are OK)
  6. Stop Kafka : EmbeddedKafka.stop()
  7. Wait 5 seconds.
  8. Restart kafka with EmbeddedKafka.start()
  9. 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.

alifirat avatar Feb 02 '18 15:02 alifirat

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.

manub avatar Feb 05 '18 13:02 manub

Hi @alifirat - could you share how you are checking the offsets in your test?

arjunchhabra avatar Apr 03 '18 17:04 arjunchhabra