This is an automated email from the ASF dual-hosted git repository.
zhangduo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hbase.git
The following commit(s) were added to refs/heads/master by this push:
new 40edced4127 HBASE-30002 Addendum remove Assert usage
40edced4127 is described below
commit 40edced41273241f0ec24281d6c5d439a132395a
Author: Duo Zhang <[email protected]>
AuthorDate: Tue Mar 17 16:38:06 2026 +0800
HBASE-30002 Addendum remove Assert usage
---
...eSystemStateWithMergeOrSplitRegionTestBase.java | 6 +--
.../hbase/snapshot/ExportSnapshotMiscTestBase.java | 4 +-
.../hbase/snapshot/ExportSnapshotTestBase.java | 22 ++++-----
.../hbase/snapshot/TestExportSnapshotHelpers.java | 56 ++++++++++------------
.../snapshot/TestExportSnapshotV1NoCluster.java | 4 +-
.../snapshot/TestExportSnapshotV2NoCluster.java | 4 +-
6 files changed, 44 insertions(+), 52 deletions(-)
diff --git
a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/snapshot/ExportFileSystemStateWithMergeOrSplitRegionTestBase.java
b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/snapshot/ExportFileSystemStateWithMergeOrSplitRegionTestBase.java
index 39f41780679..4f99d6acee3 100644
---
a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/snapshot/ExportFileSystemStateWithMergeOrSplitRegionTestBase.java
+++
b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/snapshot/ExportFileSystemStateWithMergeOrSplitRegionTestBase.java
@@ -17,7 +17,7 @@
*/
package org.apache.hadoop.hbase.snapshot;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import java.util.List;
import java.util.stream.Collectors;
@@ -72,8 +72,6 @@ public class
ExportFileSystemStateWithMergeOrSplitRegionTestBase extends ExportS
admin.snapshot(snapshotName0, tableName0);
// export snapshot and verify
testExportFileSystemState(tableName0, snapshotName0, snapshotName0,
tableNumFiles);
- // delete table
- TEST_UTIL.deleteTable(tableName0);
}
@TestTemplate
@@ -119,7 +117,5 @@ public class
ExportFileSystemStateWithMergeOrSplitRegionTestBase extends ExportS
testExportFileSystemState(tmpConf, splitTableName, splitTableSnap,
splitTableSnap,
tableNumFiles, TEST_UTIL.getDefaultRootDirPath(),
getHdfsDestinationDir(), false, false,
getBypassRegionPredicate(), true, false);
- // delete table
- TEST_UTIL.deleteTable(splitTableName);
}
}
diff --git
a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/snapshot/ExportSnapshotMiscTestBase.java
b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/snapshot/ExportSnapshotMiscTestBase.java
index 290d57f623c..25c46955133 100644
---
a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/snapshot/ExportSnapshotMiscTestBase.java
+++
b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/snapshot/ExportSnapshotMiscTestBase.java
@@ -17,8 +17,8 @@
*/
package org.apache.hadoop.hbase.snapshot;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.HashMap;
import java.util.Map;
diff --git
a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/snapshot/ExportSnapshotTestBase.java
b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/snapshot/ExportSnapshotTestBase.java
index 1a0fec2031e..355fdb67e5c 100644
---
a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/snapshot/ExportSnapshotTestBase.java
+++
b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/snapshot/ExportSnapshotTestBase.java
@@ -18,9 +18,9 @@
package org.apache.hadoop.hbase.snapshot;
import static org.apache.hadoop.util.ToolRunner.run;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.IOException;
import java.lang.reflect.Method;
@@ -185,11 +185,11 @@ public class ExportSnapshotTestBase {
// Export Snapshot
int res = runExportSnapshot(conf, snapshotName, targetName, srcDir,
rawTgtDir, overwrite,
resetTtl, checksumVerify, true, true);
- assertEquals("success " + success + ", res=" + res, success ? 0 : 1, res);
+ assertEquals(success ? 0 : 1, res, "success " + success + ", res=" + res);
if (!success) {
final Path targetDir = new Path(HConstants.SNAPSHOT_DIR_NAME,
targetName);
- assertFalse(tgtDir.toString() + " " + targetDir.toString(),
- tgtFs.exists(new Path(tgtDir, targetDir)));
+ assertFalse(tgtFs.exists(new Path(tgtDir, targetDir)),
+ tgtDir.toString() + " " + targetDir.toString());
return;
}
LOG.info("Exported snapshot");
@@ -199,9 +199,9 @@ public class ExportSnapshotTestBase {
assertEquals(filesExpected > 0 ? 2 : 1, rootFiles.length);
for (FileStatus fileStatus : rootFiles) {
String name = fileStatus.getPath().getName();
- assertTrue(fileStatus.toString(), fileStatus.isDirectory());
- assertTrue(name.toString(), name.equals(HConstants.SNAPSHOT_DIR_NAME)
- || name.equals(HConstants.HFILE_ARCHIVE_DIRECTORY));
+ assertTrue(fileStatus.isDirectory(), fileStatus.toString());
+ assertTrue(name.equals(HConstants.SNAPSHOT_DIR_NAME)
+ || name.equals(HConstants.HFILE_ARCHIVE_DIRECTORY), name.toString());
}
LOG.info("Verified filesystem state");
@@ -260,8 +260,8 @@ public class ExportSnapshotTestBase {
}
private void verifyNonEmptyFile(final Path path) throws IOException {
- assertTrue(path + " should exists", fs.exists(path));
- assertTrue(path + " should not be empty",
fs.getFileStatus(path).getLen() > 0);
+ assertTrue(fs.exists(path), path + " should exists");
+ assertTrue(fs.getFileStatus(path).getLen() > 0, path + " should not
be empty");
}
});
diff --git
a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/snapshot/TestExportSnapshotHelpers.java
b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/snapshot/TestExportSnapshotHelpers.java
index 6329674557e..79c7fb1a26c 100644
---
a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/snapshot/TestExportSnapshotHelpers.java
+++
b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/snapshot/TestExportSnapshotHelpers.java
@@ -17,8 +17,8 @@
*/
package org.apache.hadoop.hbase.snapshot;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.ArrayList;
import java.util.Collection;
@@ -107,7 +107,7 @@ public class TestExportSnapshotHelpers {
Collection<List<Pair<SnapshotFileInfo, Long>>> groups =
inputFormat.groupFilesForSplits(conf, files);
- assertEquals("Should create 3 groups", 3, groups.size());
+ assertEquals(3, groups.size(), "Should create 3 groups");
long totalSize = 0;
int totalFiles = 0;
@@ -118,8 +118,8 @@ public class TestExportSnapshotHelpers {
}
}
- assertEquals("All files should be included", 10, totalFiles);
- assertEquals("Total size should be preserved", 450, totalSize);
+ assertEquals(10, totalFiles, "All files should be included");
+ assertEquals(450, totalSize, "Total size should be preserved");
}
@Test
@@ -141,7 +141,7 @@ public class TestExportSnapshotHelpers {
Collection<List<Pair<SnapshotFileInfo, Long>>> groups =
inputFormat.groupFilesForSplits(conf, files);
- assertEquals("Should create splits based on custom grouper output", 4,
groups.size());
+ assertEquals(4, groups.size(), "Should create splits based on custom
grouper output");
long totalSize = 0;
int totalFiles = 0;
@@ -152,8 +152,8 @@ public class TestExportSnapshotHelpers {
}
}
- assertEquals("All files should be included", 8, totalFiles);
- assertEquals("Total size should be preserved", 140, totalSize);
+ assertEquals(8, totalFiles, "All files should be included");
+ assertEquals(140, totalSize, "Total size should be preserved");
}
@Test
@@ -169,7 +169,7 @@ public class TestExportSnapshotHelpers {
new ExportSnapshot.NoopFileLocationResolver();
Set<String> locations = resolver.getLocationsForInputFiles(files);
- assertTrue("NoopFileLocationResolver should return empty locations",
locations.isEmpty());
+ assertTrue(locations.isEmpty(), "NoopFileLocationResolver should return
empty locations");
}
@Test
@@ -184,13 +184,13 @@ public class TestExportSnapshotHelpers {
TestFileLocationResolver resolver = new TestFileLocationResolver();
Set<String> locations = resolver.getLocationsForInputFiles(files);
- assertEquals("Should return expected locations", 2, locations.size());
- assertTrue("Should contain rack1", locations.contains("rack1"));
- assertTrue("Should contain rack2", locations.contains("rack2"));
+ assertEquals(2, locations.size(), "Should return expected locations");
+ assertTrue(locations.contains("rack1"), "Should contain rack1");
+ assertTrue(locations.contains("rack2"), "Should contain rack2");
}
@Test
- public void testInputSplitWithFileLocationResolver() {
+ public void testInputSplitWithFileLocationResolver() throws Exception {
List<Pair<SnapshotFileInfo, Long>> files = new ArrayList<>();
for (long i = 0; i < 3; i++) {
SnapshotFileInfo fileInfo =
SnapshotFileInfo.newBuilder().setType(SnapshotFileInfo.Type.HFILE)
@@ -202,26 +202,22 @@ public class TestExportSnapshotHelpers {
ExportSnapshot.ExportSnapshotInputFormat.ExportSnapshotInputSplit split =
new
ExportSnapshot.ExportSnapshotInputFormat.ExportSnapshotInputSplit(files,
resolver);
- try {
- String[] locations = split.getLocations();
- assertEquals("Should return 2 locations", 2, locations.length);
+ String[] locations = split.getLocations();
+ assertEquals(2, locations.length, "Should return 2 locations");
- boolean hasRack1 = false;
- boolean hasRack2 = false;
- for (String location : locations) {
- if ("rack1".equals(location)) {
- hasRack1 = true;
- }
- if ("rack2".equals(location)) {
- hasRack2 = true;
- }
+ boolean hasRack1 = false;
+ boolean hasRack2 = false;
+ for (String location : locations) {
+ if ("rack1".equals(location)) {
+ hasRack1 = true;
+ }
+ if ("rack2".equals(location)) {
+ hasRack2 = true;
}
-
- assertTrue("Should contain rack1", hasRack1);
- assertTrue("Should contain rack2", hasRack2);
- } catch (Exception e) {
- throw new RuntimeException("Failed to get locations", e);
}
+
+ assertTrue(hasRack1, "Should contain rack1");
+ assertTrue(hasRack2, "Should contain rack2");
}
public static class TestCustomFileGrouper implements
ExportSnapshot.CustomFileGrouper {
diff --git
a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/snapshot/TestExportSnapshotV1NoCluster.java
b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/snapshot/TestExportSnapshotV1NoCluster.java
index 3e6f418b136..fd019c51202 100644
---
a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/snapshot/TestExportSnapshotV1NoCluster.java
+++
b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/snapshot/TestExportSnapshotV1NoCluster.java
@@ -17,7 +17,7 @@
*/
package org.apache.hadoop.hbase.snapshot;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.IOException;
import java.util.HashSet;
@@ -63,7 +63,7 @@ public class TestExportSnapshotV1NoCluster {
this.testDir = setup(fs, this.testUtil);
LOG.info("fs={}, fsuri={}, fswd={}, testDir={}", this.fs, this.fs.getUri(),
this.fs.getWorkingDirectory(), this.testDir);
- assertTrue("FileSystem '" + fs + "' is not local", fs instanceof
LocalFileSystem);
+ assertTrue(fs instanceof LocalFileSystem, "FileSystem '" + fs + "' is not
local");
}
/**
diff --git
a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/snapshot/TestExportSnapshotV2NoCluster.java
b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/snapshot/TestExportSnapshotV2NoCluster.java
index 5d759c4b31a..21679efeb82 100644
---
a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/snapshot/TestExportSnapshotV2NoCluster.java
+++
b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/snapshot/TestExportSnapshotV2NoCluster.java
@@ -17,7 +17,7 @@
*/
package org.apache.hadoop.hbase.snapshot;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.LocalFileSystem;
@@ -51,7 +51,7 @@ public class TestExportSnapshotV2NoCluster {
this.fs = FileSystem.getLocal(this.testUtil.getConfiguration());
this.testDir = TestExportSnapshotV1NoCluster.setup(this.fs, this.testUtil);
LOG.info("fs={}, testDir={}", this.fs, this.testDir);
- assertTrue("FileSystem '" + fs + "' is not local", fs instanceof
LocalFileSystem);
+ assertTrue(fs instanceof LocalFileSystem, "FileSystem '" + fs + "' is not
local");
}
@Test