kgeisz commented on code in PR #7106:
URL: https://github.com/apache/hbase/pull/7106#discussion_r2151139529
##########
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
regarding the newly created empty WAL file?
```suggestion
assertTrue("Empty WAL file should exist", dfs.exists(emptyWAL));
assertEquals("WAL file should be 0 bytes", 0,
dfs.getFileStatus(emptyWAL).getLen());
```
##########
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: For consistency, maybe add the same assertions you have in the other
test method regarding the newly created empty WAL file?
```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]