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/09 08:39:59 UTC
(hbase) branch branch-3 updated: HBASE-30059 Upgrade hbase-server to use junit5 Part6 (#8028) (#8047)
This is an automated email from the ASF dual-hosted git repository.
liuxiaocs pushed a commit to branch branch-3
in repository https://gitbox.apache.org/repos/asf/hbase.git
The following commit(s) were added to refs/heads/branch-3 by this push:
new d7c378d8390 HBASE-30059 Upgrade hbase-server to use junit5 Part6 (#8028) (#8047)
d7c378d8390 is described below
commit d7c378d83900cb123f1c364765d6df9c6e186666
Author: Xiao Liu <li...@apache.org>
AuthorDate: Thu Apr 9 16:39:53 2026 +0800
HBASE-30059 Upgrade hbase-server to use junit5 Part6 (#8028) (#8047)
Signed-off-by: Duo Zhang <zh...@apache.org>
(cherry picked from commit 03f9f17d46d98b880f62858a76ec648adc3692cc)
---
...meTestRule.java => TableNameTestExtension.java} | 21 ++--
.../org/apache/hadoop/hbase/TableNameTestRule.java | 6 ++
.../apache/hadoop/hbase/TestMetaTableAccessor.java | 100 +++++++++----------
.../hbase/TestMetaUpdatesGoToPriorityQueue.java | 22 ++--
.../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 | 33 +++---
.../master/assignment/TestRegionReplicaSplit.java | 40 ++++----
.../hbase/master/assignment/TestRegionSplit.java | 65 ++++++------
.../TestRegionSplitAndSeparateChildren.java | 55 +++++-----
.../master/assignment/TestRegionStateNodeLock.java | 25 ++---
.../master/assignment/TestRegionStateStore.java | 47 ++++-----
.../hbase/master/assignment/TestRegionStates.java | 31 +++---
.../assignment/TestReportOnlineRegionsRace.java | 23 ++---
...tReportRegionStateTransitionFromDeadServer.java | 28 ++----
.../TestReportRegionStateTransitionRetry.java | 21 ++--
.../master/assignment/TestRogueRSAssignment.java | 61 ++++++-----
.../hbase/master/assignment/TestRollbackSCP.java | 27 ++---
.../master/assignment/TestSCPGetRegionsRace.java | 25 ++---
.../assignment/TestSplitTableRegionProcedure.java | 111 ++++++++++-----------
.../TestTRSPPersistUninitializedSubProc.java | 21 ++--
.../TestTransitRegionStateProcedure.java | 49 ++++-----
.../assignment/TestWakeUpUnexpectedProcedure.java | 23 ++---
.../region/TestMasterRegionOnTwoFileSystems.java | 33 +++---
.../replication/TestDisablePeerModification.java | 55 +++++-----
.../replication/TestMigrateReplicationQueue.java | 19 ++--
...rateReplicationQueueFromZkToTableProcedure.java | 31 +++---
...icationQueueFromZkToTableProcedureRecovery.java | 31 +++---
.../TestModifyPeerProcedureRetryBackoff.java | 21 ++--
.../TestRegisterPeerWorkerWhenRestarting.java | 23 +++--
...tReplicationPeerManagerMigrateQueuesFromZk.java | 45 ++++-----
.../TestSyncReplicationReplayWALManager.java | 23 ++---
...itPeerSyncReplicationStateProcedureBackoff.java | 21 ++--
...nsitPeerSyncReplicationStateProcedureRetry.java | 19 ++--
.../hbase/regionserver/TestRegionReplicas.java | 60 ++++++-----
56 files changed, 812 insertions(+), 1045 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/TableNameTestExtension.java
similarity index 77%
copy from hbase-common/src/test/java/org/apache/hadoop/hbase/TableNameTestRule.java
copy to hbase-common/src/test/java/org/apache/hadoop/hbase/TableNameTestExtension.java
index fdaa1163ef1..a628d34f76f 100644
--- a/hbase-common/src/test/java/org/apache/hadoop/hbase/TableNameTestRule.java
+++ b/hbase-common/src/test/java/org/apache/hadoop/hbase/TableNameTestExtension.java
@@ -17,27 +17,21 @@
*/
package org.apache.hadoop.hbase;
-import org.junit.rules.TestWatcher;
-import org.junit.runner.Description;
+import org.junit.jupiter.api.extension.BeforeEachCallback;
+import org.junit.jupiter.api.extension.ExtensionContext;
/**
- * Returns a {@code TableName} based on currently running test method name. Supports tests built on
- * the {@link org.junit.runners.Parameterized} runner.
+ * Returns a {@code TableName} based on currently running test method name.
*/
-public class TableNameTestRule extends TestWatcher {
+public class TableNameTestExtension implements BeforeEachCallback {
private TableName tableName;
- @Override
- protected void starting(Description description) {
- tableName = TableName.valueOf(cleanUpTestName(description.getMethodName()));
- }
-
/**
* Helper to handle parameterized method names. Unlike regular test methods, parameterized method
* names look like 'foo[x]'. This is problematic for tests that use this name for HBase tables.
* This helper strips out the parameter suffixes.
- * @return current test method name with out parameterized suffixes.
+ * @return current test method name without parameterized suffixes.
*/
public static String cleanUpTestName(String methodName) {
int index = methodName.indexOf('[');
@@ -50,4 +44,9 @@ public class TableNameTestRule extends TestWatcher {
public TableName getTableName() {
return tableName;
}
+
+ @Override
+ public void beforeEach(ExtensionContext context) {
+ tableName = TableName.valueOf(cleanUpTestName(context.getRequiredTestMethod().getName()));
+ }
}
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 93f3ba31b2c..db87f163b66 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,10 +17,10 @@
*/
package org.apache.hadoop.hbase;
-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 static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
@@ -55,13 +55,11 @@ import org.apache.hadoop.hbase.testclassification.MiscTests;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
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;
@@ -70,21 +68,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 HBaseTestingUtil UTIL = new HBaseTestingUtil();
private static Connection connection;
- @Rule
- public TestName name = new TestName();
-
- @BeforeClass
+ @BeforeAll
public static void beforeClass() throws Exception {
UTIL.startMiniCluster(3);
@@ -96,7 +88,7 @@ public class TestMetaTableAccessor {
connection = ConnectionFactory.createConnection(c);
}
- @AfterClass
+ @AfterAll
public static void afterClass() throws Exception {
connection.close();
UTIL.shutdownMiniCluster();
@@ -122,8 +114,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;
@@ -178,8 +170,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 {
@@ -190,7 +182,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");
}
/**
@@ -242,8 +234,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 =
@@ -254,8 +246,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);
/**
@@ -291,7 +283,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());
@@ -299,15 +291,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();
@@ -372,11 +367,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 {
@@ -391,10 +388,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") };
@@ -437,11 +434,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)) {
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/TestMetaUpdatesGoToPriorityQueue.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/TestMetaUpdatesGoToPriorityQueue.java
index 91e040f1db1..8722227a9de 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/TestMetaUpdatesGoToPriorityQueue.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/TestMetaUpdatesGoToPriorityQueue.java
@@ -17,7 +17,7 @@
*/
package org.apache.hadoop.hbase;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.IOException;
import java.util.Arrays;
@@ -38,11 +38,10 @@ import org.apache.hadoop.hbase.testclassification.MiscTests;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
import org.apache.hadoop.hbase.util.FutureUtils;
-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.ClientProtos;
@@ -50,16 +49,13 @@ import org.apache.hadoop.hbase.shaded.protobuf.generated.MultiRowMutationProtos.
import org.apache.hadoop.hbase.shaded.protobuf.generated.MultiRowMutationProtos.MutateRowsRequest;
import org.apache.hadoop.hbase.shaded.protobuf.generated.MultiRowMutationProtos.MutateRowsResponse;
-@Category({ MiscTests.class, MediumTests.class })
+@Tag(MiscTests.TAG)
+@Tag(MediumTests.TAG)
public class TestMetaUpdatesGoToPriorityQueue {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestMetaUpdatesGoToPriorityQueue.class);
-
private static final HBaseTestingUtil UTIL = new HBaseTestingUtil();
- @BeforeClass
+ @BeforeAll
public static void beforeClass() throws Exception {
// This test has to be end-to-end, and do the verification from the server side
UTIL.getConfiguration().set(RSRpcServices.REGION_SERVER_RPC_SCHEDULER_FACTORY_CLASS,
@@ -67,7 +63,7 @@ public class TestMetaUpdatesGoToPriorityQueue {
UTIL.startMiniCluster();
}
- @AfterClass
+ @AfterAll
public static void afterClass() throws Exception {
UTIL.shutdownMiniCluster();
}
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 e938172d0d4..b63f02d2ff7 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 c304a6bf47b..ffe8c3feaf4 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.HBaseTestingUtil;
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 d36274c5f04..01d05177905 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.HBaseTestingUtil;
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 e207b5ed815..d79ba888015 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 HBaseTestingUtil();
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 62fae8a0b2f..295f99dc903 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.HBaseTestingUtil;
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 HBaseTestingUtil UTIL = new HBaseTestingUtil();
- @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 f6cdc14b091..ab455d90930 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,15 +17,14 @@
*/
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;
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.HBaseTestingUtil;
import org.apache.hadoop.hbase.TableName;
@@ -38,18 +37,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 HBaseTestingUtil UTIL = new HBaseTestingUtil();
@@ -61,7 +57,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);
@@ -74,7 +70,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);
@@ -87,7 +83,7 @@ public class TestAssignmentManagerUtil {
}
}
- @AfterClass
+ @AfterAll
public static void tearDown() throws Exception {
UTIL.shutdownMiniCluster();
}
@@ -128,6 +124,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 21384b073d2..fa142028a33 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.HBaseTestingUtil;
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 HBaseTestingUtil();
@@ -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 1bc9ac4a0c9..eb0f4f714eb 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.HBaseTestingUtil;
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 HBaseTestingUtil UTIL = new HBaseTestingUtil();
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 dc6be72b9d1..6ae53134b7b 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.HBaseTestingUtil;
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 HBaseTestingUtil util;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
util = new HBaseTestingUtil();
// 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 aba42eb1384..11c8ef88f0b 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.HBaseTestingUtil;
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 HBaseTestingUtil UTIL = new HBaseTestingUtil();
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(UTIL.getMiniHBaseCluster().getLiveRegionServerThreads().size(), 2,
+ "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 fcbca1ac017..eaf8cf36aac 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.HBaseTestingUtil;
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 HBaseTestingUtil UTIL = new HBaseTestingUtil();
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 70afeae4c6e..759094521c4 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.ServerName;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.RegionInfo;
@@ -47,22 +46,18 @@ 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;
-@Category({ MasterTests.class, MediumTests.class })
+@Tag(MasterTests.TAG)
+@Tag(MediumTests.TAG)
public class TestHbckChore extends TestAssignmentManagerBase {
- @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 5216067dcb6..e49c23a89de 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.HBaseTestingUtil;
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 HBaseTestingUtil UTIL = new HBaseTestingUtil();
@@ -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 936cdc032fb..1de06e82c02 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
@@ -18,14 +18,13 @@
package org.apache.hadoop.hbase.master.assignment;
import static org.apache.hadoop.hbase.procedure2.ProcedureTestingUtility.assertProcFailed;
-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.HBaseTestingUtil;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.MetaTableAccessor;
@@ -53,31 +52,25 @@ 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;
import org.apache.hadoop.hbase.shaded.protobuf.ProtobufUtil;
import org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos;
-@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 HBaseTestingUtil UTIL = new HBaseTestingUtil();
@@ -105,19 +98,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());
@@ -133,7 +126,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()) {
@@ -145,7 +143,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 {
@@ -167,7 +165,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);
@@ -232,7 +230,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);
@@ -396,7 +394,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 9dcce48845f..4e1cdea191b 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.HBaseTestingUtil;
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 HBaseTestingUtil UTIL = new HBaseTestingUtil();
@@ -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(modifyTableProcedure.getState(), ProcedureProtos.ProcedureState.SUCCESS,
+ "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 2f88f6087dd..15ba3681417 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.HBaseTestingUtil;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.ProcedureTestUtil;
@@ -37,22 +36,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.FutureUtils;
-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 {
@@ -89,7 +84,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);
@@ -97,7 +92,7 @@ public class TestOpenRegionProcedureBackoff {
UTIL.waitTableAvailable(TableName.META_TABLE_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/TestOpenRegionProcedureHang.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestOpenRegionProcedureHang.java
index 4d628db2f28..e0753fd018e 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.HBaseTestingUtil;
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 05179c5eadb..ab34877705e 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
@@ -23,7 +23,6 @@ import java.util.concurrent.CompletableFuture;
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.HBaseTestingUtil;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.ServerName;
@@ -41,22 +40,18 @@ import org.apache.hadoop.hbase.testclassification.MasterTests;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.hbase.util.FutureUtils;
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 HBaseTestingUtil UTIL = new HBaseTestingUtil();
private static TableName NAME = TableName.valueOf("Race");
@@ -125,7 +120,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);
@@ -134,7 +129,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 4cdf1ba3a63..ea40221e94e 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.HBaseTestingUtil;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.ColumnFamilyDescriptorBuilder;
@@ -34,30 +33,26 @@ 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;
/**
* 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 HBaseTestingUtil UTIL = new HBaseTestingUtil();
private static TableDescriptor TD =
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);
@@ -65,7 +60,7 @@ public class TestReduceExcessRegionReplicasBlockedByRIT {
UTIL.waitUntilNoRegionsInTransition();
}
- @AfterClass
+ @AfterAll
public static void tearDown() throws Exception {
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 506d4ec3dfe..d2a85fa2a99 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.HBaseTestingUtil;
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.startMiniCluster(
@@ -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 8295da82f49..e4e1e53db63 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.HBaseTestingUtil;
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 HBaseTestingUtil TEST_UTIL = new HBaseTestingUtil();
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 d82f2c62914..40f7cf5204f 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.HBaseTestingUtil;
import org.apache.hadoop.hbase.SingleProcessHBaseCluster;
import org.apache.hadoop.hbase.StartTestingClusterOption;
@@ -33,13 +32,11 @@ 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.junit.jupiter.api.TestInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -48,17 +45,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 HBaseTestingUtil UTIL;
private SingleProcessHBaseCluster cluster;
private MiniZooKeeperCluster zkCluster;
@@ -67,8 +58,8 @@ public class TestRegionMoveAndAbandon {
private TableName tableName;
private RegionInfo regionInfo;
- @Before
- public void setup() throws Exception {
+ @BeforeEach
+ public void setup(TestInfo testInfo) throws Exception {
UTIL = new HBaseTestingUtil();
zkCluster = UTIL.startMiniZKCluster();
StartTestingClusterOption option =
@@ -77,13 +68,13 @@ public class TestRegionMoveAndAbandon {
rs1 = cluster.getRegionServer(0);
rs2 = cluster.getRegionServer(1);
assertEquals(2, cluster.getRegionServerThreads().size());
- tableName = TableName.valueOf(name.getMethodName());
+ tableName = TableName.valueOf(testInfo.getTestMethod().get().getName());
UTIL.createTable(tableName, Bytes.toBytes("cf"));
UTIL.waitTableAvailable(tableName, 30_000);
regionInfo = Iterables.getOnlyElement(cluster.getRegions(tableName)).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 f0781e1de2d..62c4c8565a2 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,14 +17,13 @@
*/
package org.apache.hadoop.hbase.master.assignment;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+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.HBaseTestingUtil;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.TableName;
@@ -42,21 +41,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;
@@ -64,14 +60,18 @@ public class TestRegionReplicaSplit {
private static final HBaseTestingUtil HTU = new HBaseTestingUtil();
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);
@@ -91,7 +91,7 @@ public class TestRegionReplicaSplit {
return split.split(numRegions);
}
- @AfterClass
+ @AfterAll
public static void afterClass() throws Exception {
HRegionServer.TEST_SKIP_REPORTING_TRANSITION = false;
HTU.shutdownMiniCluster();
@@ -99,7 +99,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);
@@ -139,7 +139,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 cb3237402f7..13927082d17 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.HBaseTestingUtil;
import org.apache.hadoop.hbase.ServerName;
import org.apache.hadoop.hbase.StartTestingClusterOption;
@@ -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 HBaseTestingUtil UTIL = new HBaseTestingUtil();
@@ -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());
StartTestingClusterOption 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 c497e55baf9..ee97d72adaa 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.HBaseTestingUtil;
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());
StartTestingClusterOption 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/TestRegionStateNodeLock.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestRegionStateNodeLock.java
index d61fdcfce3b..4320fd87325 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestRegionStateNodeLock.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestRegionStateNodeLock.java
@@ -19,16 +19,15 @@ package org.apache.hadoop.hbase.master.assignment;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertThrows;
-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.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicLong;
-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.RegionInfoBuilder;
@@ -38,24 +37,20 @@ import org.apache.hadoop.hbase.testclassification.MasterTests;
import org.apache.hadoop.hbase.testclassification.SmallTests;
import org.apache.hadoop.hbase.util.AtomicUtils;
import org.apache.hadoop.hbase.util.Threads;
-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;
-@Category({ MasterTests.class, SmallTests.class })
+@Tag(MasterTests.TAG)
+@Tag(SmallTests.TAG)
public class TestRegionStateNodeLock {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestRegionStateNodeLock.class);
-
private final RegionInfo regionInfo =
RegionInfoBuilder.newBuilder(TableName.valueOf("test")).build();
private RegionStateNodeLock lock;
- @Before
+ @BeforeEach
public void setUp() {
lock = new RegionStateNodeLock(regionInfo);
}
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 0e00006251a..b85b7c60606 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
@@ -18,12 +18,12 @@
package org.apache.hadoop.hbase.master.assignment;
import static org.apache.hadoop.hbase.TestMetaTableAccessor.assertEmptyMetaLocation;
-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.io.IOException;
import java.util.ArrayList;
@@ -33,13 +33,12 @@ import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import org.apache.hadoop.hbase.CatalogFamilyFormat;
import org.apache.hadoop.hbase.Cell;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtil;
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.Admin;
import org.apache.hadoop.hbase.client.Get;
import org.apache.hadoop.hbase.client.Put;
@@ -55,33 +54,29 @@ 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.ManualEnvironmentEdge;
-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 HBaseTestingUtil UTIL = new HBaseTestingUtil();
- @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();
}
@@ -103,7 +98,7 @@ public class TestRegionStateStore {
visitorCalled.set(true);
}
});
- assertTrue("Visitor has not been called.", visitorCalled.get());
+ assertTrue(visitorCalled.get(), "Visitor has not been called.");
}
@Test
@@ -135,7 +130,7 @@ public class TestRegionStateStore {
visitorCalled.set(true);
}
});
- assertTrue("Visitor has not been called.", visitorCalled.get());
+ assertTrue(visitorCalled.get(), "Visitor has not been called.");
}
@Test
@@ -151,7 +146,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 871447eeea6..fc2d25668cc 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.HBaseTestingUtil;
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 HBaseTestingUtil UTIL = new HBaseTestingUtil();
@@ -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 fdf65eb0598..db425a2187d 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.HBaseTestingUtil;
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 c2286502817..8903b07c5fe 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.HBaseTestingUtil;
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 f931a025f10..e0d407bb329 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.HBaseTestingUtil;
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 24ae9d58114..df27d11a2bc 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
@@ -18,13 +18,13 @@
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.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.HBaseTestingUtil;
import org.apache.hadoop.hbase.ServerName;
import org.apache.hadoop.hbase.SingleProcessHBaseCluster;
@@ -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.balancerSwitch(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<RegionInfo> tableRegions = createTable(tableName);
@@ -158,10 +153,10 @@ 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()));
+ org.hamcrest.MatcherAssert.assertThat((YouAreDeadException) exception.getCause(),
+ isA(YouAreDeadException.class));
}
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 cd73e09af6d..14863515392 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,13 +21,12 @@ 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.CompletableFuture;
import java.util.concurrent.atomic.AtomicBoolean;
import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtil;
import org.apache.hadoop.hbase.ServerName;
import org.apache.hadoop.hbase.StartTestingClusterOption;
@@ -51,12 +50,11 @@ import org.apache.hadoop.hbase.util.FutureUtils;
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;
@@ -65,13 +63,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 HBaseTestingUtil UTIL = new HBaseTestingUtil();
private static final TableName TABLE_NAME = TableName.valueOf("test");
@@ -118,7 +113,7 @@ public class TestRollbackSCP {
}
}
- @BeforeClass
+ @BeforeAll
public static void setUpBeforeClass() throws Exception {
UTIL.getConfiguration().setInt(MasterProcedureConstants.MASTER_PROCEDURE_THREADS, 1);
UTIL.startMiniCluster(StartTestingClusterOption.builder().numDataNodes(3).numRegionServers(3)
@@ -130,12 +125,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 b8bc32e3bdd..6e07f3c4eaf 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.HBaseTestingUtil;
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(StartTestingClusterOption.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 e720a403897..95b5063c72d 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.HBaseTestingUtil;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.TableName;
@@ -59,28 +58,23 @@ import org.apache.hadoop.hbase.snapshot.SnapshotDescriptionUtils;
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;
import org.apache.hadoop.hbase.shaded.protobuf.ProtobufUtil;
import org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos;
-@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 HBaseTestingUtil UTIL = new HBaseTestingUtil();
@@ -103,9 +97,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);
@@ -114,13 +111,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();
@@ -129,7 +126,7 @@ public class TestSplitTableRegionProcedure {
}
}
- @Before
+ @BeforeEach
public void setup() throws Exception {
ProcedureTestingUtility.setKillAndToggleBeforeStoreUpdate(getMasterProcedureExecutor(), false);
@@ -143,7 +140,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()) {
@@ -153,7 +150,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;
@@ -219,7 +216,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,
@@ -228,8 +225,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();
@@ -253,7 +250,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,
@@ -261,8 +258,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();
@@ -283,7 +280,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,
@@ -293,8 +290,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();
@@ -314,7 +311,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,
@@ -324,8 +321,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();
@@ -349,7 +346,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,
@@ -360,8 +357,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();
@@ -395,15 +392,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();
@@ -424,7 +421,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,
@@ -433,8 +430,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);
@@ -465,7 +462,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,
@@ -474,8 +471,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);
@@ -499,7 +496,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,
@@ -508,8 +505,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);
@@ -532,7 +529,7 @@ public class TestSplitTableRegionProcedure {
@Test
public void testSplitRegionWhileTakingSnapshot() 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,
@@ -540,8 +537,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);
// task snapshot
@@ -578,7 +575,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 8199edc9b5a..bdfd99a33bf 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.HBaseTestingUtil;
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 HBaseTestingUtil UTIL = new HBaseTestingUtil();
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 a62c83eca0d..8369edfd345 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.HBaseTestingUtil;
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 HBaseTestingUtil UTIL = new HBaseTestingUtil();
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 f0c8cf58abe..8f9261438df 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.HBaseTestingUtil;
import org.apache.hadoop.hbase.PleaseHoldException;
import org.apache.hadoop.hbase.ServerName;
@@ -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 HBaseTestingUtil UTIL = new HBaseTestingUtil();
@@ -219,7 +214,7 @@ public class TestWakeUpUnexpectedProcedure {
}
}
- @BeforeClass
+ @BeforeAll
public static void setUp() throws Exception {
UTIL.startMiniCluster(StartTestingClusterOption.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/region/TestMasterRegionOnTwoFileSystems.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/region/TestMasterRegionOnTwoFileSystems.java
index 8f21b3778fd..a4c019335bd 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/region/TestMasterRegionOnTwoFileSystems.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/region/TestMasterRegionOnTwoFileSystems.java
@@ -17,10 +17,10 @@
*/
package org.apache.hadoop.hbase.master.region;
-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 static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -36,7 +36,6 @@ import org.apache.hadoop.fs.FileStatus;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hbase.Cell;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseCommonTestingUtil;
import org.apache.hadoop.hbase.HBaseTestingUtil;
import org.apache.hadoop.hbase.HConstants;
@@ -59,26 +58,22 @@ 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.hbase.util.HFileArchiveUtil;
-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.collect.Iterables;
-@Category({ MasterTests.class, MediumTests.class })
+@Tag(MasterTests.TAG)
+@Tag(MediumTests.TAG)
public class TestMasterRegionOnTwoFileSystems {
private static final Logger LOG = LoggerFactory.getLogger(TestMasterRegionOnTwoFileSystems.class);
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestMasterRegionOnTwoFileSystems.class);
-
private static final HBaseCommonTestingUtil HFILE_UTIL = new HBaseCommonTestingUtil();
private static final HBaseTestingUtil WAL_UTIL = new HBaseTestingUtil();
@@ -97,7 +92,7 @@ public class TestMasterRegionOnTwoFileSystems {
private MasterRegion region;
- @BeforeClass
+ @BeforeAll
public static void setUp() throws Exception {
WAL_UTIL.startMiniDFSCluster(3);
Configuration conf = HFILE_UTIL.getConfiguration();
@@ -111,7 +106,7 @@ public class TestMasterRegionOnTwoFileSystems {
}
- @AfterClass
+ @AfterAll
public static void tearDown() throws IOException {
WAL_UTIL.shutdownMiniDFSCluster();
WAL_UTIL.cleanupTestDir();
@@ -132,7 +127,7 @@ public class TestMasterRegionOnTwoFileSystems {
return MasterRegion.create(params);
}
- @Before
+ @BeforeEach
public void setUpBeforeTest() throws IOException {
Path rootDir = HFILE_UTIL.getDataTestDir();
FileSystem fs = rootDir.getFileSystem(HFILE_UTIL.getConfiguration());
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/replication/TestDisablePeerModification.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/replication/TestDisablePeerModification.java
index 2ce61cd1b5d..a1e61f3442b 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/replication/TestDisablePeerModification.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/replication/TestDisablePeerModification.java
@@ -19,18 +19,18 @@ package org.apache.hadoop.hbase.master.replication;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsString;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.IOException;
import java.util.Arrays;
-import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ForkJoinPool;
+import java.util.stream.Stream;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
+import org.apache.hadoop.hbase.HBaseParameterizedTestTemplate;
import org.apache.hadoop.hbase.HBaseTestingUtil;
import org.apache.hadoop.hbase.client.AsyncAdmin;
import org.apache.hadoop.hbase.replication.DummyReplicationEndpoint;
@@ -42,25 +42,18 @@ import org.apache.hadoop.hbase.replication.ReplicationStorageFactory;
import org.apache.hadoop.hbase.replication.SyncReplicationState;
import org.apache.hadoop.hbase.testclassification.LargeTests;
import org.apache.hadoop.hbase.testclassification.MasterTests;
-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.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameter;
-import org.junit.runners.Parameterized.Parameters;
-
-@RunWith(Parameterized.class)
-@Category({ MasterTests.class, LargeTests.class })
+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.TestTemplate;
+import org.junit.jupiter.params.provider.Arguments;
+
+@Tag(MasterTests.TAG)
+@Tag(LargeTests.TAG)
+@HBaseParameterizedTestTemplate(name = "{index}: async={0}")
public class TestDisablePeerModification {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestDisablePeerModification.class);
-
private static final HBaseTestingUtil UTIL = new HBaseTestingUtil();
private static volatile CountDownLatch ARRIVE;
@@ -86,32 +79,34 @@ public class TestDisablePeerModification {
}
}
- @Parameter
- public boolean async;
+ private final boolean async;
+
+ public TestDisablePeerModification(boolean async) {
+ this.async = async;
+ }
- @Parameters(name = "{index}: async={0}")
- public static List<Object[]> params() {
- return Arrays.asList(new Object[] { true }, new Object[] { false });
+ public static Stream<Arguments> parameters() {
+ return Arrays.asList(true, false).stream().map(Arguments::of);
}
- @BeforeClass
+ @BeforeAll
public static void setUp() throws Exception {
UTIL.getConfiguration().setClass(ReplicationStorageFactory.REPLICATION_PEER_STORAGE_IMPL,
MockPeerStorage.class, ReplicationPeerStorage.class);
UTIL.startMiniCluster(1);
}
- @AfterClass
+ @AfterAll
public static void tearDown() throws IOException {
UTIL.shutdownMiniCluster();
}
- @Before
+ @BeforeEach
public void setUpBeforeTest() throws IOException {
UTIL.getAdmin().replicationPeerModificationSwitch(true, true);
}
- @Test
+ @TestTemplate
public void testDrainProcs() throws Exception {
ARRIVE = new CountDownLatch(1);
RESUME = new CountDownLatch(1);
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/replication/TestMigrateReplicationQueue.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/replication/TestMigrateReplicationQueue.java
index 5404cfab05b..95a4c7384d1 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/replication/TestMigrateReplicationQueue.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/replication/TestMigrateReplicationQueue.java
@@ -20,15 +20,14 @@ package org.apache.hadoop.hbase.master.replication;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.contains;
import static org.hamcrest.Matchers.not;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.IOException;
import java.util.Collections;
import java.util.List;
import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtil;
import org.apache.hadoop.hbase.ServerName;
import org.apache.hadoop.hbase.TableName;
@@ -49,19 +48,15 @@ import org.apache.hadoop.hbase.util.ServerRegionReplicaUtil;
import org.apache.hadoop.hbase.zookeeper.ZKUtil;
import org.apache.hadoop.hbase.zookeeper.ZKWatcher;
import org.apache.hadoop.hbase.zookeeper.ZNodePaths;
-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.apache.hbase.thirdparty.com.google.common.collect.Iterables;
-@Category({ MasterTests.class, LargeTests.class })
+@Tag(MasterTests.TAG)
+@Tag(LargeTests.TAG)
public class TestMigrateReplicationQueue extends TestReplicationBase {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestMigrateReplicationQueue.class);
-
private int disableAndInsert() throws Exception {
UTIL1.getAdmin().disableReplicationPeer(PEER_ID2);
return UTIL1.loadTable(htable1, famName);
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/replication/TestMigrateReplicationQueueFromZkToTableProcedure.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/replication/TestMigrateReplicationQueueFromZkToTableProcedure.java
index a2709548bc3..fe2b07eb708 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/replication/TestMigrateReplicationQueueFromZkToTableProcedure.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/replication/TestMigrateReplicationQueueFromZkToTableProcedure.java
@@ -19,9 +19,9 @@ package org.apache.hadoop.hbase.master.replication;
import static org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.MigrateReplicationQueueFromZkToTableState.MIGRATE_REPLICATION_QUEUE_FROM_ZK_TO_TABLE_DISABLE_CLEANER;
import static org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.MigrateReplicationQueueFromZkToTableState.MIGRATE_REPLICATION_QUEUE_FROM_ZK_TO_TABLE_WAIT_UPGRADING;
-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 static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -32,7 +32,6 @@ import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.CountDownLatch;
import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtil;
import org.apache.hadoop.hbase.ServerMetrics;
import org.apache.hadoop.hbase.ServerName;
@@ -55,22 +54,18 @@ import org.apache.hadoop.hbase.replication.master.ReplicationLogCleanerBarrier;
import org.apache.hadoop.hbase.testclassification.MasterTests;
import org.apache.hadoop.hbase.testclassification.MediumTests;
import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
-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;
import org.apache.hadoop.hbase.shaded.protobuf.generated.ProcedureProtos.ProcedureState;
-@Category({ MasterTests.class, MediumTests.class })
+@Tag(MasterTests.TAG)
+@Tag(MediumTests.TAG)
public class TestMigrateReplicationQueueFromZkToTableProcedure {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestMigrateReplicationQueueFromZkToTableProcedure.class);
-
private static final HBaseTestingUtil UTIL = new HBaseTestingUtil();
public static final class HMasterForTest extends HMaster {
@@ -104,7 +99,7 @@ public class TestMigrateReplicationQueueFromZkToTableProcedure {
}
}
- @BeforeClass
+ @BeforeAll
public static void setupCluster() throws Exception {
// one hour, to make sure it will not run during the test
UTIL.getConfiguration().setInt(HMaster.HBASE_MASTER_CLEANER_INTERVAL, 60 * 60 * 1000);
@@ -112,7 +107,7 @@ public class TestMigrateReplicationQueueFromZkToTableProcedure {
StartTestingClusterOption.builder().masterClass(HMasterForTest.class).build());
}
- @AfterClass
+ @AfterAll
public static void cleanupTest() throws Exception {
UTIL.shutdownMiniCluster();
}
@@ -121,7 +116,7 @@ public class TestMigrateReplicationQueueFromZkToTableProcedure {
return UTIL.getHBaseCluster().getMaster().getMasterProcedureExecutor();
}
- @After
+ @AfterEach
public void tearDown() throws Exception {
Admin admin = UTIL.getAdmin();
for (ReplicationPeerDescription pd : admin.listReplicationPeers()) {
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/replication/TestMigrateReplicationQueueFromZkToTableProcedureRecovery.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/replication/TestMigrateReplicationQueueFromZkToTableProcedureRecovery.java
index 8d1a975400f..87027dac9b5 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/replication/TestMigrateReplicationQueueFromZkToTableProcedureRecovery.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/replication/TestMigrateReplicationQueueFromZkToTableProcedureRecovery.java
@@ -24,7 +24,6 @@ import static org.hamcrest.Matchers.hasSize;
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.HBaseTestingUtil;
import org.apache.hadoop.hbase.master.procedure.MasterProcedureConstants;
import org.apache.hadoop.hbase.master.procedure.MasterProcedureEnv;
@@ -41,30 +40,26 @@ import org.apache.hadoop.hbase.zookeeper.ZKUtil;
import org.apache.hadoop.hbase.zookeeper.ZKWatcher;
import org.apache.hadoop.hbase.zookeeper.ZNodePaths;
import org.hamcrest.Matchers;
-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;
-
-@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;
+
+@Tag(MasterTests.TAG)
+@Tag(MediumTests.TAG)
public class TestMigrateReplicationQueueFromZkToTableProcedureRecovery {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestMigrateReplicationQueueFromZkToTableProcedureRecovery.class);
-
private static final HBaseTestingUtil UTIL = new HBaseTestingUtil();
- @BeforeClass
+ @BeforeAll
public static void setupCluster() throws Exception {
UTIL.getConfiguration().setInt(MasterProcedureConstants.MASTER_PROCEDURE_THREADS, 1);
UTIL.startMiniCluster(1);
}
- @AfterClass
+ @AfterAll
public static void cleanupTest() throws Exception {
UTIL.shutdownMiniCluster();
}
@@ -73,12 +68,12 @@ public class TestMigrateReplicationQueueFromZkToTableProcedureRecovery {
return UTIL.getHBaseCluster().getMaster().getMasterProcedureExecutor();
}
- @Before
+ @BeforeEach
public void setup() throws Exception {
ProcedureTestingUtility.setKillAndToggleBeforeStoreUpdate(getMasterProcedureExecutor(), false);
}
- @After
+ @AfterEach
public void tearDown() throws Exception {
ProcedureTestingUtility.setKillAndToggleBeforeStoreUpdate(getMasterProcedureExecutor(), false);
}
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 8061cf90558..b56af334138 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.HBaseTestingUtil;
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 HBaseTestingUtil UTIL = new HBaseTestingUtil();
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/master/replication/TestRegisterPeerWorkerWhenRestarting.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/replication/TestRegisterPeerWorkerWhenRestarting.java
index c0a37c20e88..97c4ae01d2a 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/replication/TestRegisterPeerWorkerWhenRestarting.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/replication/TestRegisterPeerWorkerWhenRestarting.java
@@ -23,7 +23,6 @@ import static org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureP
import java.io.IOException;
import java.io.UncheckedIOException;
import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.master.HMaster;
import org.apache.hadoop.hbase.master.procedure.MasterProcedureEnv;
@@ -33,21 +32,18 @@ import org.apache.hadoop.hbase.replication.SyncReplicationTestBase;
import org.apache.hadoop.hbase.testclassification.LargeTests;
import org.apache.hadoop.hbase.testclassification.MasterTests;
import org.apache.hadoop.hbase.util.JVMClusterUtil.MasterThread;
-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-21494.
*/
-@Category({ MasterTests.class, LargeTests.class })
+@Tag(MasterTests.TAG)
+@Tag(LargeTests.TAG)
public class TestRegisterPeerWorkerWhenRestarting extends SyncReplicationTestBase {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestRegisterPeerWorkerWhenRestarting.class);
-
private static volatile boolean FAIL = false;
public static final class HMasterForTest extends HMaster {
@@ -68,12 +64,17 @@ public class TestRegisterPeerWorkerWhenRestarting extends SyncReplicationTestBas
}
}
- @BeforeClass
+ @BeforeAll
public static void setUp() throws Exception {
UTIL2.getConfiguration().setClass(HConstants.MASTER_IMPL, HMasterForTest.class, HMaster.class);
SyncReplicationTestBase.setUp();
}
+ @AfterAll
+ public static void tearDown() throws Exception {
+ SyncReplicationTestBase.tearDown();
+ }
+
@Test
public void testRestart() throws Exception {
UTIL2.getAdmin().transitReplicationPeerSyncReplicationState(PEER_ID,
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/replication/TestReplicationPeerManagerMigrateQueuesFromZk.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/replication/TestReplicationPeerManagerMigrateQueuesFromZk.java
index d211d707e92..f10ffd7045b 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/replication/TestReplicationPeerManagerMigrateQueuesFromZk.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/replication/TestReplicationPeerManagerMigrateQueuesFromZk.java
@@ -19,9 +19,9 @@ package org.apache.hadoop.hbase.master.replication;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.empty;
-import static org.junit.Assert.assertEquals;
-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.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
@@ -37,11 +37,10 @@ import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.Cell;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtil;
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.Result;
import org.apache.hadoop.hbase.client.ResultScanner;
import org.apache.hadoop.hbase.client.Table;
@@ -59,23 +58,19 @@ 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.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.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.extension.RegisterExtension;
import org.apache.hbase.thirdparty.com.google.common.util.concurrent.ThreadFactoryBuilder;
-@Category({ MasterTests.class, MediumTests.class })
+@Tag(MasterTests.TAG)
+@Tag(MediumTests.TAG)
public class TestReplicationPeerManagerMigrateQueuesFromZk {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestReplicationPeerManagerMigrateQueuesFromZk.class);
-
private static HBaseTestingUtil UTIL = new HBaseTestingUtil();
private static ExecutorService EXECUTOR;
@@ -98,10 +93,10 @@ public class TestReplicationPeerManagerMigrateQueuesFromZk {
private ServerName deadServerName;
- @Rule
- public final TableNameTestRule tableNameRule = new TableNameTestRule();
+ @RegisterExtension
+ public final TableNameTestExtension tableNameExtension = new TableNameTestExtension();
- @BeforeClass
+ @BeforeAll
public static void setUpBeforeClass() throws Exception {
UTIL.startMiniCluster(1);
EXECUTOR = Executors.newFixedThreadPool(3,
@@ -110,17 +105,17 @@ public class TestReplicationPeerManagerMigrateQueuesFromZk {
.build());
}
- @AfterClass
+ @AfterAll
public static void tearDownAfterClass() throws Exception {
EXECUTOR.shutdownNow();
UTIL.shutdownMiniCluster();
}
- @Before
+ @BeforeEach
public void setUp() throws IOException {
Configuration conf = UTIL.getConfiguration();
peerStorage = mock(ReplicationPeerStorage.class);
- TableName tableName = tableNameRule.getTableName();
+ TableName tableName = tableNameExtension.getTableName();
UTIL.getAdmin()
.createTable(ReplicationStorageFactory.createReplicationQueueTableDescriptor(tableName));
queueStorage = new TableReplicationQueueStorage(UTIL.getConnection(), tableName);
@@ -149,7 +144,7 @@ public class TestReplicationPeerManagerMigrateQueuesFromZk {
// should have called initializer
verify(queueStorageInitializer).initialize();
// should have not migrated any data since there is no peer
- try (Table table = UTIL.getConnection().getTable(tableNameRule.getTableName())) {
+ try (Table table = UTIL.getConnection().getTable(tableNameExtension.getTableName())) {
assertEquals(0, HBaseTestingUtil.countRows(table));
}
}
@@ -177,7 +172,7 @@ public class TestReplicationPeerManagerMigrateQueuesFromZk {
assertEquals(queueData.getId().getServerWALsBelongTo().toString() + ".0", offset.getWal());
}
// there is no method in ReplicationQueueStorage can list all the last pushed sequence ids
- try (Table table = UTIL.getConnection().getTable(tableNameRule.getTableName());
+ try (Table table = UTIL.getConnection().getTable(tableNameExtension.getTableName());
ResultScanner scanner =
table.getScanner(TableReplicationQueueStorage.LAST_SEQUENCE_ID_FAMILY)) {
for (int i = 0; i < 2; i++) {
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/replication/TestSyncReplicationReplayWALManager.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/replication/TestSyncReplicationReplayWALManager.java
index 7e1310df2d0..738cedbf839 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/replication/TestSyncReplicationReplayWALManager.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/replication/TestSyncReplicationReplayWALManager.java
@@ -17,9 +17,9 @@
*/
package org.apache.hadoop.hbase.master.replication;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.fail;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.mock;
@@ -36,7 +36,6 @@ import java.util.Set;
import java.util.function.Function;
import java.util.stream.Collectors;
import org.apache.hadoop.fs.Path;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtil;
import org.apache.hadoop.hbase.ServerMetrics;
import org.apache.hadoop.hbase.ServerName;
@@ -54,20 +53,16 @@ import org.apache.hadoop.hbase.procedure2.ProcedureTestingUtility.NoopProcedure;
import org.apache.hadoop.hbase.replication.ReplicationException;
import org.apache.hadoop.hbase.testclassification.MasterTests;
import org.apache.hadoop.hbase.testclassification.SmallTests;
-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.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
-@Category({ MasterTests.class, SmallTests.class })
+@Tag(MasterTests.TAG)
+@Tag(SmallTests.TAG)
public class TestSyncReplicationReplayWALManager {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestSyncReplicationReplayWALManager.class);
-
private static HBaseTestingUtil UTIL = new HBaseTestingUtil();
private SyncReplicationReplayWALManager manager;
@@ -80,7 +75,7 @@ public class TestSyncReplicationReplayWALManager {
private Queue<Procedure<?>> wokenProcedures;
- @Before
+ @BeforeEach
public void setUp() throws IOException, ReplicationException {
wokenProcedures = new ArrayDeque<>();
onlineServers = new HashSet<>();
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/replication/TestTransitPeerSyncReplicationStateProcedureBackoff.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/replication/TestTransitPeerSyncReplicationStateProcedureBackoff.java
index 045bbfc2763..8f49b1898e4 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/replication/TestTransitPeerSyncReplicationStateProcedureBackoff.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/replication/TestTransitPeerSyncReplicationStateProcedureBackoff.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.HBaseTestingUtil;
import org.apache.hadoop.hbase.ProcedureTestUtil;
import org.apache.hadoop.hbase.master.procedure.MasterProcedureEnv;
@@ -28,19 +27,15 @@ import org.apache.hadoop.hbase.replication.ReplicationException;
import org.apache.hadoop.hbase.replication.SyncReplicationState;
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;
-@Category({ MasterTests.class, LargeTests.class })
+@Tag(MasterTests.TAG)
+@Tag(LargeTests.TAG)
public class TestTransitPeerSyncReplicationStateProcedureBackoff {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestTransitPeerSyncReplicationStateProcedureBackoff.class);
-
private static final HBaseTestingUtil UTIL = new HBaseTestingUtil();
private static boolean FAIL = true;
@@ -107,12 +102,12 @@ public class TestTransitPeerSyncReplicationStateProcedureBackoff {
}
}
- @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/master/replication/TestTransitPeerSyncReplicationStateProcedureRetry.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/replication/TestTransitPeerSyncReplicationStateProcedureRetry.java
index f5a87d146b7..d0b99d9bb65 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/replication/TestTransitPeerSyncReplicationStateProcedureRetry.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/replication/TestTransitPeerSyncReplicationStateProcedureRetry.java
@@ -17,11 +17,10 @@
*/
package org.apache.hadoop.hbase.master.replication;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import java.io.IOException;
import java.io.UncheckedIOException;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.master.HMaster;
import org.apache.hadoop.hbase.master.procedure.MasterProcedureConstants;
import org.apache.hadoop.hbase.master.procedure.MasterProcedureEnv;
@@ -33,19 +32,15 @@ import org.apache.hadoop.hbase.replication.SyncReplicationState;
import org.apache.hadoop.hbase.replication.SyncReplicationTestBase;
import org.apache.hadoop.hbase.testclassification.LargeTests;
import org.apache.hadoop.hbase.testclassification.MasterTests;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
-@Category({ MasterTests.class, LargeTests.class })
+@Tag(MasterTests.TAG)
+@Tag(LargeTests.TAG)
public class TestTransitPeerSyncReplicationStateProcedureRetry extends SyncReplicationTestBase {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestTransitPeerSyncReplicationStateProcedureRetry.class);
-
- @BeforeClass
+ @BeforeAll
public static void setUp() throws Exception {
UTIL2.getConfiguration().setInt(MasterProcedureConstants.MASTER_PROCEDURE_THREADS, 1);
SyncReplicationTestBase.setUp();
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 68c6b6434c4..7bc557e5479 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,10 @@ 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 java.io.IOException;
import java.util.List;
@@ -30,7 +34,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.HBaseTestingUtil;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.KeyValue;
@@ -52,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;
@@ -71,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;
@@ -90,7 +88,7 @@ public class TestRegionReplicas {
private static final HBaseTestingUtil HTU = new HBaseTestingUtil();
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 +113,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 +132,7 @@ public class TestRegionReplicas {
HTU.loadNumericRows(table, f, 0, 1000);
// assert that we can read back from primary
- Assert.assertEquals(1000, HBaseTestingUtil.countRows(table));
+ assertEquals(1000, HBaseTestingUtil.countRows(table));
} finally {
HTU.deleteNumericRows(table, f, 0, 1000);
closeRegion(HTU, getRS(), hriSecondary);
@@ -164,7 +162,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, HBaseTestingUtil.countRows(table));
+ assertEquals(1000, HBaseTestingUtil.countRows(table));
// flush so that region replica can read
HRegion region = getRS().getRegionByEncodedName(hriPrimary.getEncodedName());
region.flush(true);
@@ -188,7 +186,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, HBaseTestingUtil.countRows(table));
+ assertEquals(1000, HBaseTestingUtil.countRows(table));
// flush so that region replica can read
HRegion region = getRS().getRegionByEncodedName(hriPrimary.getEncodedName());
region.flush(true);
@@ -201,7 +199,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,7 +211,7 @@ 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();
}
@@ -228,7 +226,7 @@ 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();
}
@@ -257,7 +255,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, HBaseTestingUtil.countRows(table));
+ assertEquals(1000, HBaseTestingUtil.countRows(table));
// flush so that region replica can read
LOG.info("Flushing primary region");
HRegion region = getRS().getRegionByEncodedName(hriPrimary.getEncodedName());
@@ -269,7 +267,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);
@@ -292,7 +290,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);
@@ -307,7 +305,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);
@@ -435,7 +433,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);
@@ -466,17 +464,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;
@@ -500,7 +498,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()));
sf.initReader();
try (StoreFileScanner scanner = sf.getPreadScanner(false, Long.MAX_VALUE, 0, false)) {
scanner.seek(KeyValue.LOWESTKEY);
@@ -515,8 +513,8 @@ public class TestRegionReplicas {
}
}
}
- 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);