jsancio commented on code in PR #14807: URL: https://github.com/apache/kafka/pull/14807#discussion_r1400991206
########## metadata/src/test/java/org/apache/kafka/image/ClusterImageTest.java: ########## @@ -205,4 +207,22 @@ private static List<ApiMessageAndVersion> getImageRecords(ClusterImage image) { image.write(writer, new ImageWriterOptions.Builder().build()); return writer.records(); } + + @Test + public void testHandleLossOfControllerRegistrations() { + ClusterImage testImage = new ClusterImage(Collections.emptyMap(), + Collections.singletonMap(1000, new ControllerRegistration.Builder(). + setId(1000). + setIncarnationId(Uuid.fromString("9ABu6HEgRuS-hjHLgC4cHw")). + setListeners(Collections.singletonMap("PLAINTEXT", + new Endpoint("PLAINTEXT", SecurityProtocol.PLAINTEXT, "localhost", 19092))). + setSupportedFeatures(Collections.emptyMap()).build())); + RecordListWriter writer = new RecordListWriter(); + final AtomicReference<String> lossString = new AtomicReference<>(""); + testImage.write(writer, new ImageWriterOptions.Builder(). + setMetadataVersion(MetadataVersion.IBP_3_6_IV2). + setLossHandler(loss -> lossString.compareAndSet("controller registration data", loss.loss())). + build()); + assertEquals("", lossString.get()); Review Comment: Does this pass? Looking at `MetadataVersion`, controller registration support was added in `3.7-IV0`. I would expect that since this test sets the MV to `3.6-IV2`, this test would call the loss handler. Can we also add a test where the controller registration record is included to the snapshot? -- 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: jira-unsubscr...@kafka.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org