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/01 14:53:08 UTC
(hbase) branch master updated: HBASE-30039 Upgrade hbase-server to use junit5 Part3 (#7999)
This is an automated email from the ASF dual-hosted git repository.
liuxiaocs pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hbase.git
The following commit(s) were added to refs/heads/master by this push:
new 39f5903f0e2 HBASE-30039 Upgrade hbase-server to use junit5 Part3 (#7999)
39f5903f0e2 is described below
commit 39f5903f0e26d018f3ff2035530eebc6aafd7a70
Author: Xiao Liu <li...@apache.org>
AuthorDate: Wed Apr 1 22:53:03 2026 +0800
HBASE-30039 Upgrade hbase-server to use junit5 Part3 (#7999)
Signed-off-by: Duo Zhang <zh...@apache.org>
---
.../hbase/quotas/SpaceQuotaHelperForTests.java | 33 +++---
.../hbase/quotas/TestActivePolicyEnforcement.java | 37 +++----
.../hadoop/hbase/quotas/TestAtomicReadQuota.java | 20 ++--
.../hbase/quotas/TestBlockBytesScannedQuota.java | 26 ++---
.../quotas/TestClusterScopeQuotaThrottle.java | 31 +++---
.../hbase/quotas/TestDefaultAtomicQuota.java | 20 ++--
.../hbase/quotas/TestDefaultOperationQuota.java | 18 ++--
.../hadoop/hbase/quotas/TestDefaultQuota.java | 20 ++--
.../quotas/TestFeedbackAdaptiveRateLimiter.java | 92 ++++++++---------
.../hbase/quotas/TestFileArchiverNotifierImpl.java | 62 +++++------
.../quotas/TestFileSystemUtilizationChore.java | 20 ++--
.../hbase/quotas/TestGlobalQuotaSettingsImpl.java | 16 +--
.../hbase/quotas/TestLowLatencySpaceQuotas.java | 68 ++++++-------
.../hbase/quotas/TestMasterQuotaManager.java | 16 +--
.../hbase/quotas/TestMasterQuotasObserver.java | 67 ++++++------
.../quotas/TestMasterQuotasObserverWithMocks.java | 30 +++---
.../quotas/TestNamespaceQuotaViolationStore.java | 20 ++--
.../apache/hadoop/hbase/quotas/TestQuotaAdmin.java | 76 +++++++-------
.../apache/hadoop/hbase/quotas/TestQuotaCache.java | 23 ++---
.../hadoop/hbase/quotas/TestQuotaCache2.java | 19 ++--
.../hbase/quotas/TestQuotaObserverChore.java | 18 ++--
.../TestQuotaObserverChoreRegionReports.java | 31 ++----
.../TestQuotaObserverChoreWithMiniCluster.java | 113 ++++++++++-----------
.../apache/hadoop/hbase/quotas/TestQuotaState.java | 38 +++----
.../hadoop/hbase/quotas/TestQuotaStatusRPCs.java | 56 +++++-----
.../hadoop/hbase/quotas/TestQuotaTableUtil.java | 73 ++++++-------
.../hadoop/hbase/quotas/TestQuotaThrottle.java | 35 +++----
.../hadoop/hbase/quotas/TestQuotaUserOverride.java | 25 ++---
.../hadoop/hbase/quotas/TestRateLimiter.java | 21 ++--
.../quotas/TestRegionServerSpaceQuotaManager.java | 24 ++---
.../hadoop/hbase/quotas/TestRegionSizeImpl.java | 13 +--
.../hbase/quotas/TestRegionSizeReportingChore.java | 17 ++--
.../hbase/quotas/TestRegionSizeStoreImpl.java | 21 ++--
.../hadoop/hbase/quotas/TestRegionSizeUse.java | 40 +++-----
.../quotas/TestSnapshotQuotaObserverChore.java | 52 ++++------
.../quotas/TestSpaceQuotaBasicFunctioning.java | 50 ++++-----
.../hbase/quotas/TestSpaceQuotaDropTable.java | 42 ++++----
.../hbase/quotas/TestSpaceQuotaIncrease.java | 36 +++----
.../hbase/quotas/TestSpaceQuotaOnBulkLoad.java | 59 +++++------
.../quotas/TestSpaceQuotaOnNonExistingTables.java | 34 +++----
.../hadoop/hbase/quotas/TestSpaceQuotaRemoval.java | 36 +++----
.../hbase/quotas/TestSpaceQuotaSwitchPolicies.java | 36 +++----
...estSpaceQuotaViolationPolicyRefresherChore.java | 18 ++--
.../quotas/TestSpaceQuotasWithRegionReplicas.java | 34 +++----
.../hbase/quotas/TestSpaceQuotasWithSnapshots.java | 56 +++++-----
.../quotas/TestSuperUserQuotaPermissions.java | 40 +++-----
.../hbase/quotas/TestTableQuotaViolationStore.java | 20 ++--
.../TestTableSpaceQuotaViolationNotifier.java | 16 +--
.../hadoop/hbase/quotas/TestTablesWithQuotas.java | 37 ++++---
...BulkLoadCheckingViolationPolicyEnforcement.java | 29 +++---
...TestDisableTableViolationPolicyEnforcement.java | 34 +++----
.../TestNoInsertsViolationPolicyEnforcement.java | 30 +++---
...ritesCompactionsViolationPolicyEnforcement.java | 34 +++----
.../TestNoWritesViolationPolicyEnforcement.java | 34 +++----
54 files changed, 817 insertions(+), 1149 deletions(-)
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/SpaceQuotaHelperForTests.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/SpaceQuotaHelperForTests.java
index 5c29748bf14..23543b70c28 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/SpaceQuotaHelperForTests.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/SpaceQuotaHelperForTests.java
@@ -17,9 +17,9 @@
*/
package org.apache.hadoop.hbase.quotas;
-import static org.junit.Assert.assertEquals;
-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.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
import java.io.IOException;
import java.util.ArrayList;
@@ -31,6 +31,7 @@ import java.util.Objects;
import java.util.Set;
import java.util.TreeMap;
import java.util.concurrent.atomic.AtomicLong;
+import java.util.function.Supplier;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
@@ -61,7 +62,6 @@ import org.apache.hadoop.hbase.regionserver.TestHRegionServerBulkLoad;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.util.StringUtils;
import org.apache.yetus.audience.InterfaceAudience;
-import org.junit.rules.TestName;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -80,11 +80,11 @@ public class SpaceQuotaHelperForTests {
public static final long ONE_GIGABYTE = ONE_MEGABYTE * ONE_KILOBYTE;
private final HBaseTestingUtil testUtil;
- private final TestName testName;
+ private final Supplier<String> testName;
private final AtomicLong counter;
private static final int NUM_RETRIES = 10;
- public SpaceQuotaHelperForTests(HBaseTestingUtil testUtil, TestName testName,
+ public SpaceQuotaHelperForTests(HBaseTestingUtil testUtil, Supplier<String> testName,
AtomicLong counter) {
this.testUtil = Objects.requireNonNull(testUtil);
this.testName = Objects.requireNonNull(testName);
@@ -228,12 +228,13 @@ public class SpaceQuotaHelperForTests {
assertTrue(
msg.contains("TableNotEnabledException") || msg.contains(policyToViolate.name()));
} else {
- assertTrue("Expected exception message to contain the word '" + policyToViolate.name()
- + "', but was " + msg, msg.contains(policyToViolate.name()));
+ assertTrue(msg.contains(policyToViolate.name()),
+ "Expected exception message to contain the word '" + policyToViolate.name()
+ + "', but was " + msg);
}
}
- assertTrue("Expected to see an exception writing data to a table exceeding its quota",
- sawError);
+ assertTrue(sawError,
+ "Expected to see an exception writing data to a table exceeding its quota");
}
/**
@@ -273,7 +274,7 @@ public class SpaceQuotaHelperForTests {
scanner.close();
}
}
- assertTrue("Expected to succeed in writing data to a table not having quota ", sawSuccess);
+ assertTrue(sawSuccess, "Expected to succeed in writing data to a table not having quota ");
}
/**
@@ -286,8 +287,8 @@ public class SpaceQuotaHelperForTests {
ResultScanner rs = quotaTable.getScanner(s);
sawUsageSnapshot = (rs.next() != null);
}
- assertTrue("Expected to succeed in getting table usage snapshots for space quota",
- sawUsageSnapshot);
+ assertTrue(sawUsageSnapshot,
+ "Expected to succeed in getting table usage snapshots for space quota");
}
/**
@@ -515,7 +516,7 @@ public class SpaceQuotaHelperForTests {
}
TableName getNextTableName(String namespace) {
- return TableName.valueOf(namespace, testName.getMethodName() + counter.getAndIncrement());
+ return TableName.valueOf(namespace, testName.get() + counter.getAndIncrement());
}
TableName createTable() throws Exception {
@@ -565,7 +566,7 @@ public class SpaceQuotaHelperForTests {
TableName createTableInNamespace(NamespaceDescriptor nd) throws Exception {
final Admin admin = testUtil.getAdmin();
final TableName tn =
- TableName.valueOf(nd.getName(), testName.getMethodName() + counter.getAndIncrement());
+ TableName.valueOf(nd.getName(), testName.get() + counter.getAndIncrement());
// Delete the old table
if (admin.tableExists(tn)) {
@@ -606,7 +607,7 @@ public class SpaceQuotaHelperForTests {
Map<byte[], List<Path>> generateFileToLoad(TableName tn, int numFiles, int numRowsPerFile)
throws Exception {
FileSystem fs = testUtil.getTestFileSystem();
- Path baseDir = new Path(fs.getHomeDirectory(), testName.getMethodName() + "_files");
+ Path baseDir = new Path(fs.getHomeDirectory(), testName.get() + "_files");
fs.mkdirs(baseDir);
List<Path> hfiles = new ArrayList<>();
for (int i = 1; i <= numFiles; i++) {
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestActivePolicyEnforcement.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestActivePolicyEnforcement.java
index 29fdaba4bfe..1e42b045b04 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestActivePolicyEnforcement.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestActivePolicyEnforcement.java
@@ -17,17 +17,16 @@
*/
package org.apache.hadoop.hbase.quotas;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-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.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.mock;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.quotas.SpaceQuotaSnapshot.SpaceQuotaStatus;
import org.apache.hadoop.hbase.quotas.policies.DefaultViolationPolicyEnforcement;
@@ -35,24 +34,19 @@ import org.apache.hadoop.hbase.quotas.policies.MissingSnapshotViolationPolicyEnf
import org.apache.hadoop.hbase.quotas.policies.NoWritesViolationPolicyEnforcement;
import org.apache.hadoop.hbase.regionserver.RegionServerServices;
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;
/**
* Test class for {@link ActivePolicyEnforcement}.
*/
-@Category(SmallTests.class)
+@Tag(SmallTests.TAG)
public class TestActivePolicyEnforcement {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestActivePolicyEnforcement.class);
-
private RegionServerServices rss;
- @Before
+ @BeforeEach
public void setup() {
rss = mock(RegionServerServices.class);
}
@@ -73,8 +67,9 @@ public class TestActivePolicyEnforcement {
SpaceViolationPolicyEnforcement enforcement =
ape.getPolicyEnforcement(TableName.valueOf("nonexistent"));
assertNotNull(enforcement);
- assertTrue("Expected an instance of MissingSnapshotViolationPolicyEnforcement, but got "
- + enforcement.getClass(), enforcement instanceof MissingSnapshotViolationPolicyEnforcement);
+ assertTrue(enforcement instanceof MissingSnapshotViolationPolicyEnforcement,
+ "Expected an instance of MissingSnapshotViolationPolicyEnforcement, but got "
+ + enforcement.getClass());
}
@Test
@@ -84,7 +79,7 @@ public class TestActivePolicyEnforcement {
Collections.<TableName, SpaceQuotaSnapshot> emptyMap(), mock(RegionServerServices.class));
SpaceViolationPolicyEnforcement enforcement =
ape.getPolicyEnforcement(TableName.valueOf("nonexistent"));
- assertFalse("Should not check bulkloads", enforcement.shouldCheckBulkLoads());
+ assertFalse(enforcement.shouldCheckBulkLoads(), "Should not check bulkloads");
}
@Test
@@ -109,10 +104,10 @@ public class TestActivePolicyEnforcement {
final ActivePolicyEnforcement ape =
new ActivePolicyEnforcement(Collections.emptyMap(), snapshots, rss);
SpaceViolationPolicyEnforcement policyEnforcement = ape.getPolicyEnforcement(tableName);
- assertTrue("Found the wrong class: " + policyEnforcement.getClass(),
- policyEnforcement instanceof DefaultViolationPolicyEnforcement);
+ assertTrue(policyEnforcement instanceof DefaultViolationPolicyEnforcement,
+ "Found the wrong class: " + policyEnforcement.getClass());
SpaceViolationPolicyEnforcement copy = ape.getPolicyEnforcement(tableName);
- assertTrue("Expected the instance to be cached", policyEnforcement == copy);
+ assertTrue(policyEnforcement == copy, "Expected the instance to be cached");
Entry<TableName, SpaceViolationPolicyEnforcement> entry =
ape.getLocallyCachedPolicies().entrySet().iterator().next();
assertTrue(policyEnforcement == entry.getValue());
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestAtomicReadQuota.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestAtomicReadQuota.java
index fc1223309ce..245dd91928f 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestAtomicReadQuota.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestAtomicReadQuota.java
@@ -22,7 +22,6 @@ import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtil;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.TableName;
@@ -38,26 +37,23 @@ import org.apache.hadoop.hbase.testclassification.MediumTests;
import org.apache.hadoop.hbase.testclassification.RegionServerTests;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.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({ RegionServerTests.class, MediumTests.class })
+@Tag(RegionServerTests.TAG)
+@Tag(MediumTests.TAG)
public class TestAtomicReadQuota {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestAtomicReadQuota.class);
private static final Logger LOG = LoggerFactory.getLogger(TestAtomicReadQuota.class);
private static final HBaseTestingUtil TEST_UTIL = new HBaseTestingUtil();
private static final TableName TABLE_NAME = TableName.valueOf(UUID.randomUUID().toString());
private static final byte[] FAMILY = Bytes.toBytes("cf");
private static final byte[] QUALIFIER = Bytes.toBytes("q");
- @AfterClass
+ @AfterAll
public static void tearDown() throws Exception {
ThrottleQuotaTestUtil.clearQuotaCache(TEST_UTIL);
EnvironmentEdgeManager.reset();
@@ -65,7 +61,7 @@ public class TestAtomicReadQuota {
TEST_UTIL.shutdownMiniCluster();
}
- @BeforeClass
+ @BeforeAll
public static void setUpBeforeClass() throws Exception {
TEST_UTIL.getConfiguration().setBoolean(QuotaUtil.QUOTA_CONF_KEY, true);
TEST_UTIL.getConfiguration().setInt(QuotaCache.REFRESH_CONF_KEY, 1000);
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestBlockBytesScannedQuota.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestBlockBytesScannedQuota.java
index 061da367954..79e84349292 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestBlockBytesScannedQuota.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestBlockBytesScannedQuota.java
@@ -23,11 +23,10 @@ import static org.apache.hadoop.hbase.quotas.ThrottleQuotaTestUtil.doPuts;
import static org.apache.hadoop.hbase.quotas.ThrottleQuotaTestUtil.doScans;
import static org.apache.hadoop.hbase.quotas.ThrottleQuotaTestUtil.triggerUserCacheRefresh;
import static org.apache.hadoop.hbase.quotas.ThrottleQuotaTestUtil.waitMinuteQuota;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.concurrent.Callable;
import java.util.concurrent.TimeUnit;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtil;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.TableName;
@@ -38,20 +37,17 @@ import org.apache.hadoop.hbase.testclassification.LargeTests;
import org.apache.hadoop.hbase.testclassification.RegionServerTests;
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.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.slf4j.Logger;
import org.slf4j.LoggerFactory;
-@Category({ RegionServerTests.class, LargeTests.class })
+@Tag(RegionServerTests.TAG)
+@Tag(LargeTests.TAG)
public class TestBlockBytesScannedQuota {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestBlockBytesScannedQuota.class);
private final static Logger LOG = LoggerFactory.getLogger(TestBlockBytesScannedQuota.class);
@@ -63,7 +59,7 @@ public class TestBlockBytesScannedQuota {
private static final TableName TABLE_NAME = TableName.valueOf("BlockBytesScannedQuotaTest");
private static final long MAX_SCANNER_RESULT_SIZE = 100 * 1024 * 1024;
- @BeforeClass
+ @BeforeAll
public static void setUpBeforeClass() throws Exception {
// client should fail fast
TEST_UTIL.getConfiguration().setInt("hbase.client.pause", 10);
@@ -86,14 +82,14 @@ public class TestBlockBytesScannedQuota {
TEST_UTIL.waitTableAvailable(TABLE_NAME);
}
- @AfterClass
+ @AfterAll
public static void tearDownAfterClass() throws Exception {
EnvironmentEdgeManager.reset();
TEST_UTIL.deleteTable(TABLE_NAME);
TEST_UTIL.shutdownMiniCluster();
}
- @After
+ @AfterEach
public void tearDown() throws Exception {
ThrottleQuotaTestUtil.clearQuotaCache(TEST_UTIL);
}
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestClusterScopeQuotaThrottle.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestClusterScopeQuotaThrottle.java
index 025d13803c4..dbe1628814b 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestClusterScopeQuotaThrottle.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestClusterScopeQuotaThrottle.java
@@ -22,11 +22,10 @@ import static org.apache.hadoop.hbase.quotas.ThrottleQuotaTestUtil.doPuts;
import static org.apache.hadoop.hbase.quotas.ThrottleQuotaTestUtil.triggerNamespaceCacheRefresh;
import static org.apache.hadoop.hbase.quotas.ThrottleQuotaTestUtil.triggerTableCacheRefresh;
import static org.apache.hadoop.hbase.quotas.ThrottleQuotaTestUtil.triggerUserCacheRefresh;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.concurrent.TimeUnit;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtil;
import org.apache.hadoop.hbase.NamespaceDescriptor;
import org.apache.hadoop.hbase.TableName;
@@ -38,20 +37,16 @@ import org.apache.hadoop.hbase.testclassification.RegionServerTests;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
import org.apache.hadoop.hbase.util.JVMClusterUtil.RegionServerThread;
-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;
-
-@Category({ RegionServerTests.class, LargeTests.class })
+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;
+
+@Tag(RegionServerTests.TAG)
+@Tag(LargeTests.TAG)
public class TestClusterScopeQuotaThrottle {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestClusterScopeQuotaThrottle.class);
-
private final static int REFRESH_TIME = 30 * 60000;
private final static HBaseTestingUtil TEST_UTIL = new HBaseTestingUtil();
@@ -67,7 +62,7 @@ public class TestClusterScopeQuotaThrottle {
private final static TableName TABLE_NAME = TableName.valueOf(NAMESPACE, "TestTable");
private static Table table;
- @BeforeClass
+ @BeforeAll
public static void setUpBeforeClass() throws Exception {
TEST_UTIL.getConfiguration().setBoolean(QuotaUtil.QUOTA_CONF_KEY, true);
TEST_UTIL.getConfiguration().setInt(QuotaCache.REFRESH_CONF_KEY, REFRESH_TIME);
@@ -92,7 +87,7 @@ public class TestClusterScopeQuotaThrottle {
.build();
}
- @AfterClass
+ @AfterAll
public static void tearDownAfterClass() throws Exception {
EnvironmentEdgeManager.reset();
for (int i = 0; i < tables.length; ++i) {
@@ -106,7 +101,7 @@ public class TestClusterScopeQuotaThrottle {
TEST_UTIL.shutdownMiniCluster();
}
- @After
+ @AfterEach
public void tearDown() throws Exception {
ThrottleQuotaTestUtil.clearQuotaCache(TEST_UTIL);
}
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestDefaultAtomicQuota.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestDefaultAtomicQuota.java
index b764a264848..acf0fa4b941 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestDefaultAtomicQuota.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestDefaultAtomicQuota.java
@@ -23,7 +23,6 @@ import static org.apache.hadoop.hbase.quotas.ThrottleQuotaTestUtil.waitMinuteQuo
import java.io.IOException;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtil;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.TableName;
@@ -34,24 +33,21 @@ import org.apache.hadoop.hbase.testclassification.MediumTests;
import org.apache.hadoop.hbase.testclassification.RegionServerTests;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.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({ RegionServerTests.class, MediumTests.class })
+@Tag(RegionServerTests.TAG)
+@Tag(MediumTests.TAG)
public class TestDefaultAtomicQuota {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestDefaultAtomicQuota.class);
private static final HBaseTestingUtil TEST_UTIL = new HBaseTestingUtil();
private static final TableName TABLE_NAME = TableName.valueOf(UUID.randomUUID().toString());
private static final int REFRESH_TIME = 5;
private static final byte[] FAMILY = Bytes.toBytes("cf");
private static final byte[] QUALIFIER = Bytes.toBytes("q");
- @AfterClass
+ @AfterAll
public static void tearDown() throws Exception {
ThrottleQuotaTestUtil.clearQuotaCache(TEST_UTIL);
EnvironmentEdgeManager.reset();
@@ -59,7 +55,7 @@ public class TestDefaultAtomicQuota {
TEST_UTIL.shutdownMiniCluster();
}
- @BeforeClass
+ @BeforeAll
public static void setUpBeforeClass() throws Exception {
// quotas enabled, using block bytes scanned
TEST_UTIL.getConfiguration().setBoolean(QuotaUtil.QUOTA_CONF_KEY, true);
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestDefaultOperationQuota.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestDefaultOperationQuota.java
index 2b9200ab646..53d020e71bc 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestDefaultOperationQuota.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestDefaultOperationQuota.java
@@ -17,30 +17,26 @@
*/
package org.apache.hadoop.hbase.quotas;
-import static org.junit.Assert.assertEquals;
-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.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.testclassification.RegionServerTests;
import org.apache.hadoop.hbase.testclassification.SmallTests;
import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
import org.apache.hadoop.hbase.util.EnvironmentEdgeManagerTestHelper;
import org.apache.hadoop.hbase.util.ManualEnvironmentEdge;
-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.hadoop.hbase.shaded.protobuf.generated.HBaseProtos;
import org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos;
-@Category({ RegionServerTests.class, SmallTests.class })
+@Tag(RegionServerTests.TAG)
+@Tag(SmallTests.TAG)
public class TestDefaultOperationQuota {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestDefaultOperationQuota.class);
private static final Configuration conf = HBaseConfiguration.create();
private static final int DEFAULT_REQUESTS_PER_SECOND = 1000;
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestDefaultQuota.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestDefaultQuota.java
index f38dbf99cac..b66dcaf0d59 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestDefaultQuota.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestDefaultQuota.java
@@ -23,7 +23,6 @@ import static org.apache.hadoop.hbase.quotas.ThrottleQuotaTestUtil.waitMinuteQuo
import java.io.IOException;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtil;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.TableName;
@@ -34,24 +33,21 @@ import org.apache.hadoop.hbase.testclassification.MediumTests;
import org.apache.hadoop.hbase.testclassification.RegionServerTests;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
-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;
-@Category({ RegionServerTests.class, MediumTests.class })
+@Tag(RegionServerTests.TAG)
+@Tag(MediumTests.TAG)
public class TestDefaultQuota {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestDefaultQuota.class);
private static final HBaseTestingUtil TEST_UTIL = new HBaseTestingUtil();
private static final TableName TABLE_NAME = TableName.valueOf(UUID.randomUUID().toString());
private static final int REFRESH_TIME = 5000;
private static final byte[] FAMILY = Bytes.toBytes("cf");
private static final byte[] QUALIFIER = Bytes.toBytes("q");
- @After
+ @AfterEach
public void tearDown() throws Exception {
ThrottleQuotaTestUtil.clearQuotaCache(TEST_UTIL);
EnvironmentEdgeManager.reset();
@@ -59,7 +55,7 @@ public class TestDefaultQuota {
TEST_UTIL.shutdownMiniCluster();
}
- @Before
+ @BeforeEach
public void setUp() throws Exception {
// quotas enabled, using block bytes scanned
TEST_UTIL.getConfiguration().setBoolean(QuotaUtil.QUOTA_CONF_KEY, true);
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestFeedbackAdaptiveRateLimiter.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestFeedbackAdaptiveRateLimiter.java
index a6a233205c8..adeaf923e97 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestFeedbackAdaptiveRateLimiter.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestFeedbackAdaptiveRateLimiter.java
@@ -17,38 +17,33 @@
*/
package org.apache.hadoop.hbase.quotas;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.concurrent.TimeUnit;
import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.testclassification.RegionServerTests;
import org.apache.hadoop.hbase.testclassification.SmallTests;
import org.apache.hadoop.hbase.util.EnvironmentEdge;
import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
-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;
/**
* Verify the behavior of the FeedbackAdaptiveRateLimiter including adaptive backoff multipliers and
* over-subscription functionality.
*/
-@Category({ RegionServerTests.class, SmallTests.class })
+@Tag(RegionServerTests.TAG)
+@Tag(SmallTests.TAG)
public class TestFeedbackAdaptiveRateLimiter {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestFeedbackAdaptiveRateLimiter.class);
-
private ManualEnvironmentEdge testEdge;
private FeedbackAdaptiveRateLimiter.FeedbackAdaptiveRateLimiterFactory factory;
- @Before
+ @BeforeEach
public void setUp() {
testEdge = new ManualEnvironmentEdge();
EnvironmentEdgeManager.injectEdge(testEdge);
@@ -70,7 +65,7 @@ public class TestFeedbackAdaptiveRateLimiter {
factory = new FeedbackAdaptiveRateLimiter.FeedbackAdaptiveRateLimiterFactory(conf);
}
- @After
+ @AfterEach
public void tearDown() {
EnvironmentEdgeManager.reset();
}
@@ -101,7 +96,7 @@ public class TestFeedbackAdaptiveRateLimiter {
// Record initial wait interval
limiter.consume(10);
long initialWaitInterval = limiter.getWaitInterval(10, 0, 1);
- assertTrue("Initial wait interval should be positive", initialWaitInterval > 0);
+ assertTrue(initialWaitInterval > 0, "Initial wait interval should be positive");
// Create sustained contention over multiple intervals to increase backoff
for (int i = 0; i < 5; i++) {
@@ -120,10 +115,9 @@ public class TestFeedbackAdaptiveRateLimiter {
// With backoffMultiplierIncrement=0.1 and 5 intervals of contention,
// multiplier should be around 1.5, so wait should be significantly higher
- assertTrue(
+ assertTrue(increasedWaitInterval > initialWaitInterval * 1.3,
"Wait interval should increase with contention. Initial: " + initialWaitInterval
- + ", After contention: " + increasedWaitInterval,
- increasedWaitInterval > initialWaitInterval * 1.3);
+ + ", After contention: " + increasedWaitInterval);
}
@Test
@@ -162,8 +156,9 @@ public class TestFeedbackAdaptiveRateLimiter {
// After 10 intervals without contention (decrement=0.05 each),
// multiplier should decrease by ~0.5, making wait interval lower
- assertTrue("Wait interval should decrease without contention. Elevated: " + elevatedWaitInterval
- + ", Reduced: " + reducedWaitInterval, reducedWaitInterval < elevatedWaitInterval * 0.9);
+ assertTrue(reducedWaitInterval < elevatedWaitInterval * 0.9,
+ "Wait interval should decrease without contention. Elevated: " + elevatedWaitInterval
+ + ", Reduced: " + reducedWaitInterval);
}
@Test
@@ -175,7 +170,7 @@ public class TestFeedbackAdaptiveRateLimiter {
// Initial refill to set up the limiter
long initialRefill = limiter.refill(10);
- assertEquals("Initial refill should match limit", 10, initialRefill);
+ assertEquals(10, initialRefill, "Initial refill should match limit");
// Create low utilization scenario (consuming much less than available)
// With error budget of 0.1, min target utilization is 0.9
@@ -202,8 +197,9 @@ public class TestFeedbackAdaptiveRateLimiter {
// With 3 intervals: refillAmount = 3 * 5 = 15
// Result = min(12, 15) = 12, which exceeds the base limit of 10
// Without oversubscription, this would be capped at min(10, 15) = 10
- assertTrue("With oversubscription from low utilization, refill should exceed base limit. Got: "
- + multiIntervalRefill, multiIntervalRefill > 10);
+ assertTrue(multiIntervalRefill > 10,
+ "With oversubscription from low utilization, refill should exceed base limit. Got: "
+ + multiIntervalRefill);
}
@Test
@@ -237,9 +233,8 @@ public class TestFeedbackAdaptiveRateLimiter {
// Oversubscription should have decreased, so refill should be closer to base limit
// With oversubscriptionDecrement=0.005 over 10 intervals, it should drop by ~0.05
- assertTrue(
- "Refill should be closer to base after high utilization. Got: " + refillAfterHighUtil,
- refillAfterHighUtil <= 6);
+ assertTrue(refillAfterHighUtil <= 6,
+ "Refill should be closer to base after high utilization. Got: " + refillAfterHighUtil);
}
@Test
@@ -271,10 +266,10 @@ public class TestFeedbackAdaptiveRateLimiter {
// Wait interval should be approximately 3x base (max multiplier)
assertTrue(
- "Wait interval should cap at max multiplier. Base: " + baseWaitInterval + ", Max backoff: "
- + maxBackoffWaitInterval,
maxBackoffWaitInterval >= baseWaitInterval * 2.5
- && maxBackoffWaitInterval <= baseWaitInterval * 3.5);
+ && maxBackoffWaitInterval <= baseWaitInterval * 3.5,
+ "Wait interval should cap at max multiplier. Base: " + baseWaitInterval + ", Max backoff: "
+ + maxBackoffWaitInterval);
// Additional contention should not increase wait further
testEdge.setValue(14500);
@@ -288,10 +283,9 @@ public class TestFeedbackAdaptiveRateLimiter {
long stillMaxWaitInterval = limiter.getWaitInterval(10, 0, 1);
// Should still be at max, not increasing further
- assertTrue(
+ assertTrue(Math.abs(stillMaxWaitInterval - maxBackoffWaitInterval) < baseWaitInterval * 0.2,
"Wait should remain capped. Previous: " + maxBackoffWaitInterval + ", Current: "
- + stillMaxWaitInterval,
- Math.abs(stillMaxWaitInterval - maxBackoffWaitInterval) < baseWaitInterval * 0.2);
+ + stillMaxWaitInterval);
}
@Test
@@ -317,8 +311,8 @@ public class TestFeedbackAdaptiveRateLimiter {
// With max oversubscription of 0.2, refill should be at most 5 * 1.2 = 6
// (5 is the interval-adjusted limit for 500ms refill interval)
- assertTrue("Refill should cap at max oversubscription. Got: " + refillWithMaxOversubscription,
- refillWithMaxOversubscription <= 7);
+ assertTrue(refillWithMaxOversubscription <= 7,
+ "Refill should cap at max oversubscription. Got: " + refillWithMaxOversubscription);
// Further low utilization should not increase refill
testEdge.setValue(14500);
@@ -329,8 +323,8 @@ public class TestFeedbackAdaptiveRateLimiter {
long stillMaxRefill = limiter.refill(10);
// Should remain at cap
- assertEquals("Refill should remain at max oversubscription", refillWithMaxOversubscription,
- stillMaxRefill);
+ assertEquals(refillWithMaxOversubscription, stillMaxRefill,
+ "Refill should remain at max oversubscription");
}
@Test
@@ -350,8 +344,9 @@ public class TestFeedbackAdaptiveRateLimiter {
// With 500ms refill interval, each interval gives 5 resources
// 3 intervals = 15, but capped at limit (no oversubscription yet) = 10
- assertTrue("Multiple interval refill should provide multiple refill amounts. Got: "
- + multiIntervalRefill, multiIntervalRefill >= 10);
+ assertTrue(multiIntervalRefill >= 10,
+ "Multiple interval refill should provide multiple refill amounts. Got: "
+ + multiIntervalRefill);
}
@Test
@@ -363,7 +358,7 @@ public class TestFeedbackAdaptiveRateLimiter {
// First refill should give full limit
long firstRefill = limiter.refill(10);
- assertEquals("First refill should give full limit", 10, firstRefill);
+ assertEquals(10, firstRefill, "First refill should give full limit");
limiter.consume(10);
@@ -372,7 +367,7 @@ public class TestFeedbackAdaptiveRateLimiter {
long adjustedRefill = limiter.refill(10);
// 500ms is half of 1000ms time unit, so should get half the limit = 5
- assertEquals("Refill after one interval should be interval-adjusted", 5, adjustedRefill);
+ assertEquals(5, adjustedRefill, "Refill after one interval should be interval-adjusted");
}
@Test
@@ -400,8 +395,8 @@ public class TestFeedbackAdaptiveRateLimiter {
limiter.consume(10);
long noContentionWait = limiter.getWaitInterval(10, 0, 1);
- assertEquals("Wait interval should not go below baseline (multiplier=1.0)", baselineWait,
- noContentionWait);
+ assertEquals(baselineWait, noContentionWait,
+ "Wait interval should not go below baseline (multiplier=1.0)");
}
@Test
@@ -432,7 +427,7 @@ public class TestFeedbackAdaptiveRateLimiter {
}
// Should complete without exceptions - basic thread safety verification
- assertTrue("Concurrent access should complete successfully", true);
+ assertTrue(true, "Concurrent access should complete successfully");
}
@Test
@@ -448,7 +443,7 @@ public class TestFeedbackAdaptiveRateLimiter {
// Should require waiting for multiple intervals (500ms refill interval)
long waitInterval = limiter.getWaitInterval(10, -10, 1);
- assertTrue("Should require substantial wait after over-consumption", waitInterval >= 500);
+ assertTrue(waitInterval >= 500, "Should require substantial wait after over-consumption");
}
@Test
@@ -484,10 +479,9 @@ public class TestFeedbackAdaptiveRateLimiter {
long lowContentionWait = limiter.getWaitInterval(10, 0, 1);
// After low contention phase, wait should be lower than after high contention
- assertTrue(
+ assertTrue(lowContentionWait < highContentionWait,
"Wait should decrease after low contention phase in cycle " + cycle + ". High: "
- + highContentionWait + ", Low: " + lowContentionWait,
- lowContentionWait < highContentionWait);
+ + highContentionWait + ", Low: " + lowContentionWait);
}
}
@@ -524,7 +518,7 @@ public class TestFeedbackAdaptiveRateLimiter {
// The EMA should have adjusted, and refills should be different
// (though exact values depend on EMA convergence rate)
- assertTrue("Refill behavior should adapt to utilization patterns", true);
+ assertTrue(true, "Refill behavior should adapt to utilization patterns");
}
private static final class ManualEnvironmentEdge implements EnvironmentEdge {
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestFileArchiverNotifierImpl.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestFileArchiverNotifierImpl.java
index 7f848d01fc9..640ee927fa0 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestFileArchiverNotifierImpl.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestFileArchiverNotifierImpl.java
@@ -17,9 +17,9 @@
*/
package org.apache.hadoop.hbase.quotas;
-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.io.IOException;
import java.util.ArrayList;
@@ -35,7 +35,6 @@ import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.CellScanner;
-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;
@@ -55,14 +54,12 @@ import org.apache.hadoop.hbase.snapshot.SnapshotDescriptionUtils;
import org.apache.hadoop.hbase.snapshot.SnapshotManifest;
import org.apache.hadoop.hbase.testclassification.MediumTests;
import org.apache.hadoop.hbase.util.CommonFSUtils;
-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.apache.hbase.thirdparty.com.google.common.collect.ImmutableSet;
import org.apache.hbase.thirdparty.com.google.common.collect.Iterables;
@@ -76,25 +73,19 @@ import org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos.Snapshot
/**
* Test class for {@link FileArchiverNotifierImpl}.
*/
-@Category(MediumTests.class)
+@Tag(MediumTests.TAG)
public class TestFileArchiverNotifierImpl {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestFileArchiverNotifierImpl.class);
-
private static final HBaseTestingUtil TEST_UTIL = new HBaseTestingUtil();
private static final AtomicLong COUNTER = new AtomicLong();
- @Rule
- public TestName testName = new TestName();
-
private Connection conn;
private Admin admin;
private SpaceQuotaHelperForTests helper;
private FileSystem fs;
private Configuration conf;
+ private String testName;
- @BeforeClass
+ @BeforeAll
public static void setUp() throws Exception {
Configuration conf = TEST_UTIL.getConfiguration();
SpaceQuotaHelperForTests.updateConfigForQuotas(conf);
@@ -106,16 +97,17 @@ public class TestFileArchiverNotifierImpl {
TEST_UTIL.startMiniCluster(1);
}
- @AfterClass
+ @AfterAll
public static void tearDown() throws Exception {
TEST_UTIL.shutdownMiniCluster();
}
- @Before
- public void setup() throws Exception {
+ @BeforeEach
+ public void setup(TestInfo testInfo) throws Exception {
+ testName = testInfo.getTestMethod().get().getName();
conn = TEST_UTIL.getConnection();
admin = TEST_UTIL.getAdmin();
- helper = new SpaceQuotaHelperForTests(TEST_UTIL, testName, COUNTER);
+ helper = new SpaceQuotaHelperForTests(TEST_UTIL, () -> testName, COUNTER);
helper.removeAllQuotas(conn);
fs = TEST_UTIL.getTestFileSystem();
conf = TEST_UTIL.getConfiguration();
@@ -124,7 +116,7 @@ public class TestFileArchiverNotifierImpl {
@Test
public void testSnapshotSizePersistence() throws IOException {
final Admin admin = TEST_UTIL.getAdmin();
- final TableName tn = TableName.valueOf(testName.getMethodName());
+ final TableName tn = TableName.valueOf(testName);
if (admin.tableExists(tn)) {
admin.disableTable(tn);
admin.deleteTable(tn);
@@ -156,7 +148,7 @@ public class TestFileArchiverNotifierImpl {
@Test
public void testIncrementalFileArchiving() throws Exception {
final Admin admin = TEST_UTIL.getAdmin();
- final TableName tn = TableName.valueOf(testName.getMethodName());
+ final TableName tn = TableName.valueOf(testName);
if (admin.tableExists(tn)) {
admin.disableTable(tn);
admin.deleteTable(tn);
@@ -177,9 +169,9 @@ public class TestFileArchiverNotifierImpl {
FileArchiverNotifierImpl notifier = new FileArchiverNotifierImpl(conn, conf, fs, tn);
long t1 = notifier.getLastFullCompute();
long snapshotSize = notifier.computeAndStoreSnapshotSizes(Arrays.asList(snapshotName1));
- assertEquals("The size of the snapshots should be zero", 0, snapshotSize);
- assertTrue("Last compute time was not less than current compute time",
- t1 < notifier.getLastFullCompute());
+ assertEquals(0, snapshotSize, "The size of the snapshots should be zero");
+ assertTrue(t1 < notifier.getLastFullCompute(),
+ "Last compute time was not less than current compute time");
// No recently archived files and the snapshot should have no size
assertEquals(0, extractSnapshotSize(quotaTable, tn, snapshotName1));
@@ -197,7 +189,7 @@ public class TestFileArchiverNotifierImpl {
// Pull one file referenced by the snapshot out of the manifest
Set<String> referencedFiles = getFilesReferencedBySnapshot(snapshotName1);
- assertTrue("Found snapshot referenced files: " + referencedFiles, referencedFiles.size() >= 1);
+ assertTrue(referencedFiles.size() >= 1, "Found snapshot referenced files: " + referencedFiles);
String referencedFile = Iterables.getFirst(referencedFiles, null);
assertNotNull(referencedFile);
@@ -216,15 +208,15 @@ public class TestFileArchiverNotifierImpl {
assertEquals(0, snapshotSize);
assertEquals(0, extractSnapshotSize(quotaTable, tn, snapshotName1));
// We should also have no recently archived files after a re-computation
- assertTrue("Last compute time was not less than current compute time",
- t2 < notifier.getLastFullCompute());
+ assertTrue(t2 < notifier.getLastFullCompute(),
+ "Last compute time was not less than current compute time");
}
@Test
public void testParseOldNamespaceSnapshotSize() throws Exception {
final Admin admin = TEST_UTIL.getAdmin();
- final TableName fakeQuotaTableName = TableName.valueOf(testName.getMethodName());
- final TableName tn = TableName.valueOf(testName.getMethodName() + "1");
+ final TableName fakeQuotaTableName = TableName.valueOf(testName);
+ final TableName tn = TableName.valueOf(testName + "1");
if (admin.tableExists(fakeQuotaTableName)) {
admin.disableTable(fakeQuotaTableName);
admin.deleteTable(fakeQuotaTableName);
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestFileSystemUtilizationChore.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestFileSystemUtilizationChore.java
index b834ddf8c33..68f3b30586a 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestFileSystemUtilizationChore.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestFileSystemUtilizationChore.java
@@ -17,8 +17,8 @@
*/
package org.apache.hadoop.hbase.quotas;
-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.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.doReturn;
@@ -34,29 +34,23 @@ import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.client.RegionInfo;
import org.apache.hadoop.hbase.regionserver.HRegionServer;
import org.apache.hadoop.hbase.regionserver.Region;
import org.apache.hadoop.hbase.regionserver.Store;
import org.apache.hadoop.hbase.testclassification.SmallTests;
-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.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
/**
* Test class for {@link FileSystemUtilizationChore}.
*/
-@Category(SmallTests.class)
+@Tag(SmallTests.TAG)
public class TestFileSystemUtilizationChore {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestFileSystemUtilizationChore.class);
-
@Test
public void testNoOnlineRegions() {
// One region with a store size of one.
@@ -331,8 +325,8 @@ public class TestFileSystemUtilizationChore {
when(r.getRegionInfo()).thenReturn(info);
List<Store> stores = new ArrayList<>();
when(r.getStores()).thenReturn((List) stores);
- assertEquals("Logic error, storeSizes and linkSizes must be equal in size", storeSizes.size(),
- hfileSizes.size());
+ assertEquals(storeSizes.size(), hfileSizes.size(),
+ "Logic error, storeSizes and linkSizes must be equal in size");
Iterator<Long> storeSizeIter = storeSizes.iterator();
Iterator<Long> hfileSizeIter = hfileSizes.iterator();
while (storeSizeIter.hasNext() && hfileSizeIter.hasNext()) {
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestGlobalQuotaSettingsImpl.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestGlobalQuotaSettingsImpl.java
index 40365f176ae..24da2e00b12 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestGlobalQuotaSettingsImpl.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestGlobalQuotaSettingsImpl.java
@@ -17,27 +17,21 @@
*/
package org.apache.hadoop.hbase.quotas;
-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 org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.testclassification.SmallTests;
-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.hadoop.hbase.shaded.protobuf.generated.HBaseProtos;
import org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos;
-@Category(SmallTests.class)
+@Tag(SmallTests.TAG)
public class TestGlobalQuotaSettingsImpl {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestGlobalQuotaSettingsImpl.class);
-
QuotaProtos.TimedQuota REQUEST_THROTTLE =
QuotaProtos.TimedQuota.newBuilder().setScope(QuotaProtos.QuotaScope.MACHINE).setSoftLimit(100)
.setTimeUnit(HBaseProtos.TimeUnit.MINUTES).build();
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestLowLatencySpaceQuotas.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestLowLatencySpaceQuotas.java
index 7daf16aa370..74dd580f3c0 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestLowLatencySpaceQuotas.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestLowLatencySpaceQuotas.java
@@ -17,9 +17,9 @@
*/
package org.apache.hadoop.hbase.quotas;
-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.Collections;
import java.util.List;
@@ -30,7 +30,6 @@ import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileStatus;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtil;
import org.apache.hadoop.hbase.ServerName;
import org.apache.hadoop.hbase.TableName;
@@ -45,35 +44,27 @@ import org.apache.hadoop.hbase.regionserver.Region;
import org.apache.hadoop.hbase.regionserver.Store;
import org.apache.hadoop.hbase.testclassification.MediumTests;
import org.apache.hadoop.hbase.tool.BulkLoadHFiles;
-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.apache.hbase.thirdparty.com.google.common.collect.Iterables;
-@Category({ MediumTests.class })
+@Tag(MediumTests.TAG)
public class TestLowLatencySpaceQuotas {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestLowLatencySpaceQuotas.class);
-
private static final HBaseTestingUtil TEST_UTIL = new HBaseTestingUtil();
// Global for all tests in the class
private static final AtomicLong COUNTER = new AtomicLong(0);
- @Rule
- public TestName testName = new TestName();
private SpaceQuotaHelperForTests helper;
private Connection conn;
private Admin admin;
- @BeforeClass
+ @BeforeAll
public static void setup() throws Exception {
Configuration conf = TEST_UTIL.getConfiguration();
// The default 1s period for QuotaObserverChore is good.
@@ -90,14 +81,15 @@ public class TestLowLatencySpaceQuotas {
TEST_UTIL.startMiniCluster(1);
}
- @AfterClass
+ @AfterAll
public static void tearDown() throws Exception {
TEST_UTIL.shutdownMiniCluster();
}
- @Before
- public void removeAllQuotas() throws Exception {
- helper = new SpaceQuotaHelperForTests(TEST_UTIL, testName, COUNTER);
+ @BeforeEach
+ public void removeAllQuotas(TestInfo testInfo) throws Exception {
+ helper = new SpaceQuotaHelperForTests(TEST_UTIL, () -> testInfo.getTestMethod().get().getName(),
+ COUNTER);
conn = TEST_UTIL.getConnection();
admin = TEST_UTIL.getAdmin();
helper.waitForQuotaTable(conn);
@@ -214,7 +206,7 @@ public class TestLowLatencySpaceQuotas {
}
@Test
- public void testBulkLoading() throws Exception {
+ public void testBulkLoading(TestInfo testInfo) throws Exception {
TableName tn = helper.createTableWithRegions(1);
// Set a quota
QuotaSettings settings = QuotaSettingsFactory.limitTableSpace(tn,
@@ -225,18 +217,18 @@ public class TestLowLatencySpaceQuotas {
Map<byte[], List<Path>> family2Files = helper.generateFileToLoad(tn, 3, 550);
// Make sure the files are about as long as we expect
FileSystem fs = TEST_UTIL.getTestFileSystem();
- FileStatus[] files =
- fs.listStatus(new Path(fs.getHomeDirectory(), testName.getMethodName() + "_files"));
+ FileStatus[] files = fs.listStatus(
+ new Path(fs.getHomeDirectory(), testInfo.getTestMethod().get().getName() + "_files"));
long totalSize = 0;
for (FileStatus file : files) {
- assertTrue("Expected the file, " + file.getPath()
- + ", length to be larger than 25KB, but was " + file.getLen(),
- file.getLen() > 25 * SpaceQuotaHelperForTests.ONE_KILOBYTE);
+ assertTrue(file.getLen() > 25 * SpaceQuotaHelperForTests.ONE_KILOBYTE, "Expected the file, "
+ + file.getPath() + ", length to be larger than 25KB, but was " + file.getLen());
totalSize += file.getLen();
}
- assertFalse("The bulk load failed",
- BulkLoadHFiles.create(TEST_UTIL.getConfiguration()).bulkLoad(tn, family2Files).isEmpty());
+ assertFalse(
+ BulkLoadHFiles.create(TEST_UTIL.getConfiguration()).bulkLoad(tn, family2Files).isEmpty(),
+ "The bulk load failed");
final long finalTotalSize = totalSize;
try {
@@ -306,16 +298,16 @@ public class TestLowLatencySpaceQuotas {
try (Table quotaTable = conn.getTable(QuotaUtil.QUOTA_TABLE_NAME)) {
Result r = quotaTable.get(QuotaTableUtil.makeGetForSnapshotSize(tn, snapshot1));
- assertTrue("Expected a non-null, non-empty Result", r != null && !r.isEmpty());
+ assertTrue(r != null && !r.isEmpty(), "Expected a non-null, non-empty Result");
assertTrue(r.advance());
- assertEquals("The snapshot's size should be the same as the origin store file", storeFileSize,
- QuotaTableUtil.parseSnapshotSize(r.current()));
+ assertEquals(storeFileSize, QuotaTableUtil.parseSnapshotSize(r.current()),
+ "The snapshot's size should be the same as the origin store file");
r = quotaTable.get(QuotaTableUtil.createGetNamespaceSnapshotSize(tn.getNamespaceAsString()));
- assertTrue("Expected a non-null, non-empty Result", r != null && !r.isEmpty());
+ assertTrue(r != null && !r.isEmpty(), "Expected a non-null, non-empty Result");
assertTrue(r.advance());
- assertEquals("The snapshot's size should be the same as the origin store file", storeFileSize,
- QuotaTableUtil.parseSnapshotSize(r.current()));
+ assertEquals(storeFileSize, QuotaTableUtil.parseSnapshotSize(r.current()),
+ "The snapshot's size should be the same as the origin store file");
}
}
}
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestMasterQuotaManager.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestMasterQuotaManager.java
index 8e58943b1bc..b7c1df867ee 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestMasterQuotaManager.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestMasterQuotaManager.java
@@ -18,27 +18,21 @@
package org.apache.hadoop.hbase.quotas;
import static org.apache.hadoop.hbase.util.Bytes.toBytes;
-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.mockito.Mockito.mock;
-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;
import org.apache.hadoop.hbase.master.MasterServices;
import org.apache.hadoop.hbase.testclassification.SmallTests;
-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;
-@Category(SmallTests.class)
+@Tag(SmallTests.TAG)
public class TestMasterQuotaManager {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestMasterQuotaManager.class);
-
@Test
public void testUninitializedQuotaManangerDoesNotFail() {
MasterServices masterServices = mock(MasterServices.class);
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestMasterQuotasObserver.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestMasterQuotasObserver.java
index a5d879ce77e..5a17b854524 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestMasterQuotasObserver.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestMasterQuotasObserver.java
@@ -17,15 +17,14 @@
*/
package org.apache.hadoop.hbase.quotas;
-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.Set;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicLong;
import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtil;
import org.apache.hadoop.hbase.NamespaceDescriptor;
import org.apache.hadoop.hbase.TableName;
@@ -38,47 +37,39 @@ import org.apache.hadoop.hbase.master.HMaster;
import org.apache.hadoop.hbase.master.MasterCoprocessorHost;
import org.apache.hadoop.hbase.testclassification.MediumTests;
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;
/**
* Test class for {@link MasterQuotasObserver}.
*/
-@Category(MediumTests.class)
+@Tag(MediumTests.TAG)
public class TestMasterQuotasObserver {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestMasterQuotasObserver.class);
-
private static final HBaseTestingUtil TEST_UTIL = new HBaseTestingUtil();
private static SpaceQuotaHelperForTests helper;
- @Rule
- public TestName testName = new TestName();
-
- @BeforeClass
+ @BeforeAll
public static void setUp() throws Exception {
Configuration conf = TEST_UTIL.getConfiguration();
conf.setBoolean(QuotaUtil.QUOTA_CONF_KEY, true);
TEST_UTIL.startMiniCluster(1);
}
- @AfterClass
+ @AfterAll
public static void tearDown() throws Exception {
TEST_UTIL.shutdownMiniCluster();
}
- @Before
- public void removeAllQuotas() throws Exception {
+ @BeforeEach
+ public void removeAllQuotas(TestInfo testInfo) throws Exception {
if (helper == null) {
- helper = new SpaceQuotaHelperForTests(TEST_UTIL, testName, new AtomicLong());
+ helper = new SpaceQuotaHelperForTests(TEST_UTIL,
+ () -> testInfo.getTestMethod().get().getName(), new AtomicLong());
}
final Connection conn = TEST_UTIL.getConnection();
// Wait for the quota table to be created
@@ -92,10 +83,10 @@ public class TestMasterQuotasObserver {
}
@Test
- public void testTableSpaceQuotaRemoved() throws Exception {
+ public void testTableSpaceQuotaRemoved(TestInfo testInfo) throws Exception {
final Connection conn = TEST_UTIL.getConnection();
final Admin admin = conn.getAdmin();
- final TableName tn = TableName.valueOf(testName.getMethodName());
+ final TableName tn = TableName.valueOf(testInfo.getTestMethod().get().getName());
// Drop the table if it somehow exists
if (admin.tableExists(tn)) {
dropTable(admin, tn);
@@ -115,10 +106,10 @@ public class TestMasterQuotasObserver {
}
@Test
- public void testTableRPCQuotaRemoved() throws Exception {
+ public void testTableRPCQuotaRemoved(TestInfo testInfo) throws Exception {
final Connection conn = TEST_UTIL.getConnection();
final Admin admin = conn.getAdmin();
- final TableName tn = TableName.valueOf(testName.getMethodName());
+ final TableName tn = TableName.valueOf(testInfo.getTestMethod().get().getName());
// Drop the table if it somehow exists
if (admin.tableExists(tn)) {
dropTable(admin, tn);
@@ -140,10 +131,10 @@ public class TestMasterQuotasObserver {
}
@Test
- public void testTableSpaceAndRPCQuotaRemoved() throws Exception {
+ public void testTableSpaceAndRPCQuotaRemoved(TestInfo testInfo) throws Exception {
final Connection conn = TEST_UTIL.getConnection();
final Admin admin = conn.getAdmin();
- final TableName tn = TableName.valueOf(testName.getMethodName());
+ final TableName tn = TableName.valueOf(testInfo.getTestMethod().get().getName());
// Drop the table if it somehow exists
if (admin.tableExists(tn)) {
dropTable(admin, tn);
@@ -195,10 +186,10 @@ public class TestMasterQuotasObserver {
}
@Test
- public void testNamespaceSpaceQuotaRemoved() throws Exception {
+ public void testNamespaceSpaceQuotaRemoved(TestInfo testInfo) throws Exception {
final Connection conn = TEST_UTIL.getConnection();
final Admin admin = conn.getAdmin();
- final String ns = testName.getMethodName();
+ final String ns = testInfo.getTestMethod().get().getName();
// Drop the ns if it somehow exists
if (namespaceExists(ns)) {
admin.deleteNamespace(ns);
@@ -221,10 +212,10 @@ public class TestMasterQuotasObserver {
}
@Test
- public void testNamespaceRPCQuotaRemoved() throws Exception {
+ public void testNamespaceRPCQuotaRemoved(TestInfo testInfo) throws Exception {
final Connection conn = TEST_UTIL.getConnection();
final Admin admin = conn.getAdmin();
- final String ns = testName.getMethodName();
+ final String ns = testInfo.getTestMethod().get().getName();
// Drop the ns if it somehow exists
if (namespaceExists(ns)) {
admin.deleteNamespace(ns);
@@ -247,10 +238,10 @@ public class TestMasterQuotasObserver {
}
@Test
- public void testNamespaceSpaceAndRPCQuotaRemoved() throws Exception {
+ public void testNamespaceSpaceAndRPCQuotaRemoved(TestInfo testInfo) throws Exception {
final Connection conn = TEST_UTIL.getConnection();
final Admin admin = conn.getAdmin();
- final String ns = testName.getMethodName();
+ final String ns = testInfo.getTestMethod().get().getName();
// Drop the ns if it somehow exists
if (namespaceExists(ns)) {
admin.deleteNamespace(ns);
@@ -312,8 +303,8 @@ public class TestMasterQuotasObserver {
final HMaster master = TEST_UTIL.getHBaseCluster().getMaster();
final MasterCoprocessorHost cpHost = master.getMasterCoprocessorHost();
Set<String> coprocessorNames = cpHost.getCoprocessors();
- assertTrue("Did not find MasterQuotasObserver in list of CPs: " + coprocessorNames,
- coprocessorNames.contains(MasterQuotasObserver.class.getSimpleName()));
+ assertTrue(coprocessorNames.contains(MasterQuotasObserver.class.getSimpleName()),
+ "Did not find MasterQuotasObserver in list of CPs: " + coprocessorNames);
}
public boolean namespaceExists(String ns) throws IOException {
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestMasterQuotasObserverWithMocks.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestMasterQuotasObserverWithMocks.java
index 1852ccc3347..d240ce6ba83 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestMasterQuotasObserverWithMocks.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestMasterQuotasObserverWithMocks.java
@@ -19,9 +19,9 @@ package org.apache.hadoop.hbase.quotas;
import static org.apache.hadoop.hbase.coprocessor.CoprocessorHost.MASTER_COPROCESSOR_CONF_KEY;
import static org.apache.hadoop.hbase.quotas.MasterQuotasObserver.REMOVE_QUOTA_ON_TABLE_DELETE;
-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.ArgumentMatchers.any;
import static org.mockito.Mockito.doCallRealMethod;
import static org.mockito.Mockito.mock;
@@ -29,30 +29,24 @@ import static org.mockito.Mockito.mock;
import java.util.HashSet;
import java.util.Set;
import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.master.HMaster;
import org.apache.hadoop.hbase.security.access.AccessController;
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;
/**
* Test class for MasterQuotasObserver that does not require a cluster.
*/
-@Category(SmallTests.class)
+@Tag(SmallTests.TAG)
public class TestMasterQuotasObserverWithMocks {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestMasterQuotasObserverWithMocks.class);
-
private HMaster master;
private Configuration conf;
- @Before
+ @BeforeEach
public void setup() {
conf = HBaseConfiguration.create();
master = mock(HMaster.class);
@@ -79,9 +73,9 @@ public class TestMasterQuotasObserverWithMocks {
master.updateConfigurationForQuotasObserver(conf);
Set<String> coprocs = new HashSet<>(conf.getStringCollection(MASTER_COPROCESSOR_CONF_KEY));
assertEquals(2, coprocs.size());
- assertTrue("Observed coprocessors were: " + coprocs,
- coprocs.contains(AccessController.class.getName()));
- assertTrue("Observed coprocessors were: " + coprocs,
- coprocs.contains(MasterQuotasObserver.class.getName()));
+ assertTrue(coprocs.contains(AccessController.class.getName()),
+ "Observed coprocessors were: " + coprocs);
+ assertTrue(coprocs.contains(MasterQuotasObserver.class.getName()),
+ "Observed coprocessors were: " + coprocs);
}
}
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestNamespaceQuotaViolationStore.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestNamespaceQuotaViolationStore.java
index 70f2d55bba7..940db1f4ae2 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestNamespaceQuotaViolationStore.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestNamespaceQuotaViolationStore.java
@@ -18,8 +18,8 @@
package org.apache.hadoop.hbase.quotas;
import static org.apache.hbase.thirdparty.com.google.common.collect.Iterables.size;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -28,7 +28,6 @@ import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.atomic.AtomicReference;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.NamespaceDescriptor;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.Connection;
@@ -39,10 +38,9 @@ import org.apache.hadoop.hbase.client.Result;
import org.apache.hadoop.hbase.client.Table;
import org.apache.hadoop.hbase.testclassification.SmallTests;
import org.apache.hadoop.hbase.util.Bytes;
-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;
@@ -54,13 +52,9 @@ import org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.SpaceQuota;
/**
* Test class for {@link NamespaceQuotaSnapshotStore}.
*/
-@Category(SmallTests.class)
+@Tag(SmallTests.TAG)
public class TestNamespaceQuotaViolationStore {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestNamespaceQuotaViolationStore.class);
-
private static final long ONE_MEGABYTE = 1024L * 1024L;
private Connection conn;
@@ -68,7 +62,7 @@ public class TestNamespaceQuotaViolationStore {
private Map<RegionInfo, Long> regionReports;
private NamespaceQuotaSnapshotStore store;
- @Before
+ @BeforeEach
public void setup() {
conn = mock(Connection.class);
chore = mock(QuotaObserverChore.class);
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestQuotaAdmin.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestQuotaAdmin.java
index cf15cef292c..aec9e6f6ea7 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestQuotaAdmin.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestQuotaAdmin.java
@@ -17,11 +17,11 @@
*/
package org.apache.hadoop.hbase.quotas;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNull;
-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.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
import java.io.IOException;
import java.util.ArrayList;
@@ -30,7 +30,6 @@ import java.util.Objects;
import java.util.concurrent.TimeUnit;
import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.CellScanner;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtil;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.TableName;
@@ -48,13 +47,11 @@ import org.apache.hadoop.hbase.testclassification.ClientTests;
import org.apache.hadoop.hbase.testclassification.LargeTests;
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.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.AfterEach;
+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 +65,10 @@ import org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.SpaceLimitR
/**
* minicluster tests that validate that quota entries are properly set in the quota table
*/
-@Category({ ClientTests.class, LargeTests.class })
+@Tag(ClientTests.TAG)
+@Tag(LargeTests.TAG)
public class TestQuotaAdmin {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestQuotaAdmin.class);
-
private static final Logger LOG = LoggerFactory.getLogger(TestQuotaAdmin.class);
private final static HBaseTestingUtil TEST_UTIL = new HBaseTestingUtil();
@@ -86,7 +80,7 @@ public class TestQuotaAdmin {
private final static String[] NAMESPACES =
new String[] { "NAMESPACE01", "NAMESPACE02", "NAMESPACE03" };
- @BeforeClass
+ @BeforeAll
public static void setUpBeforeClass() throws Exception {
TEST_UTIL.getConfiguration().setBoolean(QuotaUtil.QUOTA_CONF_KEY, true);
TEST_UTIL.getConfiguration().setInt(QuotaCache.REFRESH_CONF_KEY, 2000);
@@ -99,7 +93,7 @@ public class TestQuotaAdmin {
TEST_UTIL.waitTableAvailable(QuotaTableUtil.QUOTA_TABLE_NAME);
}
- @After
+ @AfterEach
public void clearQuotaTable() throws Exception {
if (TEST_UTIL.getAdmin().tableExists(QuotaUtil.QUOTA_TABLE_NAME)) {
TEST_UTIL.getAdmin().disableTable(QuotaUtil.QUOTA_TABLE_NAME);
@@ -107,7 +101,7 @@ public class TestQuotaAdmin {
}
}
- @AfterClass
+ @AfterAll
public static void tearDownAfterClass() throws Exception {
TEST_UTIL.shutdownMiniCluster();
}
@@ -337,7 +331,7 @@ public class TestQuotaAdmin {
try {
Result r = Iterables.getOnlyElement(scanner);
CellScanner cells = r.cellScanner();
- assertTrue("Expected to find a cell", cells.advance());
+ assertTrue(cells.advance(), "Expected to find a cell");
assertSpaceQuota(sizeLimit, violationPolicy, cells.current());
} finally {
scanner.close();
@@ -357,7 +351,7 @@ public class TestQuotaAdmin {
try (Table quotaTable = TEST_UTIL.getConnection().getTable(QuotaTableUtil.QUOTA_TABLE_NAME)) {
ResultScanner rs = quotaTable.getScanner(new Scan());
try {
- assertNull("Did not expect to find a quota entry", rs.next());
+ assertNull(rs.next(), "Did not expect to find a quota entry");
} finally {
rs.close();
}
@@ -365,7 +359,7 @@ public class TestQuotaAdmin {
// Verify that we can also not fetch it via the API
try (QuotaRetriever scanner = new QuotaRetriever(admin.getConnection())) {
- assertNull("Did not expect to find a quota entry", scanner.next());
+ assertNull(scanner.next(), "Did not expect to find a quota entry");
}
}
@@ -385,7 +379,7 @@ public class TestQuotaAdmin {
try {
Result r = Iterables.getOnlyElement(scanner);
CellScanner cells = r.cellScanner();
- assertTrue("Expected to find a cell", cells.advance());
+ assertTrue(cells.advance(), "Expected to find a cell");
assertSpaceQuota(originalSizeLimit, violationPolicy, cells.current());
} finally {
scanner.close();
@@ -410,7 +404,7 @@ public class TestQuotaAdmin {
try {
Result r = Iterables.getOnlyElement(scanner);
CellScanner cells = r.cellScanner();
- assertTrue("Expected to find a cell", cells.advance());
+ assertTrue(cells.advance(), "Expected to find a cell");
assertSpaceQuota(newSizeLimit, newViolationPolicy, cells.current());
} finally {
scanner.close();
@@ -430,7 +424,7 @@ public class TestQuotaAdmin {
try (Table quotaTable = TEST_UTIL.getConnection().getTable(QuotaTableUtil.QUOTA_TABLE_NAME)) {
ResultScanner scanner = quotaTable.getScanner(new Scan());
try {
- assertNull("Did not expect to find a quota entry", scanner.next());
+ assertNull(scanner.next(), "Did not expect to find a quota entry");
} finally {
scanner.close();
}
@@ -438,7 +432,7 @@ public class TestQuotaAdmin {
// Verify that we can also not fetch it via the API
try (QuotaRetriever quotaScanner = new QuotaRetriever(admin.getConnection())) {
- assertNull("Did not expect to find a quota entry", quotaScanner.next());
+ assertNull(quotaScanner.next(), "Did not expect to find a quota entry");
}
}
@@ -680,10 +674,10 @@ public class TestQuotaAdmin {
private void testSwitchRpcThrottle(Admin admin, boolean oldRpcThrottle, boolean newRpcThrottle)
throws IOException {
boolean state = admin.switchRpcThrottle(newRpcThrottle);
- Assert.assertEquals(oldRpcThrottle, state);
- Assert.assertEquals(newRpcThrottle, admin.isRpcThrottleEnabled());
+ assertEquals(oldRpcThrottle, state);
+ assertEquals(newRpcThrottle, admin.isRpcThrottleEnabled());
TEST_UTIL.getHBaseCluster().getRegionServerThreads().stream()
- .forEach(rs -> Assert.assertEquals(newRpcThrottle,
+ .forEach(rs -> assertEquals(newRpcThrottle,
rs.getRegionServer().getRegionServerRpcQuotaManager().isRpcThrottleEnabled()));
}
@@ -699,7 +693,7 @@ public class TestQuotaAdmin {
ResultScanner scanner = quotaTable.getScanner(new Scan())) {
Result r = Iterables.getOnlyElement(scanner);
CellScanner cells = r.cellScanner();
- assertTrue("Expected to find a cell", cells.advance());
+ assertTrue(cells.advance(), "Expected to find a cell");
assertRPCQuota(type, limit, tu, scope, cells.current());
}
}
@@ -708,7 +702,7 @@ public class TestQuotaAdmin {
// Verify that the record doesn't exist in the QuotaTableUtil.QUOTA_TABLE_NAME
try (Table quotaTable = TEST_UTIL.getConnection().getTable(QuotaTableUtil.QUOTA_TABLE_NAME);
ResultScanner scanner = quotaTable.getScanner(new Scan())) {
- assertNull("Did not expect to find a quota entry", scanner.next());
+ assertNull(scanner.next(), "Did not expect to find a quota entry");
}
}
@@ -723,7 +717,7 @@ public class TestQuotaAdmin {
private void verifyNotFetchableViaAPI(Admin admin) throws Exception {
// Verify that we can also not fetch it via the API
try (QuotaRetriever quotaScanner = new QuotaRetriever(admin.getConnection())) {
- assertNull("Did not expect to find a quota entry", quotaScanner.next());
+ assertNull(quotaScanner.next(), "Did not expect to find a quota entry");
}
}
@@ -731,7 +725,7 @@ public class TestQuotaAdmin {
Cell cell) throws Exception {
Quotas q = QuotaTableUtil.quotasFromData(cell.getValueArray(), cell.getValueOffset(),
cell.getValueLength());
- assertTrue("Quota should have rpc quota defined", q.hasThrottle());
+ assertTrue(q.hasThrottle(), "Quota should have rpc quota defined");
QuotaProtos.Throttle rpcQuota = q.getThrottle();
QuotaProtos.TimedQuota t = null;
@@ -791,8 +785,9 @@ public class TestQuotaAdmin {
private void assertRPCQuota(ThrottleType type, long limit, TimeUnit tu,
QuotaSettings actualSettings) throws Exception {
- assertTrue("The actual QuotaSettings was not an instance of " + ThrottleSettings.class
- + " but of " + actualSettings.getClass(), actualSettings instanceof ThrottleSettings);
+ assertTrue(actualSettings instanceof ThrottleSettings,
+ "The actual QuotaSettings was not an instance of " + ThrottleSettings.class + " but of "
+ + actualSettings.getClass());
QuotaProtos.ThrottleRequest throttleRequest = ((ThrottleSettings) actualSettings).getProto();
assertEquals(limit, throttleRequest.getTimedQuota().getSoftLimit());
assertEquals(ProtobufUtil.toProtoTimeUnit(tu), throttleRequest.getTimedQuota().getTimeUnit());
@@ -803,7 +798,7 @@ public class TestQuotaAdmin {
throws Exception {
Quotas q = QuotaTableUtil.quotasFromData(cell.getValueArray(), cell.getValueOffset(),
cell.getValueLength());
- assertTrue("Quota should have space quota defined", q.hasSpace());
+ assertTrue(q.hasSpace(), "Quota should have space quota defined");
QuotaProtos.SpaceQuota spaceQuota = q.getSpace();
assertEquals(sizeLimit, spaceQuota.getSoftLimit());
assertEquals(violationPolicy, ProtobufUtil.toViolationPolicy(spaceQuota.getViolationPolicy()));
@@ -811,8 +806,9 @@ public class TestQuotaAdmin {
private void assertSpaceQuota(long sizeLimit, SpaceViolationPolicy violationPolicy,
QuotaSettings actualSettings) {
- assertTrue("The actual QuotaSettings was not an instance of " + SpaceLimitSettings.class
- + " but of " + actualSettings.getClass(), actualSettings instanceof SpaceLimitSettings);
+ assertTrue(actualSettings instanceof SpaceLimitSettings,
+ "The actual QuotaSettings was not an instance of " + SpaceLimitSettings.class + " but of "
+ + actualSettings.getClass());
SpaceLimitRequest spaceLimitRequest = ((SpaceLimitSettings) actualSettings).getProto();
assertEquals(sizeLimit, spaceLimitRequest.getQuota().getSoftLimit());
assertEquals(violationPolicy,
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestQuotaCache.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestQuotaCache.java
index 73291b50b0e..844ac8c2cae 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestQuotaCache.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestQuotaCache.java
@@ -17,10 +17,9 @@
*/
package org.apache.hadoop.hbase.quotas;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
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.Admin;
@@ -28,30 +27,26 @@ import org.apache.hadoop.hbase.testclassification.MediumTests;
import org.apache.hadoop.hbase.testclassification.RegionServerTests;
import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
import org.apache.hadoop.security.UserGroupInformation;
-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;
-@Category({ RegionServerTests.class, MediumTests.class })
+@Tag(RegionServerTests.TAG)
+@Tag(MediumTests.TAG)
public class TestQuotaCache {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestQuotaCache.class);
-
private static final HBaseTestingUtil TEST_UTIL = new HBaseTestingUtil();
private static final int REFRESH_TIME_MS = 1000;
- @After
+ @AfterEach
public void tearDown() throws Exception {
ThrottleQuotaTestUtil.clearQuotaCache(TEST_UTIL);
EnvironmentEdgeManager.reset();
TEST_UTIL.shutdownMiniCluster();
}
- @Before
+ @BeforeEach
public void setUp() throws Exception {
TEST_UTIL.getConfiguration().setBoolean(QuotaUtil.QUOTA_CONF_KEY, true);
TEST_UTIL.getConfiguration().setInt(QuotaCache.REFRESH_CONF_KEY, REFRESH_TIME_MS);
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestQuotaCache2.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestQuotaCache2.java
index 3e829b5c08a..02a63baeb83 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestQuotaCache2.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestQuotaCache2.java
@@ -17,20 +17,18 @@
*/
package org.apache.hadoop.hbase.quotas;
-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.HashMap;
import java.util.Map;
import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.testclassification.RegionServerTests;
import org.apache.hadoop.hbase.testclassification.SmallTests;
-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.hadoop.hbase.shaded.protobuf.generated.HBaseProtos;
import org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos;
@@ -38,13 +36,10 @@ import org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos;
/**
* Tests of QuotaCache that don't require a minicluster, unlike in TestQuotaCache
*/
-@Category({ RegionServerTests.class, SmallTests.class })
+@Tag(RegionServerTests.TAG)
+@Tag(SmallTests.TAG)
public class TestQuotaCache2 {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestQuotaCache2.class);
-
private static final Configuration conf = HBaseConfiguration.create();
@Test
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestQuotaObserverChore.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestQuotaObserverChore.java
index ded554b9cc8..68b74dda3de 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestQuotaObserverChore.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestQuotaObserverChore.java
@@ -17,40 +17,34 @@
*/
package org.apache.hadoop.hbase.quotas;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import java.util.HashMap;
import java.util.Map;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.Connection;
import org.apache.hadoop.hbase.client.RegionInfo;
import org.apache.hadoop.hbase.client.RegionInfoBuilder;
import org.apache.hadoop.hbase.testclassification.SmallTests;
import org.apache.hadoop.hbase.util.Bytes;
-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.apache.hbase.thirdparty.com.google.common.collect.Iterables;
/**
* Non-HBase cluster unit tests for {@link QuotaObserverChore}.
*/
-@Category(SmallTests.class)
+@Tag(SmallTests.TAG)
public class TestQuotaObserverChore {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestQuotaObserverChore.class);
-
private Connection conn;
private QuotaObserverChore chore;
- @Before
+ @BeforeEach
public void setup() throws Exception {
conn = mock(Connection.class);
chore = mock(QuotaObserverChore.class);
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestQuotaObserverChoreRegionReports.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestQuotaObserverChoreRegionReports.java
index d2d2a2a52af..2d2fd21a635 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestQuotaObserverChoreRegionReports.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestQuotaObserverChoreRegionReports.java
@@ -17,8 +17,8 @@
*/
package org.apache.hadoop.hbase.quotas;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
import java.io.IOException;
import java.util.Arrays;
@@ -27,7 +27,6 @@ import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtil;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.Waiter;
@@ -44,34 +43,24 @@ import org.apache.hadoop.hbase.client.TableDescriptorBuilder;
import org.apache.hadoop.hbase.master.HMaster;
import org.apache.hadoop.hbase.testclassification.LargeTests;
import org.apache.hadoop.hbase.util.Bytes;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.ClassRule;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-import org.junit.rules.TestName;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* A test case to verify that region reports are expired when they are not sent.
*/
-@Category(LargeTests.class)
+@Tag(LargeTests.TAG)
public class TestQuotaObserverChoreRegionReports {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestQuotaObserverChoreRegionReports.class);
-
private static final Logger LOG =
LoggerFactory.getLogger(TestQuotaObserverChoreRegionReports.class);
private static final HBaseTestingUtil TEST_UTIL = new HBaseTestingUtil();
- @Rule
- public TestName testName = new TestName();
-
- @Before
+ @BeforeEach
public void setUp() throws Exception {
Configuration conf = TEST_UTIL.getConfiguration();
// Increase the frequency of some of the chores for responsiveness of the test
@@ -79,7 +68,7 @@ public class TestQuotaObserverChoreRegionReports {
conf.setInt(QuotaObserverChore.REGION_REPORT_RETENTION_DURATION_KEY, 1000);
}
- @After
+ @AfterEach
public void tearDown() throws Exception {
TEST_UTIL.shutdownMiniCluster();
}
@@ -221,7 +210,7 @@ public class TestQuotaObserverChoreRegionReports {
QuotaSnapshotStore<TableName> tableStore =
master.getQuotaObserverChore().getTableSnapshotStore();
SpaceQuotaSnapshot snapshot = tableStore.getCurrentState(tn);
- assertFalse("Quota should not be in violation", snapshot.getQuotaStatus().isInViolation());
+ assertFalse(snapshot.getQuotaStatus().isInViolation(), "Quota should not be in violation");
}
private SpaceQuotaSnapshot getSnapshotForTable(Connection conn, TableName tn) throws IOException {
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestQuotaObserverChoreWithMiniCluster.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestQuotaObserverChoreWithMiniCluster.java
index f02123f994c..29dbb8ccd47 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestQuotaObserverChoreWithMiniCluster.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestQuotaObserverChoreWithMiniCluster.java
@@ -17,11 +17,11 @@
*/
package org.apache.hadoop.hbase.quotas;
-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.Assert.fail;
+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.junit.jupiter.api.Assertions.fail;
import java.util.Arrays;
import java.util.Collections;
@@ -33,7 +33,6 @@ import java.util.Set;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicLong;
import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtil;
import org.apache.hadoop.hbase.NamespaceDescriptor;
import org.apache.hadoop.hbase.NamespaceNotFoundException;
@@ -43,14 +42,12 @@ import org.apache.hadoop.hbase.client.Connection;
import org.apache.hadoop.hbase.master.HMaster;
import org.apache.hadoop.hbase.quotas.QuotaObserverChore.TablesWithQuotas;
import org.apache.hadoop.hbase.testclassification.LargeTests;
-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;
@@ -62,28 +59,21 @@ import org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.SpaceQuota;
/**
* Test class for {@link QuotaObserverChore} that uses a live HBase cluster.
*/
-@Category(LargeTests.class)
+@Tag(LargeTests.TAG)
public class TestQuotaObserverChoreWithMiniCluster {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestQuotaObserverChoreWithMiniCluster.class);
-
private static final Logger LOG =
LoggerFactory.getLogger(TestQuotaObserverChoreWithMiniCluster.class);
private static final HBaseTestingUtil TEST_UTIL = new HBaseTestingUtil();
private static final AtomicLong COUNTER = new AtomicLong(0);
private static final long DEFAULT_WAIT_MILLIS = 500;
- @Rule
- public TestName testName = new TestName();
-
private HMaster master;
private QuotaObserverChore chore;
private SpaceQuotaSnapshotNotifierForTest snapshotNotifier;
private SpaceQuotaHelperForTests helper;
- @BeforeClass
+ @BeforeAll
public static void setUp() throws Exception {
Configuration conf = TEST_UTIL.getConfiguration();
SpaceQuotaHelperForTests.updateConfigForQuotas(conf);
@@ -92,16 +82,17 @@ public class TestQuotaObserverChoreWithMiniCluster {
TEST_UTIL.startMiniCluster(1);
}
- @AfterClass
+ @AfterAll
public static void tearDown() throws Exception {
TEST_UTIL.shutdownMiniCluster();
}
- @Before
- public void removeAllQuotas() throws Exception {
+ @BeforeEach
+ public void removeAllQuotas(TestInfo testInfo) throws Exception {
final Connection conn = TEST_UTIL.getConnection();
if (helper == null) {
- helper = new SpaceQuotaHelperForTests(TEST_UTIL, testName, COUNTER);
+ helper = new SpaceQuotaHelperForTests(TEST_UTIL,
+ () -> testInfo.getTestMethod().get().getName(), COUNTER);
}
// Wait for the quota table to be created
if (!conn.getAdmin().tableExists(QuotaUtil.QUOTA_TABLE_NAME)) {
@@ -158,17 +149,17 @@ public class TestQuotaObserverChoreWithMiniCluster {
Iterables.getOnlyElement(quotaSnapshots.entrySet());
assertEquals(tn, entry.getKey());
final SpaceQuotaSnapshot snapshot = entry.getValue();
- assertEquals("Snapshot was " + snapshot, violationPolicy,
- snapshot.getQuotaStatus().getPolicy().get());
+ assertEquals(violationPolicy, snapshot.getQuotaStatus().getPolicy().get(),
+ "Snapshot was " + snapshot);
assertEquals(sizeLimit, snapshot.getLimit());
- assertTrue("The usage should be greater than the limit, but were " + snapshot.getUsage()
- + " and " + snapshot.getLimit() + ", respectively",
- snapshot.getUsage() > snapshot.getLimit());
+ assertTrue(snapshot.getUsage() > snapshot.getLimit(),
+ "The usage should be greater than the limit, but were " + snapshot.getUsage() + " and "
+ + snapshot.getLimit() + ", respectively");
}
@Test
- public void testNamespaceViolatesQuota() throws Exception {
- final String namespace = testName.getMethodName();
+ public void testNamespaceViolatesQuota(TestInfo testInfo) throws Exception {
+ final String namespace = testInfo.getTestMethod().get().getName();
final Admin admin = TEST_UTIL.getAdmin();
// Ensure the namespace exists
try {
@@ -193,8 +184,8 @@ public class TestQuotaObserverChoreWithMiniCluster {
Map<TableName, SpaceQuotaSnapshot> snapshots = snapshotNotifier.copySnapshots();
for (int i = 0; i < 5; i++) {
// Check a few times to make sure we don't prematurely move to violation
- assertEquals("Should not see any quota violations after writing 2MB of data", 0,
- numSnapshotsInViolation(snapshots));
+ assertEquals(0, numSnapshotsInViolation(snapshots),
+ "Should not see any quota violations after writing 2MB of data");
try {
Thread.sleep(DEFAULT_WAIT_MILLIS);
} catch (InterruptedException e) {
@@ -208,8 +199,8 @@ public class TestQuotaObserverChoreWithMiniCluster {
snapshots = snapshotNotifier.copySnapshots();
for (int i = 0; i < 5; i++) {
// Check a few times to make sure we don't prematurely move to violation
- assertEquals("Should not see any quota violations after writing 4MB of data", 0,
- numSnapshotsInViolation(snapshots));
+ assertEquals(0, numSnapshotsInViolation(snapshots),
+ "Should not see any quota violations after writing 4MB of data");
try {
Thread.sleep(DEFAULT_WAIT_MILLIS);
} catch (InterruptedException e) {
@@ -236,20 +227,20 @@ public class TestQuotaObserverChoreWithMiniCluster {
}
SpaceQuotaSnapshot snapshot1 = snapshots.remove(tn1);
- assertNotNull("tn1 should be in violation", snapshot1);
+ assertNotNull(snapshot1, "tn1 should be in violation");
assertEquals(violationPolicy, snapshot1.getQuotaStatus().getPolicy().get());
SpaceQuotaSnapshot snapshot2 = snapshots.remove(tn2);
- assertNotNull("tn2 should be in violation", snapshot2);
+ assertNotNull(snapshot2, "tn2 should be in violation");
assertEquals(violationPolicy, snapshot2.getQuotaStatus().getPolicy().get());
SpaceQuotaSnapshot snapshot3 = snapshots.remove(tn3);
- assertNotNull("tn3 should be in violation", snapshot3);
+ assertNotNull(snapshot3, "tn3 should be in violation");
assertEquals(violationPolicy, snapshot3.getQuotaStatus().getPolicy().get());
- assertTrue("Unexpected additional quota violations: " + snapshots, snapshots.isEmpty());
+ assertTrue(snapshots.isEmpty(), "Unexpected additional quota violations: " + snapshots);
}
@Test
- public void testTableQuotaOverridesNamespaceQuota() throws Exception {
- final String namespace = testName.getMethodName();
+ public void testTableQuotaOverridesNamespaceQuota(TestInfo testInfo) throws Exception {
+ final String namespace = testInfo.getTestMethod().get().getName();
final Admin admin = TEST_UTIL.getAdmin();
// Ensure the namespace exists
try {
@@ -273,8 +264,8 @@ public class TestQuotaObserverChoreWithMiniCluster {
Map<TableName, SpaceQuotaSnapshot> snapshots = snapshotNotifier.copySnapshots();
for (int i = 0; i < 5; i++) {
// Check a few times to make sure we don't prematurely move to violation
- assertEquals("Should not see any quota violations after writing 2MB of data: " + snapshots, 0,
- numSnapshotsInViolation(snapshots));
+ assertEquals(0, numSnapshotsInViolation(snapshots),
+ "Should not see any quota violations after writing 2MB of data: " + snapshots);
try {
Thread.sleep(DEFAULT_WAIT_MILLIS);
} catch (InterruptedException e) {
@@ -299,10 +290,10 @@ public class TestQuotaObserverChoreWithMiniCluster {
}
SpaceQuotaSnapshot actualPolicyTN1 = snapshots.get(tn1);
- assertNotNull("Expected to see violation policy for tn1", actualPolicyTN1);
+ assertNotNull(actualPolicyTN1, "Expected to see violation policy for tn1");
assertEquals(namespaceViolationPolicy, actualPolicyTN1.getQuotaStatus().getPolicy().get());
SpaceQuotaSnapshot actualPolicyTN2 = snapshots.get(tn2);
- assertNotNull("Expected to see violation policy for tn2", actualPolicyTN2);
+ assertNotNull(actualPolicyTN2, "Expected to see violation policy for tn2");
assertEquals(namespaceViolationPolicy, actualPolicyTN2.getQuotaStatus().getPolicy().get());
// Override the namespace quota with a table quota
@@ -316,7 +307,7 @@ public class TestQuotaObserverChoreWithMiniCluster {
while (true) {
snapshots = snapshotNotifier.copySnapshots();
SpaceQuotaSnapshot actualTableSnapshot = snapshots.get(tn1);
- assertNotNull("Violation policy should never be null", actualTableSnapshot);
+ assertNotNull(actualTableSnapshot, "Violation policy should never be null");
if (tableViolationPolicy != actualTableSnapshot.getQuotaStatus().getPolicy().orElse(null)) {
LOG.debug("Saw unexpected table violation policy, waiting and re-checking.");
try {
@@ -333,7 +324,7 @@ public class TestQuotaObserverChoreWithMiniCluster {
// This should not change with the introduction of the table quota for tn1
actualPolicyTN2 = snapshots.get(tn2);
- assertNotNull("Expected to see violation policy for tn2", actualPolicyTN2);
+ assertNotNull(actualPolicyTN2, "Expected to see violation policy for tn2");
assertEquals(namespaceViolationPolicy, actualPolicyTN2.getQuotaStatus().getPolicy().get());
}
@@ -346,9 +337,9 @@ public class TestQuotaObserverChoreWithMiniCluster {
helper.partitionTablesByQuotaTarget(quotas, tablesWithQuotas, namespaceTablesWithQuotas);
TablesWithQuotas tables = chore.fetchAllTablesWithQuotasDefined();
- assertEquals("Found tables: " + tables, tablesWithQuotas, tables.getTableQuotaTables());
- assertEquals("Found tables: " + tables, namespaceTablesWithQuotas,
- tables.getNamespaceQuotaTables());
+ assertEquals(tablesWithQuotas, tables.getTableQuotaTables(), "Found tables: " + tables);
+ assertEquals(namespaceTablesWithQuotas, tables.getNamespaceQuotaTables(),
+ "Found tables: " + tables);
}
@Test
@@ -365,9 +356,9 @@ public class TestQuotaObserverChoreWithMiniCluster {
// The `rpcQuotaTable` should not be included in this Set
TablesWithQuotas tables = chore.fetchAllTablesWithQuotasDefined();
- assertEquals("Found tables: " + tables, tablesWithQuotas, tables.getTableQuotaTables());
- assertEquals("Found tables: " + tables, namespaceTablesWithQuotas,
- tables.getNamespaceQuotaTables());
+ assertEquals(tablesWithQuotas, tables.getTableQuotaTables(), "Found tables: " + tables);
+ assertEquals(namespaceTablesWithQuotas, tables.getNamespaceQuotaTables(),
+ "Found tables: " + tables);
}
@Test
@@ -418,17 +409,17 @@ public class TestQuotaObserverChoreWithMiniCluster {
final TableName table = entry.getKey();
final QuotaSettings qs = entry.getValue();
- assertTrue("QuotaSettings was an instance of " + qs.getClass(),
- qs instanceof SpaceLimitSettings);
+ assertTrue(qs instanceof SpaceLimitSettings,
+ "QuotaSettings was an instance of " + qs.getClass());
SpaceQuota spaceQuota = null;
if (qs.getTableName() != null) {
spaceQuota = chore.getTableSnapshotStore().getSpaceQuota(table);
- assertNotNull("Could not find table space quota for " + table, spaceQuota);
+ assertNotNull(spaceQuota, "Could not find table space quota for " + table);
} else if (qs.getNamespace() != null) {
spaceQuota = chore.getNamespaceSnapshotStore().getSpaceQuota(table.getNamespaceAsString());
- assertNotNull("Could not find namespace space quota for " + table.getNamespaceAsString(),
- spaceQuota);
+ assertNotNull(spaceQuota,
+ "Could not find namespace space quota for " + table.getNamespaceAsString());
} else {
fail("Expected table or namespace space quota");
}
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestQuotaState.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestQuotaState.java
index b45f78b0765..922f1818b9e 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestQuotaState.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestQuotaState.java
@@ -17,39 +17,30 @@
*/
package org.apache.hadoop.hbase.quotas;
-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.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
import java.util.concurrent.TimeUnit;
import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.testclassification.RegionServerTests;
import org.apache.hadoop.hbase.testclassification.SmallTests;
-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.Tag;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestInfo;
import org.apache.hadoop.hbase.shaded.protobuf.ProtobufUtil;
import org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.Quotas;
import org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.Throttle;
-@Category({ RegionServerTests.class, SmallTests.class })
+@Tag(RegionServerTests.TAG)
+@Tag(SmallTests.TAG)
public class TestQuotaState {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestQuotaState.class);
-
private static final TableName UNKNOWN_TABLE_NAME = TableName.valueOf("unknownTable");
- @Rule
- public TestName name = new TestName();
-
private static final Configuration conf = HBaseConfiguration.create();
@Test
@@ -64,8 +55,8 @@ public class TestQuotaState {
}
@Test
- public void testSimpleQuotaStateOperation() {
- final TableName tableName = TableName.valueOf(name.getMethodName());
+ public void testSimpleQuotaStateOperation(TestInfo testInfo) {
+ final TableName tableName = TableName.valueOf(testInfo.getTestMethod().get().getName());
final int NUM_GLOBAL_THROTTLE = 3;
final int NUM_TABLE_THROTTLE = 2;
@@ -121,10 +112,11 @@ public class TestQuotaState {
}
@Test
- public void testQuotaStateUpdateTableThrottle() {
- final TableName tableNameA = TableName.valueOf(name.getMethodName() + "A");
- final TableName tableNameB = TableName.valueOf(name.getMethodName() + "B");
- final TableName tableNameC = TableName.valueOf(name.getMethodName() + "C");
+ public void testQuotaStateUpdateTableThrottle(TestInfo testInfo) {
+ final String methodName = testInfo.getTestMethod().get().getName();
+ final TableName tableNameA = TableName.valueOf(methodName + "A");
+ final TableName tableNameB = TableName.valueOf(methodName + "B");
+ final TableName tableNameC = TableName.valueOf(methodName + "C");
final int TABLE_A_THROTTLE_1 = 3;
final int TABLE_A_THROTTLE_2 = 11;
final int TABLE_B_THROTTLE = 4;
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestQuotaStatusRPCs.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestQuotaStatusRPCs.java
index bfaa054c503..935f94cacfa 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestQuotaStatusRPCs.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestQuotaStatusRPCs.java
@@ -17,17 +17,16 @@
*/
package org.apache.hadoop.hbase.quotas;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-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.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.Map;
import java.util.Map.Entry;
import java.util.concurrent.atomic.AtomicLong;
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.TableName;
import org.apache.hadoop.hbase.Waiter;
@@ -40,36 +39,28 @@ import org.apache.hadoop.hbase.quotas.SpaceQuotaSnapshot.SpaceQuotaStatus;
import org.apache.hadoop.hbase.quotas.policies.MissingSnapshotViolationPolicyEnforcement;
import org.apache.hadoop.hbase.regionserver.HRegionServer;
import org.apache.hadoop.hbase.testclassification.MediumTests;
-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;
/**
* Test class for the quota status RPCs in the master and regionserver.
*/
-@Category({ MediumTests.class })
+@Tag(MediumTests.TAG)
public class TestQuotaStatusRPCs {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestQuotaStatusRPCs.class);
-
private static final Logger LOG = LoggerFactory.getLogger(TestQuotaStatusRPCs.class);
private static final HBaseTestingUtil TEST_UTIL = new HBaseTestingUtil();
private static final AtomicLong COUNTER = new AtomicLong(0);
- @Rule
- public TestName testName = new TestName();
private SpaceQuotaHelperForTests helper;
- @BeforeClass
+ @BeforeAll
public static void setUp() throws Exception {
Configuration conf = TEST_UTIL.getConfiguration();
// Increase the frequency of some of the chores for responsiveness of the test
@@ -77,14 +68,15 @@ public class TestQuotaStatusRPCs {
TEST_UTIL.startMiniCluster(1);
}
- @AfterClass
+ @AfterAll
public static void tearDown() throws Exception {
TEST_UTIL.shutdownMiniCluster();
}
- @Before
- public void setupForTest() throws Exception {
- helper = new SpaceQuotaHelperForTests(TEST_UTIL, testName, COUNTER);
+ @BeforeEach
+ public void setupForTest(TestInfo testInfo) throws Exception {
+ helper = new SpaceQuotaHelperForTests(TEST_UTIL, () -> testInfo.getTestMethod().get().getName(),
+ COUNTER);
}
@Test
@@ -110,8 +102,8 @@ public class TestQuotaStatusRPCs {
Map<TableName, Long> sizes = TEST_UTIL.getAdmin().getSpaceQuotaTableSizes();
Long size = sizes.get(tn);
- assertNotNull("No reported size for " + tn, size);
- assertTrue("Reported table size was " + size, size.longValue() >= tableSize);
+ assertNotNull(size, "No reported size for " + tn);
+ assertTrue(size.longValue() >= tableSize, "Reported table size was " + size);
}
@Test
@@ -146,8 +138,8 @@ public class TestQuotaStatusRPCs {
Map<TableName, SpaceQuotaSnapshot> snapshots = (Map<TableName, SpaceQuotaSnapshot>) TEST_UTIL
.getAdmin().getRegionServerSpaceQuotaSnapshots(rs.getServerName());
SpaceQuotaSnapshot snapshot = snapshots.get(tn);
- assertNotNull("Did not find snapshot for " + tn, snapshot);
- assertTrue("Observed table usage was " + snapshot.getUsage(), snapshot.getUsage() >= tableSize);
+ assertNotNull(snapshot, "Did not find snapshot for " + tn);
+ assertTrue(snapshot.getUsage() >= tableSize, "Observed table usage was " + snapshot.getUsage());
assertEquals(sizeLimit, snapshot.getLimit());
SpaceQuotaStatus pbStatus = snapshot.getQuotaStatus();
assertFalse(pbStatus.isInViolation());
@@ -192,7 +184,7 @@ public class TestQuotaStatusRPCs {
Map<TableName, SpaceQuotaSnapshot> snapshots = (Map<TableName, SpaceQuotaSnapshot>) TEST_UTIL
.getAdmin().getRegionServerSpaceQuotaSnapshots(rs.getServerName());
SpaceQuotaSnapshot snapshot = snapshots.get(tn);
- assertNotNull("Did not find snapshot for " + tn, snapshot);
+ assertNotNull(snapshot, "Did not find snapshot for " + tn);
assertTrue(snapshot.getQuotaStatus().isInViolation());
assertEquals(SpaceViolationPolicy.NO_INSERTS, snapshot.getQuotaStatus().getPolicy().get());
}
@@ -253,8 +245,8 @@ public class TestQuotaStatusRPCs {
// and force the table to move into violation before we write the second bit of data.
SpaceQuotaSnapshot snapshot =
(SpaceQuotaSnapshot) conn.getAdmin().getCurrentSpaceQuotaSnapshot(tn);
- assertTrue("QuotaSnapshot for " + tn + " should be non-null and not in violation",
- snapshot != null && !snapshot.getQuotaStatus().isInViolation());
+ assertTrue(snapshot != null && !snapshot.getQuotaStatus().isInViolation(),
+ "QuotaSnapshot for " + tn + " should be non-null and not in violation");
try {
helper.writeData(tn, tableSize * 2L);
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestQuotaTableUtil.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestQuotaTableUtil.java
index fa00428330f..f20a97af7a2 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestQuotaTableUtil.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestQuotaTableUtil.java
@@ -17,9 +17,9 @@
*/
package org.apache.hadoop.hbase.quotas;
-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.ArrayList;
@@ -31,7 +31,6 @@ import java.util.Set;
import java.util.concurrent.TimeUnit;
import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.CellScanner;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtil;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.NamespaceDescriptor;
@@ -46,15 +45,13 @@ import org.apache.hadoop.hbase.client.Table;
import org.apache.hadoop.hbase.quotas.SpaceQuotaSnapshot.SpaceQuotaStatus;
import org.apache.hadoop.hbase.testclassification.MasterTests;
import org.apache.hadoop.hbase.testclassification.MediumTests;
-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.apache.hbase.thirdparty.com.google.common.collect.HashMultimap;
import org.apache.hbase.thirdparty.com.google.common.collect.Multimap;
@@ -68,24 +65,15 @@ import org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.Throttle;
/**
* Test the quota table helpers (e.g. CRUD operations)
*/
-@Category({ MasterTests.class, MediumTests.class })
+@Tag(MasterTests.TAG)
+@Tag(MediumTests.TAG)
public class TestQuotaTableUtil {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestQuotaTableUtil.class);
-
private final static HBaseTestingUtil TEST_UTIL = new HBaseTestingUtil();
private Connection connection;
private int tableNameCounter;
- @Rule
- public TestName testName = new TestName();
-
- @Rule
- public TestName name = new TestName();
-
- @BeforeClass
+ @BeforeAll
public static void setUpBeforeClass() throws Exception {
TEST_UTIL.getConfiguration().setBoolean(QuotaUtil.QUOTA_CONF_KEY, true);
TEST_UTIL.getConfiguration().setInt(QuotaCache.REFRESH_CONF_KEY, 2000);
@@ -98,32 +86,33 @@ public class TestQuotaTableUtil {
TEST_UTIL.waitTableAvailable(QuotaTableUtil.QUOTA_TABLE_NAME);
}
- @AfterClass
+ @AfterAll
public static void tearDownAfterClass() throws Exception {
TEST_UTIL.shutdownMiniCluster();
}
- @Before
+ @BeforeEach
public void before() throws IOException {
this.connection = ConnectionFactory.createConnection(TEST_UTIL.getConfiguration());
this.tableNameCounter = 0;
}
- @After
+ @AfterEach
public void after() throws IOException {
this.connection.close();
}
@Test
- public void testDeleteSnapshots() throws Exception {
- TableName tn = TableName.valueOf(name.getMethodName());
+ public void testDeleteSnapshots(TestInfo testInfo) throws Exception {
+ String methodName = testInfo.getTestMethod().get().getName();
+ TableName tn = TableName.valueOf(methodName);
try (Table t = connection.getTable(QuotaTableUtil.QUOTA_TABLE_NAME)) {
Quotas quota =
Quotas.newBuilder().setSpace(QuotaProtos.SpaceQuota.newBuilder().setSoftLimit(7L)
.setViolationPolicy(QuotaProtos.SpaceViolationPolicy.NO_WRITES).build()).build();
QuotaUtil.addTableQuota(connection, tn, quota);
- String snapshotName = name.getMethodName() + "_snapshot";
+ String snapshotName = methodName + "_snapshot";
t.put(QuotaTableUtil.createPutForSnapshotSize(tn, snapshotName, 3L));
t.put(QuotaTableUtil.createPutForSnapshotSize(tn, snapshotName, 5L));
assertEquals(1, QuotaTableUtil.getObservedSnapshotSizes(connection).size());
@@ -134,7 +123,7 @@ public class TestQuotaTableUtil {
t.delete(deletes);
assertEquals(0, QuotaTableUtil.getObservedSnapshotSizes(connection).size());
- String ns = name.getMethodName();
+ String ns = methodName;
t.put(QuotaTableUtil.createPutForNamespaceSnapshotSize(ns, 5L));
t.put(QuotaTableUtil.createPutForNamespaceSnapshotSize(ns, 3L));
assertEquals(3L, QuotaTableUtil.getNamespaceSnapshotSize(connection, ns));
@@ -177,8 +166,8 @@ public class TestQuotaTableUtil {
}
@Test
- public void testTableQuotaUtil() throws Exception {
- final TableName tableName = TableName.valueOf(name.getMethodName());
+ public void testTableQuotaUtil(TestInfo testInfo) throws Exception {
+ final TableName tableName = TableName.valueOf(testInfo.getTestMethod().get().getName());
Quotas quota = Quotas.newBuilder()
.setThrottle(Throttle.newBuilder()
@@ -221,8 +210,8 @@ public class TestQuotaTableUtil {
}
@Test
- public void testUserQuotaUtil() throws Exception {
- final TableName tableName = TableName.valueOf(name.getMethodName());
+ public void testUserQuotaUtil(TestInfo testInfo) throws Exception {
+ final TableName tableName = TableName.valueOf(testInfo.getTestMethod().get().getName());
final String namespace = "testNS";
final String user = "testUser";
@@ -274,14 +263,14 @@ public class TestQuotaTableUtil {
}
@Test
- public void testSerDeViolationPolicies() throws Exception {
- final TableName tn1 = getUniqueTableName();
+ public void testSerDeViolationPolicies(TestInfo testInfo) throws Exception {
+ final TableName tn1 = getUniqueTableName(testInfo);
final SpaceQuotaSnapshot snapshot1 =
new SpaceQuotaSnapshot(new SpaceQuotaStatus(SpaceViolationPolicy.DISABLE), 512L, 1024L);
- final TableName tn2 = getUniqueTableName();
+ final TableName tn2 = getUniqueTableName(testInfo);
final SpaceQuotaSnapshot snapshot2 =
new SpaceQuotaSnapshot(new SpaceQuotaStatus(SpaceViolationPolicy.NO_INSERTS), 512L, 1024L);
- final TableName tn3 = getUniqueTableName();
+ final TableName tn3 = getUniqueTableName(testInfo);
final SpaceQuotaSnapshot snapshot3 =
new SpaceQuotaSnapshot(new SpaceQuotaStatus(SpaceViolationPolicy.NO_WRITES), 512L, 1024L);
List<Put> puts = new ArrayList<>();
@@ -350,8 +339,8 @@ public class TestQuotaTableUtil {
}
}
- private TableName getUniqueTableName() {
- return TableName.valueOf(testName.getMethodName() + "_" + tableNameCounter++);
+ private TableName getUniqueTableName(TestInfo testInfo) {
+ return TableName.valueOf(testInfo.getTestMethod().get().getName() + "_" + tableNameCounter++);
}
private void verifyTableSnapshotSize(Table quotaTable, TableName tn, String snapshotName,
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestQuotaThrottle.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestQuotaThrottle.java
index 4309c3640dd..7dc9a5ec6e6 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestQuotaThrottle.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestQuotaThrottle.java
@@ -25,13 +25,12 @@ import static org.apache.hadoop.hbase.quotas.ThrottleQuotaTestUtil.triggerRegion
import static org.apache.hadoop.hbase.quotas.ThrottleQuotaTestUtil.triggerTableCacheRefresh;
import static org.apache.hadoop.hbase.quotas.ThrottleQuotaTestUtil.triggerUserCacheRefresh;
import static org.apache.hadoop.hbase.quotas.ThrottleQuotaTestUtil.waitMinuteQuota;
-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.List;
import java.util.concurrent.TimeUnit;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtil;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.TableName;
@@ -43,26 +42,22 @@ import org.apache.hadoop.hbase.testclassification.MediumTests;
import org.apache.hadoop.hbase.testclassification.RegionServerTests;
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.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Ignore;
-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.Disabled;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
// This tests breaks monotonic WAL numbering after HBASE-20746 because of how it
// manipulates the EnvironmentEdge.
-@Ignore("See HBASE-27243")
-@Category({ RegionServerTests.class, MediumTests.class })
+@Disabled("See HBASE-27243")
+@Tag(RegionServerTests.TAG)
+@Tag(MediumTests.TAG)
public class TestQuotaThrottle {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestQuotaThrottle.class);
-
private final static Logger LOG = LoggerFactory.getLogger(TestQuotaThrottle.class);
private final static int REFRESH_TIME = 30 * 60000;
@@ -77,7 +72,7 @@ public class TestQuotaThrottle {
private static Table[] tables;
- @BeforeClass
+ @BeforeAll
public static void setUpBeforeClass() throws Exception {
TEST_UTIL.getConfiguration().setBoolean(QuotaUtil.QUOTA_CONF_KEY, true);
TEST_UTIL.getConfiguration().setInt(QuotaCache.REFRESH_CONF_KEY, REFRESH_TIME);
@@ -95,7 +90,7 @@ public class TestQuotaThrottle {
}
}
- @AfterClass
+ @AfterAll
public static void tearDownAfterClass() throws Exception {
EnvironmentEdgeManager.reset();
for (int i = 0; i < tables.length; ++i) {
@@ -108,7 +103,7 @@ public class TestQuotaThrottle {
TEST_UTIL.shutdownMiniCluster();
}
- @After
+ @AfterEach
public void tearDown() throws Exception {
ThrottleQuotaTestUtil.clearQuotaCache(TEST_UTIL);
}
@@ -685,7 +680,7 @@ public class TestQuotaThrottle {
}
}
- assertTrue("Expected to find " + throttleType.name() + " quota for user " + userName, found);
+ assertTrue(found, "Expected to find " + throttleType.name() + " quota for user " + userName);
admin.setQuota(QuotaSettingsFactory.unthrottleUserByThrottleType(userName, throttleType));
}
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestQuotaUserOverride.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestQuotaUserOverride.java
index 2c8420ef932..622a27bf2f3 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestQuotaUserOverride.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestQuotaUserOverride.java
@@ -18,11 +18,10 @@
package org.apache.hadoop.hbase.quotas;
import static org.apache.hadoop.hbase.quotas.ThrottleQuotaTestUtil.doPuts;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.concurrent.TimeUnit;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtil;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.TableName;
@@ -33,19 +32,15 @@ import org.apache.hadoop.hbase.testclassification.MediumTests;
import org.apache.hadoop.hbase.testclassification.RegionServerTests;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.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({ RegionServerTests.class, MediumTests.class })
+@Tag(RegionServerTests.TAG)
+@Tag(MediumTests.TAG)
public class TestQuotaUserOverride {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestQuotaUserOverride.class);
-
private static final HBaseTestingUtil TEST_UTIL = new HBaseTestingUtil();
private static final byte[] FAMILY = Bytes.toBytes("cf");
private static final byte[] QUALIFIER = Bytes.toBytes("q");
@@ -54,7 +49,7 @@ public class TestQuotaUserOverride {
private static final TableName TABLE_NAME = TableName.valueOf("TestQuotaUserOverride");
- @BeforeClass
+ @BeforeAll
public static void setUpBeforeClass() throws Exception {
TEST_UTIL.getConfiguration().setBoolean(QuotaUtil.QUOTA_CONF_KEY, true);
TEST_UTIL.getConfiguration().setInt(QuotaCache.REFRESH_CONF_KEY, 1_000);
@@ -68,7 +63,7 @@ public class TestQuotaUserOverride {
TEST_UTIL.createTable(TABLE_NAME, FAMILY);
}
- @AfterClass
+ @AfterAll
public static void tearDownAfterClass() throws Exception {
EnvironmentEdgeManager.reset();
TEST_UTIL.shutdownMiniCluster();
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestRateLimiter.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestRateLimiter.java
index 721c0df8525..1d9710c9901 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestRateLimiter.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestRateLimiter.java
@@ -17,32 +17,27 @@
*/
package org.apache.hadoop.hbase.quotas;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-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.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.concurrent.TimeUnit;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.testclassification.RegionServerTests;
import org.apache.hadoop.hbase.testclassification.SmallTests;
import org.apache.hadoop.hbase.util.EnvironmentEdge;
import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
import org.apache.hadoop.hbase.util.ManualEnvironmentEdge;
-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;
/**
* Verify the behaviour of the Rate Limiter.
*/
-@Category({ RegionServerTests.class, SmallTests.class })
+@Tag(RegionServerTests.TAG)
+@Tag(SmallTests.TAG)
public class TestRateLimiter {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestRateLimiter.class);
-
@Test
public void testWaitIntervalTimeUnitSeconds() {
testWaitInterval(TimeUnit.SECONDS, 10, 100);
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestRegionServerSpaceQuotaManager.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestRegionServerSpaceQuotaManager.java
index 9e93e0ea7f9..d00b01cc66e 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestRegionServerSpaceQuotaManager.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestRegionServerSpaceQuotaManager.java
@@ -17,8 +17,8 @@
*/
package org.apache.hadoop.hbase.quotas;
-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 static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.mock;
@@ -27,7 +27,6 @@ import static org.mockito.Mockito.when;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.quotas.SpaceQuotaSnapshot.SpaceQuotaStatus;
import org.apache.hadoop.hbase.quotas.policies.DefaultViolationPolicyEnforcement;
@@ -37,25 +36,20 @@ import org.apache.hadoop.hbase.quotas.policies.NoWritesCompactionsViolationPolic
import org.apache.hadoop.hbase.quotas.policies.NoWritesViolationPolicyEnforcement;
import org.apache.hadoop.hbase.regionserver.RegionServerServices;
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;
/**
* Test class for {@link RegionServerSpaceQuotaManager}.
*/
-@Category(SmallTests.class)
+@Tag(SmallTests.TAG)
public class TestRegionServerSpaceQuotaManager {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestRegionServerSpaceQuotaManager.class);
-
private RegionServerSpaceQuotaManager quotaManager;
private RegionServerServices rss;
- @Before
+ @BeforeEach
public void setup() throws Exception {
quotaManager = mock(RegionServerSpaceQuotaManager.class);
rss = mock(RegionServerServices.class);
@@ -122,8 +116,8 @@ public class TestRegionServerSpaceQuotaManager {
realManager.enforceViolationPolicy(tableName, snapshot);
Map<TableName, SpaceViolationPolicyEnforcement> enforcements =
realManager.copyActiveEnforcements();
- assertTrue("Expected active enforcements to be empty, but were " + enforcements,
- enforcements.isEmpty());
+ assertTrue(enforcements.isEmpty(),
+ "Expected active enforcements to be empty, but were " + enforcements);
}
@Test
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestRegionSizeImpl.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestRegionSizeImpl.java
index 479f5324b20..6a37d5fd085 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestRegionSizeImpl.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestRegionSizeImpl.java
@@ -17,19 +17,14 @@
*/
package org.apache.hadoop.hbase.quotas;
-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.testclassification.SmallTests;
-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;
-@Category({ SmallTests.class })
+@Tag(SmallTests.TAG)
public class TestRegionSizeImpl {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestRegionSizeImpl.class);
@Test
public void testReportingWithSizeChanges() {
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestRegionSizeReportingChore.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestRegionSizeReportingChore.java
index 7aadfc40aa4..04ac6f220e8 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestRegionSizeReportingChore.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestRegionSizeReportingChore.java
@@ -17,9 +17,9 @@
*/
package org.apache.hadoop.hbase.quotas;
-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 static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -28,7 +28,6 @@ import java.util.Collections;
import java.util.HashSet;
import java.util.concurrent.TimeUnit;
import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.RegionInfo;
@@ -36,15 +35,11 @@ import org.apache.hadoop.hbase.client.RegionInfoBuilder;
import org.apache.hadoop.hbase.regionserver.HRegionServer;
import org.apache.hadoop.hbase.testclassification.SmallTests;
import org.apache.hadoop.hbase.util.Bytes;
-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;
-@Category({ SmallTests.class })
+@Tag(SmallTests.TAG)
public class TestRegionSizeReportingChore {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestRegionSizeReportingChore.class);
@Test
public void testDefaultConfigurationProperties() {
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestRegionSizeStoreImpl.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestRegionSizeStoreImpl.java
index 089443373c4..a2d2460f2a2 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestRegionSizeStoreImpl.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestRegionSizeStoreImpl.java
@@ -17,30 +17,25 @@
*/
package org.apache.hadoop.hbase.quotas;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
-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;
import org.apache.hadoop.hbase.testclassification.SmallTests;
import org.apache.hadoop.hbase.util.Bytes;
-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;
-@Category({ SmallTests.class })
+@Tag(SmallTests.TAG)
public class TestRegionSizeStoreImpl {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestRegionSizeStoreImpl.class);
private static final RegionInfo INFOA = RegionInfoBuilder.newBuilder(TableName.valueOf("TEST"))
.setStartKey(Bytes.toBytes("a")).setEndKey(Bytes.toBytes("b")).build();
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestRegionSizeUse.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestRegionSizeUse.java
index 1ab062462e1..a52b7bb359f 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestRegionSizeUse.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestRegionSizeUse.java
@@ -17,7 +17,7 @@
*/
package org.apache.hadoop.hbase.quotas;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.IOException;
import java.util.ArrayList;
@@ -25,7 +25,6 @@ import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtil;
import org.apache.hadoop.hbase.SingleProcessHBaseCluster;
import org.apache.hadoop.hbase.TableName;
@@ -40,26 +39,20 @@ import org.apache.hadoop.hbase.client.TableDescriptorBuilder;
import org.apache.hadoop.hbase.master.HMaster;
import org.apache.hadoop.hbase.testclassification.MediumTests;
import org.apache.hadoop.hbase.util.Bytes;
-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;
/**
* Test class which verifies that region sizes are reported to the master.
*/
-@Category(MediumTests.class)
+@Tag(MediumTests.TAG)
public class TestRegionSizeUse {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestRegionSizeUse.class);
-
private static final Logger LOG = LoggerFactory.getLogger(TestRegionSizeUse.class);
private static final int SIZE_PER_VALUE = 256;
private static final int NUM_SPLITS = 10;
@@ -68,10 +61,7 @@ public class TestRegionSizeUse {
private SingleProcessHBaseCluster cluster;
- @Rule
- public TestName testName = new TestName();
-
- @Before
+ @BeforeEach
public void setUp() throws Exception {
Configuration conf = TEST_UTIL.getConfiguration();
// Increase the frequency of some of the chores for responsiveness of the test
@@ -79,15 +69,15 @@ public class TestRegionSizeUse {
cluster = TEST_UTIL.startMiniCluster(2);
}
- @After
+ @AfterEach
public void tearDown() throws Exception {
TEST_UTIL.shutdownMiniCluster();
}
@Test
- public void testBasicRegionSizeReports() throws Exception {
+ public void testBasicRegionSizeReports(TestInfo testInfo) throws Exception {
final long bytesWritten = 5L * 1024L * 1024L; // 5MB
- final TableName tn = writeData(bytesWritten);
+ final TableName tn = writeData(bytesWritten, testInfo);
LOG.debug("Data was written to HBase");
final Admin admin = TEST_UTIL.getAdmin();
// Push the data to disk.
@@ -116,8 +106,8 @@ public class TestRegionSizeUse {
for (Long regionSize : regionSizes.values()) {
totalRegionSize += regionSize;
}
- assertTrue("Expected region size report to exceed " + bytesWritten + ", but was "
- + totalRegionSize + ". RegionSizes=" + regionSizes, bytesWritten < totalRegionSize);
+ assertTrue(bytesWritten < totalRegionSize, "Expected region size report to exceed "
+ + bytesWritten + ", but was " + totalRegionSize + ". RegionSizes=" + regionSizes);
}
/**
@@ -125,10 +115,10 @@ public class TestRegionSizeUse {
* @param sizeInBytes The amount of data to write in bytes.
* @return The table the data was written to
*/
- private TableName writeData(long sizeInBytes) throws IOException {
+ private TableName writeData(long sizeInBytes, TestInfo testInfo) throws IOException {
final Connection conn = TEST_UTIL.getConnection();
final Admin admin = TEST_UTIL.getAdmin();
- final TableName tn = TableName.valueOf(testName.getMethodName());
+ final TableName tn = TableName.valueOf(testInfo.getTestMethod().get().getName());
// Delete the old table
if (admin.tableExists(tn)) {
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestSnapshotQuotaObserverChore.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestSnapshotQuotaObserverChore.java
index 4851634f419..365b20d5433 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestSnapshotQuotaObserverChore.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestSnapshotQuotaObserverChore.java
@@ -17,10 +17,10 @@
*/
package org.apache.hadoop.hbase.quotas;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-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.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.IOException;
import java.util.Arrays;
@@ -35,7 +35,6 @@ import java.util.concurrent.atomic.AtomicReference;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.hbase.Cell;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtil;
import org.apache.hadoop.hbase.NamespaceDescriptor;
import org.apache.hadoop.hbase.TableName;
@@ -52,14 +51,12 @@ import org.apache.hadoop.hbase.quotas.SpaceQuotaHelperForTests.NoFilesToDischarg
import org.apache.hadoop.hbase.quotas.SpaceQuotaHelperForTests.SpaceQuotaSnapshotPredicate;
import org.apache.hadoop.hbase.regionserver.HStore;
import org.apache.hadoop.hbase.testclassification.LargeTests;
-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;
@@ -70,27 +67,21 @@ import org.apache.hbase.thirdparty.com.google.common.collect.Multimap;
/**
* Test class for the {@link SnapshotQuotaObserverChore}.
*/
-@Category(LargeTests.class)
+@Tag(LargeTests.TAG)
public class TestSnapshotQuotaObserverChore {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestSnapshotQuotaObserverChore.class);
-
private static final Logger LOG = LoggerFactory.getLogger(TestSnapshotQuotaObserverChore.class);
private static final HBaseTestingUtil TEST_UTIL = new HBaseTestingUtil();
private static final AtomicLong COUNTER = new AtomicLong();
- @Rule
- public TestName testName = new TestName();
-
private Connection conn;
private Admin admin;
private SpaceQuotaHelperForTests helper;
private HMaster master;
private SnapshotQuotaObserverChore testChore;
+ private String testName;
- @BeforeClass
+ @BeforeAll
public static void setUp() throws Exception {
Configuration conf = TEST_UTIL.getConfiguration();
SpaceQuotaHelperForTests.updateConfigForQuotas(conf);
@@ -99,16 +90,17 @@ public class TestSnapshotQuotaObserverChore {
TEST_UTIL.startMiniCluster(1);
}
- @AfterClass
+ @AfterAll
public static void tearDown() throws Exception {
TEST_UTIL.shutdownMiniCluster();
}
- @Before
- public void setup() throws Exception {
+ @BeforeEach
+ public void setup(TestInfo testInfo) throws Exception {
+ testName = testInfo.getTestMethod().get().getName();
conn = TEST_UTIL.getConnection();
admin = TEST_UTIL.getAdmin();
- helper = new SpaceQuotaHelperForTests(TEST_UTIL, testName, COUNTER);
+ helper = new SpaceQuotaHelperForTests(TEST_UTIL, () -> testName, COUNTER);
master = TEST_UTIL.getHBaseCluster().getMaster();
helper.removeAllQuotas(conn);
testChore = new SnapshotQuotaObserverChore(TEST_UTIL.getConnection(),
@@ -228,8 +220,8 @@ public class TestSnapshotQuotaObserverChore {
// Get the snapshots
Multimap<TableName, String> snapshotsToCompute = testChore.getSnapshotsToComputeSize();
- assertEquals("Expected to see the single snapshot: " + snapshotsToCompute, 1,
- snapshotsToCompute.size());
+ assertEquals(1, snapshotsToCompute.size(),
+ "Expected to see the single snapshot: " + snapshotsToCompute);
// Get the size of our snapshot
Map<String, Long> namespaceSnapshotSizes = testChore.computeSnapshotSizes(snapshotsToCompute);
@@ -263,8 +255,8 @@ public class TestSnapshotQuotaObserverChore {
// Still should see only one snapshot
snapshotsToCompute = testChore.getSnapshotsToComputeSize();
- assertEquals("Expected to see the single snapshot: " + snapshotsToCompute, 1,
- snapshotsToCompute.size());
+ assertEquals(1, snapshotsToCompute.size(),
+ "Expected to see the single snapshot: " + snapshotsToCompute);
namespaceSnapshotSizes = testChore.computeSnapshotSizes(snapshotsToCompute);
assertEquals(1, namespaceSnapshotSizes.size());
size = namespaceSnapshotSizes.get(tn1.getNamespaceAsString());
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestSpaceQuotaBasicFunctioning.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestSpaceQuotaBasicFunctioning.java
index 4aeba39625c..c9d56c6715a 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestSpaceQuotaBasicFunctioning.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestSpaceQuotaBasicFunctioning.java
@@ -17,16 +17,15 @@
*/
package org.apache.hadoop.hbase.quotas;
-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.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicLong;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.DoNotRetryIOException;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtil;
import org.apache.hadoop.hbase.MetaTableAccessor;
import org.apache.hadoop.hbase.TableName;
@@ -43,48 +42,40 @@ import org.apache.hadoop.hbase.security.AccessDeniedException;
import org.apache.hadoop.hbase.testclassification.LargeTests;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.util.StringUtils;
-import org.junit.AfterClass;
-import org.junit.Assert;
-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;
-@Category(LargeTests.class)
+@Tag(LargeTests.TAG)
public class TestSpaceQuotaBasicFunctioning {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestSpaceQuotaBasicFunctioning.class);
-
private static final Logger LOG = LoggerFactory.getLogger(TestSpaceQuotaBasicFunctioning.class);
private static final HBaseTestingUtil TEST_UTIL = new HBaseTestingUtil();
private static final int NUM_RETRIES = 10;
- @Rule
- public TestName testName = new TestName();
private SpaceQuotaHelperForTests helper;
- @BeforeClass
+ @BeforeAll
public static void setUp() throws Exception {
Configuration conf = TEST_UTIL.getConfiguration();
SpaceQuotaHelperForTests.updateConfigForQuotas(conf);
TEST_UTIL.startMiniCluster(1);
}
- @AfterClass
+ @AfterAll
public static void tearDown() throws Exception {
TEST_UTIL.shutdownMiniCluster();
}
- @Before
- public void removeAllQuotas() throws Exception {
- helper = new SpaceQuotaHelperForTests(TEST_UTIL, testName, new AtomicLong(0));
+ @BeforeEach
+ public void removeAllQuotas(TestInfo testInfo) throws Exception {
+ helper = new SpaceQuotaHelperForTests(TEST_UTIL, () -> testInfo.getTestMethod().get().getName(),
+ new AtomicLong(0));
helper.removeAllQuotas();
}
@@ -193,15 +184,14 @@ public class TestSpaceQuotaBasicFunctioning {
Thread.sleep(2000);
}
}
- assertFalse(tn + " is still enabled but it should be disabled", admin.isTableEnabled(tn));
+ assertFalse(admin.isTableEnabled(tn), tn + " is still enabled but it should be disabled");
try {
admin.enableTable(tn);
} catch (AccessDeniedException e) {
String exceptionContents = StringUtils.stringifyException(e);
final String expectedText = "violated space quota";
- assertTrue(
- "Expected the exception to contain " + expectedText + ", but was: " + exceptionContents,
- exceptionContents.contains(expectedText));
+ assertTrue(exceptionContents.contains(expectedText),
+ "Expected the exception to contain " + expectedText + ", but was: " + exceptionContents);
}
}
@@ -255,6 +245,6 @@ public class TestSpaceQuotaBasicFunctioning {
// It should be present after retention period expired.
final long regionSizes = quotaManager.snapshotRegionSizes().keySet().stream()
.filter(k -> k.getTable().equals(tableName)).count();
- Assert.assertTrue(regionSizes > 0);
+ assertTrue(regionSizes > 0);
}
}
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestSpaceQuotaDropTable.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestSpaceQuotaDropTable.java
index 91f3be9b2a6..42e3b5bd2f5 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestSpaceQuotaDropTable.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestSpaceQuotaDropTable.java
@@ -17,11 +17,13 @@
*/
package org.apache.hadoop.hbase.quotas;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
+
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicLong;
import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtil;
import org.apache.hadoop.hbase.MetaTableAccessor;
import org.apache.hadoop.hbase.TableName;
@@ -31,47 +33,39 @@ import org.apache.hadoop.hbase.client.RegionInfo;
import org.apache.hadoop.hbase.master.HMaster;
import org.apache.hadoop.hbase.testclassification.LargeTests;
import org.apache.hadoop.hbase.util.Bytes;
-import org.junit.AfterClass;
-import org.junit.Assert;
-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;
-@Category(LargeTests.class)
+@Tag(LargeTests.TAG)
public class TestSpaceQuotaDropTable {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestSpaceQuotaDropTable.class);
-
private static final Logger LOG = LoggerFactory.getLogger(TestSpaceQuotaDropTable.class);
private static final HBaseTestingUtil TEST_UTIL = new HBaseTestingUtil();
- @Rule
- public TestName testName = new TestName();
private SpaceQuotaHelperForTests helper;
- @BeforeClass
+ @BeforeAll
public static void setUp() throws Exception {
Configuration conf = TEST_UTIL.getConfiguration();
SpaceQuotaHelperForTests.updateConfigForQuotas(conf);
TEST_UTIL.startMiniCluster(1);
}
- @AfterClass
+ @AfterAll
public static void tearDown() throws Exception {
TEST_UTIL.shutdownMiniCluster();
}
- @Before
- public void removeAllQuotas() throws Exception {
- helper = new SpaceQuotaHelperForTests(TEST_UTIL, testName, new AtomicLong(0));
+ @BeforeEach
+ public void removeAllQuotas(TestInfo testInfo) throws Exception {
+ helper = new SpaceQuotaHelperForTests(TEST_UTIL, () -> testInfo.getTestMethod().get().getName(),
+ new AtomicLong(0));
helper.removeAllQuotas();
}
@@ -126,7 +120,7 @@ public class TestSpaceQuotaDropTable {
}
// regionSize report for the given table should be present before dropping the table.
- Assert.assertTrue(hasRegionSize);
+ assertTrue(hasRegionSize);
// drop the table
TEST_UTIL.getAdmin().disableTable(tn);
@@ -135,7 +129,7 @@ public class TestSpaceQuotaDropTable {
// check if deleted table region report still present in the map.
for (Map.Entry<RegionInfo, Long> entry : quotaManager.snapshotRegionSizes().entrySet()) {
if (entry.getKey().getTable().equals(tn)) {
- Assert.fail("Dropped table regionSizes were not deleted during the drop command");
+ fail("Dropped table regionSizes were not deleted during the drop command");
}
}
}
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestSpaceQuotaIncrease.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestSpaceQuotaIncrease.java
index 261d6c9d6f9..1bd9ebf8d0d 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestSpaceQuotaIncrease.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestSpaceQuotaIncrease.java
@@ -19,49 +19,41 @@ package org.apache.hadoop.hbase.quotas;
import java.util.concurrent.atomic.AtomicLong;
import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtil;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.Put;
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;
-
-@Category(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.Test;
+import org.junit.jupiter.api.TestInfo;
+
+@Tag(LargeTests.TAG)
public class TestSpaceQuotaIncrease {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestSpaceQuotaIncrease.class);
-
private static final HBaseTestingUtil TEST_UTIL = new HBaseTestingUtil();
- @Rule
- public TestName testName = new TestName();
private SpaceQuotaHelperForTests helper;
- @BeforeClass
+ @BeforeAll
public static void setUp() throws Exception {
Configuration conf = TEST_UTIL.getConfiguration();
SpaceQuotaHelperForTests.updateConfigForQuotas(conf);
TEST_UTIL.startMiniCluster(1);
}
- @AfterClass
+ @AfterAll
public static void tearDown() throws Exception {
TEST_UTIL.shutdownMiniCluster();
}
- @Before
- public void removeAllQuotas() throws Exception {
- helper = new SpaceQuotaHelperForTests(TEST_UTIL, testName, new AtomicLong(0));
+ @BeforeEach
+ public void removeAllQuotas(TestInfo testInfo) throws Exception {
+ helper = new SpaceQuotaHelperForTests(TEST_UTIL, () -> testInfo.getTestMethod().get().getName(),
+ new AtomicLong(0));
helper.removeAllQuotas();
}
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestSpaceQuotaOnBulkLoad.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestSpaceQuotaOnBulkLoad.java
index 7ae661d8dcd..64c1feda9c3 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestSpaceQuotaOnBulkLoad.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestSpaceQuotaOnBulkLoad.java
@@ -19,10 +19,10 @@ package org.apache.hadoop.hbase.quotas;
import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-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.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
import java.io.IOException;
import java.util.HashMap;
@@ -33,7 +33,6 @@ import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileStatus;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtil;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.Put;
@@ -47,46 +46,41 @@ import org.apache.hadoop.hbase.regionserver.HRegionServer;
import org.apache.hadoop.hbase.testclassification.MediumTests;
import org.apache.hadoop.hbase.tool.BulkLoadHFiles;
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;
-@Category(MediumTests.class)
+@Tag(MediumTests.TAG)
public class TestSpaceQuotaOnBulkLoad {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestSpaceQuotaOnBulkLoad.class);
-
private static final Logger LOG = LoggerFactory.getLogger(TestSpaceQuotaOnBulkLoad.class);
private static final HBaseTestingUtil TEST_UTIL = new HBaseTestingUtil();
- @Rule
- public TestName testName = new TestName();
private SpaceQuotaHelperForTests helper;
+ private TestInfo testInfo;
- @BeforeClass
+ @BeforeAll
public static void setUp() throws Exception {
Configuration conf = TEST_UTIL.getConfiguration();
SpaceQuotaHelperForTests.updateConfigForQuotas(conf);
TEST_UTIL.startMiniCluster(1);
}
- @AfterClass
+ @AfterAll
public static void tearDown() throws Exception {
TEST_UTIL.shutdownMiniCluster();
}
- @Before
- public void removeAllQuotas() throws Exception {
- helper = new SpaceQuotaHelperForTests(TEST_UTIL, testName, new AtomicLong(0));
+ @BeforeEach
+ public void removeAllQuotas(TestInfo testInfo) throws Exception {
+ this.testInfo = testInfo;
+ helper = new SpaceQuotaHelperForTests(TEST_UTIL, () -> testInfo.getTestMethod().get().getName(),
+ new AtomicLong(0));
helper.removeAllQuotas();
}
@@ -143,18 +137,17 @@ public class TestSpaceQuotaOnBulkLoad {
// We would also not have a "real" policy in violation
ActivePolicyEnforcement activePolicies = spaceQuotaManager.getActiveEnforcements();
SpaceViolationPolicyEnforcement enforcement = activePolicies.getPolicyEnforcement(tn);
- assertTrue("Expected to find Noop policy, but got " + enforcement.getClass().getSimpleName(),
- enforcement instanceof DefaultViolationPolicyEnforcement);
+ assertTrue(enforcement instanceof DefaultViolationPolicyEnforcement,
+ "Expected to find Noop policy, but got " + enforcement.getClass().getSimpleName());
// Should generate two files, each of which is over 25KB each
Map<byte[], List<Path>> family2Files = helper.generateFileToLoad(tn, 2, 525);
FileSystem fs = TEST_UTIL.getTestFileSystem();
- FileStatus[] files =
- fs.listStatus(new Path(fs.getHomeDirectory(), testName.getMethodName() + "_files"));
+ FileStatus[] files = fs.listStatus(
+ new Path(fs.getHomeDirectory(), testInfo.getTestMethod().get().getName() + "_files"));
for (FileStatus file : files) {
- assertTrue("Expected the file, " + file.getPath()
- + ", length to be larger than 25KB, but was " + file.getLen(),
- file.getLen() > 25 * SpaceQuotaHelperForTests.ONE_KILOBYTE);
+ assertTrue(file.getLen() > 25 * SpaceQuotaHelperForTests.ONE_KILOBYTE, "Expected the file, "
+ + file.getPath() + ", length to be larger than 25KB, but was " + file.getLen());
LOG.debug(file.getPath() + " -> " + file.getLen() + "B");
}
@@ -171,7 +164,7 @@ public class TestSpaceQuotaOnBulkLoad {
Table table = TEST_UTIL.getConnection().getTable(tn);
ResultScanner scanner = table.getScanner(new Scan());
try {
- assertNull("Expected no results", scanner.next());
+ assertNull(scanner.next(), "Expected no results");
} finally {
scanner.close();
}
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestSpaceQuotaOnNonExistingTables.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestSpaceQuotaOnNonExistingTables.java
index bb38893fa68..23db2bdf1a3 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestSpaceQuotaOnNonExistingTables.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestSpaceQuotaOnNonExistingTables.java
@@ -19,49 +19,41 @@ package org.apache.hadoop.hbase.quotas;
import java.util.concurrent.atomic.AtomicLong;
import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtil;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.testclassification.SmallTests;
-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;
-@Category(SmallTests.class)
+@Tag(SmallTests.TAG)
public class TestSpaceQuotaOnNonExistingTables {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestSpaceQuotaOnNonExistingTables.class);
-
private static final HBaseTestingUtil TEST_UTIL = new HBaseTestingUtil();
private final TableName NON_EXISTENT_TABLE = TableName.valueOf("NON_EXISTENT_TABLE");
- @Rule
- public TestName testName = new TestName();
private SpaceQuotaHelperForTests helper;
- @BeforeClass
+ @BeforeAll
public static void setUp() throws Exception {
Configuration conf = TEST_UTIL.getConfiguration();
SpaceQuotaHelperForTests.updateConfigForQuotas(conf);
TEST_UTIL.startMiniCluster(1);
}
- @AfterClass
+ @AfterAll
public static void tearDown() throws Exception {
TEST_UTIL.shutdownMiniCluster();
}
- @Before
- public void removeAllQuotas() throws Exception {
- helper = new SpaceQuotaHelperForTests(TEST_UTIL, testName, new AtomicLong(0));
+ @BeforeEach
+ public void removeAllQuotas(TestInfo testInfo) throws Exception {
+ helper = new SpaceQuotaHelperForTests(TEST_UTIL, () -> testInfo.getTestMethod().get().getName(),
+ new AtomicLong(0));
helper.removeAllQuotas();
}
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestSpaceQuotaRemoval.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestSpaceQuotaRemoval.java
index aff059fd2e6..3e30fc350d9 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestSpaceQuotaRemoval.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestSpaceQuotaRemoval.java
@@ -19,50 +19,42 @@ package org.apache.hadoop.hbase.quotas;
import java.util.concurrent.atomic.AtomicLong;
import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtil;
import org.apache.hadoop.hbase.NamespaceDescriptor;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.Put;
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;
-
-@Category(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.Test;
+import org.junit.jupiter.api.TestInfo;
+
+@Tag(LargeTests.TAG)
public class TestSpaceQuotaRemoval {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestSpaceQuotaRemoval.class);
-
private static final HBaseTestingUtil TEST_UTIL = new HBaseTestingUtil();
- @Rule
- public TestName testName = new TestName();
private SpaceQuotaHelperForTests helper;
- @BeforeClass
+ @BeforeAll
public static void setUp() throws Exception {
Configuration conf = TEST_UTIL.getConfiguration();
SpaceQuotaHelperForTests.updateConfigForQuotas(conf);
TEST_UTIL.startMiniCluster(1);
}
- @AfterClass
+ @AfterAll
public static void tearDown() throws Exception {
TEST_UTIL.shutdownMiniCluster();
}
- @Before
- public void removeAllQuotas() throws Exception {
- helper = new SpaceQuotaHelperForTests(TEST_UTIL, testName, new AtomicLong(0));
+ @BeforeEach
+ public void removeAllQuotas(TestInfo testInfo) throws Exception {
+ helper = new SpaceQuotaHelperForTests(TEST_UTIL, () -> testInfo.getTestMethod().get().getName(),
+ new AtomicLong(0));
helper.removeAllQuotas();
}
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestSpaceQuotaSwitchPolicies.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestSpaceQuotaSwitchPolicies.java
index e40083f64fc..6a69832b83c 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestSpaceQuotaSwitchPolicies.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestSpaceQuotaSwitchPolicies.java
@@ -19,49 +19,41 @@ package org.apache.hadoop.hbase.quotas;
import java.util.concurrent.atomic.AtomicLong;
import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtil;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.Put;
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;
-
-@Category(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.Test;
+import org.junit.jupiter.api.TestInfo;
+
+@Tag(LargeTests.TAG)
public class TestSpaceQuotaSwitchPolicies {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestSpaceQuotaSwitchPolicies.class);
-
private static final HBaseTestingUtil TEST_UTIL = new HBaseTestingUtil();
- @Rule
- public TestName testName = new TestName();
private SpaceQuotaHelperForTests helper;
- @BeforeClass
+ @BeforeAll
public static void setUp() throws Exception {
Configuration conf = TEST_UTIL.getConfiguration();
SpaceQuotaHelperForTests.updateConfigForQuotas(conf);
TEST_UTIL.startMiniCluster(1);
}
- @AfterClass
+ @AfterAll
public static void tearDown() throws Exception {
TEST_UTIL.shutdownMiniCluster();
}
- @Before
- public void removeAllQuotas() throws Exception {
- helper = new SpaceQuotaHelperForTests(TEST_UTIL, testName, new AtomicLong(0));
+ @BeforeEach
+ public void removeAllQuotas(TestInfo testInfo) throws Exception {
+ helper = new SpaceQuotaHelperForTests(TEST_UTIL, () -> testInfo.getTestMethod().get().getName(),
+ new AtomicLong(0));
helper.removeAllQuotas();
}
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestSpaceQuotaViolationPolicyRefresherChore.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestSpaceQuotaViolationPolicyRefresherChore.java
index a827470a00b..94a4665c17f 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestSpaceQuotaViolationPolicyRefresherChore.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestSpaceQuotaViolationPolicyRefresherChore.java
@@ -18,7 +18,7 @@
package org.apache.hadoop.hbase.quotas;
import static org.apache.hadoop.hbase.util.Bytes.toBytes;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.fail;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doCallRealMethod;
import static org.mockito.Mockito.mock;
@@ -35,7 +35,6 @@ import java.util.Map;
import java.util.Map.Entry;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.Cell;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.KeyValue;
import org.apache.hadoop.hbase.TableName;
@@ -47,28 +46,23 @@ import org.apache.hadoop.hbase.client.Table;
import org.apache.hadoop.hbase.quotas.SpaceQuotaSnapshot.SpaceQuotaStatus;
import org.apache.hadoop.hbase.regionserver.RegionServerServices;
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;
/**
* Test class for {@link SpaceQuotaRefresherChore}.
*/
-@Category(SmallTests.class)
+@Tag(SmallTests.TAG)
public class TestSpaceQuotaViolationPolicyRefresherChore {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestSpaceQuotaViolationPolicyRefresherChore.class);
-
private RegionServerSpaceQuotaManager manager;
private RegionServerServices rss;
private SpaceQuotaRefresherChore chore;
private Configuration conf;
private Connection conn;
- @Before
+ @BeforeEach
public void setup() throws IOException {
conf = HBaseConfiguration.create();
rss = mock(RegionServerServices.class);
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestSpaceQuotasWithRegionReplicas.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestSpaceQuotasWithRegionReplicas.java
index bd2cd5506d0..6507b7b5159 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestSpaceQuotasWithRegionReplicas.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestSpaceQuotasWithRegionReplicas.java
@@ -19,54 +19,46 @@ package org.apache.hadoop.hbase.quotas;
import java.util.concurrent.atomic.AtomicLong;
import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtil;
import org.apache.hadoop.hbase.NamespaceDescriptor;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.Put;
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;
-@Category(LargeTests.class)
+@Tag(LargeTests.TAG)
public class TestSpaceQuotasWithRegionReplicas {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestSpaceQuotasWithRegionReplicas.class);
-
private static final Logger LOG =
LoggerFactory.getLogger(TestSpaceQuotasWithRegionReplicas.class);
private static final HBaseTestingUtil TEST_UTIL = new HBaseTestingUtil();
- @Rule
- public TestName testName = new TestName();
private SpaceQuotaHelperForTests helper;
- @BeforeClass
+ @BeforeAll
public static void setUp() throws Exception {
Configuration conf = TEST_UTIL.getConfiguration();
SpaceQuotaHelperForTests.updateConfigForQuotas(conf);
TEST_UTIL.startMiniCluster(1);
}
- @AfterClass
+ @AfterAll
public static void tearDown() throws Exception {
TEST_UTIL.shutdownMiniCluster();
}
- @Before
- public void removeAllQuotas() throws Exception {
- helper = new SpaceQuotaHelperForTests(TEST_UTIL, testName, new AtomicLong(0));
+ @BeforeEach
+ public void removeAllQuotas(TestInfo testInfo) throws Exception {
+ helper = new SpaceQuotaHelperForTests(TEST_UTIL, () -> testInfo.getTestMethod().get().getName(),
+ new AtomicLong(0));
helper.removeAllQuotas();
}
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestSpaceQuotasWithSnapshots.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestSpaceQuotasWithSnapshots.java
index 11d2199d021..7887334e3c7 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestSpaceQuotasWithSnapshots.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestSpaceQuotasWithSnapshots.java
@@ -17,9 +17,9 @@
*/
package org.apache.hadoop.hbase.quotas;
-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.io.IOException;
import java.util.Map;
@@ -28,7 +28,6 @@ import java.util.concurrent.atomic.AtomicLong;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.CellScanner;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtil;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.Waiter;
@@ -42,14 +41,12 @@ import org.apache.hadoop.hbase.client.SnapshotType;
import org.apache.hadoop.hbase.client.Table;
import org.apache.hadoop.hbase.quotas.SpaceQuotaHelperForTests.SpaceQuotaSnapshotPredicate;
import org.apache.hadoop.hbase.testclassification.LargeTests;
-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;
@@ -61,26 +58,20 @@ import org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos;
/**
* Test class to exercise the inclusion of snapshots in space quotas
*/
-@Category({ LargeTests.class })
+@Tag(LargeTests.TAG)
public class TestSpaceQuotasWithSnapshots {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestSpaceQuotasWithSnapshots.class);
-
private static final Logger LOG = LoggerFactory.getLogger(TestSpaceQuotasWithSnapshots.class);
private static final HBaseTestingUtil TEST_UTIL = new HBaseTestingUtil();
// Global for all tests in the class
private static final AtomicLong COUNTER = new AtomicLong(0);
private static final long FUDGE_FOR_TABLE_SIZE = 500L * SpaceQuotaHelperForTests.ONE_KILOBYTE;
- @Rule
- public TestName testName = new TestName();
private SpaceQuotaHelperForTests helper;
private Connection conn;
private Admin admin;
- @BeforeClass
+ @BeforeAll
public static void setUp() throws Exception {
Configuration conf = TEST_UTIL.getConfiguration();
SpaceQuotaHelperForTests.updateConfigForQuotas(conf);
@@ -94,14 +85,15 @@ public class TestSpaceQuotasWithSnapshots {
});
}
- @AfterClass
+ @AfterAll
public static void tearDown() throws Exception {
TEST_UTIL.shutdownMiniCluster();
}
- @Before
- public void removeAllQuotas() throws Exception {
- helper = new SpaceQuotaHelperForTests(TEST_UTIL, testName, COUNTER);
+ @BeforeEach
+ public void removeAllQuotas(TestInfo testInfo) throws Exception {
+ helper = new SpaceQuotaHelperForTests(TEST_UTIL, () -> testInfo.getTestMethod().get().getName(),
+ COUNTER);
conn = TEST_UTIL.getConnection();
admin = TEST_UTIL.getAdmin();
}
@@ -164,7 +156,7 @@ public class TestSpaceQuotasWithSnapshots {
// Make sure we see the "final" new size for the table, not some intermediate
waitForStableRegionSizeReport(conn, tn);
final long finalSize = getRegionSizeReportForTable(conn, tn);
- assertTrue("Table data size must be greater than zero", finalSize > 0);
+ assertTrue(finalSize > 0, "Table data size must be greater than zero");
LOG.info("Last seen size: " + finalSize);
// Make sure the QuotaObserverChore has time to reflect the new region size reports
@@ -193,9 +185,9 @@ public class TestSpaceQuotasWithSnapshots {
Map<String, Long> snapshotSizes = QuotaTableUtil.getObservedSnapshotSizes(conn);
Long size = snapshotSizes.get(snapshot1);
- assertNotNull("Did not observe the size of the snapshot", size);
- assertEquals("The recorded size of the HBase snapshot was not the size we expected",
- actualInitialSize, size.longValue());
+ assertNotNull(size, "Did not observe the size of the snapshot");
+ assertEquals(actualInitialSize, size.longValue(),
+ "The recorded size of the HBase snapshot was not the size we expected");
}
@Test
@@ -263,7 +255,7 @@ public class TestSpaceQuotasWithSnapshots {
// Make sure we see the "final" new size for the table, not some intermediate
waitForStableRegionSizeReport(conn, tn);
final long finalSize = getRegionSizeReportForTable(conn, tn);
- assertTrue("Table data size must be greater than zero", finalSize > 0);
+ assertTrue(finalSize > 0, "Table data size must be greater than zero");
LOG.info("Final observed size of table: " + finalSize);
// Make sure the QuotaObserverChore has time to reflect the new region size reports
@@ -292,9 +284,9 @@ public class TestSpaceQuotasWithSnapshots {
Map<String, Long> snapshotSizes = QuotaTableUtil.getObservedSnapshotSizes(conn);
Long size = snapshotSizes.get(snapshot1);
- assertNotNull("Did not observe the size of the snapshot", size);
- assertEquals("The recorded size of the HBase snapshot was not the size we expected",
- actualInitialSize, size.longValue());
+ assertNotNull(size, "Did not observe the size of the snapshot");
+ assertEquals(actualInitialSize, size.longValue(),
+ "The recorded size of the HBase snapshot was not the size we expected");
}
@Test
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestSuperUserQuotaPermissions.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestSuperUserQuotaPermissions.java
index 4444e38e56a..25c85f14832 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestSuperUserQuotaPermissions.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestSuperUserQuotaPermissions.java
@@ -17,9 +17,9 @@
*/
package org.apache.hadoop.hbase.quotas;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.fail;
import java.io.IOException;
import java.security.PrivilegedExceptionAction;
@@ -28,7 +28,6 @@ import java.util.concurrent.Callable;
import java.util.concurrent.atomic.AtomicLong;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.DoNotRetryIOException;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtil;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.Waiter;
@@ -44,27 +43,21 @@ import org.apache.hadoop.hbase.security.access.Permission.Action;
import org.apache.hadoop.hbase.testclassification.MediumTests;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.security.UserGroupInformation;
-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;
/**
* Test class to verify that the HBase superuser can override quotas.
*/
-@Category(MediumTests.class)
+@Tag(MediumTests.TAG)
public class TestSuperUserQuotaPermissions {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestSuperUserQuotaPermissions.class);
-
private static final Logger LOG = LoggerFactory.getLogger(TestSuperUserQuotaPermissions.class);
private static final HBaseTestingUtil TEST_UTIL = new HBaseTestingUtil();
// Default to the user running the tests
@@ -76,11 +69,9 @@ public class TestSuperUserQuotaPermissions {
UserGroupInformation.createUserForTesting(REGULARUSER_NAME, new String[0]);
private static final AtomicLong COUNTER = new AtomicLong(0);
- @Rule
- public TestName testName = new TestName();
private SpaceQuotaHelperForTests helper;
- @BeforeClass
+ @BeforeAll
public static void setupMiniCluster() throws Exception {
Configuration conf = TEST_UTIL.getConfiguration();
// Increase the frequency of some of the chores for responsiveness of the test
@@ -96,16 +87,17 @@ public class TestSuperUserQuotaPermissions {
TEST_UTIL.startMiniCluster(1);
}
- @AfterClass
+ @AfterAll
public static void tearDown() throws Exception {
TEST_UTIL.shutdownMiniCluster();
}
- @Before
- public void removeAllQuotas() throws Exception {
+ @BeforeEach
+ public void removeAllQuotas(TestInfo testInfo) throws Exception {
final Connection conn = TEST_UTIL.getConnection();
if (helper == null) {
- helper = new SpaceQuotaHelperForTests(TEST_UTIL, testName, COUNTER);
+ helper = new SpaceQuotaHelperForTests(TEST_UTIL,
+ () -> testInfo.getTestMethod().get().getName(), COUNTER);
}
// Wait for the quota table to be created
if (!conn.getAdmin().tableExists(QuotaUtil.QUOTA_TABLE_NAME)) {
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestTableQuotaViolationStore.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestTableQuotaViolationStore.java
index ca34410bdad..ac7e126723d 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestTableQuotaViolationStore.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestTableQuotaViolationStore.java
@@ -18,8 +18,8 @@
package org.apache.hadoop.hbase.quotas;
import static org.apache.hbase.thirdparty.com.google.common.collect.Iterables.size;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -29,7 +29,6 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.atomic.AtomicReference;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.Connection;
import org.apache.hadoop.hbase.client.RegionInfo;
@@ -41,10 +40,9 @@ import org.apache.hadoop.hbase.client.Table;
import org.apache.hadoop.hbase.quotas.SpaceQuotaSnapshot.SpaceQuotaStatus;
import org.apache.hadoop.hbase.testclassification.SmallTests;
import org.apache.hadoop.hbase.util.Bytes;
-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;
@@ -56,13 +54,9 @@ import org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.SpaceQuota;
/**
* Test class for {@link TableQuotaSnapshotStore}.
*/
-@Category(SmallTests.class)
+@Tag(SmallTests.TAG)
public class TestTableQuotaViolationStore {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestTableQuotaViolationStore.class);
-
private static final long ONE_MEGABYTE = 1024L * 1024L;
private Connection conn;
@@ -70,7 +64,7 @@ public class TestTableQuotaViolationStore {
private Map<RegionInfo, Long> regionReports;
private TableQuotaSnapshotStore store;
- @Before
+ @BeforeEach
public void setup() {
conn = mock(Connection.class);
chore = mock(QuotaObserverChore.class);
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestTableSpaceQuotaViolationNotifier.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestTableSpaceQuotaViolationNotifier.java
index d7de58786ad..6f3117a19ca 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestTableSpaceQuotaViolationNotifier.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestTableSpaceQuotaViolationNotifier.java
@@ -28,7 +28,6 @@ import java.util.Map.Entry;
import java.util.NavigableMap;
import java.util.Objects;
import org.apache.hadoop.hbase.Cell;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.Connection;
import org.apache.hadoop.hbase.client.Mutation;
@@ -37,10 +36,9 @@ import org.apache.hadoop.hbase.client.Table;
import org.apache.hadoop.hbase.quotas.SpaceQuotaSnapshot.SpaceQuotaStatus;
import org.apache.hadoop.hbase.testclassification.SmallTests;
import org.apache.hadoop.hbase.util.Bytes;
-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.ArgumentMatcher;
import org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos;
@@ -48,17 +46,13 @@ import org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos;
/**
* Test case for {@link TableSpaceQuotaSnapshotNotifier}.
*/
-@Category(SmallTests.class)
+@Tag(SmallTests.TAG)
public class TestTableSpaceQuotaViolationNotifier {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestTableSpaceQuotaViolationNotifier.class);
-
private TableSpaceQuotaSnapshotNotifier notifier;
private Connection conn;
- @Before
+ @BeforeEach
public void setup() throws Exception {
notifier = new TableSpaceQuotaSnapshotNotifier();
conn = mock(Connection.class);
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestTablesWithQuotas.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestTablesWithQuotas.java
index 3fb69149817..83b19a45b4b 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestTablesWithQuotas.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestTablesWithQuotas.java
@@ -17,9 +17,9 @@
*/
package org.apache.hadoop.hbase.quotas;
-import static org.junit.Assert.assertEquals;
-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.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -31,7 +31,6 @@ import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.Admin;
@@ -39,27 +38,22 @@ import org.apache.hadoop.hbase.client.Connection;
import org.apache.hadoop.hbase.client.RegionInfo;
import org.apache.hadoop.hbase.quotas.QuotaObserverChore.TablesWithQuotas;
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.apache.hbase.thirdparty.com.google.common.collect.Multimap;
/**
* Non-HBase cluster unit tests for {@link TablesWithQuotas}.
*/
-@Category(SmallTests.class)
+@Tag(SmallTests.TAG)
public class TestTablesWithQuotas {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestTablesWithQuotas.class);
-
private Connection conn;
private Configuration conf;
- @Before
+ @BeforeEach
public void setup() throws Exception {
conn = mock(Connection.class);
conf = HBaseConfiguration.create();
@@ -162,13 +156,16 @@ public class TestTablesWithQuotas {
Multimap<String, TableName> tablesByNamespace = tables.getTablesByNamespace();
Collection<TableName> tablesInNs = tablesByNamespace.get("ns1");
assertEquals(3, tablesInNs.size());
- assertTrue("Unexpected results for ns1: " + tablesInNs,
+ assertTrue(
tablesInNs.containsAll(Arrays.asList(TableName.valueOf("ns1", "t1"),
- TableName.valueOf("ns1", "t2"), TableName.valueOf("ns1", "t3"))));
+ TableName.valueOf("ns1", "t2"), TableName.valueOf("ns1", "t3"))),
+ "Unexpected results for ns1: " + tablesInNs);
tablesInNs = tablesByNamespace.get("ns2");
assertEquals(2, tablesInNs.size());
- assertTrue("Unexpected results for ns2: " + tablesInNs, tablesInNs
- .containsAll(Arrays.asList(TableName.valueOf("ns2", "t1"), TableName.valueOf("ns2", "t2"))));
+ assertTrue(
+ tablesInNs
+ .containsAll(Arrays.asList(TableName.valueOf("ns2", "t1"), TableName.valueOf("ns2", "t2"))),
+ "Unexpected results for ns2: " + tablesInNs);
}
@Test
@@ -196,7 +193,7 @@ public class TestTablesWithQuotas {
tables.filterInsufficientlyReportedTables(store);
final Set<TableName> tablesWithQuotas = tables.getTableQuotaTables();
- assertTrue("Expected to find no tables, but found " + tablesWithQuotas,
- tablesWithQuotas.isEmpty());
+ assertTrue(tablesWithQuotas.isEmpty(),
+ "Expected to find no tables, but found " + tablesWithQuotas);
}
}
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/policies/TestBulkLoadCheckingViolationPolicyEnforcement.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/policies/TestBulkLoadCheckingViolationPolicyEnforcement.java
index 11458a4f564..ac481897120 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/policies/TestBulkLoadCheckingViolationPolicyEnforcement.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/policies/TestBulkLoadCheckingViolationPolicyEnforcement.java
@@ -17,6 +17,7 @@
*/
package org.apache.hadoop.hbase.quotas.policies;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -25,7 +26,6 @@ import java.util.List;
import org.apache.hadoop.fs.FileStatus;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.quotas.SpaceLimitingException;
import org.apache.hadoop.hbase.quotas.SpaceQuotaSnapshot;
@@ -33,24 +33,19 @@ import org.apache.hadoop.hbase.quotas.SpaceQuotaSnapshot.SpaceQuotaStatus;
import org.apache.hadoop.hbase.quotas.SpaceViolationPolicyEnforcement;
import org.apache.hadoop.hbase.regionserver.RegionServerServices;
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;
-@Category(SmallTests.class)
+@Tag(SmallTests.TAG)
public class TestBulkLoadCheckingViolationPolicyEnforcement {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestBulkLoadCheckingViolationPolicyEnforcement.class);
-
FileSystem fs;
RegionServerServices rss;
TableName tableName;
SpaceViolationPolicyEnforcement policy;
- @Before
+ @BeforeEach
public void setup() {
fs = mock(FileSystem.class);
rss = mock(RegionServerServices.class);
@@ -82,7 +77,7 @@ public class TestBulkLoadCheckingViolationPolicyEnforcement {
policy.computeBulkLoadSize(fs, paths);
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testFileIsNotAFile() throws Exception {
final List<String> paths = new ArrayList<>();
String path = "/1";
@@ -99,10 +94,10 @@ public class TestBulkLoadCheckingViolationPolicyEnforcement {
policy.initialize(rss, tableName, snapshot);
// If the file to bulk load isn't a file, this should throw an exception
- policy.computeBulkLoadSize(fs, paths);
+ assertThrows(IllegalArgumentException.class, () -> policy.computeBulkLoadSize(fs, paths));
}
- @Test(expected = SpaceLimitingException.class)
+ @Test
public void testOneFileInBatchOverLimit() throws Exception {
final List<String> paths = new ArrayList<>();
final List<FileStatus> statuses = new ArrayList<>();
@@ -123,10 +118,10 @@ public class TestBulkLoadCheckingViolationPolicyEnforcement {
policy.initialize(rss, tableName, snapshot);
- policy.computeBulkLoadSize(fs, paths);
+ assertThrows(SpaceLimitingException.class, () -> policy.computeBulkLoadSize(fs, paths));
}
- @Test(expected = SpaceLimitingException.class)
+ @Test
public void testSumOfFilesOverLimit() throws Exception {
final List<String> paths = new ArrayList<>();
final List<FileStatus> statuses = new ArrayList<>();
@@ -147,6 +142,6 @@ public class TestBulkLoadCheckingViolationPolicyEnforcement {
policy.initialize(rss, tableName, snapshot);
- policy.computeBulkLoadSize(fs, paths);
+ assertThrows(SpaceLimitingException.class, () -> policy.computeBulkLoadSize(fs, paths));
}
}
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/policies/TestDisableTableViolationPolicyEnforcement.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/policies/TestDisableTableViolationPolicyEnforcement.java
index e99e31c1a71..ac97ed406ef 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/policies/TestDisableTableViolationPolicyEnforcement.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/policies/TestDisableTableViolationPolicyEnforcement.java
@@ -17,50 +17,46 @@
*/
package org.apache.hadoop.hbase.quotas.policies;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
import org.apache.hadoop.hbase.quotas.SpaceLimitingException;
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;
/**
* Test class for {@link DisableTableViolationPolicyEnforcement}.
*/
-@Category(SmallTests.class)
+@Tag(SmallTests.TAG)
public class TestDisableTableViolationPolicyEnforcement extends BaseViolationPolicyEnforcement {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestDisableTableViolationPolicyEnforcement.class);
-
private DisableTableViolationPolicyEnforcement enforcement;
- @Before
+ @BeforeEach
public void setup() {
enforcement = new DisableTableViolationPolicyEnforcement();
}
- @Test(expected = SpaceLimitingException.class)
+ @Test
public void testCheckPut() throws SpaceLimitingException {
// If the policy is enacted, it will always throw an exception
// to avoid constantly re-checking the table state.
- enforcement.check(PUT);
+ assertThrows(SpaceLimitingException.class, () -> enforcement.check(PUT));
}
- @Test(expected = SpaceLimitingException.class)
+ @Test
public void testCheckAppend() throws SpaceLimitingException {
- enforcement.check(APPEND);
+ assertThrows(SpaceLimitingException.class, () -> enforcement.check(APPEND));
}
- @Test(expected = SpaceLimitingException.class)
+ @Test
public void testCheckDelete() throws SpaceLimitingException {
- enforcement.check(DELETE);
+ assertThrows(SpaceLimitingException.class, () -> enforcement.check(DELETE));
}
- @Test(expected = SpaceLimitingException.class)
+ @Test
public void testCheckIncrement() throws SpaceLimitingException {
- enforcement.check(INCREMENT);
+ assertThrows(SpaceLimitingException.class, () -> enforcement.check(INCREMENT));
}
}
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/policies/TestNoInsertsViolationPolicyEnforcement.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/policies/TestNoInsertsViolationPolicyEnforcement.java
index bca9176c4cc..f33e5783f5f 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/policies/TestNoInsertsViolationPolicyEnforcement.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/policies/TestNoInsertsViolationPolicyEnforcement.java
@@ -17,34 +17,30 @@
*/
package org.apache.hadoop.hbase.quotas.policies;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
import org.apache.hadoop.hbase.quotas.SpaceLimitingException;
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;
/**
* Test class for {@link NoInsertsViolationPolicyEnforcement}.
*/
-@Category(SmallTests.class)
+@Tag(SmallTests.TAG)
public class TestNoInsertsViolationPolicyEnforcement extends BaseViolationPolicyEnforcement {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestNoInsertsViolationPolicyEnforcement.class);
-
private NoInsertsViolationPolicyEnforcement enforcement;
- @Before
+ @BeforeEach
public void setup() {
enforcement = new NoInsertsViolationPolicyEnforcement();
}
- @Test(expected = SpaceLimitingException.class)
+ @Test
public void testCheckAppend() throws Exception {
- enforcement.check(APPEND);
+ assertThrows(SpaceLimitingException.class, () -> enforcement.check(APPEND));
}
@Test
@@ -52,13 +48,13 @@ public class TestNoInsertsViolationPolicyEnforcement extends BaseViolationPolicy
enforcement.check(DELETE);
}
- @Test(expected = SpaceLimitingException.class)
+ @Test
public void testCheckIncrement() throws Exception {
- enforcement.check(INCREMENT);
+ assertThrows(SpaceLimitingException.class, () -> enforcement.check(INCREMENT));
}
- @Test(expected = SpaceLimitingException.class)
+ @Test
public void testCheckPut() throws Exception {
- enforcement.check(PUT);
+ assertThrows(SpaceLimitingException.class, () -> enforcement.check(PUT));
}
}
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/policies/TestNoWritesCompactionsViolationPolicyEnforcement.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/policies/TestNoWritesCompactionsViolationPolicyEnforcement.java
index 1338beea7a4..7282f9e4b77 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/policies/TestNoWritesCompactionsViolationPolicyEnforcement.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/policies/TestNoWritesCompactionsViolationPolicyEnforcement.java
@@ -17,49 +17,45 @@
*/
package org.apache.hadoop.hbase.quotas.policies;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
import org.apache.hadoop.hbase.quotas.SpaceLimitingException;
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;
/**
* Test class for {@link NoWritesCompactionsViolationPolicyEnforcement};
*/
-@Category(SmallTests.class)
+@Tag(SmallTests.TAG)
public class TestNoWritesCompactionsViolationPolicyEnforcement
extends BaseViolationPolicyEnforcement {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestNoWritesCompactionsViolationPolicyEnforcement.class);
-
private NoWritesCompactionsViolationPolicyEnforcement enforcement;
- @Before
+ @BeforeEach
public void setup() {
enforcement = new NoWritesCompactionsViolationPolicyEnforcement();
}
- @Test(expected = SpaceLimitingException.class)
+ @Test
public void testCheckAppend() throws Exception {
- enforcement.check(APPEND);
+ assertThrows(SpaceLimitingException.class, () -> enforcement.check(APPEND));
}
- @Test(expected = SpaceLimitingException.class)
+ @Test
public void testCheckDelete() throws Exception {
- enforcement.check(DELETE);
+ assertThrows(SpaceLimitingException.class, () -> enforcement.check(DELETE));
}
- @Test(expected = SpaceLimitingException.class)
+ @Test
public void testCheckIncrement() throws Exception {
- enforcement.check(INCREMENT);
+ assertThrows(SpaceLimitingException.class, () -> enforcement.check(INCREMENT));
}
- @Test(expected = SpaceLimitingException.class)
+ @Test
public void testCheckPut() throws Exception {
- enforcement.check(PUT);
+ assertThrows(SpaceLimitingException.class, () -> enforcement.check(PUT));
}
}
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/policies/TestNoWritesViolationPolicyEnforcement.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/policies/TestNoWritesViolationPolicyEnforcement.java
index 1c9ebb74122..c4d3c3258f4 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/policies/TestNoWritesViolationPolicyEnforcement.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/policies/TestNoWritesViolationPolicyEnforcement.java
@@ -17,48 +17,44 @@
*/
package org.apache.hadoop.hbase.quotas.policies;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
import org.apache.hadoop.hbase.quotas.SpaceLimitingException;
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;
/**
* Test class for {@link NoWritesViolationPolicyEnforcement}.
*/
-@Category(SmallTests.class)
+@Tag(SmallTests.TAG)
public class TestNoWritesViolationPolicyEnforcement extends BaseViolationPolicyEnforcement {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestNoWritesViolationPolicyEnforcement.class);
-
private NoWritesViolationPolicyEnforcement enforcement;
- @Before
+ @BeforeEach
public void setup() {
enforcement = new NoWritesViolationPolicyEnforcement();
}
- @Test(expected = SpaceLimitingException.class)
+ @Test
public void testCheckAppend() throws Exception {
- enforcement.check(APPEND);
+ assertThrows(SpaceLimitingException.class, () -> enforcement.check(APPEND));
}
- @Test(expected = SpaceLimitingException.class)
+ @Test
public void testCheckDelete() throws Exception {
- enforcement.check(DELETE);
+ assertThrows(SpaceLimitingException.class, () -> enforcement.check(DELETE));
}
- @Test(expected = SpaceLimitingException.class)
+ @Test
public void testCheckIncrement() throws Exception {
- enforcement.check(INCREMENT);
+ assertThrows(SpaceLimitingException.class, () -> enforcement.check(INCREMENT));
}
- @Test(expected = SpaceLimitingException.class)
+ @Test
public void testCheckPut() throws Exception {
- enforcement.check(PUT);
+ assertThrows(SpaceLimitingException.class, () -> enforcement.check(PUT));
}
}