Skip to content

test: fix unstable batch consumer in MessageDrivenAdapterTests.#10942

Merged
artembilan merged 1 commit into
spring-projects:mainfrom
mjd507:kafka-batch-test
Apr 14, 2026
Merged

test: fix unstable batch consumer in MessageDrivenAdapterTests.#10942
artembilan merged 1 commit into
spring-projects:mainfrom
mjd507:kafka-batch-test

Conversation

@mjd507
Copy link
Copy Markdown
Contributor

@mjd507 mjd507 commented Apr 14, 2026

By starting the adapter after sending messages, ensure a single poll retrieves the full batch messages.

By starting the adapter after sending messages, ensure a single poll
retrieves the full batch messages.

Signed-off-by: Jiandong Ma <jiandong.ma.cn@gmail.com>
template.sendDefault(0, 1487694048608L, 1, "bar");

adapter.start();
ContainerTestUtils.waitForAssignment(container, 1);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for looking into this @mjd507 !

Well, I don't think it helps to make sure both records are in the topic because those max.record and so Consumer properties should do the trick somehow from Kafka standpoint, but I'm OK accepting your contribution since that is really out of our project scope to verify Kafka behavior.

assertThat(((ConversionException) error.getPayload()).getMessage())
.contains("Failed to convert to message");
assertThat(((ConversionException) error.getPayload()).getRecords()).hasSize(2);
assertThat(restartAssignmentLatch.await(10, TimeUnit.SECONDS)).isTrue();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is somehow out of order of the whole test suite expectations.
I mean we probably should verify assignment first before checking for consumed record.
At the same time I don't understand why do we need to check this at all.
Looks like your main point is to ensure consumer is stopped until after we send records to the topic.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, I have same doubts when writing this, I saw the first existing latch also do the verify after all the assertions passed.

I also ask myself do we need the second latch, and I think better have that, the batch mode test has two part, one is happy path , the other is error path , I think we can treat both equally? (keep second latch?)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I missed the part that we already checking for assignment for the first start.
Yes, it feels like we definitely do need it for the second one.

Thanks.
Merging!..

assertThat(((ConversionException) error.getPayload()).getMessage())
.contains("Failed to convert to message");
assertThat(((ConversionException) error.getPayload()).getRecords()).hasSize(2);
assertThat(restartAssignmentLatch.await(10, TimeUnit.SECONDS)).isTrue();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I missed the part that we already checking for assignment for the first start.
Yes, it feels like we definitely do need it for the second one.

Thanks.
Merging!..

@artembilan artembilan added this to the 7.1.0-RC1 milestone Apr 14, 2026
@artembilan artembilan merged commit 03e239d into spring-projects:main Apr 14, 2026
3 checks passed
@mjd507 mjd507 deleted the kafka-batch-test branch April 14, 2026 14:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants