Skip to content

Commit c036670

Browse files
vishwasioolegz
authored andcommitted
test(kafka-binder): update retry expectations to align with corrected maxAttempts semantics
Updated Kafka binder tests to reflect the corrected semantics of `maxAttempts`. Previously, tests assumed `maxAttempts` represented the number of retries, leading to expectations of `maxAttempts + 1` total executions. With the fix in AbstractBinder, `maxAttempts` now correctly represents the total number of delivery attempts. As a result, test assertions have been updated to match the new behavior. No functional changes in Kafka binder logic; only test expectations updated. Signed-off-by: vishwasio <im.vishwas.03@gmail.com> Resolves #3186
1 parent 7bc2b88 commit c036670

File tree

1 file changed

+5
-6
lines changed
  • binders/kafka-binder/spring-cloud-stream-binder-kafka/src/test/java/org/springframework/cloud/stream/binder/kafka

1 file changed

+5
-6
lines changed

binders/kafka-binder/spring-cloud-stream-binder-kafka/src/test/java/org/springframework/cloud/stream/binder/kafka/KafkaBinderTests.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1309,8 +1309,7 @@ else if (!HeaderMode.none.equals(headerMode)) {
13091309
boolean shouldHaveRetried = withRetry && !useConfiguredRetryableException;
13101310
assertThat(handler.getInvocationCount())
13111311
.isEqualTo(
1312-
shouldHaveRetried ? consumerProperties.getMaxAttempts() + 1 : 1);
1313-
1312+
shouldHaveRetried ? consumerProperties.getMaxAttempts() : 1);
13141313
assertThat(receivedMessage.getHeaders()
13151314
.get(KafkaMessageChannelBinder.X_ORIGINAL_TOPIC))
13161315
.isEqualTo(producerName.getBytes(StandardCharsets.UTF_8));
@@ -1422,7 +1421,7 @@ void defaultAutoCommitOnErrorWithDlq() throws Exception {
14221421
new String((byte[]) handledMessage.getPayload(), StandardCharsets.UTF_8))
14231422
.isEqualTo(testMessagePayload);
14241423
assertThat(handler.getInvocationCount())
1425-
.isEqualTo(consumerProperties.getMaxAttempts() + 1);
1424+
.isEqualTo(consumerProperties.getMaxAttempts());
14261425
binderBindUnbindLatency();
14271426
dlqConsumerBinding.unbind();
14281427
consumerBinding.unbind();
@@ -1484,7 +1483,7 @@ void retriesWithoutDlq() throws Exception {
14841483
// Since we don't have a DLQ, assert that we are invoking the handler exactly the same number of times
14851484
// as set in consumerProperties.maxAttempt and not the default set by Spring Kafka (10 times).
14861485
assertThat(handler.getInvocationCount())
1487-
.isEqualTo(consumerProperties.getMaxAttempts() + 1);
1486+
.isEqualTo(consumerProperties.getMaxAttempts());
14881487
binderBindUnbindLatency();
14891488
consumerBinding.unbind();
14901489
producerBinding.unbind();
@@ -1609,7 +1608,7 @@ void autoCommitOnErrorWhenManualAcknowledgement() throws Exception {
16091608
new String((byte[]) handledMessage.getPayload(), StandardCharsets.UTF_8))
16101609
.isEqualTo(testMessagePayload);
16111610
assertThat(handler.getInvocationCount())
1612-
.isEqualTo(consumerProperties.getMaxAttempts() + 1);
1611+
.isEqualTo(consumerProperties.getMaxAttempts());
16131612
binderBindUnbindLatency();
16141613
dlqConsumerBinding.unbind();
16151614
consumerBinding.unbind();
@@ -1689,7 +1688,7 @@ void configurableDlqName() throws Exception {
16891688
new String((byte[]) handledMessage.getPayload(), StandardCharsets.UTF_8))
16901689
.isEqualTo(testMessagePayload);
16911690
assertThat(handler.getInvocationCount())
1692-
.isEqualTo(consumerProperties.getMaxAttempts() + 1);
1691+
.isEqualTo(consumerProperties.getMaxAttempts());
16931692
binderBindUnbindLatency();
16941693
dlqConsumerBinding.unbind();
16951694
consumerBinding.unbind();

0 commit comments

Comments
 (0)