You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by li...@apache.org on 2026/04/24 17:22:01 UTC
(hbase) branch branch-2.5 updated: HBASE-30059 Upgrade hbase-server to use junit5 Part6 (#8124)
This is an automated email from the ASF dual-hosted git repository.
liuxiaocs7 pushed a commit to branch branch-2.5
in repository https://gitbox.apache.org/repos/asf/hbase.git
The following commit(s) were added to refs/heads/branch-2.5 by this push:
new b558b84de4e HBASE-30059 Upgrade hbase-server to use junit5 Part6 (#8124)
b558b84de4e is described below
commit b558b84de4e230f0cfaf3187abb6d78db7c4b44a
Author: Xiao Liu <li...@apache.org>
AuthorDate: Sat Apr 25 01:21:55 2026 +0800
HBASE-30059 Upgrade hbase-server to use junit5 Part6 (#8124)
Signed-off-by: Duo Zhang <zh...@apache.org>
(cherry picked from commit 03f9f17d46d98b880f62858a76ec648adc3692cc)
(cherry picked from commit 72c1824941edfc43bfe558c485136408c0adb973)
---
.../org/apache/hadoop/hbase/TableNameTestRule.java | 6 +
.../apache/hadoop/hbase/TestMetaTableAccessor.java | 213 +++++++++++----------
.../master/assignment/AssignmentTestingUtil.java | 4 +-
.../assignment/TestAMAssignWithRandExec.java | 13 +-
.../master/assignment/TestAMServerFailedOpen.java | 19 +-
...estAssignRegionToUninitializedRegionServer.java | 27 ++-
.../master/assignment/TestAssignmentManager.java | 43 ++---
.../assignment/TestAssignmentManagerBase.java | 26 +--
.../TestAssignmentManagerLoadMetaRegionState.java | 25 +--
.../assignment/TestAssignmentManagerUtil.java | 30 ++-
.../master/assignment/TestAssignmentOnRSCrash.java | 31 ++-
.../assignment/TestCloseRegionWhileRSCrash.java | 21 +-
.../TestDeadServerMetricRegionChore.java | 23 +--
.../assignment/TestExceptionInAssignRegion.java | 41 ++--
.../TestExceptionInUnassignedRegion.java | 41 ++--
.../hbase/master/assignment/TestHbckChore.java | 29 ++-
.../TestMasterAbortWhileMergingTable.java | 32 ++--
.../assignment/TestMergeTableRegionsProcedure.java | 52 +++--
.../assignment/TestModifyTableWhileMerging.java | 28 ++-
.../assignment/TestOpenRegionProcedureBackoff.java | 21 +-
.../assignment/TestOpenRegionProcedureHang.java | 21 +-
.../assignment/TestRaceBetweenSCPAndTRSP.java | 21 +-
...TestReduceExcessRegionReplicasBlockedByRIT.java | 27 ++-
.../TestRegionAssignedToMultipleRegionServers.java | 25 +--
.../hbase/master/assignment/TestRegionBypass.java | 42 ++--
.../assignment/TestRegionMoveAndAbandon.java | 28 +--
.../master/assignment/TestRegionReplicaSplit.java | 38 ++--
.../hbase/master/assignment/TestRegionSplit.java | 65 +++----
.../TestRegionSplitAndSeparateChildren.java | 55 +++---
.../master/assignment/TestRegionStateStore.java | 45 ++---
.../hbase/master/assignment/TestRegionStates.java | 31 ++-
.../assignment/TestReportOnlineRegionsRace.java | 23 +--
...tReportRegionStateTransitionFromDeadServer.java | 28 ++-
.../TestReportRegionStateTransitionRetry.java | 21 +-
.../master/assignment/TestRogueRSAssignment.java | 62 +++---
.../hbase/master/assignment/TestRollbackSCP.java | 27 ++-
.../master/assignment/TestSCPGetRegionsRace.java | 25 +--
.../assignment/TestSplitTableRegionProcedure.java | 105 +++++-----
.../TestTRSPPersistUninitializedSubProc.java | 21 +-
.../TestTransitRegionStateProcedure.java | 49 ++---
.../assignment/TestWakeUpUnexpectedProcedure.java | 23 +--
.../TestModifyPeerProcedureRetryBackoff.java | 21 +-
.../hbase/regionserver/TestRegionReplicas.java | 65 ++++---
43 files changed, 711 insertions(+), 882 deletions(-)
diff --git a/hbase-common/src/test/java/org/apache/hadoop/hbase/TableNameTestRule.java b/hbase-common/src/test/java/org/apache/hadoop/hbase/TableNameTestRule.java
index fdaa1163ef1..ef73abd042e 100644
--- a/hbase-common/src/test/java/org/apache/hadoop/hbase/TableNameTestRule.java
+++ b/hbase-common/src/test/java/org/apache/hadoop/hbase/TableNameTestRule.java
@@ -23,7 +23,13 @@ import org.junit.runner.Description;
/**
* Returns a {@code TableName} based on currently running test method name. Supports tests built on
* the {@link org.junit.runners.Parameterized} runner.
+ * @deprecated Use {@link TableNameTestExtension} instead, once we finish the migration of JUnit5,
+ * which means we do not need {@link TableNameTestRule} any more, we can remove these
+ * dependencies, see
+ * <a href="https://issues.apache.org/jira/browse/HBASE-23671">HBASE-23671</a> for more
+ * details.
*/
+@Deprecated
public class TableNameTestRule extends TestWatcher {
private TableName tableName;
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/TestMetaTableAccessor.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/TestMetaTableAccessor.java
index f9c70dac610..2890be4af8d 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/TestMetaTableAccessor.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/TestMetaTableAccessor.java
@@ -17,12 +17,12 @@
*/
package org.apache.hadoop.hbase;
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
@@ -65,13 +65,11 @@ import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
import org.apache.hadoop.hbase.util.ManualEnvironmentEdge;
import org.apache.hadoop.hbase.util.Pair;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-import org.junit.rules.TestName;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -80,22 +78,15 @@ import org.apache.hbase.thirdparty.com.google.common.collect.Lists;
/**
* Test {@link org.apache.hadoop.hbase.MetaTableAccessor}.
*/
-@Category({ MiscTests.class, MediumTests.class })
+@Tag(MiscTests.TAG)
+@Tag(MediumTests.TAG)
@SuppressWarnings("deprecation")
public class TestMetaTableAccessor {
-
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestMetaTableAccessor.class);
-
private static final Logger LOG = LoggerFactory.getLogger(TestMetaTableAccessor.class);
private static final HBaseTestingUtility UTIL = new HBaseTestingUtility();
private static Connection connection;
- @Rule
- public TestName name = new TestName();
-
- @BeforeClass
+ @BeforeAll
public static void beforeClass() throws Exception {
UTIL.startMiniCluster(3);
@@ -107,7 +98,7 @@ public class TestMetaTableAccessor {
connection = ConnectionFactory.createConnection(c);
}
- @AfterClass
+ @AfterAll
public static void afterClass() throws Exception {
connection.close();
UTIL.shutdownMiniCluster();
@@ -117,8 +108,8 @@ public class TestMetaTableAccessor {
* Test for HBASE-23044.
*/
@Test
- public void testGetMergeRegions() throws Exception {
- TableName tn = TableName.valueOf(this.name.getMethodName());
+ public void testGetMergeRegions(TestInfo testInfo) throws Exception {
+ TableName tn = TableName.valueOf(testInfo.getTestMethod().get().getName());
UTIL.createMultiRegionTable(tn, Bytes.toBytes("CF"), 4);
UTIL.waitTableAvailable(tn);
try (Admin admin = UTIL.getAdmin()) {
@@ -154,9 +145,9 @@ public class TestMetaTableAccessor {
}
@Test
- public void testAddMergeRegions() throws IOException {
- TableName tn = TableName.valueOf(this.name.getMethodName());
- Put put = new Put(Bytes.toBytes(this.name.getMethodName()));
+ public void testAddMergeRegions(TestInfo testInfo) throws IOException {
+ TableName tn = TableName.valueOf(testInfo.getTestMethod().get().getName());
+ Put put = new Put(Bytes.toBytes(testInfo.getTestMethod().get().getName()));
List<RegionInfo> ris = new ArrayList<>();
int limit = 10;
byte[] previous = HConstants.EMPTY_START_ROW;
@@ -198,8 +189,8 @@ public class TestMetaTableAccessor {
* while its hosted server is restarted to prove our retrying works.
*/
@Test
- public void testRetrying() throws IOException, InterruptedException {
- final TableName tableName = TableName.valueOf(name.getMethodName());
+ public void testRetrying(TestInfo testInfo) throws IOException, InterruptedException {
+ final TableName tableName = TableName.valueOf(testInfo.getTestMethod().get().getName());
LOG.info("Started " + tableName);
Table t = UTIL.createMultiRegionTable(tableName, HConstants.CATALOG_FAMILY);
int regionCount = -1;
@@ -254,8 +245,8 @@ public class TestMetaTableAccessor {
}
}
- assertTrue("reader: " + reader.toString(), reader.isProgressing());
- assertTrue("writer: " + writer.toString(), writer.isProgressing());
+ assertTrue(reader.isProgressing(), "reader: " + reader.toString());
+ assertTrue(writer.isProgressing(), "writer: " + writer.toString());
} catch (IOException e) {
throw e;
} finally {
@@ -266,7 +257,7 @@ public class TestMetaTableAccessor {
t.close();
}
long exeTime = EnvironmentEdgeManager.currentTime() - startTime;
- assertTrue("Timeout: test took " + exeTime / 1000 + " sec", exeTime < timeOut);
+ assertTrue(exeTime < timeOut, "Timeout: test took " + exeTime / 1000 + " sec");
}
/**
@@ -318,8 +309,8 @@ public class TestMetaTableAccessor {
}
@Test
- public void testGetRegion() throws IOException, InterruptedException {
- final String name = this.name.getMethodName();
+ public void testGetRegion(TestInfo testInfo) throws IOException, InterruptedException {
+ final String name = testInfo.getTestMethod().get().getName();
LOG.info("Started " + name);
// Test get on non-existent region.
Pair<RegionInfo, ServerName> pair =
@@ -330,8 +321,8 @@ public class TestMetaTableAccessor {
// Test for the optimization made in HBASE-3650
@Test
- public void testScanMetaForTable() throws IOException, InterruptedException {
- final TableName tableName = TableName.valueOf(name.getMethodName());
+ public void testScanMetaForTable(TestInfo testInfo) throws IOException, InterruptedException {
+ final TableName tableName = TableName.valueOf(testInfo.getTestMethod().get().getName());
LOG.info("Started " + tableName);
/**
@@ -386,22 +377,22 @@ public class TestMetaTableAccessor {
* The info we can get from the regionName is: table name, start key, regionId, replicaId.
*/
@Test
- public void testParseRegionInfoFromRegionName() throws IOException {
- RegionInfo originalRegionInfo =
- RegionInfoBuilder.newBuilder(TableName.valueOf(name.getMethodName())).setRegionId(999999L)
- .setStartKey(Bytes.toBytes("2")).setEndKey(Bytes.toBytes("3")).setReplicaId(1).build();
+ public void testParseRegionInfoFromRegionName(TestInfo testInfo) throws IOException {
+ RegionInfo originalRegionInfo = RegionInfoBuilder
+ .newBuilder(TableName.valueOf(testInfo.getTestMethod().get().getName())).setRegionId(999999L)
+ .setStartKey(Bytes.toBytes("2")).setEndKey(Bytes.toBytes("3")).setReplicaId(1).build();
RegionInfo newParsedRegionInfo =
MetaTableAccessor.parseRegionInfoFromRegionName(originalRegionInfo.getRegionName());
- assertEquals("Parse TableName error", originalRegionInfo.getTable(),
- newParsedRegionInfo.getTable());
- assertEquals("Parse regionId error", originalRegionInfo.getRegionId(),
- newParsedRegionInfo.getRegionId());
- assertTrue("Parse startKey error",
- Bytes.equals(originalRegionInfo.getStartKey(), newParsedRegionInfo.getStartKey()));
- assertEquals("Parse replicaId error", originalRegionInfo.getReplicaId(),
- newParsedRegionInfo.getReplicaId());
- assertTrue("We can't parse endKey from regionName only",
- Bytes.equals(HConstants.EMPTY_END_ROW, newParsedRegionInfo.getEndKey()));
+ assertEquals(originalRegionInfo.getTable(), newParsedRegionInfo.getTable(),
+ "Parse TableName error");
+ assertEquals(originalRegionInfo.getRegionId(), newParsedRegionInfo.getRegionId(),
+ "Parse regionId error");
+ assertTrue(Bytes.equals(originalRegionInfo.getStartKey(), newParsedRegionInfo.getStartKey()),
+ "Parse startKey error");
+ assertEquals(originalRegionInfo.getReplicaId(), newParsedRegionInfo.getReplicaId(),
+ "Parse replicaId error");
+ assertTrue(Bytes.equals(HConstants.EMPTY_END_ROW, newParsedRegionInfo.getEndKey()),
+ "We can't parse endKey from regionName only");
}
@Test
@@ -426,7 +417,7 @@ public class TestMetaTableAccessor {
}
@Test
- public void testMetaLocationsForRegionReplicas() throws IOException {
+ public void testMetaLocationsForRegionReplicas(TestInfo testInfo) throws IOException {
Random rand = ThreadLocalRandom.current();
ServerName serverName0 = ServerName.valueOf("foo", 60010, rand.nextLong());
@@ -434,15 +425,18 @@ public class TestMetaTableAccessor {
ServerName serverName100 = ServerName.valueOf("baz", 60010, rand.nextLong());
long regionId = EnvironmentEdgeManager.currentTime();
- RegionInfo primary = RegionInfoBuilder.newBuilder(TableName.valueOf(name.getMethodName()))
- .setStartKey(HConstants.EMPTY_START_ROW).setEndKey(HConstants.EMPTY_END_ROW).setSplit(false)
- .setRegionId(regionId).setReplicaId(0).build();
- RegionInfo replica1 = RegionInfoBuilder.newBuilder(TableName.valueOf(name.getMethodName()))
- .setStartKey(HConstants.EMPTY_START_ROW).setEndKey(HConstants.EMPTY_END_ROW).setSplit(false)
- .setRegionId(regionId).setReplicaId(1).build();
- RegionInfo replica100 = RegionInfoBuilder.newBuilder(TableName.valueOf(name.getMethodName()))
- .setStartKey(HConstants.EMPTY_START_ROW).setEndKey(HConstants.EMPTY_END_ROW).setSplit(false)
- .setRegionId(regionId).setReplicaId(100).build();
+ RegionInfo primary =
+ RegionInfoBuilder.newBuilder(TableName.valueOf(testInfo.getTestMethod().get().getName()))
+ .setStartKey(HConstants.EMPTY_START_ROW).setEndKey(HConstants.EMPTY_END_ROW).setSplit(false)
+ .setRegionId(regionId).setReplicaId(0).build();
+ RegionInfo replica1 =
+ RegionInfoBuilder.newBuilder(TableName.valueOf(testInfo.getTestMethod().get().getName()))
+ .setStartKey(HConstants.EMPTY_START_ROW).setEndKey(HConstants.EMPTY_END_ROW).setSplit(false)
+ .setRegionId(regionId).setReplicaId(1).build();
+ RegionInfo replica100 =
+ RegionInfoBuilder.newBuilder(TableName.valueOf(testInfo.getTestMethod().get().getName()))
+ .setStartKey(HConstants.EMPTY_START_ROW).setEndKey(HConstants.EMPTY_END_ROW).setSplit(false)
+ .setRegionId(regionId).setReplicaId(100).build();
long seqNum0 = rand.nextLong();
long seqNum1 = rand.nextLong();
@@ -507,11 +501,13 @@ public class TestMetaTableAccessor {
}
@Test
- public void testMetaLocationForRegionReplicasIsAddedAtTableCreation() throws IOException {
+ public void testMetaLocationForRegionReplicasIsAddedAtTableCreation(TestInfo testInfo)
+ throws IOException {
long regionId = EnvironmentEdgeManager.currentTime();
- RegionInfo primary = RegionInfoBuilder.newBuilder(TableName.valueOf(name.getMethodName()))
- .setStartKey(HConstants.EMPTY_START_ROW).setEndKey(HConstants.EMPTY_END_ROW).setSplit(false)
- .setRegionId(regionId).setReplicaId(0).build();
+ RegionInfo primary =
+ RegionInfoBuilder.newBuilder(TableName.valueOf(testInfo.getTestMethod().get().getName()))
+ .setStartKey(HConstants.EMPTY_START_ROW).setEndKey(HConstants.EMPTY_END_ROW).setSplit(false)
+ .setRegionId(regionId).setReplicaId(0).build();
Table meta = MetaTableAccessor.getMetaHTable(connection);
try {
@@ -526,20 +522,24 @@ public class TestMetaTableAccessor {
}
@Test
- public void testMetaLocationForRegionReplicasIsAddedAtRegionSplit() throws IOException {
+ public void testMetaLocationForRegionReplicasIsAddedAtRegionSplit(TestInfo testInfo)
+ throws IOException {
long regionId = EnvironmentEdgeManager.currentTime();
ServerName serverName0 =
ServerName.valueOf("foo", 60010, ThreadLocalRandom.current().nextLong());
- RegionInfo parent = RegionInfoBuilder.newBuilder(TableName.valueOf(name.getMethodName()))
- .setStartKey(HConstants.EMPTY_START_ROW).setEndKey(HConstants.EMPTY_END_ROW).setSplit(false)
- .setRegionId(regionId).setReplicaId(0).build();
+ RegionInfo parent =
+ RegionInfoBuilder.newBuilder(TableName.valueOf(testInfo.getTestMethod().get().getName()))
+ .setStartKey(HConstants.EMPTY_START_ROW).setEndKey(HConstants.EMPTY_END_ROW).setSplit(false)
+ .setRegionId(regionId).setReplicaId(0).build();
- RegionInfo splitA = RegionInfoBuilder.newBuilder(TableName.valueOf(name.getMethodName()))
- .setStartKey(HConstants.EMPTY_START_ROW).setEndKey(Bytes.toBytes("a")).setSplit(false)
- .setRegionId(regionId + 1).setReplicaId(0).build();
- RegionInfo splitB = RegionInfoBuilder.newBuilder(TableName.valueOf(name.getMethodName()))
- .setStartKey(Bytes.toBytes("a")).setEndKey(HConstants.EMPTY_END_ROW).setSplit(false)
- .setRegionId(regionId + 1).setReplicaId(0).build();
+ RegionInfo splitA =
+ RegionInfoBuilder.newBuilder(TableName.valueOf(testInfo.getTestMethod().get().getName()))
+ .setStartKey(HConstants.EMPTY_START_ROW).setEndKey(Bytes.toBytes("a")).setSplit(false)
+ .setRegionId(regionId + 1).setReplicaId(0).build();
+ RegionInfo splitB =
+ RegionInfoBuilder.newBuilder(TableName.valueOf(testInfo.getTestMethod().get().getName()))
+ .setStartKey(Bytes.toBytes("a")).setEndKey(HConstants.EMPTY_END_ROW).setSplit(false)
+ .setRegionId(regionId + 1).setReplicaId(0).build();
try (Table meta = MetaTableAccessor.getMetaHTable(connection)) {
List<RegionInfo> regionInfos = Lists.newArrayList(parent);
@@ -555,21 +555,25 @@ public class TestMetaTableAccessor {
}
@Test
- public void testMetaLocationForRegionReplicasIsAddedAtRegionMerge() throws IOException {
+ public void testMetaLocationForRegionReplicasIsAddedAtRegionMerge(TestInfo testInfo)
+ throws IOException {
long regionId = EnvironmentEdgeManager.currentTime();
ServerName serverName0 =
ServerName.valueOf("foo", 60010, ThreadLocalRandom.current().nextLong());
- RegionInfo parentA = RegionInfoBuilder.newBuilder(TableName.valueOf(name.getMethodName()))
- .setStartKey(Bytes.toBytes("a")).setEndKey(HConstants.EMPTY_END_ROW).setSplit(false)
- .setRegionId(regionId).setReplicaId(0).build();
+ RegionInfo parentA =
+ RegionInfoBuilder.newBuilder(TableName.valueOf(testInfo.getTestMethod().get().getName()))
+ .setStartKey(Bytes.toBytes("a")).setEndKey(HConstants.EMPTY_END_ROW).setSplit(false)
+ .setRegionId(regionId).setReplicaId(0).build();
- RegionInfo parentB = RegionInfoBuilder.newBuilder(TableName.valueOf(name.getMethodName()))
- .setStartKey(HConstants.EMPTY_START_ROW).setEndKey(Bytes.toBytes("a")).setSplit(false)
- .setRegionId(regionId).setReplicaId(0).build();
- RegionInfo merged = RegionInfoBuilder.newBuilder(TableName.valueOf(name.getMethodName()))
- .setStartKey(HConstants.EMPTY_START_ROW).setEndKey(HConstants.EMPTY_END_ROW).setSplit(false)
- .setRegionId(regionId + 1).setReplicaId(0).build();
+ RegionInfo parentB =
+ RegionInfoBuilder.newBuilder(TableName.valueOf(testInfo.getTestMethod().get().getName()))
+ .setStartKey(HConstants.EMPTY_START_ROW).setEndKey(Bytes.toBytes("a")).setSplit(false)
+ .setRegionId(regionId).setReplicaId(0).build();
+ RegionInfo merged =
+ RegionInfoBuilder.newBuilder(TableName.valueOf(testInfo.getTestMethod().get().getName()))
+ .setStartKey(HConstants.EMPTY_START_ROW).setEndKey(HConstants.EMPTY_END_ROW).setSplit(false)
+ .setRegionId(regionId + 1).setReplicaId(0).build();
try (Table meta = MetaTableAccessor.getMetaHTable(connection)) {
List<RegionInfo> regionInfos = Lists.newArrayList(parentA, parentB);
@@ -590,10 +594,10 @@ public class TestMetaTableAccessor {
}
@Test
- public void testMetaScanner() throws Exception {
- LOG.info("Starting " + name.getMethodName());
+ public void testMetaScanner(TestInfo testInfo) throws Exception {
+ LOG.info("Starting " + testInfo.getTestMethod().get().getName());
- final TableName tableName = TableName.valueOf(name.getMethodName());
+ final TableName tableName = TableName.valueOf(testInfo.getTestMethod().get().getName());
final byte[] FAMILY = Bytes.toBytes("family");
final byte[][] SPLIT_KEYS =
new byte[][] { Bytes.toBytes("region_a"), Bytes.toBytes("region_b") };
@@ -636,11 +640,12 @@ public class TestMetaTableAccessor {
* Tests whether maximum of masters system time versus RSs local system time is used
*/
@Test
- public void testMastersSystemTimeIsUsedInUpdateLocations() throws IOException {
+ public void testMastersSystemTimeIsUsedInUpdateLocations(TestInfo testInfo) throws IOException {
long regionId = EnvironmentEdgeManager.currentTime();
- RegionInfo regionInfo = RegionInfoBuilder.newBuilder(TableName.valueOf(name.getMethodName()))
- .setStartKey(HConstants.EMPTY_START_ROW).setEndKey(HConstants.EMPTY_END_ROW).setSplit(false)
- .setRegionId(regionId).setReplicaId(0).build();
+ RegionInfo regionInfo =
+ RegionInfoBuilder.newBuilder(TableName.valueOf(testInfo.getTestMethod().get().getName()))
+ .setStartKey(HConstants.EMPTY_START_ROW).setEndKey(HConstants.EMPTY_END_ROW).setSplit(false)
+ .setRegionId(regionId).setReplicaId(0).build();
ServerName sn = ServerName.valueOf("bar", 0, 0);
try (Table meta = MetaTableAccessor.getMetaHTable(connection)) {
@@ -671,18 +676,20 @@ public class TestMetaTableAccessor {
}
@Test
- public void testMastersSystemTimeIsUsedInMergeRegions() throws IOException {
+ public void testMastersSystemTimeIsUsedInMergeRegions(TestInfo testInfo) throws IOException {
long regionId = EnvironmentEdgeManager.currentTime();
- RegionInfo regionInfoA = RegionInfoBuilder.newBuilder(TableName.valueOf(name.getMethodName()))
- .setStartKey(HConstants.EMPTY_START_ROW).setEndKey(new byte[] { 'a' }).setSplit(false)
- .setRegionId(regionId).setReplicaId(0).build();
+ RegionInfo regionInfoA =
+ RegionInfoBuilder.newBuilder(TableName.valueOf(testInfo.getTestMethod().get().getName()))
+ .setStartKey(HConstants.EMPTY_START_ROW).setEndKey(new byte[] { 'a' }).setSplit(false)
+ .setRegionId(regionId).setReplicaId(0).build();
- RegionInfo regionInfoB = RegionInfoBuilder.newBuilder(TableName.valueOf(name.getMethodName()))
- .setStartKey(new byte[] { 'a' }).setEndKey(HConstants.EMPTY_END_ROW).setSplit(false)
- .setRegionId(regionId).setReplicaId(0).build();
+ RegionInfo regionInfoB =
+ RegionInfoBuilder.newBuilder(TableName.valueOf(testInfo.getTestMethod().get().getName()))
+ .setStartKey(new byte[] { 'a' }).setEndKey(HConstants.EMPTY_END_ROW).setSplit(false)
+ .setRegionId(regionId).setReplicaId(0).build();
RegionInfo mergedRegionInfo =
- RegionInfoBuilder.newBuilder(TableName.valueOf(name.getMethodName()))
+ RegionInfoBuilder.newBuilder(TableName.valueOf(testInfo.getTestMethod().get().getName()))
.setStartKey(HConstants.EMPTY_START_ROW).setEndKey(HConstants.EMPTY_END_ROW).setSplit(false)
.setRegionId(regionId).setReplicaId(0).build();
@@ -759,7 +766,7 @@ public class TestMetaTableAccessor {
}
@Test
- public void testMetaUpdatesGoToPriorityQueue() throws Exception {
+ public void testMetaUpdatesGoToPriorityQueue(TestInfo testInfo) throws Exception {
// This test has to be end-to-end, and do the verification from the server side
Configuration c = UTIL.getConfiguration();
@@ -770,7 +777,7 @@ public class TestMetaTableAccessor {
afterClass();
beforeClass();
- final TableName tableName = TableName.valueOf(name.getMethodName());
+ final TableName tableName = TableName.valueOf(testInfo.getTestMethod().get().getName());
try (Admin admin = connection.getAdmin();
RegionLocator rl = connection.getRegionLocator(tableName)) {
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/AssignmentTestingUtil.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/AssignmentTestingUtil.java
index a36c5bb2da8..8e8f76913f4 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/AssignmentTestingUtil.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/AssignmentTestingUtil.java
@@ -17,8 +17,8 @@
*/
package org.apache.hadoop.hbase.master.assignment;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import java.io.IOException;
import java.util.Set;
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestAMAssignWithRandExec.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestAMAssignWithRandExec.java
index ce01d61b69b..73605b5f7b7 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestAMAssignWithRandExec.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestAMAssignWithRandExec.java
@@ -17,24 +17,19 @@
*/
package org.apache.hadoop.hbase.master.assignment;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.RegionInfo;
import org.apache.hadoop.hbase.testclassification.LargeTests;
import org.apache.hadoop.hbase.testclassification.MasterTests;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-@Category({ MasterTests.class, LargeTests.class })
+@Tag(MasterTests.TAG)
+@Tag(LargeTests.TAG)
public class TestAMAssignWithRandExec extends TestAssignmentManagerBase {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestAMAssignWithRandExec.class);
-
private static final Logger LOG = LoggerFactory.getLogger(TestAMAssignWithRandExec.class);
@Test
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestAMServerFailedOpen.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestAMServerFailedOpen.java
index 390c9bfd54a..29184fd800e 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestAMServerFailedOpen.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestAMServerFailedOpen.java
@@ -17,30 +17,25 @@
*/
package org.apache.hadoop.hbase.master.assignment;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.fail;
import org.apache.hadoop.hbase.CallQueueTooBigException;
import org.apache.hadoop.hbase.DoNotRetryIOException;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.RegionInfo;
import org.apache.hadoop.hbase.client.RetriesExhaustedException;
import org.apache.hadoop.hbase.testclassification.MasterTests;
import org.apache.hadoop.hbase.testclassification.MediumTests;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-@Category({ MasterTests.class, MediumTests.class })
+@Tag(MasterTests.TAG)
+@Tag(MediumTests.TAG)
public class TestAMServerFailedOpen extends TestAssignmentManagerBase {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestAMServerFailedOpen.class);
-
private static final Logger LOG = LoggerFactory.getLogger(TestAMServerFailedOpen.class);
@Override
@@ -51,7 +46,7 @@ public class TestAMServerFailedOpen extends TestAssignmentManagerBase {
@Test
public void testServerNotYetRunning() throws Exception {
- testRetriesExhaustedFailure(TableName.valueOf(this.name.getMethodName()),
+ testRetriesExhaustedFailure(TableName.valueOf(testMethodName),
new ServerNotYetRunningRsExecutor());
}
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestAssignRegionToUninitializedRegionServer.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestAssignRegionToUninitializedRegionServer.java
index f4d16fc2252..f78428d0a1c 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestAssignRegionToUninitializedRegionServer.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestAssignRegionToUninitializedRegionServer.java
@@ -17,9 +17,9 @@
*/
package org.apache.hadoop.hbase.master.assignment;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.IOException;
import java.util.concurrent.CountDownLatch;
@@ -27,7 +27,6 @@ import java.util.concurrent.ForkJoinPool;
import java.util.concurrent.Future;
import java.util.concurrent.atomic.AtomicBoolean;
import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.TableName;
@@ -36,11 +35,10 @@ import org.apache.hadoop.hbase.regionserver.RSRpcServices;
import org.apache.hadoop.hbase.testclassification.MasterTests;
import org.apache.hadoop.hbase.testclassification.MediumTests;
import org.apache.hadoop.hbase.util.Bytes;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
import org.apache.hbase.thirdparty.com.google.protobuf.RpcController;
import org.apache.hbase.thirdparty.com.google.protobuf.ServiceException;
@@ -51,13 +49,10 @@ import org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.ExecuteProc
/**
* UT for HBASE-25032.
*/
-@Category({ MasterTests.class, MediumTests.class })
+@Tag(MasterTests.TAG)
+@Tag(MediumTests.TAG)
public class TestAssignRegionToUninitializedRegionServer {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestAssignRegionToUninitializedRegionServer.class);
-
private static CountDownLatch ARRIVE;
private static CountDownLatch RESUME;
@@ -112,14 +107,14 @@ public class TestAssignRegionToUninitializedRegionServer {
private static byte[] FAMILY = Bytes.toBytes("family");
- @BeforeClass
+ @BeforeAll
public static void setUp() throws Exception {
UTIL.startMiniCluster(1);
UTIL.createTable(NAME, FAMILY);
UTIL.waitTableAvailable(NAME);
}
- @AfterClass
+ @AfterAll
public static void tearDown() throws IOException {
UTIL.shutdownMiniCluster();
}
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestAssignmentManager.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestAssignmentManager.java
index a0434788e78..ffa4e6b54b9 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestAssignmentManager.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestAssignmentManager.java
@@ -17,15 +17,14 @@
*/
package org.apache.hadoop.hbase.master.assignment;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.Collections;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.MetaTableAccessor;
import org.apache.hadoop.hbase.TableName;
@@ -37,19 +36,15 @@ import org.apache.hadoop.hbase.procedure2.util.StringUtils;
import org.apache.hadoop.hbase.testclassification.LargeTests;
import org.apache.hadoop.hbase.testclassification.MasterTests;
import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-@Category({ MasterTests.class, LargeTests.class })
+@Tag(MasterTests.TAG)
+@Tag(LargeTests.TAG)
public class TestAssignmentManager extends TestAssignmentManagerBase {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestAssignmentManager.class);
-
private static final Logger LOG = LoggerFactory.getLogger(TestAssignmentManager.class);
@Test
@@ -88,7 +83,7 @@ public class TestAssignmentManager extends TestAssignmentManagerBase {
@Test
public void testAssignSocketTimeout() throws Exception {
- TableName tableName = TableName.valueOf(this.name.getMethodName());
+ TableName tableName = TableName.valueOf(testMethodName);
RegionInfo hri = createRegionInfo(tableName, 1);
// collect AM metrics before test
@@ -105,7 +100,7 @@ public class TestAssignmentManager extends TestAssignmentManagerBase {
@Test
public void testAssignQueueFullOnce() throws Exception {
- TableName tableName = TableName.valueOf(this.name.getMethodName());
+ TableName tableName = TableName.valueOf(testMethodName);
RegionInfo hri = createRegionInfo(tableName, 1);
// collect AM metrics before test
@@ -120,7 +115,7 @@ public class TestAssignmentManager extends TestAssignmentManagerBase {
@Test
public void testTimeoutThenQueueFull() throws Exception {
- TableName tableName = TableName.valueOf(this.name.getMethodName());
+ TableName tableName = TableName.valueOf(testMethodName);
RegionInfo hri = createRegionInfo(tableName, 1);
// collect AM metrics before test
@@ -151,7 +146,7 @@ public class TestAssignmentManager extends TestAssignmentManagerBase {
for (int i = 0; i < assignments.length; ++i) {
ProcedureTestingUtility.waitProcedure(master.getMasterProcedureExecutor(), assignments[i]);
- assertTrue(assignments[i].toString(), assignments[i].isSuccess());
+ assertTrue(assignments[i].isSuccess(), assignments[i].toString());
}
long et = EnvironmentEdgeManager.currentTime();
float sec = ((et - st) / 1000.0f);
@@ -300,14 +295,14 @@ public class TestAssignmentManager extends TestAssignmentManagerBase {
TableName.valueOf("testLoadRegionFromMetaAfterRegionManuallyAdded");
this.util.createTable(tableName, "f");
RegionInfo hri = createRegionInfo(tableName, 1);
- assertNull("RegionInfo was just instantiated by the test, but "
- + "shouldn't be in AM regionStates yet.", am.getRegionStates().getRegionState(hri));
+ assertNull(am.getRegionStates().getRegionState(hri), "RegionInfo was just instantiated by "
+ + "the test, but shouldn't be in AM regionStates yet.");
MetaTableAccessor.addRegionsToMeta(this.util.getConnection(), Collections.singletonList(hri),
1);
// TODO: is there a race here -- no other thread else will refresh the table states behind
// the scenes?
- assertNull("RegionInfo was manually added in META, but shouldn't be in AM regionStates yet.",
- am.getRegionStates().getRegionState(hri));
+ assertNull(am.getRegionStates().getRegionState(hri),
+ "RegionInfo was manually added in META, but shouldn't be in AM regionStates yet.");
am.populateRegionStatesFromMeta(hri.getEncodedName());
assertNotNull(am.getRegionInfo(hri.getRegionName()));
assertNotNull(am.getRegionInfo(hri.getEncodedName()));
@@ -324,10 +319,10 @@ public class TestAssignmentManager extends TestAssignmentManagerBase {
final TableName tableName = TableName.valueOf("testLoadRegionFromMetaRegionNotInMeta");
this.util.createTable(tableName, "f");
final RegionInfo hri = createRegionInfo(tableName, 1);
- assertNull("Bogus RegionInfo discovered in RegionStates.",
- am.getRegionStates().getRegionState(hri));
+ assertNull(am.getRegionStates().getRegionState(hri),
+ "Bogus RegionInfo discovered in RegionStates.");
am.populateRegionStatesFromMeta(hri.getEncodedName());
- assertNull("RegionInfo was never added in META", am.getRegionStates().getRegionState(hri));
+ assertNull(am.getRegionStates().getRegionState(hri), "RegionInfo was never added in META");
} finally {
this.util.killMiniHBaseCluster();
}
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestAssignmentManagerBase.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestAssignmentManagerBase.java
index 667a1ea9bd5..053fbe75db0 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestAssignmentManagerBase.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestAssignmentManagerBase.java
@@ -17,9 +17,9 @@
*/
package org.apache.hadoop.hbase.master.assignment;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
import java.io.IOException;
import java.io.InterruptedIOException;
@@ -64,10 +64,9 @@ import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.hbase.util.CommonFSUtils;
import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
import org.apache.hadoop.ipc.RemoteException;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.rules.TestName;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.TestInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -92,9 +91,7 @@ import org.apache.hadoop.hbase.shaded.protobuf.generated.RegionServerStatusProto
public abstract class TestAssignmentManagerBase {
private static final Logger LOG = LoggerFactory.getLogger(TestAssignmentManagerBase.class);
-
- @Rule
- public TestName name = new TestName();
+ protected String testMethodName;
protected static final int PROC_NTHREADS = 64;
protected static final int NREGIONS = 1 * 1000;
@@ -149,7 +146,7 @@ public abstract class TestAssignmentManagerBase {
conf.setInt("hbase.master.rs.remote.proc.fail.fast.limit", Integer.MAX_VALUE);
}
- @Before
+ @BeforeEach
public void setUp() throws Exception {
util = new HBaseTestingUtility();
this.executor = Executors.newSingleThreadScheduledExecutor(new ThreadFactoryBuilder()
@@ -169,13 +166,18 @@ public abstract class TestAssignmentManagerBase {
setUpMeta();
}
+ @BeforeEach
+ public void setTestMethod(TestInfo testInfo) {
+ testMethodName = testInfo.getTestMethod().get().getName();
+ }
+
protected void setUpMeta() throws Exception {
rsDispatcher.setMockRsExecutor(new GoodRsExecutor());
am.assign(RegionInfoBuilder.FIRST_META_REGIONINFO);
am.wakeMetaLoadedEvent();
}
- @After
+ @AfterEach
public void tearDown() throws Exception {
master.stop("tearDown");
this.executor.shutdownNow();
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestAssignmentManagerLoadMetaRegionState.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestAssignmentManagerLoadMetaRegionState.java
index 6c8f1b2310a..59f2c7dbb81 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestAssignmentManagerLoadMetaRegionState.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestAssignmentManagerLoadMetaRegionState.java
@@ -17,41 +17,36 @@
*/
package org.apache.hadoop.hbase.master.assignment;
-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.io.IOException;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.ServerName;
import org.apache.hadoop.hbase.client.RegionInfo;
import org.apache.hadoop.hbase.master.HMaster;
import org.apache.hadoop.hbase.testclassification.MasterTests;
import org.apache.hadoop.hbase.testclassification.MediumTests;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
-@Category({ MasterTests.class, MediumTests.class })
+@Tag(MasterTests.TAG)
+@Tag(MediumTests.TAG)
public class TestAssignmentManagerLoadMetaRegionState {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestAssignmentManagerLoadMetaRegionState.class);
-
private static final HBaseTestingUtility UTIL = new HBaseTestingUtility();
- @BeforeClass
+ @BeforeAll
public static void setUp() throws Exception {
UTIL.startMiniCluster(1);
}
- @AfterClass
+ @AfterAll
public static void tearDown() throws IOException {
UTIL.shutdownMiniCluster();
}
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestAssignmentManagerUtil.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestAssignmentManagerUtil.java
index 6a599f12fcc..ce8e7f32d36 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestAssignmentManagerUtil.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestAssignmentManagerUtil.java
@@ -17,8 +17,8 @@
*/
package org.apache.hadoop.hbase.master.assignment;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.fail;
import java.io.IOException;
import java.util.List;
@@ -26,7 +26,6 @@ import java.util.concurrent.locks.ReentrantLock;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import java.util.stream.Stream;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseIOException;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.TableName;
@@ -39,18 +38,15 @@ import org.apache.hadoop.hbase.master.procedure.MasterProcedureEnv;
import org.apache.hadoop.hbase.testclassification.MasterTests;
import org.apache.hadoop.hbase.testclassification.MediumTests;
import org.apache.hadoop.hbase.util.Bytes;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
-@Category({ MasterTests.class, MediumTests.class })
+@Tag(MasterTests.TAG)
+@Tag(MediumTests.TAG)
public class TestAssignmentManagerUtil {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestAssignmentManagerUtil.class);
private static final HBaseTestingUtility UTIL = new HBaseTestingUtility();
@@ -62,7 +58,7 @@ public class TestAssignmentManagerUtil {
private static int REGION_REPLICATION = 3;
- @BeforeClass
+ @BeforeAll
public static void setUp() throws Exception {
UTIL.startMiniCluster(1);
UTIL.getAdmin().balancerSwitch(false, true);
@@ -75,7 +71,7 @@ public class TestAssignmentManagerUtil {
AM = master.getAssignmentManager();
}
- @After
+ @AfterEach
public void tearDownAfterTest() throws IOException {
for (RegionInfo region : UTIL.getAdmin().getRegions(TABLE_NAME)) {
RegionStateNode regionNode = AM.getRegionStates().getRegionStateNode(region);
@@ -88,7 +84,7 @@ public class TestAssignmentManagerUtil {
}
}
- @AfterClass
+ @AfterAll
public static void tearDown() throws Exception {
UTIL.shutdownMiniCluster();
}
@@ -129,6 +125,6 @@ public class TestAssignmentManagerUtil {
IntStream.range(0, REGION_REPLICATION)
.mapToObj(i -> RegionReplicaUtil.getRegionInfoForReplica(regionA, i))
.map(AM.getRegionStates()::getRegionStateNode).forEachOrdered(
- rn -> assertFalse("Should have unset the proc for " + rn, rn.isTransitionScheduled()));
+ rn -> assertFalse(rn.isTransitionScheduled(), "Should have unset the proc for " + rn));
}
}
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestAssignmentOnRSCrash.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestAssignmentOnRSCrash.java
index 1841efc2fd9..26604b8ecee 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestAssignmentOnRSCrash.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestAssignmentOnRSCrash.java
@@ -17,13 +17,12 @@
*/
package org.apache.hadoop.hbase.master.assignment;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.IOException;
import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.ServerName;
import org.apache.hadoop.hbase.TableName;
@@ -36,21 +35,17 @@ import org.apache.hadoop.hbase.master.procedure.MasterProcedureConstants;
import org.apache.hadoop.hbase.testclassification.LargeTests;
import org.apache.hadoop.hbase.testclassification.MasterTests;
import org.apache.hadoop.hbase.util.Bytes;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-@Category({ MasterTests.class, LargeTests.class })
+@Tag(MasterTests.TAG)
+@Tag(LargeTests.TAG)
public class TestAssignmentOnRSCrash {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestAssignmentOnRSCrash.class);
-
private static final Logger LOG = LoggerFactory.getLogger(TestAssignmentOnRSCrash.class);
private static final TableName TEST_TABLE = TableName.valueOf("testb");
@@ -65,7 +60,7 @@ public class TestAssignmentOnRSCrash {
conf.set("hbase.balancer.tablesOnMaster", "none");
}
- @Before
+ @BeforeEach
public void setup() throws Exception {
UTIL = new HBaseTestingUtility();
@@ -76,7 +71,7 @@ public class TestAssignmentOnRSCrash {
Bytes.toBytes("D"), Bytes.toBytes("F"), Bytes.toBytes("L") });
}
- @After
+ @AfterEach
public void tearDown() throws Exception {
UTIL.shutdownMiniCluster();
}
@@ -129,7 +124,7 @@ public class TestAssignmentOnRSCrash {
break;
}
}
- assertTrue("expected RSs to be killed", nkilled > 0);
+ assertTrue(nkilled > 0, "expected RSs to be killed");
}
@Test
@@ -159,7 +154,7 @@ public class TestAssignmentOnRSCrash {
break;
}
}
- assertTrue("expected RSs to be killed", nkilled > 0);
+ assertTrue(nkilled > 0, "expected RSs to be killed");
}
private void testInsert(final RegionInfo hri, final int nrows) throws IOException {
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestCloseRegionWhileRSCrash.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestCloseRegionWhileRSCrash.java
index 9a6d5de1062..14306b3005e 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestCloseRegionWhileRSCrash.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestCloseRegionWhileRSCrash.java
@@ -19,7 +19,6 @@ package org.apache.hadoop.hbase.master.assignment;
import java.io.IOException;
import java.util.concurrent.CountDownLatch;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.ProcedureTestUtil;
import org.apache.hadoop.hbase.ServerName;
@@ -41,11 +40,10 @@ import org.apache.hadoop.hbase.regionserver.HRegionServer;
import org.apache.hadoop.hbase.testclassification.LargeTests;
import org.apache.hadoop.hbase.testclassification.MasterTests;
import org.apache.hadoop.hbase.util.Bytes;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -53,14 +51,11 @@ import org.slf4j.LoggerFactory;
* Confirm that we will do backoff when retrying on closing a region, to avoid consuming all the
* CPUs.
*/
-@Category({ MasterTests.class, LargeTests.class })
+@Tag(MasterTests.TAG)
+@Tag(LargeTests.TAG)
public class TestCloseRegionWhileRSCrash {
private static final Logger LOG = LoggerFactory.getLogger(TestCloseRegionWhileRSCrash.class);
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestCloseRegionWhileRSCrash.class);
-
private static final HBaseTestingUtility UTIL = new HBaseTestingUtility();
private static TableName TABLE_NAME = TableName.valueOf("Backoff");
@@ -143,7 +138,7 @@ public class TestCloseRegionWhileRSCrash {
}
}
- @BeforeClass
+ @BeforeAll
public static void setUp() throws Exception {
UTIL.getConfiguration().setInt(ServerManager.WAIT_ON_REGIONSERVERS_MINTOSTART, 1);
UTIL.startMiniCluster(3);
@@ -158,7 +153,7 @@ public class TestCloseRegionWhileRSCrash {
}
}
- @AfterClass
+ @AfterAll
public static void tearDown() throws Exception {
UTIL.shutdownMiniCluster();
}
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestDeadServerMetricRegionChore.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestDeadServerMetricRegionChore.java
index bc497d59989..45b687dd46c 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestDeadServerMetricRegionChore.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestDeadServerMetricRegionChore.java
@@ -17,31 +17,26 @@
*/
package org.apache.hadoop.hbase.master.assignment;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.fail;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.testclassification.MasterTests;
import org.apache.hadoop.hbase.testclassification.MediumTests;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
/**
* Testcase for HBASE-23682.
*/
-@Category({ MasterTests.class, MediumTests.class })
+@Tag(MasterTests.TAG)
+@Tag(MediumTests.TAG)
public class TestDeadServerMetricRegionChore {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestDeadServerMetricRegionChore.class);
-
protected HBaseTestingUtility util;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
util = new HBaseTestingUtility();
// Disable DeadServerMetricRegionChore
@@ -49,7 +44,7 @@ public class TestDeadServerMetricRegionChore {
.setInt(AssignmentManager.DEAD_REGION_METRIC_CHORE_INTERVAL_MSEC_CONF_KEY, -1);
}
- @After
+ @AfterEach
public void tearDown() throws Exception {
this.util.shutdownMiniCluster();
}
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestExceptionInAssignRegion.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestExceptionInAssignRegion.java
index 0ac8105a31c..f93bcfb817c 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestExceptionInAssignRegion.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestExceptionInAssignRegion.java
@@ -17,9 +17,11 @@
*/
package org.apache.hadoop.hbase.master.assignment;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+
import java.util.Optional;
import java.util.concurrent.CountDownLatch;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.RegionInfo;
@@ -35,20 +37,15 @@ import org.apache.hadoop.hbase.testclassification.MasterTests;
import org.apache.hadoop.hbase.testclassification.MediumTests;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.hbase.util.JVMClusterUtil;
-import org.junit.AfterClass;
-import org.junit.Assert;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
-@Category({ MasterTests.class, MediumTests.class })
+@Tag(MasterTests.TAG)
+@Tag(MediumTests.TAG)
public class TestExceptionInAssignRegion {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestExceptionInAssignRegion.class);
-
private static final HBaseTestingUtility UTIL = new HBaseTestingUtility();
private static final TableName TABLE_NAME = TableName.valueOf("test");
@@ -57,7 +54,7 @@ public class TestExceptionInAssignRegion {
private static final byte[] CF = Bytes.toBytes("cf");
- @BeforeClass
+ @BeforeAll
public static void setUp() throws Exception {
UTIL.getConfiguration().setStrings(CoprocessorHost.REGION_COPROCESSOR_CONF_KEY,
ThrowInOpenCP.class.getName());
@@ -67,7 +64,7 @@ public class TestExceptionInAssignRegion {
UTIL.waitTableAvailable(TABLE_NAME);
}
- @AfterClass
+ @AfterAll
public static void tearDown() throws Exception {
UTIL.shutdownMiniCluster();
}
@@ -98,14 +95,14 @@ public class TestExceptionInAssignRegion {
long prodId = procedureExecutor.submitProcedure(assignRegionProcedure);
ProcedureTestingUtility.waitProcedure(procedureExecutor, prodId);
- Assert.assertEquals("Should be two RS since other is aborted", 2,
- UTIL.getMiniHBaseCluster().getLiveRegionServerThreads().size());
- Assert.assertNull("RIT Map doesn't have correct value",
- getRegionServer(0).getRegionsInTransitionInRS().get(hri.getEncodedNameAsBytes()));
- Assert.assertNull("RIT Map doesn't have correct value",
- getRegionServer(1).getRegionsInTransitionInRS().get(hri.getEncodedNameAsBytes()));
- Assert.assertNull("RIT Map doesn't have correct value",
- getRegionServer(2).getRegionsInTransitionInRS().get(hri.getEncodedNameAsBytes()));
+ assertEquals(2, UTIL.getMiniHBaseCluster().getLiveRegionServerThreads().size(),
+ "Should be two RS since other is aborted");
+ assertNull(getRegionServer(0).getRegionsInTransitionInRS().get(hri.getEncodedNameAsBytes()),
+ "RIT Map doesn't have correct value");
+ assertNull(getRegionServer(1).getRegionsInTransitionInRS().get(hri.getEncodedNameAsBytes()),
+ "RIT Map doesn't have correct value");
+ assertNull(getRegionServer(2).getRegionsInTransitionInRS().get(hri.getEncodedNameAsBytes()),
+ "RIT Map doesn't have correct value");
}
private HRegionServer getRegionServer(int index) {
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestExceptionInUnassignedRegion.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestExceptionInUnassignedRegion.java
index 55de533e3d2..82718640635 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestExceptionInUnassignedRegion.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestExceptionInUnassignedRegion.java
@@ -17,8 +17,10 @@
*/
package org.apache.hadoop.hbase.master.assignment;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+
import java.util.Optional;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.RegionInfo;
@@ -34,27 +36,22 @@ import org.apache.hadoop.hbase.testclassification.MasterTests;
import org.apache.hadoop.hbase.testclassification.MediumTests;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.hbase.util.JVMClusterUtil;
-import org.junit.AfterClass;
-import org.junit.Assert;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
-@Category({ MasterTests.class, MediumTests.class })
+@Tag(MasterTests.TAG)
+@Tag(MediumTests.TAG)
public class TestExceptionInUnassignedRegion {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestExceptionInUnassignedRegion.class);
-
private static final HBaseTestingUtility UTIL = new HBaseTestingUtility();
private static final TableName TABLE_NAME = TableName.valueOf("test");
private static final byte[] CF = Bytes.toBytes("cf");
- @BeforeClass
+ @BeforeAll
public static void setUp() throws Exception {
UTIL.getConfiguration().setStrings(CoprocessorHost.REGION_COPROCESSOR_CONF_KEY,
ThrowInCloseCP.class.getName());
@@ -64,7 +61,7 @@ public class TestExceptionInUnassignedRegion {
UTIL.waitTableAvailable(TABLE_NAME);
}
- @AfterClass
+ @AfterAll
public static void tearDown() throws Exception {
UTIL.shutdownMiniCluster();
}
@@ -93,14 +90,14 @@ public class TestExceptionInUnassignedRegion {
long prodId = procedureExecutor.submitProcedure(moveRegionProcedure);
ProcedureTestingUtility.waitProcedure(procedureExecutor, prodId);
- Assert.assertEquals("Should be two RS since other is aborted", 2,
- UTIL.getMiniHBaseCluster().getLiveRegionServerThreads().size());
- Assert.assertNull("RIT Map doesn't have correct value",
- getRegionServer(0).getRegionsInTransitionInRS().get(hri.getEncodedNameAsBytes()));
- Assert.assertNull("RIT Map doesn't have correct value",
- getRegionServer(1).getRegionsInTransitionInRS().get(hri.getEncodedNameAsBytes()));
- Assert.assertNull("RIT Map doesn't have correct value",
- getRegionServer(2).getRegionsInTransitionInRS().get(hri.getEncodedNameAsBytes()));
+ assertEquals(2, UTIL.getMiniHBaseCluster().getLiveRegionServerThreads().size(),
+ "Should be two RS since other is aborted");
+ assertNull(getRegionServer(0).getRegionsInTransitionInRS().get(hri.getEncodedNameAsBytes()),
+ "RIT Map doesn't have correct value");
+ assertNull(getRegionServer(1).getRegionsInTransitionInRS().get(hri.getEncodedNameAsBytes()),
+ "RIT Map doesn't have correct value");
+ assertNull(getRegionServer(2).getRegionsInTransitionInRS().get(hri.getEncodedNameAsBytes()),
+ "RIT Map doesn't have correct value");
}
private HRegionServer getRegionServer(int index) {
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestHbckChore.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestHbckChore.java
index 43665f2842d..175ec7b2651 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestHbckChore.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestHbckChore.java
@@ -17,12 +17,12 @@
*/
package org.apache.hadoop.hbase.master.assignment;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-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.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.time.Instant;
import java.util.Collections;
@@ -31,7 +31,6 @@ import java.util.Map;
import java.util.Optional;
import java.util.concurrent.Future;
import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HRegionInfo;
import org.apache.hadoop.hbase.ServerName;
import org.apache.hadoop.hbase.TableName;
@@ -48,25 +47,21 @@ import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.hbase.util.CommonFSUtils;
import org.apache.hadoop.hbase.util.FSUtils;
import org.apache.hadoop.hbase.util.Pair;
-import org.junit.Before;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-@Category({ MasterTests.class, MediumTests.class })
+@Tag(MasterTests.TAG)
+@Tag(MediumTests.TAG)
public class TestHbckChore extends TestAssignmentManagerBase {
private static final Logger LOG = LoggerFactory.getLogger(TestHbckChore.class);
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestHbckChore.class);
-
private HbckChore hbckChore;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
super.setUp();
hbckChore = new HbckChore(master);
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestMasterAbortWhileMergingTable.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestMasterAbortWhileMergingTable.java
index 41d08002e1b..3e071328604 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestMasterAbortWhileMergingTable.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestMasterAbortWhileMergingTable.java
@@ -17,10 +17,11 @@
*/
package org.apache.hadoop.hbase.master.assignment;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
import java.util.List;
import java.util.Optional;
import java.util.concurrent.CountDownLatch;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.Admin;
@@ -34,22 +35,17 @@ import org.apache.hadoop.hbase.coprocessor.ObserverContext;
import org.apache.hadoop.hbase.testclassification.MasterTests;
import org.apache.hadoop.hbase.testclassification.MediumTests;
import org.apache.hadoop.hbase.util.Bytes;
-import org.junit.AfterClass;
-import org.junit.Assert;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-@Category({ MasterTests.class, MediumTests.class })
+@Tag(MasterTests.TAG)
+@Tag(MediumTests.TAG)
public class TestMasterAbortWhileMergingTable {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestMasterAbortWhileMergingTable.class);
-
private static final Logger LOG = LoggerFactory.getLogger(TestMasterAbortWhileMergingTable.class);
protected static final HBaseTestingUtility UTIL = new HBaseTestingUtility();
@@ -59,7 +55,7 @@ public class TestMasterAbortWhileMergingTable {
private static byte[] SPLITKEY = Bytes.toBytes("bbbbbbb");
private static CountDownLatch mergeCommitArrive = new CountDownLatch(1);
- @BeforeClass
+ @BeforeAll
public static void setupCluster() throws Exception {
UTIL.getConfiguration().set(CoprocessorHost.MASTER_COPROCESSOR_CONF_KEY,
MergeRegionObserver.class.getName());
@@ -71,7 +67,7 @@ public class TestMasterAbortWhileMergingTable {
UTIL.waitTableAvailable(TABLE_NAME);
}
- @AfterClass
+ @AfterAll
public static void cleanupTest() throws Exception {
try {
UTIL.shutdownMiniCluster();
@@ -96,11 +92,11 @@ public class TestMasterAbortWhileMergingTable {
&& UTIL.getMiniHBaseCluster().getMaster().isInitialized());
UTIL.waitFor(30000,
() -> UTIL.getMiniHBaseCluster().getMaster().getMasterProcedureExecutor().isFinished(procID));
- Assert.assertTrue(
- "Found region RIT, that's impossible! "
- + UTIL.getMiniHBaseCluster().getMaster().getAssignmentManager().getRegionsInTransition(),
+ assertTrue(
UTIL.getMiniHBaseCluster().getMaster().getAssignmentManager().getRegionsInTransition().size()
- == 0);
+ == 0,
+ "Found region RIT, that's impossible! "
+ + UTIL.getMiniHBaseCluster().getMaster().getAssignmentManager().getRegionsInTransition());
}
public static class MergeRegionObserver implements MasterCoprocessor, MasterObserver {
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestMergeTableRegionsProcedure.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestMergeTableRegionsProcedure.java
index 0c95057bbf0..6e417dc9a84 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestMergeTableRegionsProcedure.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestMergeTableRegionsProcedure.java
@@ -17,14 +17,13 @@
*/
package org.apache.hadoop.hbase.master.assignment;
-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.io.IOException;
import java.util.ArrayList;
import java.util.List;
import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.MetaTableAccessor;
@@ -48,28 +47,22 @@ import org.apache.hadoop.hbase.testclassification.LargeTests;
import org.apache.hadoop.hbase.testclassification.MasterTests;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.hbase.util.Threads;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-import org.junit.rules.TestName;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-@Category({ MasterTests.class, LargeTests.class })
+@Tag(MasterTests.TAG)
+@Tag(LargeTests.TAG)
public class TestMergeTableRegionsProcedure {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestMergeTableRegionsProcedure.class);
-
private static final Logger LOG = LoggerFactory.getLogger(TestMergeTableRegionsProcedure.class);
- @Rule
- public final TestName name = new TestName();
+ private String testMethodName;
private static final HBaseTestingUtility UTIL = new HBaseTestingUtility();
@@ -97,19 +90,19 @@ public class TestMergeTableRegionsProcedure {
RegionServerHostingReplicaSlowOpenCoprocessor.class.getName());
}
- @BeforeClass
+ @BeforeAll
public static void setupCluster() throws Exception {
setupConf(UTIL.getConfiguration());
UTIL.startMiniCluster(1);
admin = UTIL.getAdmin();
}
- @AfterClass
+ @AfterAll
public static void cleanupTest() throws Exception {
UTIL.shutdownMiniCluster();
}
- @Before
+ @BeforeEach
public void setup() throws Exception {
resetProcExecutorTestingKillFlag();
MasterProcedureTestingUtility.generateNonceGroup(UTIL.getHBaseCluster().getMaster());
@@ -125,7 +118,12 @@ public class TestMergeTableRegionsProcedure {
unassignProcMetrics = am.getAssignmentManagerMetrics().getUnassignProcMetrics();
}
- @After
+ @BeforeEach
+ public void setTestMethod(TestInfo testInfo) {
+ testMethodName = testInfo.getTestMethod().get().getName();
+ }
+
+ @AfterEach
public void tearDown() throws Exception {
resetProcExecutorTestingKillFlag();
for (TableDescriptor htd : admin.listTableDescriptors()) {
@@ -137,7 +135,7 @@ public class TestMergeTableRegionsProcedure {
private void resetProcExecutorTestingKillFlag() {
final ProcedureExecutor<MasterProcedureEnv> procExec = getMasterProcedureExecutor();
ProcedureTestingUtility.setKillAndToggleBeforeStoreUpdate(procExec, false);
- assertTrue("expected executor to be running", procExec.isRunning());
+ assertTrue(procExec.isRunning(), "expected executor to be running");
}
private int loadARowPerRegion(final Table t, List<RegionInfo> ris) throws IOException {
@@ -159,7 +157,7 @@ public class TestMergeTableRegionsProcedure {
*/
@Test
public void testMergeTwoRegions() throws Exception {
- final TableName tableName = TableName.valueOf(this.name.getMethodName());
+ final TableName tableName = TableName.valueOf(testMethodName);
UTIL.createTable(tableName, new byte[][] { HConstants.CATALOG_FAMILY }, new byte[][] {
new byte[] { 'b' }, new byte[] { 'c' }, new byte[] { 'd' }, new byte[] { 'e' } });
testMerge(tableName, 2);
@@ -222,7 +220,7 @@ public class TestMergeTableRegionsProcedure {
*/
@Test
public void testMergeTenRegions() throws Exception {
- final TableName tableName = TableName.valueOf(this.name.getMethodName());
+ final TableName tableName = TableName.valueOf(testMethodName);
final ProcedureExecutor<MasterProcedureEnv> procExec = getMasterProcedureExecutor();
UTIL.createMultiRegionTable(tableName, HConstants.CATALOG_FAMILY);
testMerge(tableName, 10);
@@ -350,7 +348,7 @@ public class TestMergeTableRegionsProcedure {
@Test
public void testMergeDetectsModifyTableProcedure() throws Exception {
- final TableName tableName = TableName.valueOf(name.getMethodName());
+ final TableName tableName = TableName.valueOf(testMethodName);
final ProcedureExecutor<MasterProcedureEnv> procExec = getMasterProcedureExecutor();
List<RegionInfo> regions = createTable(tableName);
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestModifyTableWhileMerging.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestModifyTableWhileMerging.java
index a35a8a3274a..3366ee4158f 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestModifyTableWhileMerging.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestModifyTableWhileMerging.java
@@ -17,8 +17,9 @@
*/
package org.apache.hadoop.hbase.master.assignment;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
import java.util.List;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.Admin;
@@ -32,24 +33,19 @@ import org.apache.hadoop.hbase.procedure2.ProcedureExecutor;
import org.apache.hadoop.hbase.testclassification.MasterTests;
import org.apache.hadoop.hbase.testclassification.MediumTests;
import org.apache.hadoop.hbase.util.Bytes;
-import org.junit.AfterClass;
-import org.junit.Assert;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.hadoop.hbase.shaded.protobuf.generated.ProcedureProtos;
-@Category({ MasterTests.class, MediumTests.class })
+@Tag(MasterTests.TAG)
+@Tag(MediumTests.TAG)
public class TestModifyTableWhileMerging {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestModifyTableWhileMerging.class);
-
private static final Logger LOG = LoggerFactory.getLogger(TestModifyTableWhileMerging.class);
protected static final HBaseTestingUtility UTIL = new HBaseTestingUtility();
@@ -59,7 +55,7 @@ public class TestModifyTableWhileMerging {
private static byte[] CF = Bytes.toBytes("cf");
private static byte[] SPLITKEY = Bytes.toBytes("bbbbbbb");
- @BeforeClass
+ @BeforeAll
public static void setupCluster() throws Exception {
// Set procedure executor thread to 1, making reproducing this issue of HBASE-20921 easier
UTIL.getConfiguration().setInt(MasterProcedureConstants.MASTER_PROCEDURE_THREADS, 1);
@@ -71,7 +67,7 @@ public class TestModifyTableWhileMerging {
UTIL.waitTableAvailable(TABLE_NAME);
}
- @AfterClass
+ @AfterAll
public static void cleanupTest() throws Exception {
try {
UTIL.shutdownMiniCluster();
@@ -98,8 +94,8 @@ public class TestModifyTableWhileMerging {
long proc = executor.submitProcedure(mergeTableRegionsProcedure);
UTIL.waitFor(3000000, () -> UTIL.getMiniHBaseCluster().getMaster().getMasterProcedureExecutor()
.isFinished(procModify));
- Assert.assertEquals("Modify Table procedure should success!",
- ProcedureProtos.ProcedureState.SUCCESS, modifyTableProcedure.getState());
+ assertEquals(ProcedureProtos.ProcedureState.SUCCESS, modifyTableProcedure.getState(),
+ "Modify Table procedure should success!");
}
}
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestOpenRegionProcedureBackoff.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestOpenRegionProcedureBackoff.java
index 9d8febccca5..87aa0f66bf0 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestOpenRegionProcedureBackoff.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestOpenRegionProcedureBackoff.java
@@ -22,7 +22,6 @@ import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.ProcedureTestUtil;
@@ -39,22 +38,18 @@ import org.apache.hadoop.hbase.master.region.MasterRegion;
import org.apache.hadoop.hbase.testclassification.MasterTests;
import org.apache.hadoop.hbase.testclassification.MediumTests;
import org.apache.hadoop.hbase.util.Bytes;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
/**
* Testcase for HBASE-23079.
*/
-@Category({ MasterTests.class, MediumTests.class })
+@Tag(MasterTests.TAG)
+@Tag(MediumTests.TAG)
public class TestOpenRegionProcedureBackoff {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestOpenRegionProcedureBackoff.class);
-
private static volatile boolean FAIL = false;
private static final class AssignmentManagerForTest extends AssignmentManager {
@@ -91,7 +86,7 @@ public class TestOpenRegionProcedureBackoff {
private static byte[] CF = Bytes.toBytes("cf");
- @BeforeClass
+ @BeforeAll
public static void setUp() throws Exception {
Configuration conf = UTIL.getConfiguration();
conf.setClass(HConstants.MASTER_IMPL, HMasterForTest.class, HMaster.class);
@@ -106,7 +101,7 @@ public class TestOpenRegionProcedureBackoff {
});
}
- @AfterClass
+ @AfterAll
public static void tearDown() throws Exception {
UTIL.shutdownMiniCluster();
}
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestOpenRegionProcedureHang.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestOpenRegionProcedureHang.java
index f495cc7c0c8..ec0788ac550 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestOpenRegionProcedureHang.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestOpenRegionProcedureHang.java
@@ -21,7 +21,6 @@ import java.io.IOException;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.PleaseHoldException;
@@ -40,11 +39,10 @@ import org.apache.hadoop.hbase.testclassification.MediumTests;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.hbase.util.JVMClusterUtil.MasterThread;
import org.apache.zookeeper.KeeperException;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -57,13 +55,10 @@ import org.apache.hadoop.hbase.shaded.protobuf.generated.RegionServerStatusProto
/**
* See HBASE-22060 and HBASE-22074 for more details.
*/
-@Category({ MasterTests.class, MediumTests.class })
+@Tag(MasterTests.TAG)
+@Tag(MediumTests.TAG)
public class TestOpenRegionProcedureHang {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestOpenRegionProcedureHang.class);
-
private static final Logger LOG = LoggerFactory.getLogger(TestOpenRegionProcedureHang.class);
private static CountDownLatch ARRIVE;
@@ -140,7 +135,7 @@ public class TestOpenRegionProcedureHang {
private static byte[] CF = Bytes.toBytes("cf");
- @BeforeClass
+ @BeforeAll
public static void setUp() throws Exception {
Configuration conf = UTIL.getConfiguration();
conf.setClass(HConstants.MASTER_IMPL, HMasterForTest.class, HMaster.class);
@@ -155,7 +150,7 @@ public class TestOpenRegionProcedureHang {
UTIL.getAdmin().balancerSwitch(false, true);
}
- @AfterClass
+ @AfterAll
public static void tearDown() throws Exception {
UTIL.shutdownMiniCluster();
}
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestRaceBetweenSCPAndTRSP.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestRaceBetweenSCPAndTRSP.java
index 2cf96aa24eb..aeab317958b 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestRaceBetweenSCPAndTRSP.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestRaceBetweenSCPAndTRSP.java
@@ -22,7 +22,6 @@ import java.util.List;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.Future;
import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.ServerName;
@@ -39,22 +38,18 @@ import org.apache.hadoop.hbase.testclassification.LargeTests;
import org.apache.hadoop.hbase.testclassification.MasterTests;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.zookeeper.KeeperException;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
/**
* Testcase for HBASE-23594.
*/
-@Category({ MasterTests.class, LargeTests.class })
+@Tag(MasterTests.TAG)
+@Tag(LargeTests.TAG)
public class TestRaceBetweenSCPAndTRSP {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestRaceBetweenSCPAndTRSP.class);
-
private static final HBaseTestingUtility UTIL = new HBaseTestingUtility();
private static TableName NAME = TableName.valueOf("Race");
@@ -116,7 +111,7 @@ public class TestRaceBetweenSCPAndTRSP {
}
}
- @BeforeClass
+ @BeforeAll
public static void setUp() throws Exception {
UTIL.getConfiguration().setClass(HConstants.MASTER_IMPL, HMasterForTest.class, HMaster.class);
UTIL.startMiniCluster(2);
@@ -125,7 +120,7 @@ public class TestRaceBetweenSCPAndTRSP {
UTIL.getAdmin().balancerSwitch(false, true);
}
- @AfterClass
+ @AfterAll
public static void tearDown() throws Exception {
UTIL.shutdownMiniCluster();
}
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestReduceExcessRegionReplicasBlockedByRIT.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestReduceExcessRegionReplicasBlockedByRIT.java
index 74a442523a7..7a585ca0b1d 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestReduceExcessRegionReplicasBlockedByRIT.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestReduceExcessRegionReplicasBlockedByRIT.java
@@ -17,12 +17,11 @@
*/
package org.apache.hadoop.hbase.master.assignment;
-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.util.concurrent.CompletableFuture;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.AsyncConnection;
@@ -36,11 +35,10 @@ import org.apache.hadoop.hbase.master.procedure.MasterProcedureEnv;
import org.apache.hadoop.hbase.procedure2.ProcedureExecutor;
import org.apache.hadoop.hbase.testclassification.MasterTests;
import org.apache.hadoop.hbase.testclassification.MediumTests;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
import org.apache.hbase.thirdparty.com.google.common.io.Closeables;
@@ -48,13 +46,10 @@ import org.apache.hbase.thirdparty.com.google.common.io.Closeables;
* A test to make sure that we will wait for RIT to finish while closing excess region replicas. See
* HBASE-28582 and related issues for more details.
*/
-@Category({ MasterTests.class, MediumTests.class })
+@Tag(MasterTests.TAG)
+@Tag(MediumTests.TAG)
public class TestReduceExcessRegionReplicasBlockedByRIT {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestReduceExcessRegionReplicasBlockedByRIT.class);
-
private static final HBaseTestingUtility UTIL = new HBaseTestingUtility();
private static AsyncConnection CONN;
@@ -63,7 +58,7 @@ public class TestReduceExcessRegionReplicasBlockedByRIT {
TableDescriptorBuilder.newBuilder(TableName.valueOf("CloseExcessRegionReplicas"))
.setColumnFamily(ColumnFamilyDescriptorBuilder.of("family")).setRegionReplication(4).build();
- @BeforeClass
+ @BeforeAll
public static void setUp() throws Exception {
UTIL.startMiniCluster(1);
UTIL.getAdmin().createTable(TD);
@@ -72,7 +67,7 @@ public class TestReduceExcessRegionReplicasBlockedByRIT {
CONN = ConnectionFactory.createAsyncConnection(UTIL.getConfiguration()).get();
}
- @AfterClass
+ @AfterAll
public static void tearDown() throws Exception {
Closeables.close(CONN, true);
UTIL.shutdownMiniCluster();
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestRegionAssignedToMultipleRegionServers.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestRegionAssignedToMultipleRegionServers.java
index f2b73eac9be..f5037a6cd19 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestRegionAssignedToMultipleRegionServers.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestRegionAssignedToMultipleRegionServers.java
@@ -17,15 +17,14 @@
*/
package org.apache.hadoop.hbase.master.assignment;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CountDownLatch;
import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.PleaseHoldException;
@@ -43,23 +42,19 @@ import org.apache.hadoop.hbase.regionserver.HRegionServer;
import org.apache.hadoop.hbase.testclassification.MasterTests;
import org.apache.hadoop.hbase.testclassification.MediumTests;
import org.apache.hadoop.hbase.util.Bytes;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
import org.apache.hadoop.hbase.shaded.protobuf.generated.RegionServerStatusProtos.RegionStateTransition.TransitionCode;
import org.apache.hadoop.hbase.shaded.protobuf.generated.RegionServerStatusProtos.ReportRegionStateTransitionRequest;
import org.apache.hadoop.hbase.shaded.protobuf.generated.RegionServerStatusProtos.ReportRegionStateTransitionResponse;
-@Category({ MasterTests.class, MediumTests.class })
+@Tag(MasterTests.TAG)
+@Tag(MediumTests.TAG)
public class TestRegionAssignedToMultipleRegionServers {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestRegionAssignedToMultipleRegionServers.class);
-
private static final List<ServerName> EXCLUDE_SERVERS = new ArrayList<>();
private static boolean HALT = false;
@@ -135,7 +130,7 @@ public class TestRegionAssignedToMultipleRegionServers {
private static byte[] CF = Bytes.toBytes("cf");
- @BeforeClass
+ @BeforeAll
public static void setUp() throws Exception {
UTIL.getConfiguration().setClass(HConstants.MASTER_IMPL, HMasterForTest.class, HMaster.class);
UTIL
@@ -145,7 +140,7 @@ public class TestRegionAssignedToMultipleRegionServers {
UTIL.getAdmin().balancerSwitch(false, true);
}
- @AfterClass
+ @AfterAll
public static void tearDown() throws Exception {
UTIL.shutdownMiniCluster();
}
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestRegionBypass.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestRegionBypass.java
index 0a695456d6a..5747134aca3 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestRegionBypass.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestRegionBypass.java
@@ -18,15 +18,14 @@
package org.apache.hadoop.hbase.master.assignment;
import static org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.RegionStateTransitionState.REGION_STATE_TRANSITION_OPEN;
-import static org.junit.Assert.assertThrows;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.CountDownLatch;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.ServerName;
import org.apache.hadoop.hbase.TableName;
@@ -39,14 +38,12 @@ import org.apache.hadoop.hbase.procedure2.ProcedureSuspendedException;
import org.apache.hadoop.hbase.procedure2.ProcedureYieldException;
import org.apache.hadoop.hbase.testclassification.LargeTests;
import org.apache.hadoop.hbase.util.Bytes;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-import org.junit.rules.TestName;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -55,33 +52,26 @@ import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.R
/**
* Tests bypass on a region assign/unassign
*/
-@Category({ LargeTests.class })
+@Tag(LargeTests.TAG)
public class TestRegionBypass {
private final static Logger LOG = LoggerFactory.getLogger(TestRegionBypass.class);
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestRegionBypass.class);
-
- @Rule
- public TestName name = new TestName();
-
private static final HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility();
private TableName tableName;
- @BeforeClass
+ @BeforeAll
public static void startCluster() throws Exception {
TEST_UTIL.startMiniCluster(2);
}
- @AfterClass
+ @AfterAll
public static void stopCluster() throws Exception {
TEST_UTIL.shutdownMiniCluster();
}
- @Before
- public void before() throws IOException {
- this.tableName = TableName.valueOf(this.name.getMethodName());
+ @BeforeEach
+ public void before(TestInfo testInfo) throws IOException {
+ this.tableName = TableName.valueOf(testInfo.getTestMethod().get().getName());
// Create a table. Has one region at least.
TEST_UTIL.createTable(this.tableName, Bytes.toBytes("cf"));
@@ -130,8 +120,8 @@ public class TestRegionBypass {
TEST_UTIL.waitFor(60000, () -> TEST_UTIL.getHBaseCluster().getMaster()
.getMasterProcedureExecutor().getActiveProcIds().isEmpty());
for (RegionInfo ri : regions) {
- assertTrue(ri.toString(), TEST_UTIL.getMiniHBaseCluster().getMaster().getAssignmentManager()
- .getRegionStates().isRegionOnline(ri));
+ assertTrue(TEST_UTIL.getMiniHBaseCluster().getMaster().getAssignmentManager()
+ .getRegionStates().isRegionOnline(ri), ri.toString());
}
}
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestRegionMoveAndAbandon.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestRegionMoveAndAbandon.java
index 19fa6889215..49bfbe1627c 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestRegionMoveAndAbandon.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestRegionMoveAndAbandon.java
@@ -17,9 +17,8 @@
*/
package org.apache.hadoop.hbase.master.assignment;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.MiniHBaseCluster;
import org.apache.hadoop.hbase.StartMiniClusterOption;
@@ -33,13 +32,10 @@ import org.apache.hadoop.hbase.testclassification.MasterTests;
import org.apache.hadoop.hbase.testclassification.MediumTests;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.hbase.zookeeper.MiniZooKeeperCluster;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.ClassRule;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-import org.junit.rules.TestName;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -48,17 +44,11 @@ import org.apache.hbase.thirdparty.com.google.common.collect.Iterables;
/**
* Testcase for HBASE-20792.
*/
-@Category({ MediumTests.class, MasterTests.class })
+@Tag(MediumTests.TAG)
+@Tag(MasterTests.TAG)
public class TestRegionMoveAndAbandon {
private static final Logger LOG = LoggerFactory.getLogger(TestRegionMoveAndAbandon.class);
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestRegionMoveAndAbandon.class);
-
- @Rule
- public TestName name = new TestName();
-
private HBaseTestingUtility UTIL;
private MiniHBaseCluster cluster;
private MiniZooKeeperCluster zkCluster;
@@ -66,7 +56,7 @@ public class TestRegionMoveAndAbandon {
private HRegionServer rs2;
private RegionInfo regionInfo;
- @Before
+ @BeforeEach
public void setup() throws Exception {
UTIL = new HBaseTestingUtility();
zkCluster = UTIL.startMiniZKCluster();
@@ -81,7 +71,7 @@ public class TestRegionMoveAndAbandon {
Iterables.getOnlyElement(cluster.getRegions(TableName.NAMESPACE_TABLE_NAME)).getRegionInfo();
}
- @After
+ @AfterEach
public void teardown() throws Exception {
if (cluster != null) {
cluster.shutdown();
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestRegionReplicaSplit.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestRegionReplicaSplit.java
index fdd40c2cee7..278c38e04d7 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestRegionReplicaSplit.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestRegionReplicaSplit.java
@@ -17,13 +17,12 @@
*/
package org.apache.hadoop.hbase.master.assignment;
-import static org.junit.Assert.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.TableName;
@@ -40,21 +39,18 @@ import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
import org.apache.hadoop.hbase.util.JVMClusterUtil.RegionServerThread;
import org.apache.hadoop.hbase.util.RegionSplitter;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-import org.junit.rules.TestName;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-@Category({ RegionServerTests.class, MediumTests.class })
+@Tag(RegionServerTests.TAG)
+@Tag(MediumTests.TAG)
public class TestRegionReplicaSplit {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestRegionReplicaSplit.class);
private static final Logger LOG = LoggerFactory.getLogger(TestRegionReplicaSplit.class);
private static final int NB_SERVERS = 4;
@@ -62,14 +58,18 @@ public class TestRegionReplicaSplit {
private static final HBaseTestingUtility HTU = new HBaseTestingUtility();
private static final byte[] f = HConstants.CATALOG_FAMILY;
- @BeforeClass
+ @BeforeAll
public static void beforeClass() throws Exception {
HTU.getConfiguration().setInt("hbase.master.wait.on.regionservers.mintostart", 3);
HTU.startMiniCluster(NB_SERVERS);
}
- @Rule
- public TestName name = new TestName();
+ private String testMethodName;
+
+ @BeforeEach
+ public void setTestMethod(TestInfo testInfo) {
+ testMethodName = testInfo.getTestMethod().get().getName();
+ }
private static Table createTableAndLoadData(final TableName tableName) throws IOException {
TableDescriptorBuilder builder = TableDescriptorBuilder.newBuilder(tableName);
@@ -88,7 +88,7 @@ public class TestRegionReplicaSplit {
return split.split(numRegions);
}
- @AfterClass
+ @AfterAll
public static void afterClass() throws Exception {
HRegionServer.TEST_SKIP_REPORTING_TRANSITION = false;
HTU.shutdownMiniCluster();
@@ -96,7 +96,7 @@ public class TestRegionReplicaSplit {
@Test
public void testRegionReplicaSplitRegionAssignment() throws Exception {
- TableName tn = TableName.valueOf(this.name.getMethodName());
+ TableName tn = TableName.valueOf(testMethodName);
Table table = null;
try {
table = createTableAndLoadData(tn);
@@ -132,7 +132,7 @@ public class TestRegionReplicaSplit {
@Test
public void testAssignFakeReplicaRegion() throws Exception {
- TableName tn = TableName.valueOf(this.name.getMethodName());
+ TableName tn = TableName.valueOf(testMethodName);
Table table = null;
try {
table = createTableAndLoadData(tn);
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestRegionSplit.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestRegionSplit.java
index 4f0795e79be..bed5de2c520 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestRegionSplit.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestRegionSplit.java
@@ -18,14 +18,13 @@
package org.apache.hadoop.hbase.master.assignment;
import static org.apache.hadoop.hbase.master.assignment.AssignmentTestingUtil.insertData;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.List;
import java.util.Map;
import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.ServerName;
import org.apache.hadoop.hbase.StartMiniClusterOption;
@@ -41,25 +40,20 @@ import org.apache.hadoop.hbase.testclassification.MasterTests;
import org.apache.hadoop.hbase.testclassification.MediumTests;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.hbase.util.JVMClusterUtil;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-import org.junit.rules.TestName;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-@Category({ MasterTests.class, MediumTests.class })
+@Tag(MasterTests.TAG)
+@Tag(MediumTests.TAG)
public class TestRegionSplit {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestRegionSplit.class);
-
private static final Logger LOG = LoggerFactory.getLogger(TestRegionSplit.class);
protected static final HBaseTestingUtility UTIL = new HBaseTestingUtility();
@@ -68,14 +62,17 @@ public class TestRegionSplit {
private static final int startRowNum = 11;
private static final int rowCount = 60;
+ private String testMethodName;
- @Rule
- public TestName name = new TestName();
+ @BeforeEach
+ public void setTestMethod(TestInfo testInfo) {
+ testMethodName = testInfo.getTestMethod().get().getName();
+ }
private static void setupConf(Configuration conf) {
}
- @BeforeClass
+ @BeforeAll
public static void setupCluster() throws Exception {
setupConf(UTIL.getConfiguration());
StartMiniClusterOption option =
@@ -83,7 +80,7 @@ public class TestRegionSplit {
UTIL.startMiniCluster(option);
}
- @AfterClass
+ @AfterAll
public static void cleanupTest() throws Exception {
try {
UTIL.shutdownMiniCluster();
@@ -92,7 +89,7 @@ public class TestRegionSplit {
}
}
- @Before
+ @BeforeEach
public void setup() throws Exception {
// Turn off the meta scanner so it don't remove parent on us.
UTIL.getHBaseCluster().getMaster().setCatalogJanitorEnabled(false);
@@ -102,7 +99,7 @@ public class TestRegionSplit {
}
}
- @After
+ @AfterEach
public void tearDown() throws Exception {
for (TableDescriptor htd : UTIL.getAdmin().listTableDescriptors()) {
UTIL.deleteTable(htd.getTableName());
@@ -111,7 +108,7 @@ public class TestRegionSplit {
@Test
public void testSplitTableRegion() throws Exception {
- final TableName tableName = TableName.valueOf(name.getMethodName());
+ final TableName tableName = TableName.valueOf(testMethodName);
final ProcedureExecutor<MasterProcedureEnv> procExec = getMasterProcedureExecutor();
RegionInfo[] regions =
@@ -120,8 +117,8 @@ public class TestRegionSplit {
int splitRowNum = startRowNum + rowCount / 2;
byte[] splitKey = Bytes.toBytes("" + splitRowNum);
- assertTrue("not able to find a splittable region", regions != null);
- assertTrue("not able to find a splittable region", regions.length == 1);
+ assertTrue(regions != null, "not able to find a splittable region");
+ assertTrue(regions.length == 1, "not able to find a splittable region");
// Split region of the table
long procId = procExec.submitProcedure(
@@ -130,7 +127,7 @@ public class TestRegionSplit {
ProcedureTestingUtility.waitProcedure(procExec, procId);
ProcedureTestingUtility.assertProcNotFailed(procExec, procId);
- assertTrue("not able to split table", UTIL.getHBaseCluster().getRegions(tableName).size() == 2);
+ assertTrue(UTIL.getHBaseCluster().getRegions(tableName).size() == 2, "not able to split table");
// disable table
UTIL.getAdmin().disableTable(tableName);
@@ -151,7 +148,7 @@ public class TestRegionSplit {
Thread.sleep(500);
List<HRegion> tableRegions = UTIL.getHBaseCluster().getRegions(tableName);
- assertEquals("Table region not correct.", 2, tableRegions.size());
+ assertEquals(2, tableRegions.size(), "Table region not correct.");
Map<RegionInfo, ServerName> regionInfoMap = UTIL.getHBaseCluster().getMaster()
.getAssignmentManager().getRegionStates().getRegionAssignments();
assertEquals(regionInfoMap.get(tableRegions.get(0).getRegionInfo()),
@@ -160,7 +157,7 @@ public class TestRegionSplit {
@Test
public void testSplitStoreFiles() throws Exception {
- final TableName tableName = TableName.valueOf(name.getMethodName());
+ final TableName tableName = TableName.valueOf(testMethodName);
final ProcedureExecutor<MasterProcedureEnv> procExec = getMasterProcedureExecutor();
RegionInfo[] regions =
@@ -178,8 +175,8 @@ public class TestRegionSplit {
// split at the start row
byte[] splitKey = Bytes.toBytes("" + startRowNum);
- assertNotNull("Not able to find a splittable region", regions);
- assertEquals("Not able to find a splittable region", 1, regions.length);
+ assertNotNull(regions, "Not able to find a splittable region");
+ assertEquals(1, regions.length, "Not able to find a splittable region");
// Split region of the table
long procId = procExec.submitProcedure(
@@ -188,7 +185,7 @@ public class TestRegionSplit {
ProcedureTestingUtility.waitProcedure(procExec, procId);
ProcedureTestingUtility.assertProcNotFailed(procExec, procId);
- assertEquals("Not able to split table", 2, UTIL.getHBaseCluster().getRegions(tableName).size());
+ assertEquals(2, UTIL.getHBaseCluster().getRegions(tableName).size(), "Not able to split table");
// assert sum of the hfiles of all regions
int childStoreFilesSum = 0;
@@ -198,7 +195,7 @@ public class TestRegionSplit {
assertEquals(1, childStoreFilesSum);
List<HRegion> tableRegions = UTIL.getHBaseCluster().getRegions(tableName);
- assertEquals("Table region not correct.", 2, tableRegions.size());
+ assertEquals(2, tableRegions.size(), "Table region not correct.");
Map<RegionInfo, ServerName> regionInfoMap = UTIL.getHBaseCluster().getMaster()
.getAssignmentManager().getRegionStates().getRegionAssignments();
assertEquals(regionInfoMap.get(tableRegions.get(0).getRegionInfo()),
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestRegionSplitAndSeparateChildren.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestRegionSplitAndSeparateChildren.java
index 5e052cf5b25..645e7735696 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestRegionSplitAndSeparateChildren.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestRegionSplitAndSeparateChildren.java
@@ -18,14 +18,13 @@
package org.apache.hadoop.hbase.master.assignment;
import static org.apache.hadoop.hbase.master.assignment.AssignmentTestingUtil.insertData;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.List;
import java.util.Map;
import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.ServerName;
@@ -42,25 +41,20 @@ import org.apache.hadoop.hbase.testclassification.MasterTests;
import org.apache.hadoop.hbase.testclassification.MediumTests;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.hbase.util.JVMClusterUtil;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-import org.junit.rules.TestName;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-@Category({ MasterTests.class, MediumTests.class })
+@Tag(MasterTests.TAG)
+@Tag(MediumTests.TAG)
public class TestRegionSplitAndSeparateChildren {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestRegionSplitAndSeparateChildren.class);
-
private static final Logger LOG =
LoggerFactory.getLogger(TestRegionSplitAndSeparateChildren.class);
@@ -70,16 +64,19 @@ public class TestRegionSplitAndSeparateChildren {
private static final int startRowNum = 11;
private static final int rowCount = 60;
+ private String testMethodName;
- @Rule
- public TestName name = new TestName();
+ @BeforeEach
+ public void setTestMethod(TestInfo testInfo) {
+ testMethodName = testInfo.getTestMethod().get().getName();
+ }
private static void setupConf(Configuration conf) {
// enable automatically separate child regions
conf.setBoolean(HConstants.HBASE_ENABLE_SEPARATE_CHILD_REGIONS, true);
}
- @BeforeClass
+ @BeforeAll
public static void setupCluster() throws Exception {
setupConf(UTIL.getConfiguration());
StartMiniClusterOption option =
@@ -87,7 +84,7 @@ public class TestRegionSplitAndSeparateChildren {
UTIL.startMiniCluster(option);
}
- @AfterClass
+ @AfterAll
public static void cleanupTest() throws Exception {
try {
UTIL.shutdownMiniCluster();
@@ -96,7 +93,7 @@ public class TestRegionSplitAndSeparateChildren {
}
}
- @Before
+ @BeforeEach
public void setup() throws Exception {
// Turn off the meta scanner so it don't remove parent on us.
UTIL.getHBaseCluster().getMaster().setCatalogJanitorEnabled(false);
@@ -106,7 +103,7 @@ public class TestRegionSplitAndSeparateChildren {
}
}
- @After
+ @AfterEach
public void tearDown() throws Exception {
for (TableDescriptor htd : UTIL.getAdmin().listTableDescriptors()) {
UTIL.deleteTable(htd.getTableName());
@@ -115,7 +112,7 @@ public class TestRegionSplitAndSeparateChildren {
@Test
public void testSplitTableRegionAndSeparateChildRegions() throws Exception {
- final TableName tableName = TableName.valueOf(name.getMethodName());
+ final TableName tableName = TableName.valueOf(testMethodName);
final ProcedureExecutor<MasterProcedureEnv> procExec = getMasterProcedureExecutor();
RegionInfo[] regions =
@@ -124,8 +121,8 @@ public class TestRegionSplitAndSeparateChildren {
int splitRowNum = startRowNum + rowCount / 2;
byte[] splitKey = Bytes.toBytes("" + splitRowNum);
- assertTrue("not able to find a splittable region", regions != null);
- assertTrue("not able to find a splittable region", regions.length == 1);
+ assertTrue(regions != null, "not able to find a splittable region");
+ assertTrue(regions.length == 1, "not able to find a splittable region");
// Split region of the table
long procId = procExec.submitProcedure(
@@ -134,7 +131,7 @@ public class TestRegionSplitAndSeparateChildren {
ProcedureTestingUtility.waitProcedure(procExec, procId);
ProcedureTestingUtility.assertProcNotFailed(procExec, procId);
- assertTrue("not able to split table", UTIL.getHBaseCluster().getRegions(tableName).size() == 2);
+ assertTrue(UTIL.getHBaseCluster().getRegions(tableName).size() == 2, "not able to split table");
// disable table
UTIL.getAdmin().disableTable(tableName);
@@ -155,7 +152,7 @@ public class TestRegionSplitAndSeparateChildren {
Thread.sleep(500);
List<HRegion> tableRegions = UTIL.getHBaseCluster().getRegions(tableName);
- assertEquals("Table region not correct.", 2, tableRegions.size());
+ assertEquals(2, tableRegions.size(), "Table region not correct.");
Map<RegionInfo, ServerName> regionInfoMap = UTIL.getHBaseCluster().getMaster()
.getAssignmentManager().getRegionStates().getRegionAssignments();
assertNotEquals(regionInfoMap.get(tableRegions.get(0).getRegionInfo()),
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestRegionStateStore.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestRegionStateStore.java
index 236c89f21bf..5ae6b30d6e9 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestRegionStateStore.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestRegionStateStore.java
@@ -17,23 +17,22 @@
*/
package org.apache.hadoop.hbase.master.assignment;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-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.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.IOException;
import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;
import org.apache.hadoop.hbase.Cell;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.MetaTableAccessor;
import org.apache.hadoop.hbase.ServerName;
import org.apache.hadoop.hbase.TableName;
-import org.apache.hadoop.hbase.TableNameTestRule;
+import org.apache.hadoop.hbase.TableNameTestExtension;
import org.apache.hadoop.hbase.client.Get;
import org.apache.hadoop.hbase.client.Put;
import org.apache.hadoop.hbase.client.RegionInfo;
@@ -46,33 +45,29 @@ import org.apache.hadoop.hbase.testclassification.MasterTests;
import org.apache.hadoop.hbase.testclassification.MediumTests;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
import org.apache.hbase.thirdparty.com.google.common.collect.Lists;
-@Category({ MasterTests.class, MediumTests.class })
+@Tag(MasterTests.TAG)
+@Tag(MediumTests.TAG)
public class TestRegionStateStore {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestRegionStateStore.class);
-
private static HBaseTestingUtility UTIL = new HBaseTestingUtility();
- @Rule
- public final TableNameTestRule name = new TableNameTestRule();
+ @RegisterExtension
+ public final TableNameTestExtension name = new TableNameTestExtension();
- @BeforeClass
+ @BeforeAll
public static void beforeClass() throws Exception {
UTIL.startMiniCluster();
}
- @AfterClass
+ @AfterAll
public static void tearDown() throws Exception {
UTIL.shutdownMiniCluster();
}
@@ -94,7 +89,7 @@ public class TestRegionStateStore {
visitorCalled.set(true);
}
});
- assertTrue("Visitor has not been called.", visitorCalled.get());
+ assertTrue(visitorCalled.get(), "Visitor has not been called.");
}
@Test
@@ -126,7 +121,7 @@ public class TestRegionStateStore {
visitorCalled.set(true);
}
});
- assertTrue("Visitor has not been called.", visitorCalled.get());
+ assertTrue(visitorCalled.get(), "Visitor has not been called.");
}
@Test
@@ -142,7 +137,7 @@ public class TestRegionStateStore {
visitorCalled.set(true);
}
});
- assertFalse("Visitor has been called, but it shouldn't.", visitorCalled.get());
+ assertFalse(visitorCalled.get(), "Visitor has been called, but it shouldn't.");
}
@Test
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestRegionStates.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestRegionStates.java
index 6c45e1dc611..160fb010823 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestRegionStates.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestRegionStates.java
@@ -17,7 +17,7 @@
*/
package org.apache.hadoop.hbase.master.assignment;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import java.util.List;
import java.util.concurrent.Callable;
@@ -25,7 +25,6 @@ import java.util.concurrent.ExecutorCompletionService;
import java.util.concurrent.Future;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.RegionInfo;
@@ -36,25 +35,21 @@ import org.apache.hadoop.hbase.testclassification.MediumTests;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
import org.apache.hadoop.hbase.util.Threads;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.hbase.thirdparty.com.google.common.util.concurrent.ThreadFactoryBuilder;
-@Category({ MasterTests.class, MediumTests.class })
+@Tag(MasterTests.TAG)
+@Tag(MediumTests.TAG)
public class TestRegionStates {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestRegionStates.class);
-
private static final Logger LOG = LoggerFactory.getLogger(TestRegionStates.class);
protected static final HBaseTestingUtility UTIL = new HBaseTestingUtility();
@@ -62,7 +57,7 @@ public class TestRegionStates {
private static ThreadPoolExecutor threadPool;
private static ExecutorCompletionService<Object> executorService;
- @BeforeClass
+ @BeforeAll
public static void setUp() throws Exception {
threadPool = Threads.getBoundedCachedThreadPool(32, 60L, TimeUnit.SECONDS,
new ThreadFactoryBuilder().setNameFormat("ProcedureDispatcher-pool-%d").setDaemon(true)
@@ -71,16 +66,16 @@ public class TestRegionStates {
executorService = new ExecutorCompletionService<>(threadPool);
}
- @AfterClass
+ @AfterAll
public static void tearDown() throws Exception {
threadPool.shutdown();
}
- @Before
+ @BeforeEach
public void testSetup() {
}
- @After
+ @AfterEach
public void testTearDown() throws Exception {
while (true) {
Future<Object> f = executorService.poll();
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestReportOnlineRegionsRace.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestReportOnlineRegionsRace.java
index 2fdf89345ec..1109a2a5b96 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestReportOnlineRegionsRace.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestReportOnlineRegionsRace.java
@@ -18,14 +18,13 @@
package org.apache.hadoop.hbase.master.assignment;
import static org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.RegionStateTransitionState.REGION_STATE_TRANSITION_CONFIRM_OPENED_VALUE;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import java.io.IOException;
import java.util.Set;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.Future;
import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.PleaseHoldException;
@@ -45,22 +44,18 @@ import org.apache.hadoop.hbase.testclassification.MasterTests;
import org.apache.hadoop.hbase.testclassification.MediumTests;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.hbase.util.IdLock;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
import org.apache.hadoop.hbase.shaded.protobuf.generated.RegionServerStatusProtos.ReportRegionStateTransitionRequest;
import org.apache.hadoop.hbase.shaded.protobuf.generated.RegionServerStatusProtos.ReportRegionStateTransitionResponse;
-@Category({ MasterTests.class, MediumTests.class })
+@Tag(MasterTests.TAG)
+@Tag(MediumTests.TAG)
public class TestReportOnlineRegionsRace {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestReportOnlineRegionsRace.class);
-
private static volatile CountDownLatch ARRIVE_RS_REPORT;
private static volatile CountDownLatch RESUME_RS_REPORT;
private static volatile CountDownLatch FINISH_RS_REPORT;
@@ -123,7 +118,7 @@ public class TestReportOnlineRegionsRace {
private static byte[] CF = Bytes.toBytes("cf");
- @BeforeClass
+ @BeforeAll
public static void setUp() throws Exception {
UTIL.getConfiguration().setClass(HConstants.MASTER_IMPL, HMasterForTest.class, HMaster.class);
UTIL.getConfiguration().setInt("hbase.regionserver.msginterval", 1000);
@@ -134,7 +129,7 @@ public class TestReportOnlineRegionsRace {
UTIL.waitTableAvailable(NAME);
}
- @AfterClass
+ @AfterAll
public static void tearDown() throws Exception {
UTIL.shutdownMiniCluster();
}
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestReportRegionStateTransitionFromDeadServer.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestReportRegionStateTransitionFromDeadServer.java
index c952aca52f3..44e15e84179 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestReportRegionStateTransitionFromDeadServer.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestReportRegionStateTransitionFromDeadServer.java
@@ -17,7 +17,7 @@
*/
package org.apache.hadoop.hbase.master.assignment;
-import static org.junit.Assert.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
import java.io.IOException;
import java.util.ArrayList;
@@ -28,7 +28,6 @@ import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseIOException;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.HConstants;
@@ -46,23 +45,19 @@ import org.apache.hadoop.hbase.regionserver.HRegionServer;
import org.apache.hadoop.hbase.testclassification.MasterTests;
import org.apache.hadoop.hbase.testclassification.MediumTests;
import org.apache.hadoop.hbase.util.Bytes;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
import org.apache.hadoop.hbase.shaded.protobuf.ProtobufUtil;
import org.apache.hadoop.hbase.shaded.protobuf.generated.RegionServerStatusProtos.ReportRegionStateTransitionRequest;
import org.apache.hadoop.hbase.shaded.protobuf.generated.RegionServerStatusProtos.ReportRegionStateTransitionResponse;
-@Category({ MasterTests.class, MediumTests.class })
+@Tag(MasterTests.TAG)
+@Tag(MediumTests.TAG)
public class TestReportRegionStateTransitionFromDeadServer {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestReportRegionStateTransitionFromDeadServer.class);
-
private static final List<ServerName> EXCLUDE_SERVERS = new ArrayList<>();
private static CountDownLatch ARRIVE_GET_REGIONS;
@@ -144,7 +139,7 @@ public class TestReportRegionStateTransitionFromDeadServer {
private static byte[] CF = Bytes.toBytes("cf");
- @BeforeClass
+ @BeforeAll
public static void setUp() throws Exception {
UTIL.getConfiguration().setClass(HConstants.MASTER_IMPL, HMasterForTest.class, HMaster.class);
UTIL.getConfiguration().setInt("hbase.regionserver.msginterval", 1000);
@@ -154,7 +149,7 @@ public class TestReportRegionStateTransitionFromDeadServer {
UTIL.waitTableAvailable(NAME);
}
- @AfterClass
+ @AfterAll
public static void tearDown() throws Exception {
UTIL.shutdownMiniCluster();
}
@@ -199,8 +194,7 @@ public class TestReportRegionStateTransitionFromDeadServer {
.getActiveProcIds().isEmpty());
boolean onRS1 = !rs1.getRegions(NAME).isEmpty();
boolean onRS2 = !rs2.getRegions(NAME).isEmpty();
- assertNotEquals(
- "should either be on rs1 or rs2, but onRS1 is " + onRS1 + " and on RS2 is " + onRS2, onRS1,
- onRS2);
+ assertNotEquals(onRS2, onRS1,
+ "should either be on rs1 or rs2, but onRS1 is " + onRS1 + " and on RS2 is " + onRS2);
}
}
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestReportRegionStateTransitionRetry.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestReportRegionStateTransitionRetry.java
index 32e4ce087a8..6bef9a242dc 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestReportRegionStateTransitionRetry.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestReportRegionStateTransitionRetry.java
@@ -24,7 +24,6 @@ import java.util.concurrent.CountDownLatch;
import java.util.concurrent.Future;
import java.util.concurrent.atomic.AtomicReference;
import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.PleaseHoldException;
@@ -41,22 +40,18 @@ import org.apache.hadoop.hbase.procedure2.ProcedureExecutor;
import org.apache.hadoop.hbase.testclassification.MasterTests;
import org.apache.hadoop.hbase.testclassification.MediumTests;
import org.apache.hadoop.hbase.util.Bytes;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
import org.apache.hadoop.hbase.shaded.protobuf.generated.RegionServerStatusProtos.ReportRegionStateTransitionRequest;
import org.apache.hadoop.hbase.shaded.protobuf.generated.RegionServerStatusProtos.ReportRegionStateTransitionResponse;
-@Category({ MasterTests.class, MediumTests.class })
+@Tag(MasterTests.TAG)
+@Tag(MediumTests.TAG)
public class TestReportRegionStateTransitionRetry {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestReportRegionStateTransitionRetry.class);
-
private static final AtomicReference<CountDownLatch> RESUME_AND_FAIL = new AtomicReference<>();
private static final class AssignmentManagerForTest extends AssignmentManager {
@@ -101,7 +96,7 @@ public class TestReportRegionStateTransitionRetry {
private static byte[] CF = Bytes.toBytes("cf");
- @BeforeClass
+ @BeforeAll
public static void setUp() throws Exception {
UTIL.getConfiguration().setClass(HConstants.MASTER_IMPL, HMasterForTest.class, HMaster.class);
UTIL.startMiniCluster(1);
@@ -109,7 +104,7 @@ public class TestReportRegionStateTransitionRetry {
UTIL.waitTableAvailable(NAME);
}
- @AfterClass
+ @AfterAll
public static void tearDown() throws Exception {
UTIL.shutdownMiniCluster();
}
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestRogueRSAssignment.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestRogueRSAssignment.java
index ba7689df588..0bdb5513255 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestRogueRSAssignment.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestRogueRSAssignment.java
@@ -17,14 +17,14 @@
*/
package org.apache.hadoop.hbase.master.assignment;
-import static org.hamcrest.core.Is.isA;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import java.io.IOException;
import java.util.List;
import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.HRegionInfo;
import org.apache.hadoop.hbase.MiniHBaseCluster;
@@ -41,17 +41,14 @@ import org.apache.hadoop.hbase.testclassification.MasterTests;
import org.apache.hadoop.hbase.testclassification.MediumTests;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Ignore;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-import org.junit.rules.ExpectedException;
-import org.junit.rules.TestName;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -66,20 +63,18 @@ import org.apache.hadoop.hbase.shaded.protobuf.generated.RegionServerStatusProto
/**
* Tests to verify master/ assignment manager functionality against rogue RS
*/
-@Category({ MasterTests.class, MediumTests.class })
+@Tag(MasterTests.TAG)
+@Tag(MediumTests.TAG)
public class TestRogueRSAssignment {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestRogueRSAssignment.class);
-
private static final Logger LOG = LoggerFactory.getLogger(TestRogueRSAssignment.class);
+ private String testMethodName;
- @Rule
- public final TestName name = new TestName();
+ @BeforeEach
+ public void setTestMethod(TestInfo testInfo) {
+ testMethodName = testInfo.getTestMethod().get().getName();
+ }
- @Rule
- public ExpectedException exception = ExpectedException.none();
private static final int initialRegionCount = 3;
private final static byte[] FAMILY = Bytes.toBytes("FAMILY");
@@ -97,7 +92,7 @@ public class TestRogueRSAssignment {
conf.setInt(MasterProcedureConstants.MASTER_PROCEDURE_THREADS, 1);
}
- @BeforeClass
+ @BeforeAll
public static void setupCluster() throws Exception {
setupConf(conf);
UTIL.startMiniCluster(2);
@@ -112,7 +107,7 @@ public class TestRogueRSAssignment {
assertNotNull(master);
}
- @AfterClass
+ @AfterAll
public static void cleanupTest() throws Exception {
try {
UTIL.shutdownMiniCluster();
@@ -123,13 +118,13 @@ public class TestRogueRSAssignment {
}
}
- @Before
+ @BeforeEach
public void setup() throws IOException {
// Turn off balancer
admin.setBalancerRunning(false, true);
}
- @After
+ @AfterEach
public void tearDown() throws Exception {
for (TableDescriptor td : UTIL.getAdmin().listTableDescriptors()) {
LOG.info("Tear down, remove table=" + td.getTableName());
@@ -143,9 +138,9 @@ public class TestRogueRSAssignment {
* Ignore this test, see HBASE-21421
*/
@Test
- @Ignore
+ @Disabled
public void testReportRSWithWrongRegion() throws Exception {
- final TableName tableName = TableName.valueOf(this.name.getMethodName());
+ final TableName tableName = TableName.valueOf(testMethodName);
List<HRegionInfo> tableRegions = createTable(tableName);
@@ -158,10 +153,9 @@ public class TestRogueRSAssignment {
// sending fake request to master
// TODO: replace YouAreDeadException with appropriate exception as and when necessary
- exception.expect(ServiceException.class);
- exception.expectCause(isA(YouAreDeadException.class));
- RegionServerStatusProtos.RegionServerReportResponse response =
- master.getMasterRpcServices().regionServerReport(null, request.build());
+ ServiceException exception = assertThrows(ServiceException.class,
+ () -> master.getMasterRpcServices().regionServerReport(null, request.build()));
+ assertInstanceOf(YouAreDeadException.class, exception.getCause());
}
private RegionServerStatusProtos.RegionServerReportRequest.Builder
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestRollbackSCP.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestRollbackSCP.java
index 25f2e582068..4eebc72f65d 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestRollbackSCP.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestRollbackSCP.java
@@ -21,12 +21,11 @@ import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.everyItem;
import static org.hamcrest.Matchers.not;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import java.io.IOException;
import java.util.concurrent.atomic.AtomicBoolean;
import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.ServerName;
import org.apache.hadoop.hbase.StartMiniClusterOption;
@@ -49,12 +48,11 @@ import org.apache.hadoop.hbase.util.Bytes;
import org.hamcrest.BaseMatcher;
import org.hamcrest.Description;
import org.hamcrest.Matcher;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
import org.apache.hadoop.hbase.shaded.protobuf.generated.ProcedureProtos.ProcedureState;
@@ -63,13 +61,10 @@ import org.apache.hadoop.hbase.shaded.protobuf.generated.ProcedureProtos.Procedu
* bug, SCP and its sub procedures will not hang there forever, and it will not mess up the
* procedure store.
*/
-@Category({ MasterTests.class, LargeTests.class })
+@Tag(MasterTests.TAG)
+@Tag(LargeTests.TAG)
public class TestRollbackSCP {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestRollbackSCP.class);
-
private static final HBaseTestingUtility UTIL = new HBaseTestingUtility();
private static final TableName TABLE_NAME = TableName.valueOf("test");
@@ -116,7 +111,7 @@ public class TestRollbackSCP {
}
}
- @BeforeClass
+ @BeforeAll
public static void setUpBeforeClass() throws Exception {
UTIL.getConfiguration().setInt(MasterProcedureConstants.MASTER_PROCEDURE_THREADS, 1);
UTIL.startMiniCluster(StartMiniClusterOption.builder().numDataNodes(3).numRegionServers(3)
@@ -128,12 +123,12 @@ public class TestRollbackSCP {
UTIL.getAdmin().balancerSwitch(false, true);
}
- @AfterClass
+ @AfterAll
public static void tearDownAfterClass() throws IOException {
UTIL.shutdownMiniCluster();
}
- @Before
+ @BeforeEach
public void setUp() throws IOException {
UTIL.ensureSomeNonStoppedRegionServersAvailable(2);
}
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestSCPGetRegionsRace.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestSCPGetRegionsRace.java
index f9e2bead1e0..a8c0b8fed3b 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestSCPGetRegionsRace.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestSCPGetRegionsRace.java
@@ -17,8 +17,8 @@
*/
package org.apache.hadoop.hbase.master.assignment;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
import java.io.IOException;
import java.util.ArrayList;
@@ -26,7 +26,6 @@ import java.util.List;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.Future;
import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.PleaseHoldException;
import org.apache.hadoop.hbase.ServerName;
@@ -45,11 +44,10 @@ import org.apache.hadoop.hbase.testclassification.MasterTests;
import org.apache.hadoop.hbase.testclassification.MediumTests;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.hbase.util.IdLock;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
import org.apache.hbase.thirdparty.com.google.common.collect.Iterables;
@@ -60,13 +58,10 @@ import org.apache.hadoop.hbase.shaded.protobuf.generated.RegionServerStatusProto
/**
* Testcase for HBASE-22365.
*/
-@Category({ MasterTests.class, MediumTests.class })
+@Tag(MasterTests.TAG)
+@Tag(MediumTests.TAG)
public class TestSCPGetRegionsRace {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestSCPGetRegionsRace.class);
-
private static final List<ServerName> EXCLUDE_SERVERS = new ArrayList<>();
private static final class ServerManagerForTest extends ServerManager {
@@ -155,7 +150,7 @@ public class TestSCPGetRegionsRace {
private static byte[] CF = Bytes.toBytes("cf");
- @BeforeClass
+ @BeforeAll
public static void setUp() throws Exception {
UTIL.startMiniCluster(StartMiniClusterOption.builder().masterClass(HMasterForTest.class)
.numMasters(1).numRegionServers(3).build());
@@ -164,7 +159,7 @@ public class TestSCPGetRegionsRace {
UTIL.getAdmin().balancerSwitch(false, true);
}
- @AfterClass
+ @AfterAll
public static void tearDown() throws Exception {
UTIL.shutdownMiniCluster();
}
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestSplitTableRegionProcedure.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestSplitTableRegionProcedure.java
index 7be7839e116..4396e4233f9 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestSplitTableRegionProcedure.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestSplitTableRegionProcedure.java
@@ -18,10 +18,10 @@
package org.apache.hadoop.hbase.master.assignment;
import static org.apache.hadoop.hbase.master.assignment.AssignmentTestingUtil.insertData;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+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 static org.junit.jupiter.api.Assertions.fail;
import java.io.IOException;
import java.util.List;
@@ -29,7 +29,6 @@ import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.CellUtil;
import org.apache.hadoop.hbase.DoNotRetryIOException;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.TableName;
@@ -55,25 +54,20 @@ import org.apache.hadoop.hbase.regionserver.HRegion;
import org.apache.hadoop.hbase.testclassification.LargeTests;
import org.apache.hadoop.hbase.testclassification.MasterTests;
import org.apache.hadoop.hbase.util.Bytes;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-import org.junit.rules.TestName;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-@Category({ MasterTests.class, LargeTests.class })
+@Tag(MasterTests.TAG)
+@Tag(LargeTests.TAG)
public class TestSplitTableRegionProcedure {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestSplitTableRegionProcedure.class);
-
private static final Logger LOG = LoggerFactory.getLogger(TestSplitTableRegionProcedure.class);
protected static final HBaseTestingUtility UTIL = new HBaseTestingUtility();
@@ -96,9 +90,12 @@ public class TestSplitTableRegionProcedure {
private long assignFailedCount = 0;
private long unassignSubmittedCount = 0;
private long unassignFailedCount = 0;
+ private String testMethodName;
- @Rule
- public TestName name = new TestName();
+ @BeforeEach
+ public void setTestMethod(TestInfo testInfo) {
+ testMethodName = testInfo.getTestMethod().get().getName();
+ }
private static void setupConf(Configuration conf) {
conf.setInt(MasterProcedureConstants.MASTER_PROCEDURE_THREADS, 1);
@@ -107,13 +104,13 @@ public class TestSplitTableRegionProcedure {
RegionServerHostingReplicaSlowOpenCoprocessor.class.getName());
}
- @BeforeClass
+ @BeforeAll
public static void setupCluster() throws Exception {
setupConf(UTIL.getConfiguration());
UTIL.startMiniCluster(3);
}
- @AfterClass
+ @AfterAll
public static void cleanupTest() throws Exception {
try {
UTIL.shutdownMiniCluster();
@@ -122,7 +119,7 @@ public class TestSplitTableRegionProcedure {
}
}
- @Before
+ @BeforeEach
public void setup() throws Exception {
ProcedureTestingUtility.setKillAndToggleBeforeStoreUpdate(getMasterProcedureExecutor(), false);
@@ -136,7 +133,7 @@ public class TestSplitTableRegionProcedure {
unassignProcMetrics = am.getAssignmentManagerMetrics().getUnassignProcMetrics();
}
- @After
+ @AfterEach
public void tearDown() throws Exception {
ProcedureTestingUtility.setKillAndToggleBeforeStoreUpdate(getMasterProcedureExecutor(), false);
for (TableDescriptor htd : UTIL.getAdmin().listTableDescriptors()) {
@@ -146,7 +143,7 @@ public class TestSplitTableRegionProcedure {
@Test
public void testRollbackForSplitTableRegionWithReplica() throws Exception {
- final TableName tableName = TableName.valueOf(name.getMethodName());
+ final TableName tableName = TableName.valueOf(testMethodName);
final ProcedureExecutor<MasterProcedureEnv> procExec = getMasterProcedureExecutor();
RegionServerHostingReplicaSlowOpenCoprocessor.slowDownReplicaOpen = true;
@@ -212,7 +209,7 @@ public class TestSplitTableRegionProcedure {
@Test
public void testSplitTableRegion() throws Exception {
- final TableName tableName = TableName.valueOf(name.getMethodName());
+ final TableName tableName = TableName.valueOf(testMethodName);
final ProcedureExecutor<MasterProcedureEnv> procExec = getMasterProcedureExecutor();
RegionInfo[] regions = MasterProcedureTestingUtility.createTable(procExec, tableName, null,
@@ -221,8 +218,8 @@ public class TestSplitTableRegionProcedure {
int splitRowNum = startRowNum + rowCount / 2;
byte[] splitKey = Bytes.toBytes("" + splitRowNum);
- assertTrue("not able to find a splittable region", regions != null);
- assertTrue("not able to find a splittable region", regions.length == 1);
+ assertTrue(regions != null, "not able to find a splittable region");
+ assertTrue(regions.length == 1, "not able to find a splittable region");
// collect AM metrics before test
collectAssignmentManagerMetrics();
@@ -246,7 +243,7 @@ public class TestSplitTableRegionProcedure {
@Test
public void testSplitTableRegionNoStoreFile() throws Exception {
- final TableName tableName = TableName.valueOf(name.getMethodName());
+ final TableName tableName = TableName.valueOf(testMethodName);
final ProcedureExecutor<MasterProcedureEnv> procExec = getMasterProcedureExecutor();
RegionInfo[] regions = MasterProcedureTestingUtility.createTable(procExec, tableName, null,
@@ -254,8 +251,8 @@ public class TestSplitTableRegionProcedure {
int splitRowNum = startRowNum + rowCount / 2;
byte[] splitKey = Bytes.toBytes("" + splitRowNum);
- assertTrue("not able to find a splittable region", regions != null);
- assertTrue("not able to find a splittable region", regions.length == 1);
+ assertTrue(regions != null, "not able to find a splittable region");
+ assertTrue(regions.length == 1, "not able to find a splittable region");
// collect AM metrics before test
collectAssignmentManagerMetrics();
@@ -276,7 +273,7 @@ public class TestSplitTableRegionProcedure {
@Test
public void testSplitTableRegionUnevenDaughter() throws Exception {
- final TableName tableName = TableName.valueOf(name.getMethodName());
+ final TableName tableName = TableName.valueOf(testMethodName);
final ProcedureExecutor<MasterProcedureEnv> procExec = getMasterProcedureExecutor();
RegionInfo[] regions = MasterProcedureTestingUtility.createTable(procExec, tableName, null,
@@ -286,8 +283,8 @@ public class TestSplitTableRegionProcedure {
int splitRowNum = startRowNum + rowCount / 4;
byte[] splitKey = Bytes.toBytes("" + splitRowNum);
- assertTrue("not able to find a splittable region", regions != null);
- assertTrue("not able to find a splittable region", regions.length == 1);
+ assertTrue(regions != null, "not able to find a splittable region");
+ assertTrue(regions.length == 1, "not able to find a splittable region");
// collect AM metrics before test
collectAssignmentManagerMetrics();
@@ -307,7 +304,7 @@ public class TestSplitTableRegionProcedure {
@Test
public void testSplitTableRegionEmptyDaughter() throws Exception {
- final TableName tableName = TableName.valueOf(name.getMethodName());
+ final TableName tableName = TableName.valueOf(testMethodName);
final ProcedureExecutor<MasterProcedureEnv> procExec = getMasterProcedureExecutor();
RegionInfo[] regions = MasterProcedureTestingUtility.createTable(procExec, tableName, null,
@@ -317,8 +314,8 @@ public class TestSplitTableRegionProcedure {
int splitRowNum = startRowNum + rowCount;
byte[] splitKey = Bytes.toBytes("" + splitRowNum);
- assertTrue("not able to find a splittable region", regions != null);
- assertTrue("not able to find a splittable region", regions.length == 1);
+ assertTrue(regions != null, "not able to find a splittable region");
+ assertTrue(regions.length == 1, "not able to find a splittable region");
// collect AM metrics before test
collectAssignmentManagerMetrics();
@@ -342,7 +339,7 @@ public class TestSplitTableRegionProcedure {
@Test
public void testSplitTableRegionDeletedRowsDaughter() throws Exception {
- final TableName tableName = TableName.valueOf(name.getMethodName());
+ final TableName tableName = TableName.valueOf(testMethodName);
final ProcedureExecutor<MasterProcedureEnv> procExec = getMasterProcedureExecutor();
RegionInfo[] regions = MasterProcedureTestingUtility.createTable(procExec, tableName, null,
@@ -353,8 +350,8 @@ public class TestSplitTableRegionProcedure {
deleteData(tableName, splitRowNum);
byte[] splitKey = Bytes.toBytes("" + splitRowNum);
- assertTrue("not able to find a splittable region", regions != null);
- assertTrue("not able to find a splittable region", regions.length == 1);
+ assertTrue(regions != null, "not able to find a splittable region");
+ assertTrue(regions.length == 1, "not able to find a splittable region");
// collect AM metrics before test
collectAssignmentManagerMetrics();
@@ -388,15 +385,15 @@ public class TestSplitTableRegionProcedure {
@Test
public void testInvalidSplitKey() throws Exception {
- final TableName tableName = TableName.valueOf(name.getMethodName());
+ final TableName tableName = TableName.valueOf(testMethodName);
final ProcedureExecutor<MasterProcedureEnv> procExec = getMasterProcedureExecutor();
RegionInfo[] regions = MasterProcedureTestingUtility.createTable(procExec, tableName, null,
columnFamilyName1, columnFamilyName2);
insertData(UTIL, tableName, rowCount, startRowNum, columnFamilyName1, columnFamilyName2);
- assertTrue("not able to find a splittable region", regions != null);
- assertTrue("not able to find a splittable region", regions.length == 1);
+ assertTrue(regions != null, "not able to find a splittable region");
+ assertTrue(regions.length == 1, "not able to find a splittable region");
// collect AM metrics before test
collectAssignmentManagerMetrics();
@@ -417,7 +414,7 @@ public class TestSplitTableRegionProcedure {
@Test
public void testRollbackAndDoubleExecution() throws Exception {
- final TableName tableName = TableName.valueOf(name.getMethodName());
+ final TableName tableName = TableName.valueOf(testMethodName);
final ProcedureExecutor<MasterProcedureEnv> procExec = getMasterProcedureExecutor();
RegionInfo[] regions = MasterProcedureTestingUtility.createTable(procExec, tableName, null,
@@ -426,8 +423,8 @@ public class TestSplitTableRegionProcedure {
int splitRowNum = startRowNum + rowCount / 2;
byte[] splitKey = Bytes.toBytes("" + splitRowNum);
- assertTrue("not able to find a splittable region", regions != null);
- assertTrue("not able to find a splittable region", regions.length == 1);
+ assertTrue(regions != null, "not able to find a splittable region");
+ assertTrue(regions.length == 1, "not able to find a splittable region");
ProcedureTestingUtility.waitNoProcedureRunning(procExec);
ProcedureTestingUtility.setKillAndToggleBeforeStoreUpdate(procExec, true);
@@ -458,7 +455,7 @@ public class TestSplitTableRegionProcedure {
@Test
public void testRecoveryAndDoubleExecution() throws Exception {
- final TableName tableName = TableName.valueOf(name.getMethodName());
+ final TableName tableName = TableName.valueOf(testMethodName);
final ProcedureExecutor<MasterProcedureEnv> procExec = getMasterProcedureExecutor();
RegionInfo[] regions = MasterProcedureTestingUtility.createTable(procExec, tableName, null,
@@ -467,8 +464,8 @@ public class TestSplitTableRegionProcedure {
int splitRowNum = startRowNum + rowCount / 2;
byte[] splitKey = Bytes.toBytes("" + splitRowNum);
- assertTrue("not able to find a splittable region", regions != null);
- assertTrue("not able to find a splittable region", regions.length == 1);
+ assertTrue(regions != null, "not able to find a splittable region");
+ assertTrue(regions.length == 1, "not able to find a splittable region");
ProcedureTestingUtility.waitNoProcedureRunning(procExec);
ProcedureTestingUtility.setKillIfHasParent(procExec, false);
ProcedureTestingUtility.setKillAndToggleBeforeStoreUpdate(procExec, true);
@@ -492,7 +489,7 @@ public class TestSplitTableRegionProcedure {
@Test
public void testSplitWithoutPONR() throws Exception {
- final TableName tableName = TableName.valueOf(name.getMethodName());
+ final TableName tableName = TableName.valueOf(testMethodName);
final ProcedureExecutor<MasterProcedureEnv> procExec = getMasterProcedureExecutor();
RegionInfo[] regions = MasterProcedureTestingUtility.createTable(procExec, tableName, null,
@@ -501,8 +498,8 @@ public class TestSplitTableRegionProcedure {
int splitRowNum = startRowNum + rowCount / 2;
byte[] splitKey = Bytes.toBytes("" + splitRowNum);
- assertTrue("not able to find a splittable region", regions != null);
- assertTrue("not able to find a splittable region", regions.length == 1);
+ assertTrue(regions != null, "not able to find a splittable region");
+ assertTrue(regions.length == 1, "not able to find a splittable region");
ProcedureTestingUtility.waitNoProcedureRunning(procExec);
ProcedureTestingUtility.setKillAndToggleBeforeStoreUpdate(procExec, true);
@@ -525,7 +522,7 @@ public class TestSplitTableRegionProcedure {
@Test
public void testSplitDetectsModifyTableProcedure() throws Exception {
- final TableName tableName = TableName.valueOf(name.getMethodName());
+ final TableName tableName = TableName.valueOf(testMethodName);
final ProcedureExecutor<MasterProcedureEnv> procExec = getMasterProcedureExecutor();
RegionInfo[] regions =
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestTRSPPersistUninitializedSubProc.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestTRSPPersistUninitializedSubProc.java
index 3145c340102..98dba98a79d 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestTRSPPersistUninitializedSubProc.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestTRSPPersistUninitializedSubProc.java
@@ -19,7 +19,6 @@ package org.apache.hadoop.hbase.master.assignment;
import java.io.IOException;
import java.io.UncheckedIOException;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.ServerName;
import org.apache.hadoop.hbase.TableName;
@@ -36,24 +35,20 @@ import org.apache.hadoop.hbase.procedure2.ProcedureYieldException;
import org.apache.hadoop.hbase.testclassification.MasterTests;
import org.apache.hadoop.hbase.testclassification.MediumTests;
import org.apache.hadoop.hbase.util.Bytes;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
import org.apache.hadoop.hbase.shaded.protobuf.generated.ProcedureProtos.ProcedureState;
/**
* Testcase for HBASE-29259
*/
-@Category({ MasterTests.class, MediumTests.class })
+@Tag(MasterTests.TAG)
+@Tag(MediumTests.TAG)
public class TestTRSPPersistUninitializedSubProc {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestTRSPPersistUninitializedSubProc.class);
-
private static HBaseTestingUtility UTIL = new HBaseTestingUtility();
private static byte[] CF = Bytes.toBytes("cf");
@@ -93,7 +88,7 @@ public class TestTRSPPersistUninitializedSubProc {
}
}
- @BeforeClass
+ @BeforeAll
public static void setUpBeforeClass() throws Exception {
UTIL.startMiniCluster(2);
UTIL.getAdmin().balancerSwitch(false, true);
@@ -101,7 +96,7 @@ public class TestTRSPPersistUninitializedSubProc {
UTIL.waitTableAvailable(TN);
}
- @AfterClass
+ @AfterAll
public static void tearDownAfterClass() throws Exception {
UTIL.shutdownMiniCluster();
}
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestTransitRegionStateProcedure.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestTransitRegionStateProcedure.java
index 6120de50e38..73eb990b8f0 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestTransitRegionStateProcedure.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestTransitRegionStateProcedure.java
@@ -17,12 +17,11 @@
*/
package org.apache.hadoop.hbase.master.assignment;
-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 org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.RegionInfo;
@@ -37,47 +36,39 @@ import org.apache.hadoop.hbase.regionserver.HRegionServer;
import org.apache.hadoop.hbase.testclassification.MasterTests;
import org.apache.hadoop.hbase.testclassification.MediumTests;
import org.apache.hadoop.hbase.util.Bytes;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-import org.junit.rules.TestName;
-
-@Category({ MasterTests.class, MediumTests.class })
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestInfo;
+
+@Tag(MasterTests.TAG)
+@Tag(MediumTests.TAG)
public class TestTransitRegionStateProcedure {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestTransitRegionStateProcedure.class);
-
private static HBaseTestingUtility UTIL = new HBaseTestingUtility();
private static byte[] CF = Bytes.toBytes("cf");
- @Rule
- public TestName name = new TestName();
-
private TableName tableName;
- @BeforeClass
+ @BeforeAll
public static void setUpBeforeClass() throws Exception {
UTIL.getConfiguration().setInt(MasterProcedureConstants.MASTER_PROCEDURE_THREADS, 1);
UTIL.startMiniCluster(3);
UTIL.getAdmin().balancerSwitch(false, true);
}
- @AfterClass
+ @AfterAll
public static void tearDownAfterClass() throws Exception {
UTIL.shutdownMiniCluster();
}
- @Before
- public void setUp() throws IOException, InterruptedException {
- tableName = TableName.valueOf(name.getMethodName());
+ @BeforeEach
+ public void setUp(TestInfo testInfo) throws IOException, InterruptedException {
+ tableName = TableName.valueOf(testInfo.getTestMethod().get().getName());
UTIL.createTable(tableName, CF);
UTIL.waitTableAvailable(tableName);
}
@@ -86,10 +77,10 @@ public class TestTransitRegionStateProcedure {
ProcedureExecutor<MasterProcedureEnv> procExec =
UTIL.getHBaseCluster().getMaster().getMasterProcedureExecutor();
ProcedureTestingUtility.setKillAndToggleBeforeStoreUpdate(procExec, false);
- assertTrue("expected executor to be running", procExec.isRunning());
+ assertTrue(procExec.isRunning(), "expected executor to be running");
}
- @After
+ @AfterEach
public void tearDown() throws IOException {
resetProcExecutorTestingKillFlag();
UTIL.deleteTable(tableName);
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestWakeUpUnexpectedProcedure.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestWakeUpUnexpectedProcedure.java
index 395f1b7adbf..795f78d9229 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestWakeUpUnexpectedProcedure.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestWakeUpUnexpectedProcedure.java
@@ -17,7 +17,7 @@
*/
package org.apache.hadoop.hbase.master.assignment;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import java.io.IOException;
import java.net.ConnectException;
@@ -25,7 +25,6 @@ import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.CountDownLatch;
import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.MiniHBaseCluster.MiniHBaseClusterRegionServer;
import org.apache.hadoop.hbase.PleaseHoldException;
@@ -46,11 +45,10 @@ import org.apache.hadoop.hbase.testclassification.LargeTests;
import org.apache.hadoop.hbase.testclassification.MasterTests;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.hbase.util.JVMClusterUtil.RegionServerThread;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -68,13 +66,10 @@ import org.apache.hadoop.hbase.shaded.protobuf.generated.RegionServerStatusProto
/**
* Testcase for HBASE-21811.
*/
-@Category({ MasterTests.class, LargeTests.class })
+@Tag(MasterTests.TAG)
+@Tag(LargeTests.TAG)
public class TestWakeUpUnexpectedProcedure {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestWakeUpUnexpectedProcedure.class);
-
private static final Logger LOG = LoggerFactory.getLogger(TestWakeUpUnexpectedProcedure.class);
private static final HBaseTestingUtility UTIL = new HBaseTestingUtility();
@@ -219,7 +214,7 @@ public class TestWakeUpUnexpectedProcedure {
}
}
- @BeforeClass
+ @BeforeAll
public static void setUp() throws Exception {
UTIL.startMiniCluster(StartMiniClusterOption.builder().numMasters(1)
.masterClass(HMasterForTest.class).numRegionServers(3).rsClass(RSForTest.class).build());
@@ -231,7 +226,7 @@ public class TestWakeUpUnexpectedProcedure {
UTIL.getAdmin().balancerSwitch(false, true);
}
- @AfterClass
+ @AfterAll
public static void tearDown() throws Exception {
UTIL.shutdownMiniCluster();
}
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/replication/TestModifyPeerProcedureRetryBackoff.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/replication/TestModifyPeerProcedureRetryBackoff.java
index 5e1be757f9c..5bfe0f0ff11 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/replication/TestModifyPeerProcedureRetryBackoff.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/replication/TestModifyPeerProcedureRetryBackoff.java
@@ -18,7 +18,6 @@
package org.apache.hadoop.hbase.master.replication;
import java.io.IOException;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.ProcedureTestUtil;
import org.apache.hadoop.hbase.master.procedure.MasterProcedureEnv;
@@ -27,21 +26,17 @@ import org.apache.hadoop.hbase.procedure2.ProcedureExecutor;
import org.apache.hadoop.hbase.replication.ReplicationException;
import org.apache.hadoop.hbase.testclassification.LargeTests;
import org.apache.hadoop.hbase.testclassification.MasterTests;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.PeerModificationState;
-@Category({ MasterTests.class, LargeTests.class })
+@Tag(MasterTests.TAG)
+@Tag(LargeTests.TAG)
public class TestModifyPeerProcedureRetryBackoff {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestModifyPeerProcedureRetryBackoff.class);
-
private static final HBaseTestingUtility UTIL = new HBaseTestingUtility();
private static boolean FAIL = true;
@@ -123,12 +118,12 @@ public class TestModifyPeerProcedureRetryBackoff {
}
}
- @BeforeClass
+ @BeforeAll
public static void setUp() throws Exception {
UTIL.startMiniCluster(1);
}
- @AfterClass
+ @AfterAll
public static void tearDown() throws Exception {
UTIL.shutdownMiniCluster();
}
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestRegionReplicas.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestRegionReplicas.java
index 6df904d2aa6..2ea2f84e8e4 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestRegionReplicas.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestRegionReplicas.java
@@ -19,6 +19,11 @@ package org.apache.hadoop.hbase.regionserver;
import static org.apache.hadoop.hbase.regionserver.TestRegionServerNoMaster.closeRegion;
import static org.apache.hadoop.hbase.regionserver.TestRegionServerNoMaster.openRegion;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.IOException;
import java.util.List;
@@ -30,7 +35,6 @@ import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicReference;
import org.apache.hadoop.hbase.Cell;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.HRegionInfo;
@@ -51,12 +55,10 @@ import org.apache.hadoop.hbase.util.JVMClusterUtil.RegionServerThread;
import org.apache.hadoop.hbase.util.Threads;
import org.apache.hadoop.hdfs.DFSConfigKeys;
import org.apache.hadoop.util.StringUtils;
-import org.junit.AfterClass;
-import org.junit.Assert;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -70,13 +72,10 @@ import org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos;
* Tests for region replicas. Sad that we cannot isolate these without bringing up a whole cluster.
* See {@link TestRegionServerNoMaster}.
*/
-@Category({ RegionServerTests.class, LargeTests.class })
+@Tag(RegionServerTests.TAG)
+@Tag(LargeTests.TAG)
public class TestRegionReplicas {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestRegionReplicas.class);
-
private static final Logger LOG = LoggerFactory.getLogger(TestRegionReplicas.class);
private static final int NB_SERVERS = 1;
@@ -89,7 +88,7 @@ public class TestRegionReplicas {
private static final HBaseTestingUtility HTU = new HBaseTestingUtility();
private static final byte[] f = HConstants.CATALOG_FAMILY;
- @BeforeClass
+ @BeforeAll
public static void before() throws Exception {
// Reduce the hdfs block size and prefetch to trigger the file-link reopen
// when the file is moved to archive (e.g. compaction)
@@ -115,7 +114,7 @@ public class TestRegionReplicas {
TestRegionServerNoMaster.stopMasterAndCacheMetaLocation(HTU);
}
- @AfterClass
+ @AfterAll
public static void afterClass() throws Exception {
HRegionServer.TEST_SKIP_REPORTING_TRANSITION = false;
table.close();
@@ -134,7 +133,7 @@ public class TestRegionReplicas {
HTU.loadNumericRows(table, f, 0, 1000);
// assert that we can read back from primary
- Assert.assertEquals(1000, HTU.countRows(table));
+ assertEquals(1000, HTU.countRows(table));
} finally {
HTU.deleteNumericRows(table, f, 0, 1000);
closeRegion(HTU, getRS(), hriSecondary);
@@ -164,7 +163,7 @@ public class TestRegionReplicas {
// load some data to primary
HTU.loadNumericRows(table, f, 0, 1000);
// assert that we can read back from primary
- Assert.assertEquals(1000, HTU.countRows(table));
+ assertEquals(1000, HTU.countRows(table));
// flush so that region replica can read
HRegion region = getRS().getRegionByEncodedName(hriPrimary.getEncodedName());
region.flush(true);
@@ -188,7 +187,7 @@ public class TestRegionReplicas {
// load some data to primary
HTU.loadNumericRows(table, f, 0, 1000);
// assert that we can read back from primary
- Assert.assertEquals(1000, HTU.countRows(table));
+ assertEquals(1000, HTU.countRows(table));
// flush so that region replica can read
HRegion region = getRS().getRegionByEncodedName(hriPrimary.getEncodedName());
region.flush(true);
@@ -201,7 +200,7 @@ public class TestRegionReplicas {
get.setConsistency(Consistency.TIMELINE);
get.setReplicaId(1);
Result result = table.get(get);
- Assert.assertArrayEquals(row, result.getValue(f, null));
+ assertArrayEquals(row, result.getValue(f, null));
} finally {
HTU.deleteNumericRows(table, HConstants.CATALOG_FAMILY, 0, 1000);
closeRegion(HTU, getRS(), hriSecondary);
@@ -213,9 +212,9 @@ public class TestRegionReplicas {
Get get = new Get(row);
Result result = region.get(get);
if (expect) {
- Assert.assertArrayEquals(row, result.getValue(f, null));
+ assertArrayEquals(row, result.getValue(f, null));
} else {
- result.isEmpty();
+ assertTrue(result.isEmpty());
}
}
@@ -228,9 +227,9 @@ public class TestRegionReplicas {
ClientProtos.GetResponse getResp = getRS().getRSRpcServices().get(null, getReq);
Result result = ProtobufUtil.toResult(getResp.getResult());
if (expect) {
- Assert.assertArrayEquals(row, result.getValue(f, null));
+ assertArrayEquals(row, result.getValue(f, null));
} else {
- result.isEmpty();
+ assertTrue(result.isEmpty());
}
}
@@ -257,7 +256,7 @@ public class TestRegionReplicas {
LOG.info("Loading data to primary region");
HTU.loadNumericRows(table, f, 0, 1000);
// assert that we can read back from primary
- Assert.assertEquals(1000, HTU.countRows(table));
+ assertEquals(1000, HTU.countRows(table));
// flush so that region replica can read
LOG.info("Flushing primary region");
HRegion region = getRS().getRegionByEncodedName(hriPrimary.getEncodedName());
@@ -270,7 +269,7 @@ public class TestRegionReplicas {
LOG.info("Checking results from secondary region replica");
Region secondaryRegion = getRS().getRegion(hriSecondary.getEncodedName());
- Assert.assertEquals(1, secondaryRegion.getStore(f).getStorefilesCount());
+ assertEquals(1, secondaryRegion.getStore(f).getStorefilesCount());
assertGet(secondaryRegion, 42, true);
assertGetRpc(hriSecondary, 42, true);
@@ -293,7 +292,7 @@ public class TestRegionReplicas {
assertGetRpc(hriSecondary, 2042, true);
// ensure that we see the 3 store files
- Assert.assertEquals(3, secondaryRegion.getStore(f).getStorefilesCount());
+ assertEquals(3, secondaryRegion.getStore(f).getStorefilesCount());
// force compaction
HTU.compact(table.getName(), true);
@@ -308,7 +307,7 @@ public class TestRegionReplicas {
// ensure that we see the compacted file only
// This will be 4 until the cleaner chore runs
- Assert.assertEquals(4, secondaryRegion.getStore(f).getStorefilesCount());
+ assertEquals(4, secondaryRegion.getStore(f).getStorefilesCount());
} finally {
HTU.deleteNumericRows(table, HConstants.CATALOG_FAMILY, 0, 1000);
@@ -436,7 +435,7 @@ public class TestRegionReplicas {
executor.awaitTermination(30, TimeUnit.SECONDS);
for (AtomicReference<Exception> exRef : exceptions) {
- Assert.assertNull(exRef.get());
+ assertNull(exRef.get());
}
} finally {
HTU.deleteNumericRows(table, HConstants.CATALOG_FAMILY, startKey, endKey);
@@ -467,17 +466,17 @@ public class TestRegionReplicas {
}
HRegion primaryRegion = getRS().getRegion(hriPrimary.getEncodedName());
- Assert.assertEquals(3, primaryRegion.getStore(f).getStorefilesCount());
+ assertEquals(3, primaryRegion.getStore(f).getStorefilesCount());
// Refresh store files on the secondary
Region secondaryRegion = getRS().getRegion(hriSecondary.getEncodedName());
secondaryRegion.getStore(f).refreshStoreFiles();
- Assert.assertEquals(3, secondaryRegion.getStore(f).getStorefilesCount());
+ assertEquals(3, secondaryRegion.getStore(f).getStorefilesCount());
// force compaction
LOG.info("Force Major compaction on primary region " + hriPrimary);
primaryRegion.compact(true);
- Assert.assertEquals(1, primaryRegion.getStore(f).getStorefilesCount());
+ assertEquals(1, primaryRegion.getStore(f).getStorefilesCount());
List<RegionServerThread> regionServerThreads =
HTU.getMiniHBaseCluster().getRegionServerThreads();
HRegionServer hrs = null;
@@ -501,7 +500,7 @@ public class TestRegionReplicas {
for (HStoreFile sf : ((HStore) secondaryRegion.getStore(f)).getStorefiles()) {
// Our file does not exist anymore. was moved by the compaction above.
LOG.debug(Boolean.toString(getRS().getFileSystem().exists(sf.getPath())));
- Assert.assertFalse(getRS().getFileSystem().exists(sf.getPath()));
+ assertFalse(getRS().getFileSystem().exists(sf.getPath()));
HFileScanner scanner = sf.getReader().getScanner(false, false);
scanner.seekTo();
@@ -513,8 +512,8 @@ public class TestRegionReplicas {
.parseInt(Bytes.toString(cell.getRowArray(), cell.getRowOffset(), cell.getRowLength()));
} while (scanner.next());
}
- Assert.assertEquals(3000, keys);
- Assert.assertEquals(4498500, sum);
+ assertEquals(3000, keys);
+ assertEquals(4498500, sum);
} finally {
HTU.deleteNumericRows(table, HConstants.CATALOG_FAMILY, 0, 1000);
closeRegion(HTU, getRS(), hriSecondary);