kgeisz commented on code in PR #7106:
URL: https://github.com/apache/hbase/pull/7106#discussion_r2151138685


##########
hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestWALPlayer.java:
##########
@@ -338,4 +340,45 @@ public void testMainMethod() throws Exception {
 
   }
 
+  @Test
+  public void testIgnoreEmptyWALFiles() throws Exception {
+    // Create an empty WAL file in a test input directory
+    FileSystem dfs = TEST_UTIL.getDFSCluster().getFileSystem();
+    Path inputDir = new Path("/empty-wal-dir");
+    dfs.mkdirs(inputDir);
+
+    Path emptyWAL = new Path(inputDir, "empty.wal");
+    FSDataOutputStream out = dfs.create(emptyWAL);
+    out.close(); // Creates a 0-byte file

Review Comment:
   nit:  I see some code that's used in both test methods, so you could put 
this in a function if you'd like.  Something like:
   
   ```
   private void createEmptyWALFile(String walDir) {
       // Create an empty WAL file in a test input directory
       FileSystem dfs = TEST_UTIL.getDFSCluster().getFileSystem();
       Path inputDir = new Path("/" + walDir);
       dfs.mkdirs(inputDir);
       Path emptyWAL = new Path(inputDir, "empty.wal");
       FSDataOutputStream out = dfs.create(emptyWAL);
       out.close(); // Creates a 0-byte file
   }
   ```



##########
hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestWALPlayer.java:
##########
@@ -338,4 +340,45 @@ public void testMainMethod() throws Exception {
 
   }
 
+  @Test
+  public void testIgnoreEmptyWALFiles() throws Exception {
+    // Create an empty WAL file in a test input directory
+    FileSystem dfs = TEST_UTIL.getDFSCluster().getFileSystem();
+    Path inputDir = new Path("/empty-wal-dir");
+    dfs.mkdirs(inputDir);
+
+    Path emptyWAL = new Path(inputDir, "empty.wal");
+    FSDataOutputStream out = dfs.create(emptyWAL);
+    out.close(); // Creates a 0-byte file
+
+    assertTrue("Empty WAL file should exist", dfs.exists(emptyWAL));
+    assertEquals("WAL file should be 0 bytes", 0, 
dfs.getFileStatus(emptyWAL).getLen());
+
+    // Run WALPlayer with IGNORE_EMPTY_FILES = true
+    Configuration conf = new Configuration(TEST_UTIL.getConfiguration());
+    conf.setBoolean(WALPlayer.IGNORE_EMPTY_FILES, true);
+
+    int exitCode = ToolRunner.run(conf, new WALPlayer(conf), new String[] { 
inputDir.toString() });
+
+    assertEquals("WALPlayer should exit cleanly even with empty files", 0, 
exitCode);
+  }
+
+  @Test
+  public void testFailOnEmptyWALFilesWhenNotIgnored() throws Exception {
+    // Create an empty WAL file again
+    FileSystem dfs = TEST_UTIL.getDFSCluster().getFileSystem();
+    Path inputDir = new Path("/fail-empty-wal-dir");
+    dfs.mkdirs(inputDir);
+    Path emptyWAL = new Path(inputDir, "empty.wal");
+    FSDataOutputStream out = dfs.create(emptyWAL);
+    out.close();
+

Review Comment:
   nit:  Maybe add the same assertions you have in the other test method?
   
   ```suggestion
       assertTrue("Empty WAL file should exist", dfs.exists(emptyWAL));
       assertEquals("WAL file should be 0 bytes", 0, 
dfs.getFileStatus(emptyWAL).getLen());
       
   ```



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