-
Notifications
You must be signed in to change notification settings - Fork 15.4k
KAFKA-9492; Ignore record errors in ProduceResponse for older versions #8030
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -170,6 +170,7 @@ | |
|
|
||
| import static java.util.Arrays.asList; | ||
| import static org.apache.kafka.common.protocol.ApiKeys.FETCH; | ||
| import static org.apache.kafka.common.protocol.ApiKeys.PRODUCE; | ||
| import static org.apache.kafka.common.requests.FetchMetadata.INVALID_SESSION_ID; | ||
| import static org.apache.kafka.test.TestUtils.toBuffer; | ||
| import static org.junit.Assert.assertEquals; | ||
|
|
@@ -653,6 +654,33 @@ public void produceResponseVersionTest() { | |
| assertEquals("Response data does not match", responseData, v2Response.responses()); | ||
| } | ||
|
|
||
| @Test | ||
| public void produceResponseRecordErrorsTest() { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe this should be in
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @ijuma Thanks for the review. I have moved this test and the other two produce response tests to |
||
| Map<TopicPartition, ProduceResponse.PartitionResponse> responseData = new HashMap<>(); | ||
| TopicPartition tp = new TopicPartition("test", 0); | ||
| ProduceResponse.PartitionResponse partResponse = new ProduceResponse.PartitionResponse(Errors.NONE, | ||
| 10000, RecordBatch.NO_TIMESTAMP, 100, | ||
| Collections.singletonList(new ProduceResponse.RecordError(3, "Record error")), | ||
| "Produce failed"); | ||
| responseData.put(tp, partResponse); | ||
|
|
||
| for (short ver = 0; ver <= PRODUCE.latestVersion(); ver++) { | ||
| ProduceResponse response = new ProduceResponse(responseData); | ||
| Struct struct = response.toStruct(ver); | ||
| assertEquals("Should use schema version " + ver, ApiKeys.PRODUCE.responseSchema(ver), struct.schema()); | ||
| ProduceResponse.PartitionResponse deserialized = new ProduceResponse(struct).responses().get(tp); | ||
| if (ver >= 8) { | ||
| assertEquals(1, deserialized.recordErrors.size()); | ||
| assertEquals(3, deserialized.recordErrors.get(0).batchIndex); | ||
| assertEquals("Record error", deserialized.recordErrors.get(0).message); | ||
| assertEquals("Produce failed", deserialized.errorMessage); | ||
| } else { | ||
| assertEquals(0, deserialized.recordErrors.size()); | ||
| assertEquals(null, deserialized.errorMessage); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| @Test | ||
| public void fetchResponseVersionTest() { | ||
| LinkedHashMap<TopicPartition, FetchResponse.PartitionData<MemoryRecords>> responseData = new LinkedHashMap<>(); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we convert the type of LOG_APPEND_TIME_KEY_NAME from long to Field.Int64? the benefit of using Field.Int64 is shown below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@chia7712 Thanks for the review. As @hachikuji mentioned, we can convert to use the generated classes, so will leave that for a separate PR.