junrao commented on code in PR #19607:
URL: https://github.com/apache/kafka/pull/19607#discussion_r2117627110


##########
server/src/test/java/org/apache/kafka/server/LogManagerIntegrationTest.java:
##########
@@ -57,6 +58,70 @@ public LogManagerIntegrationTest(ClusterInstance cluster) {
         this.cluster = cluster;
     }
 
+    @ClusterTest(types = {Type.KRAFT}, brokers = 3)
+    public void testIOExceptionOnLogSegmentCloseResultsInRecovery() throws 
IOException, InterruptedException, ExecutionException {
+        try (Admin admin = cluster.admin()) {
+            admin.createTopics(List.of(new NewTopic("foo", 1, (short) 
3))).all().get();
+        }
+        cluster.waitForTopic("foo", 1);
+
+        // Produce some data into the topic
+        Map<String, Object> producerConfigs = Map.of(
+                ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, 
cluster.bootstrapServers(),
+                ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, 
StringSerializer.class.getName(),
+                ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, 
StringSerializer.class.getName()
+        );
+
+        try (Producer<String, String> producer = new 
KafkaProducer<>(producerConfigs)) {
+            producer.send(new ProducerRecord<>("foo", 0, null, "bar")).get();
+            producer.flush();
+        }
+
+        File timeIndexFile = cluster.brokers().get(0).logManager()
+                .getLog(new TopicPartition("foo", 0), false).get()
+                .activeSegment()
+                .timeIndexFile();
+
+        // Set read only so that we throw an IOException on shutdown
+        assertTrue(timeIndexFile.exists());
+        assertTrue(timeIndexFile.setReadOnly());
+
+        cluster.brokers().get(0).shutdown();

Review Comment:
   Could we verify that the cleanShutdown file is not written?



##########
server/src/test/java/org/apache/kafka/server/LogManagerIntegrationTest.java:
##########
@@ -57,6 +58,70 @@ public LogManagerIntegrationTest(ClusterInstance cluster) {
         this.cluster = cluster;
     }
 
+    @ClusterTest(types = {Type.KRAFT}, brokers = 3)

Review Comment:
   Could we just use 1 broker in the test? 



-- 
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

Reply via email to