-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
EmbeddedKafkaBroker#consumeFromEmbeddedTopics ignores latest offset reset strategy #2061
Comments
Yes, this is wrong, but it is extremely unusual to write a test that wants to ignore records published by the same test (so unusual, nobody has complained in nearly 4 years since this was added). Please explain the use case for why you want the test to ignore records published in the same test. |
Indeed it shouldn't ignore records from current test. In my scenario, I have an async task which could produce records, the previous test triggerred the async task but didn't wait for the task to be completed. And in the following test the async task finally produced a record and ran into the code snippet I pasted above. Actually After I have fixed the test by waiting for the async task, all my test passed without changing the behavior of I have serveral tests work with same embedded kafka and same topic. It's hard to clear(remove) topics from kafka after each test. So I manually set the offset strategy to the |
Of course, we'll fix the bug, but it is generally best practice to use a different topic for each test to avoid this kind of contamination. |
According to the document https://docs.spring.io/spring-kafka/reference/html/#junit it says:
I created my consumer and manually overrides the
ConsumerConfig.AUTO_OFFSET_RESET_CONFIG
tolatest
as below:But implementation of
EmbeddedKafkaBroker#consumeFromEmbeddedTopics
, it tries to poll records and reset the offset to earilest if there are records present:Could EmbeddedKafkaBroker respects the offset reset config or provides options that just create consumer but not trying to pull the records and reset the offset?
The text was updated successfully, but these errors were encountered: