jiafu1115 commented on code in PR #20007:
URL: https://github.com/apache/kafka/pull/20007#discussion_r2228505874


##########
storage/src/test/java/org/apache/kafka/server/log/remote/metadata/storage/TopicBasedRemoteLogMetadataManagerTest.java:
##########
@@ -336,14 +340,37 @@ public void 
testRemoteLogSizeCalculationWithSegmentsHavingNonExistentEpochs() th
 
     @ClusterTest
     public void testInitializationFailure() throws IOException, 
InterruptedException {
+        // Set up a custom exit procedure for testing
+        final AtomicBoolean exitCalled = new AtomicBoolean(false);
+        final AtomicInteger exitCode = new AtomicInteger(-1);
+        final AtomicReference<String> exitMessage = new AtomicReference<>();
+        
+        // Set custom exit procedure that won't actually exit the process
+        Exit.setExitProcedure((statusCode, message) -> {
+            exitCalled.set(true);
+            exitCode.set(statusCode);
+            exitMessage.set(message);
+        });
+
         try (TopicBasedRemoteLogMetadataManager rlmm = new 
TopicBasedRemoteLogMetadataManager()) {
             // configure rlmm without bootstrap servers, so it will fail to 
initialize admin client.
             Map<String, Object> configs = Map.of(
                 TopicBasedRemoteLogMetadataManagerConfig.LOG_DIR, 
TestUtils.tempDirectory("rlmm_segs_").getAbsolutePath(),
                 TopicBasedRemoteLogMetadataManagerConfig.BROKER_ID, 0
             );
             rlmm.configure(configs);
-            TestUtils.waitForCondition(rlmm::isInitializationFailed, 
"Initialization should fail");
+            
+            // Wait for initialization failure and exit procedure to be called
+            TestUtils.waitForCondition(() -> exitCalled.get(), 
+                "Exit procedure should be called due to initialization 
failure");
+            
+            // Verify exit code and initialization failure status
+            assertTrue(exitCalled.get(), "Exit procedure should have been 
called");

Review Comment:
   thanks. I remove the duplicated verify and isInitializationFailed's verify 
due to we change it to local variable.



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