cmccabe commented on code in PR #14807: URL: https://github.com/apache/kafka/pull/14807#discussion_r1402476918
########## 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("", loss.loss())). + build()); + assertEquals("controller registration data", lossString.get()); Review Comment: Both of the unit tests I added in this PR verify that a `ClusterImage` with controller registration generates a snapshot with `RegisterControllerRecords` if the metadata version is `3.7-IV0` -- 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