AndrewJSchofield commented on code in PR #18136:
URL: https://github.com/apache/kafka/pull/18136#discussion_r1893087600


##########
core/src/test/scala/unit/kafka/tools/DumpLogSegmentsTest.scala:
##########
@@ -831,6 +832,86 @@ class DumpLogSegmentsTest {
     )
   }
 
+  @Test
+  def testTransactionLogMessageParser(): Unit = {
+    val serde = new TransactionCoordinatorRecordSerde()
+    val parser = new TransactionLogMessageParser()
+
+    def serializedRecord(key: ApiMessageAndVersion, value: 
ApiMessageAndVersion): Record = {
+      val record = new CoordinatorRecord(key, value)
+      TestUtils.singletonRecords(
+        key = serde.serializeKey(record),
+        value = serde.serializeValue(record)
+      ).records.iterator.next
+    }
+
+    // The key is mandatory.
+    assertEquals(
+      "Failed to decode message at offset 0 using offset transaction-log 
decoder (message had a missing key)",
+      assertThrows(
+        classOf[RuntimeException],
+        () => parser.parse(TestUtils.singletonRecords(key = null, value = 
null).records.iterator.next)
+      ).getMessage
+    )
+
+    // A valid key and value should work.

Review Comment:
   I think that will do. The point is to catch a situation where we 
inadvertently break this.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to