This is an automated email from the ASF dual-hosted git repository.
Apache9 pushed a commit to branch branch-2.5
in repository https://gitbox.apache.org/repos/asf/hbase.git
The following commit(s) were added to refs/heads/branch-2.5 by this push:
new f7a76fa2377 HBASE-30175 Upgrade hbase-server to use junit5 Part19
(#8278) (#8285) (#8290)
f7a76fa2377 is described below
commit f7a76fa23773d11e33767922d5501379e8638afb
Author: Duo Zhang <[email protected]>
AuthorDate: Mon Jun 1 22:47:48 2026 +0800
HBASE-30175 Upgrade hbase-server to use junit5 Part19 (#8278) (#8285)
(#8290)
(cherry picked from commit 8d39f9f372d14c6c781789b6780cfcc88be6c7ec)
Signed-off-by: Xiao Liu <[email protected]>
---
.../hbase/replication/TestReplicationBase.java | 385 +--------------------
...se.java => TestReplicationBaseNoBeforeAll.java} | 36 +-
.../regionserver/TestBasicWALEntryStream.java | 42 +--
.../TestBasicWALEntryStreamAsyncFSWAL.java | 15 +-
.../TestBasicWALEntryStreamFSHLog.java | 15 +-
.../regionserver/TestDumpReplicationQueues.java | 32 +-
.../TestGlobalReplicationThrottler.java | 57 ++-
...InterClusterReplicationEndpointFilterEdits.java | 25 +-
.../TestMetaRegionReplicaReplicationEndpoint.java | 60 ++--
.../TestRaceWhenCreatingReplicationSource.java | 27 +-
.../TestRefreshPeerWhileRegionServerRestarts.java | 15 +-
.../TestRefreshRecoveredReplication.java | 75 ++--
.../TestRegionReplicaReplicationEndpoint.java | 51 ++-
...stRegionReplicaReplicationEndpointNoMaster.java | 38 +-
.../regionserver/TestReplicationCompressedWAL.java | 35 +-
.../regionserver/TestReplicationSink.java | 48 +--
.../regionserver/TestReplicationSinkManager.java | 19 +-
.../regionserver/TestReplicationSource.java | 31 +-
.../TestReplicationSourceLogQueue.java | 17 +-
.../regionserver/TestReplicationSourceManager.java | 60 ++--
.../TestReplicationSourceManagerJoin.java | 39 +--
.../TestReplicationSourceManagerZkImpl.java | 19 +-
.../regionserver/TestReplicationThrottler.java | 17 +-
.../TestReplicationValueCompressedWAL.java | 31 +-
.../replication/regionserver/TestReplicator.java | 45 +--
.../regionserver/TestSerialReplicationChecker.java | 40 +--
.../TestSerialReplicationEndpoint.java | 38 +-
.../regionserver/TestWALEntrySinkFilter.java | 53 +--
.../TestWALEntryStreamCompressionReset.java | 25 +-
.../TestWALEntryStreamDifferentCounts.java | 45 +--
...estWALEntryStreamDifferentCountsAsyncFSWAL.java | 40 ++-
.../TestWALEntryStreamDifferentCountsFSHLog.java | 40 ++-
.../regionserver/WALEntryStreamTestBase.java | 25 +-
33 files changed, 484 insertions(+), 1056 deletions(-)
diff --git
a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationBase.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationBase.java
index e87e13d151b..02924dcaa61 100644
---
a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationBase.java
+++
b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationBase.java
@@ -17,256 +17,15 @@
*/
package org.apache.hadoop.hbase.replication;
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.atomic.AtomicInteger;
-import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hbase.HBaseConfiguration;
-import org.apache.hadoop.hbase.HBaseTestingUtility;
-import org.apache.hadoop.hbase.HConstants;
-import org.apache.hadoop.hbase.TableName;
-import org.apache.hadoop.hbase.client.Admin;
-import org.apache.hadoop.hbase.client.ColumnFamilyDescriptorBuilder;
-import org.apache.hadoop.hbase.client.Connection;
-import org.apache.hadoop.hbase.client.ConnectionFactory;
-import org.apache.hadoop.hbase.client.Delete;
-import org.apache.hadoop.hbase.client.Get;
-import org.apache.hadoop.hbase.client.Put;
-import org.apache.hadoop.hbase.client.Result;
-import org.apache.hadoop.hbase.client.ResultScanner;
-import org.apache.hadoop.hbase.client.Scan;
-import org.apache.hadoop.hbase.client.Table;
-import org.apache.hadoop.hbase.client.TableDescriptor;
-import org.apache.hadoop.hbase.client.TableDescriptorBuilder;
-import org.apache.hadoop.hbase.client.replication.ReplicationAdmin;
-import
org.apache.hadoop.hbase.replication.regionserver.HBaseInterClusterReplicationEndpoint;
-import org.apache.hadoop.hbase.util.Bytes;
-import org.apache.hadoop.hbase.util.JVMClusterUtil;
-import org.apache.hadoop.hbase.wal.WAL;
-import org.apache.hadoop.hbase.zookeeper.MiniZooKeeperCluster;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
import org.junit.BeforeClass;
-import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeAll;
-import org.junit.jupiter.api.BeforeEach;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import org.apache.hbase.thirdparty.com.google.common.collect.Lists;
-import org.apache.hbase.thirdparty.com.google.common.io.Closeables;
/**
* This class is only a base for other integration-level replication tests. Do
not add tests here.
* TestReplicationSmallTests is where tests that don't require bring machines
up/down should go All
* other tests should have their own classes and extend this one
*/
-public class TestReplicationBase {
- private static final Logger LOG =
LoggerFactory.getLogger(TestReplicationBase.class);
- protected static Connection connection1;
- protected static Connection connection2;
- protected static Configuration CONF_WITH_LOCALFS;
-
- protected static ReplicationAdmin admin;
- protected static Admin hbaseAdmin;
-
- protected static Table htable1;
- protected static Table htable2;
-
- protected static final HBaseTestingUtility UTIL1 = new HBaseTestingUtility();
- protected static final HBaseTestingUtility UTIL2 = new HBaseTestingUtility();
- protected static Configuration CONF1 = UTIL1.getConfiguration();
- protected static Configuration CONF2 = UTIL2.getConfiguration();
-
- protected static int NUM_SLAVES1 = 1;
- protected static int NUM_SLAVES2 = 1;
- protected static final int NB_ROWS_IN_BATCH = 100;
- protected static final int NB_ROWS_IN_BIG_BATCH = NB_ROWS_IN_BATCH * 10;
- protected static final long SLEEP_TIME = 500;
- protected static final int NB_RETRIES = 50;
- protected static AtomicInteger replicateCount = new AtomicInteger();
- protected static volatile List<WAL.Entry> replicatedEntries =
Lists.newArrayList();
-
- protected static final TableName tableName = TableName.valueOf("test");
- protected static final byte[] famName = Bytes.toBytes("f");
- protected static final byte[] row = Bytes.toBytes("row");
- protected static final byte[] noRepfamName = Bytes.toBytes("norep");
- protected static final String PEER_ID2 = "2";
-
- protected boolean isSerialPeer() {
- return false;
- }
-
- protected final void cleanUp() throws IOException, InterruptedException {
- // Starting and stopping replication can make us miss new logs,
- // rolling like this makes sure the most recent one gets added to the queue
- for (JVMClusterUtil.RegionServerThread r :
UTIL1.getHBaseCluster().getRegionServerThreads()) {
- UTIL1.getAdmin().rollWALWriter(r.getRegionServer().getServerName());
- }
- int rowCount = UTIL1.countRows(tableName);
- UTIL1.deleteTableData(tableName);
- // truncating the table will send one Delete per row to the slave cluster
- // in an async fashion, which is why we cannot just call deleteTableData on
- // utility2 since late writes could make it to the slave in some way.
- // Instead, we truncate the first table and wait for all the Deletes to
- // make it to the slave.
- Scan scan = new Scan();
- int lastCount = 0;
- for (int i = 0; i < NB_RETRIES; i++) {
- if (i == NB_RETRIES - 1) {
- fail("Waited too much time for truncate");
- }
- ResultScanner scanner = htable2.getScanner(scan);
- Result[] res = scanner.next(rowCount);
- scanner.close();
- if (res.length != 0) {
- if (res.length < lastCount) {
- i--; // Don't increment timeout if we make progress
- }
- lastCount = res.length;
- LOG.info("Still got " + res.length + " rows");
- Thread.sleep(SLEEP_TIME);
- } else {
- break;
- }
- }
- }
-
- protected static void waitForReplication(int expectedRows, int retries)
- throws IOException, InterruptedException {
- waitForReplication(htable2, expectedRows, retries);
- }
-
- protected static void waitForReplication(Table table, int expectedRows, int
retries)
- throws IOException, InterruptedException {
- Scan scan;
- for (int i = 0; i < retries; i++) {
- scan = new Scan();
- if (i == retries - 1) {
- fail("Waited too much time for normal batch replication");
- }
- int count = 0;
- try (ResultScanner scanner = table.getScanner(scan)) {
- while (scanner.next() != null) {
- count++;
- }
- }
- if (count != expectedRows) {
- LOG.info("Only got " + count + " rows");
- Thread.sleep(SLEEP_TIME);
- } else {
- break;
- }
- }
- }
-
- protected static void loadData(String prefix, byte[] row) throws IOException
{
- loadData(prefix, row, famName);
- }
-
- protected static void loadData(String prefix, byte[] row, byte[] familyName)
throws IOException {
- List<Put> puts = new ArrayList<>(NB_ROWS_IN_BATCH);
- for (int i = 0; i < NB_ROWS_IN_BATCH; i++) {
- Put put = new Put(Bytes.toBytes(prefix + Integer.toString(i)));
- put.addColumn(familyName, row, row);
- puts.add(put);
- }
- htable1.put(puts);
- }
-
- protected static void setupConfig(HBaseTestingUtility util, String
znodeParent) {
- Configuration conf = util.getConfiguration();
- conf.set(HConstants.ZOOKEEPER_ZNODE_PARENT, znodeParent);
- // We don't want too many edits per batch sent to the ReplicationEndpoint
to trigger
- // sufficient number of events. But we don't want to go too low because
- // HBaseInterClusterReplicationEndpoint partitions entries into batches
and we want
- // more than one batch sent to the peer cluster for better testing.
- conf.setInt("replication.source.size.capacity", 102400);
- conf.setLong("replication.source.sleepforretries", 100);
- conf.setInt("hbase.regionserver.maxlogs", 10);
- conf.setLong("hbase.master.logcleaner.ttl", 10);
- conf.setInt("zookeeper.recovery.retry", 1);
- conf.setInt("zookeeper.recovery.retry.intervalmill", 10);
- conf.setLong(HConstants.THREAD_WAKE_FREQUENCY, 100);
- conf.setInt("replication.stats.thread.period.seconds", 5);
- conf.setBoolean("hbase.tests.use.shortcircuit.reads", false);
- conf.setLong("replication.sleep.before.failover", 2000);
- conf.setInt("replication.source.maxretriesmultiplier", 10);
- conf.setFloat("replication.source.ratio", 1.0f);
- conf.setBoolean("replication.source.eof.autorecovery", true);
- conf.setLong("hbase.serial.replication.waiting.ms", 100);
- }
-
- static void configureClusters(HBaseTestingUtility util1, HBaseTestingUtility
util2) {
- setupConfig(util1, "/1");
- setupConfig(util2, "/2");
-
- Configuration conf2 = util2.getConfiguration();
- conf2.set(HConstants.ZOOKEEPER_ZNODE_PARENT, "/2");
- conf2.setInt(HConstants.HBASE_CLIENT_RETRIES_NUMBER, 6);
- conf2.setBoolean("hbase.tests.use.shortcircuit.reads", false);
- }
-
- static void restartSourceCluster(int numSlaves) throws Exception {
- Closeables.close(hbaseAdmin, true);
- Closeables.close(htable1, true);
- UTIL1.shutdownMiniHBaseCluster();
- UTIL1.restartHBaseCluster(numSlaves);
- // Invalidate the cached connection state.
- CONF1 = UTIL1.getConfiguration();
- hbaseAdmin = UTIL1.getAdmin();
- Connection connection1 = UTIL1.getConnection();
- htable1 = connection1.getTable(tableName);
- }
-
- static void restartTargetHBaseCluster(int numSlaves) throws Exception {
- Closeables.close(htable2, true);
- UTIL2.restartHBaseCluster(numSlaves);
- // Invalidate the cached connection state
- CONF2 = UTIL2.getConfiguration();
- htable2 = UTIL2.getConnection().getTable(tableName);
- }
-
- protected static void createTable(TableName tableName) throws IOException {
- TableDescriptor table = TableDescriptorBuilder.newBuilder(tableName)
-
.setColumnFamily(ColumnFamilyDescriptorBuilder.newBuilder(famName).setMaxVersions(100)
- .setScope(HConstants.REPLICATION_SCOPE_GLOBAL).build())
- .setColumnFamily(ColumnFamilyDescriptorBuilder.of(noRepfamName)).build();
- UTIL1.createTable(table, HBaseTestingUtility.KEYS_FOR_HBA_CREATE_TABLE);
- UTIL2.createTable(table, HBaseTestingUtility.KEYS_FOR_HBA_CREATE_TABLE);
- UTIL1.waitUntilAllRegionsAssigned(tableName);
- UTIL2.waitUntilAllRegionsAssigned(tableName);
- }
-
- private static void startClusters() throws Exception {
- UTIL1.startMiniZKCluster();
- MiniZooKeeperCluster miniZK = UTIL1.getZkCluster();
- LOG.info("Setup first Zk");
-
- UTIL2.setZkCluster(miniZK);
- LOG.info("Setup second Zk");
-
- CONF_WITH_LOCALFS = HBaseConfiguration.create(CONF1);
- UTIL1.startMiniCluster(NUM_SLAVES1);
- // Have a bunch of slave servers, because inter-cluster shipping logic
uses number of sinks
- // as a component in deciding maximum number of parallel batches to send
to the peer cluster.
- UTIL2.startMiniCluster(NUM_SLAVES2);
-
- connection1 = ConnectionFactory.createConnection(CONF1);
- connection2 = ConnectionFactory.createConnection(CONF2);
- admin = new ReplicationAdmin(CONF1);
- hbaseAdmin = connection1.getAdmin();
-
- createTable(tableName);
- htable1 = connection1.getTable(tableName);
- htable2 = connection2.getTable(tableName);
- }
+public class TestReplicationBase extends TestReplicationBaseNoBeforeAll {
@BeforeAll
@BeforeClass
@@ -274,146 +33,4 @@ public class TestReplicationBase {
configureClusters(UTIL1, UTIL2);
startClusters();
}
-
- private boolean peerExist(String peerId) throws IOException {
- return peerExist(peerId, UTIL1);
- }
-
- private boolean peerExist(String peerId, HBaseTestingUtility util) throws
IOException {
- return util.getAdmin().listReplicationPeers().stream()
- .anyMatch(p -> peerId.equals(p.getPeerId()));
- }
-
- protected final void addPeer(String peerId, TableName tableName) throws
Exception {
- addPeer(peerId, tableName, UTIL1, UTIL2);
- }
-
- protected final void addPeer(String peerId, TableName tableName,
HBaseTestingUtility source,
- HBaseTestingUtility target) throws Exception {
- if (peerExist(peerId, source)) {
- return;
- }
- ReplicationPeerConfigBuilder builder = ReplicationPeerConfig.newBuilder()
- .setClusterKey(target.getClusterKey()).setSerial(isSerialPeer())
- .setReplicationEndpointImpl(ReplicationEndpointTest.class.getName());
- source.getAdmin().addReplicationPeer(peerId, builder.build());
- }
-
- @Before
- @BeforeEach
- public void setUpBase() throws Exception {
- addPeer(PEER_ID2, tableName);
- }
-
- protected final void removePeer(String peerId) throws Exception {
- removePeer(peerId, UTIL1);
- }
-
- protected final void removePeer(String peerId, HBaseTestingUtility util)
throws Exception {
- if (peerExist(peerId, util)) {
- util.getAdmin().removeReplicationPeer(peerId);
- }
- }
-
- @After
- @AfterEach
- public void tearDownBase() throws Exception {
- removePeer(PEER_ID2);
- }
-
- protected static void runSimplePutDeleteTest() throws IOException,
InterruptedException {
- Put put = new Put(row);
- put.addColumn(famName, row, row);
-
- htable1 = UTIL1.getConnection().getTable(tableName);
- htable1.put(put);
-
- Get get = new Get(row);
- for (int i = 0; i < NB_RETRIES; i++) {
- if (i == NB_RETRIES - 1) {
- fail("Waited too much time for put replication");
- }
- Result res = htable2.get(get);
- if (res.isEmpty()) {
- LOG.info("Row not available");
- Thread.sleep(SLEEP_TIME);
- } else {
- assertArrayEquals(row, res.value());
- break;
- }
- }
-
- Delete del = new Delete(row);
- htable1.delete(del);
-
- get = new Get(row);
- for (int i = 0; i < NB_RETRIES; i++) {
- if (i == NB_RETRIES - 1) {
- fail("Waited too much time for del replication");
- }
- Result res = htable2.get(get);
- if (res.size() >= 1) {
- LOG.info("Row not deleted");
- Thread.sleep(SLEEP_TIME);
- } else {
- break;
- }
- }
- }
-
- protected static void runSmallBatchTest() throws IOException,
InterruptedException {
- // normal Batch tests
- loadData("", row);
-
- Scan scan = new Scan();
-
- ResultScanner scanner1 = htable1.getScanner(scan);
- Result[] res1 = scanner1.next(NB_ROWS_IN_BATCH);
- scanner1.close();
- assertEquals(NB_ROWS_IN_BATCH, res1.length);
-
- waitForReplication(NB_ROWS_IN_BATCH, NB_RETRIES);
- }
-
- @AfterClass
- public static void tearDownAfterClass() throws Exception {
- if (htable2 != null) {
- htable2.close();
- }
- if (htable1 != null) {
- htable1.close();
- }
- if (admin != null) {
- admin.close();
- }
- if (hbaseAdmin != null) {
- hbaseAdmin.close();
- }
-
- if (connection2 != null) {
- connection2.close();
- }
- if (connection1 != null) {
- connection1.close();
- }
- UTIL2.shutdownMiniCluster();
- UTIL1.shutdownMiniCluster();
- }
-
- /**
- * Custom replication endpoint to keep track of replication status for tests.
- */
- public static class ReplicationEndpointTest extends
HBaseInterClusterReplicationEndpoint {
- public ReplicationEndpointTest() {
- replicateCount.set(0);
- }
-
- @Override
- public boolean replicate(ReplicateContext replicateContext) {
- replicateCount.incrementAndGet();
- replicatedEntries.addAll(replicateContext.getEntries());
-
- return super.replicate(replicateContext);
- }
- }
}
diff --git
a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationBase.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationBaseNoBeforeAll.java
similarity index 93%
copy from
hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationBase.java
copy to
hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationBaseNoBeforeAll.java
index e87e13d151b..96cc8e23ac7 100644
---
a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationBase.java
+++
b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationBaseNoBeforeAll.java
@@ -52,9 +52,7 @@ import org.apache.hadoop.hbase.zookeeper.MiniZooKeeperCluster;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
-import org.junit.BeforeClass;
import org.junit.jupiter.api.AfterEach;
-import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -63,12 +61,12 @@ import
org.apache.hbase.thirdparty.com.google.common.collect.Lists;
import org.apache.hbase.thirdparty.com.google.common.io.Closeables;
/**
- * This class is only a base for other integration-level replication tests. Do
not add tests here.
- * TestReplicationSmallTests is where tests that don't require bring machines
up/down should go All
- * other tests should have their own classes and extend this one
+ * Replication test base class without BeforeAll method, as in some tests we
need to do some changes
+ * before starting clusters.
+ * @see TestReplicationBase
*/
-public class TestReplicationBase {
- private static final Logger LOG =
LoggerFactory.getLogger(TestReplicationBase.class);
+public class TestReplicationBaseNoBeforeAll {
+ private static final Logger LOG =
LoggerFactory.getLogger(TestReplicationBaseNoBeforeAll.class);
protected static Connection connection1;
protected static Connection connection2;
protected static Configuration CONF_WITH_LOCALFS;
@@ -203,7 +201,7 @@ public class TestReplicationBase {
conf.setLong("hbase.serial.replication.waiting.ms", 100);
}
- static void configureClusters(HBaseTestingUtility util1, HBaseTestingUtility
util2) {
+ protected static void configureClusters(HBaseTestingUtility util1,
HBaseTestingUtility util2) {
setupConfig(util1, "/1");
setupConfig(util2, "/2");
@@ -216,21 +214,24 @@ public class TestReplicationBase {
static void restartSourceCluster(int numSlaves) throws Exception {
Closeables.close(hbaseAdmin, true);
Closeables.close(htable1, true);
+ Closeables.close(connection1, true);
UTIL1.shutdownMiniHBaseCluster();
UTIL1.restartHBaseCluster(numSlaves);
// Invalidate the cached connection state.
CONF1 = UTIL1.getConfiguration();
- hbaseAdmin = UTIL1.getAdmin();
- Connection connection1 = UTIL1.getConnection();
+ connection1 = ConnectionFactory.createConnection(CONF1);
+ hbaseAdmin = connection1.getAdmin();
htable1 = connection1.getTable(tableName);
}
static void restartTargetHBaseCluster(int numSlaves) throws Exception {
Closeables.close(htable2, true);
+ Closeables.close(connection2, true);
UTIL2.restartHBaseCluster(numSlaves);
// Invalidate the cached connection state
CONF2 = UTIL2.getConfiguration();
- htable2 = UTIL2.getConnection().getTable(tableName);
+ connection2 = ConnectionFactory.createConnection(CONF2);
+ htable2 = connection2.getTable(tableName);
}
protected static void createTable(TableName tableName) throws IOException {
@@ -244,7 +245,7 @@ public class TestReplicationBase {
UTIL2.waitUntilAllRegionsAssigned(tableName);
}
- private static void startClusters() throws Exception {
+ protected static void startClusters() throws Exception {
UTIL1.startMiniZKCluster();
MiniZooKeeperCluster miniZK = UTIL1.getZkCluster();
LOG.info("Setup first Zk");
@@ -268,17 +269,6 @@ public class TestReplicationBase {
htable2 = connection2.getTable(tableName);
}
- @BeforeAll
- @BeforeClass
- public static void setUpBeforeClass() throws Exception {
- configureClusters(UTIL1, UTIL2);
- startClusters();
- }
-
- private boolean peerExist(String peerId) throws IOException {
- return peerExist(peerId, UTIL1);
- }
-
private boolean peerExist(String peerId, HBaseTestingUtility util) throws
IOException {
return util.getAdmin().listReplicationPeers().stream()
.anyMatch(p -> peerId.equals(p.getPeerId()));
diff --git
a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestBasicWALEntryStream.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestBasicWALEntryStream.java
index a997cd0a9d5..10bb83ec665 100644
---
a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestBasicWALEntryStream.java
+++
b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestBasicWALEntryStream.java
@@ -17,13 +17,14 @@
*/
package org.apache.hadoop.hbase.replication.regionserver;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -66,16 +67,15 @@ import org.apache.hadoop.hbase.wal.WALEdit;
import org.apache.hadoop.hbase.wal.WALFactory;
import org.apache.hadoop.hbase.wal.WALKeyImpl;
import org.apache.hadoop.hbase.wal.WALProvider;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
import org.apache.hadoop.hbase.shaded.protobuf.generated.WALProtos;
public abstract class TestBasicWALEntryStream extends WALEntryStreamTestBase {
- @Before
+ @BeforeEach
public void setUp() throws Exception {
initWAL();
}
@@ -247,7 +247,7 @@ public abstract class TestBasicWALEntryStream extends
WALEntryStreamTestBase {
WALKeyImpl key =
new WALKeyImpl(info.getEncodedNameAsBytes(), tableName,
EnvironmentEdgeManager.currentTime(),
new ArrayList<UUID>(), 0L, 0L, mvcc, scopes, attributes);
- Assert.assertEquals(attributes, key.getExtendedAttributes());
+ assertEquals(attributes, key.getExtendedAttributes());
WALProtos.WALKey.Builder builder =
key.getBuilder(WALCellCodec.getNoneCompressor());
WALProtos.WALKey serializedKey = builder.build();
@@ -256,14 +256,14 @@ public abstract class TestBasicWALEntryStream extends
WALEntryStreamTestBase {
deserializedKey.readFieldsFromPb(serializedKey,
WALCellCodec.getNoneUncompressor());
// equals() only checks region name, sequence id and write time
- Assert.assertEquals(key, deserializedKey);
+ assertEquals(key, deserializedKey);
// can't use Map.equals() because byte arrays use reference equality
- Assert.assertEquals(key.getExtendedAttributes().keySet(),
+ assertEquals(key.getExtendedAttributes().keySet(),
deserializedKey.getExtendedAttributes().keySet());
for (Map.Entry<String, byte[]> entry :
deserializedKey.getExtendedAttributes().entrySet()) {
- Assert.assertArrayEquals(key.getExtendedAttribute(entry.getKey()),
entry.getValue());
+ assertArrayEquals(key.getExtendedAttribute(entry.getKey()),
entry.getValue());
}
- Assert.assertEquals(key.getReplicationScopes(),
deserializedKey.getReplicationScopes());
+ assertEquals(key.getReplicationScopes(),
deserializedKey.getReplicationScopes());
}
private ReplicationSource mockReplicationSource(boolean recovered,
Configuration conf) {
@@ -430,8 +430,8 @@ public abstract class TestBasicWALEntryStream extends
WALEntryStreamTestBase {
assertEquals(walPath, entryBatch.getLastWalPath());
long walLength = fs.getFileStatus(walPath).getLen();
- assertTrue("Position " + entryBatch.getLastWalPosition() + " is out of
range, file length is "
- + walLength, entryBatch.getLastWalPosition() <= walLength);
+ assertTrue(entryBatch.getLastWalPosition() <= walLength, "Position "
+ + entryBatch.getLastWalPosition() + " is out of range, file length is "
+ walLength);
assertEquals(1, entryBatch.getNbEntries());
assertTrue(entryBatch.isEndOfFile());
@@ -656,14 +656,14 @@ public abstract class TestBasicWALEntryStream extends
WALEntryStreamTestBase {
// Create a reader thread.
ReplicationSourceWALReader reader = new ReplicationSourceWALReader(fs,
conf, localLogQueue, 0,
getDummyFilter(), source, fakeWalGroupId);
- assertEquals("Initial log queue size is not correct", 2,
- localLogQueue.getQueueSize(fakeWalGroupId));
+ assertEquals(2, localLogQueue.getQueueSize(fakeWalGroupId),
+ "Initial log queue size is not correct");
reader.start();
reader.join();
// remove empty log from logQueue.
assertEquals(0, localLogQueue.getQueueSize(fakeWalGroupId));
- assertEquals("Log queue should be empty", 0,
localLogQueue.getQueueSize(fakeWalGroupId));
+ assertEquals(0, localLogQueue.getQueueSize(fakeWalGroupId), "Log queue
should be empty");
}
private PriorityBlockingQueue<Path> getQueue() {
diff --git
a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestBasicWALEntryStreamAsyncFSWAL.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestBasicWALEntryStreamAsyncFSWAL.java
index 8e2a01c177e..f368e5425c3 100644
---
a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestBasicWALEntryStreamAsyncFSWAL.java
+++
b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestBasicWALEntryStreamAsyncFSWAL.java
@@ -17,27 +17,22 @@
*/
package org.apache.hadoop.hbase.replication.regionserver;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.testclassification.MediumTests;
import org.apache.hadoop.hbase.testclassification.ReplicationTests;
import org.apache.hadoop.hbase.wal.AbstractFSWALProvider;
import org.apache.hadoop.hbase.wal.AsyncFSWALProvider;
import org.apache.hadoop.hbase.wal.WALFactory;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Tag;
/**
* TestBasicWALEntryStream with {@link AsyncFSWALProvider} as the WAL provider.
*/
-@Category({ ReplicationTests.class, MediumTests.class })
+@Tag(ReplicationTests.TAG)
+@Tag(MediumTests.TAG)
public class TestBasicWALEntryStreamAsyncFSWAL extends TestBasicWALEntryStream
{
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestBasicWALEntryStreamAsyncFSWAL.class);
-
- @BeforeClass
+ @BeforeAll
public static void setUpBeforeClass() throws Exception {
TEST_UTIL.getConfiguration().setClass(WALFactory.WAL_PROVIDER,
AsyncFSWALProvider.class,
AbstractFSWALProvider.class);
diff --git
a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestBasicWALEntryStreamFSHLog.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestBasicWALEntryStreamFSHLog.java
index db3e7fe8cf5..4c582bf9c1f 100644
---
a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestBasicWALEntryStreamFSHLog.java
+++
b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestBasicWALEntryStreamFSHLog.java
@@ -17,27 +17,22 @@
*/
package org.apache.hadoop.hbase.replication.regionserver;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.testclassification.MediumTests;
import org.apache.hadoop.hbase.testclassification.ReplicationTests;
import org.apache.hadoop.hbase.wal.AbstractFSWALProvider;
import org.apache.hadoop.hbase.wal.FSHLogProvider;
import org.apache.hadoop.hbase.wal.WALFactory;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Tag;
/**
* TestBasicWALEntryStream with {@link FSHLogProvider} as the WAL provider.
*/
-@Category({ ReplicationTests.class, MediumTests.class })
+@Tag(ReplicationTests.TAG)
+@Tag(MediumTests.TAG)
public class TestBasicWALEntryStreamFSHLog extends TestBasicWALEntryStream {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestBasicWALEntryStreamFSHLog.class);
-
- @BeforeClass
+ @BeforeAll
public static void setUpBeforeClass() throws Exception {
TEST_UTIL.getConfiguration().setClass(WALFactory.WAL_PROVIDER,
FSHLogProvider.class,
AbstractFSWALProvider.class);
diff --git
a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestDumpReplicationQueues.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestDumpReplicationQueues.java
index d78a45ca6b9..7385e13ea41 100644
---
a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestDumpReplicationQueues.java
+++
b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestDumpReplicationQueues.java
@@ -17,8 +17,8 @@
*/
package org.apache.hadoop.hbase.replication.regionserver;
-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.mock;
import static org.mockito.Mockito.when;
@@ -27,7 +27,6 @@ import java.util.HashSet;
import java.util.List;
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.testclassification.ReplicationTests;
import org.apache.hadoop.hbase.testclassification.SmallTests;
@@ -35,20 +34,18 @@ import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
import org.apache.hadoop.hbase.zookeeper.RecoverableZooKeeper;
import org.apache.hadoop.hbase.zookeeper.ZKWatcher;
import org.apache.hadoop.hbase.zookeeper.ZNodePaths;
-import org.junit.ClassRule;
-import org.junit.Test;
import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
/**
* Tests for DumpReplicationQueues tool
*/
+@Tag(ReplicationTests.TAG)
+@Tag(SmallTests.TAG)
@Category({ ReplicationTests.class, SmallTests.class })
public class TestDumpReplicationQueues {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestDumpReplicationQueues.class);
-
/**
* Makes sure dumpQueues returns wals znodes ordered chronologically.
* @throws Exception if dumpqueues finds any error while handling list of
znodes.
@@ -82,16 +79,13 @@ public class TestDumpReplicationQueues {
dumpQueues.setConf(config);
String dump = dumpQueues.dumpQueues(zkWatcherMock, peerIds, false);
String[] parsedDump = dump.split("Replication position for");
- assertEquals("Parsed dump should have 4 parts.", 4, parsedDump.length);
- assertTrue(
- "First wal should be rs1%2C60964%2C1549394085556.1549394101426, but got:
" + parsedDump[1],
- parsedDump[1].indexOf("rs1%2C60964%2C1549394085556.1549394101426") >= 0);
- assertTrue(
- "Second wal should be rs1%2C60964%2C1549394085556.1549394101427, but
got: " + parsedDump[2],
- parsedDump[2].indexOf("rs1%2C60964%2C1549394085556.1549394101427") >= 0);
- assertTrue(
- "Third wal should be rs1%2C60964%2C1549394085556.1549394101428, but got:
" + parsedDump[3],
- parsedDump[3].indexOf("rs1%2C60964%2C1549394085556.1549394101428") >= 0);
+ assertEquals(4, parsedDump.length, "Parsed dump should have 4 parts.");
+
assertTrue(parsedDump[1].indexOf("rs1%2C60964%2C1549394085556.1549394101426")
>= 0,
+ "First wal should be rs1%2C60964%2C1549394085556.1549394101426, but got:
" + parsedDump[1]);
+
assertTrue(parsedDump[2].indexOf("rs1%2C60964%2C1549394085556.1549394101427")
>= 0,
+ "Second wal should be rs1%2C60964%2C1549394085556.1549394101427, but
got: " + parsedDump[2]);
+
assertTrue(parsedDump[3].indexOf("rs1%2C60964%2C1549394085556.1549394101428")
>= 0,
+ "Third wal should be rs1%2C60964%2C1549394085556.1549394101428, but got:
" + parsedDump[3]);
}
}
diff --git
a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestGlobalReplicationThrottler.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestGlobalReplicationThrottler.java
index 5f4ceaa60da..656bc90bc80 100644
---
a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestGlobalReplicationThrottler.java
+++
b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestGlobalReplicationThrottler.java
@@ -17,22 +17,23 @@
*/
package org.apache.hadoop.hbase.replication.regionserver;
-import java.io.IOException;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
import java.util.concurrent.atomic.AtomicLong;
import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.HBaseTestingUtility;
-import org.apache.hadoop.hbase.HColumnDescriptor;
import org.apache.hadoop.hbase.HConstants;
-import org.apache.hadoop.hbase.HTableDescriptor;
import org.apache.hadoop.hbase.HTestConst;
import org.apache.hadoop.hbase.TableName;
+import org.apache.hadoop.hbase.client.ColumnFamilyDescriptorBuilder;
import org.apache.hadoop.hbase.client.Put;
import org.apache.hadoop.hbase.client.Result;
import org.apache.hadoop.hbase.client.ResultScanner;
import org.apache.hadoop.hbase.client.Scan;
import org.apache.hadoop.hbase.client.Table;
+import org.apache.hadoop.hbase.client.TableDescriptor;
+import org.apache.hadoop.hbase.client.TableDescriptorBuilder;
import org.apache.hadoop.hbase.client.replication.ReplicationAdmin;
import org.apache.hadoop.hbase.replication.ReplicationPeerConfig;
import org.apache.hadoop.hbase.testclassification.LargeTests;
@@ -42,25 +43,20 @@ import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
import org.apache.hadoop.hbase.util.Threads;
import org.apache.hadoop.hbase.zookeeper.MiniZooKeeperCluster;
import org.apache.hadoop.hbase.zookeeper.ZKWatcher;
-import org.junit.AfterClass;
-import org.junit.Assert;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-import org.junit.rules.TestName;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-@Category({ ReplicationTests.class, LargeTests.class })
+@Tag(ReplicationTests.TAG)
+@Tag(LargeTests.TAG)
public class TestGlobalReplicationThrottler {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestGlobalReplicationThrottler.class);
-
private static final Logger LOG =
LoggerFactory.getLogger(TestGlobalReplicationThrottler.class);
+
private static final int REPLICATION_SOURCE_QUOTA = 200;
private static int numOfPeer = 0;
private static Configuration conf1;
@@ -74,10 +70,9 @@ public class TestGlobalReplicationThrottler {
private static final byte[] ROW = Bytes.toBytes("r");
private static final byte[][] ROWS = HTestConst.makeNAscii(ROW, 100);
- @Rule
- public TestName name = new TestName();
+ private String testName;
- @BeforeClass
+ @BeforeAll
public static void setUpBeforeClass() throws Exception {
conf1 = HBaseConfiguration.create();
conf1.set(HConstants.ZOOKEEPER_ZNODE_PARENT, "/1");
@@ -111,7 +106,7 @@ public class TestGlobalReplicationThrottler {
numOfPeer = admin1.getPeersCount();
}
- @AfterClass
+ @AfterAll
public static void tearDownAfterClass() throws Exception {
utility2.shutdownMiniCluster();
utility1.shutdownMiniCluster();
@@ -121,14 +116,14 @@ public class TestGlobalReplicationThrottler {
volatile private boolean testQuotaNonZero = false;
@Test
- public void testQuota() throws IOException {
- final TableName tableName = TableName.valueOf(name.getMethodName());
- HTableDescriptor table = new HTableDescriptor(tableName);
- HColumnDescriptor fam = new HColumnDescriptor(famName);
- fam.setScope(HConstants.REPLICATION_SCOPE_GLOBAL);
- table.addFamily(fam);
- utility1.getAdmin().createTable(table);
- utility2.getAdmin().createTable(table);
+ public void testQuota(TestInfo testInfo) throws Exception {
+ testName = testInfo.getTestMethod().get().getName();
+ final TableName tableName = TableName.valueOf(testName);
+ TableDescriptor tableDescriptor =
+
TableDescriptorBuilder.newBuilder(tableName).setColumnFamily(ColumnFamilyDescriptorBuilder
+
.newBuilder(famName).setScope(HConstants.REPLICATION_SCOPE_GLOBAL).build()).build();
+ utility1.getAdmin().createTable(tableDescriptor);
+ utility2.getAdmin().createTable(tableDescriptor);
Thread watcher = new Thread(() -> {
Replication replication = (Replication)
utility1.getMiniHBaseCluster().getRegionServer(0)
@@ -183,8 +178,8 @@ public class TestGlobalReplicationThrottler {
}
watcher.interrupt();
- Assert.assertTrue(testQuotaPass);
- Assert.assertTrue(testQuotaNonZero);
+ assertTrue(testQuotaPass);
+ assertTrue(testQuotaNonZero);
}
}
diff --git
a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestHBaseInterClusterReplicationEndpointFilterEdits.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestHBaseInterClusterReplicationEndpointFilterEdits.java
index 9f71bee4b07..d9c9fd11454 100644
---
a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestHBaseInterClusterReplicationEndpointFilterEdits.java
+++
b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestHBaseInterClusterReplicationEndpointFilterEdits.java
@@ -17,8 +17,8 @@
*/
package org.apache.hadoop.hbase.replication.regionserver;
-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.mock;
import static org.mockito.Mockito.when;
@@ -26,7 +26,6 @@ import java.util.ArrayList;
import java.util.List;
import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.CellUtil;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.KeyValue;
import org.apache.hadoop.hbase.KeyValue.Type;
@@ -41,11 +40,10 @@ import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
import org.apache.hadoop.hbase.wal.WAL.Entry;
import org.apache.hadoop.hbase.wal.WALEdit;
import org.apache.hadoop.hbase.wal.WALKeyImpl;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
import org.apache.hbase.thirdparty.com.google.common.collect.Lists;
@@ -53,13 +51,10 @@ import
org.apache.hbase.thirdparty.com.google.common.collect.Lists;
* Tests {@link
HBaseInterClusterReplicationEndpoint#filterNotExistColumnFamilyEdits(List)} and
* {@link HBaseInterClusterReplicationEndpoint#filterNotExistTableEdits(List)}
*/
-@Category({ ReplicationTests.class, MediumTests.class })
+@Tag(ReplicationTests.TAG)
+@Tag(MediumTests.TAG)
public class TestHBaseInterClusterReplicationEndpointFilterEdits {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
-
HBaseClassTestRule.forClass(TestHBaseInterClusterReplicationEndpointFilterEdits.class);
-
private static final HBaseTestingUtility UTIL = new HBaseTestingUtility();
private static HBaseInterClusterReplicationEndpoint endpoint;
@@ -73,7 +68,7 @@ public class
TestHBaseInterClusterReplicationEndpointFilterEdits {
private static final byte[] ROW = Bytes.toBytes("r");
private static final byte[] VALUE = Bytes.toBytes("v");
- @BeforeClass
+ @BeforeAll
public static void setUpBeforeClass() throws Exception {
UTIL.startMiniCluster();
ReplicationPeer replicationPeer = mock(ReplicationPeer.class);
@@ -88,7 +83,7 @@ public class
TestHBaseInterClusterReplicationEndpointFilterEdits {
UTIL.createTable(TABLE1, FAMILY);
}
- @AfterClass
+ @AfterAll
public static void tearDownAfterClass() throws Exception {
UTIL.shutdownMiniCluster();
}
diff --git
a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestMetaRegionReplicaReplicationEndpoint.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestMetaRegionReplicaReplicationEndpoint.java
index 7196c2827ca..41a61e48f58 100644
---
a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestMetaRegionReplicaReplicationEndpoint.java
+++
b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestMetaRegionReplicaReplicationEndpoint.java
@@ -18,11 +18,11 @@
package org.apache.hadoop.hbase.replication.regionserver;
import static
org.apache.hadoop.hbase.client.RegionLocator.LOCATOR_META_REPLICAS_MODE;
-import static org.junit.Assert.assertArrayEquals;
-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.assertArrayEquals;
+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.ArrayList;
@@ -34,7 +34,6 @@ import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.CellScanner;
import org.apache.hadoop.hbase.CellUtil;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.HRegionLocation;
@@ -56,15 +55,14 @@ import org.apache.hadoop.hbase.regionserver.Region;
import org.apache.hadoop.hbase.regionserver.RegionScanner;
import org.apache.hadoop.hbase.replication.ReplicationPeerImpl;
import org.apache.hadoop.hbase.testclassification.LargeTests;
+import org.apache.hadoop.hbase.testclassification.ReplicationTests;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.hbase.util.ServerRegionReplicaUtil;
-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;
@@ -73,11 +71,10 @@ import org.slf4j.LoggerFactory;
* verifying async wal replication replays the edits to the secondary region
in various scenarios.
* @see TestRegionReplicaReplicationEndpoint
*/
-@Category({ LargeTests.class })
+@Tag(ReplicationTests.TAG)
+@Tag(LargeTests.TAG)
public class TestMetaRegionReplicaReplicationEndpoint {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
-
HBaseClassTestRule.forClass(TestMetaRegionReplicaReplicationEndpoint.class);
+
private static final Logger LOG =
LoggerFactory.getLogger(TestMetaRegionReplicaReplicationEndpoint.class);
private static final int NB_SERVERS = 4;
@@ -85,11 +82,10 @@ public class TestMetaRegionReplicaReplicationEndpoint {
private int numOfMetaReplica = NB_SERVERS - 1;
private static byte[] VALUE = Bytes.toBytes("value");
- @Rule
- public TestName name = new TestName();
+ private String methodName;
- @Before
- public void before() throws Exception {
+ @BeforeEach
+ public void before(TestInfo testInfo) throws Exception {
Configuration conf = HTU.getConfiguration();
conf.setFloat("hbase.regionserver.logroll.multiplier", 0.0003f);
conf.setInt("replication.source.size.capacity", 10240);
@@ -112,9 +108,10 @@ public class TestMetaRegionReplicaReplicationEndpoint {
HTU.waitFor(30000, () ->
HTU.getMiniHBaseCluster().getRegions(TableName.META_TABLE_NAME).size()
>= numOfMetaReplica);
+ methodName = testInfo.getTestMethod().get().getName();
}
- @After
+ @AfterEach
public void after() throws Exception {
HTU.shutdownMiniCluster();
}
@@ -169,8 +166,8 @@ public class TestMetaRegionReplicaReplicationEndpoint {
*/
private void testHBaseMetaReplicatesOneRow(int i) throws Exception {
waitForMetaReplicasToOnline();
- try (Table table =
HTU.createTable(TableName.valueOf(this.name.getMethodName() + "_" + i),
- HConstants.CATALOG_FAMILY)) {
+ try (Table table =
+ HTU.createTable(TableName.valueOf(methodName + "_" + i),
HConstants.CATALOG_FAMILY)) {
verifyReplication(TableName.META_TABLE_NAME, numOfMetaReplica,
getMetaCells(table.getName()));
}
}
@@ -187,14 +184,14 @@ public class TestMetaRegionReplicaReplicationEndpoint {
*/
@Test
public void testHBaseMetaReplicates() throws Exception {
- try (Table table =
HTU.createTable(TableName.valueOf(this.name.getMethodName() + "_0"),
- HConstants.CATALOG_FAMILY,
- Arrays.copyOfRange(HBaseTestingUtility.KEYS, 1,
HBaseTestingUtility.KEYS.length))) {
+ try (
+ Table table = HTU.createTable(TableName.valueOf(methodName + "_0"),
HConstants.CATALOG_FAMILY,
+ Arrays.copyOfRange(HBaseTestingUtility.KEYS, 1,
HBaseTestingUtility.KEYS.length))) {
verifyReplication(TableName.META_TABLE_NAME, numOfMetaReplica,
getMetaCells(table.getName()));
}
- try (Table table =
HTU.createTable(TableName.valueOf(this.name.getMethodName() + "_1"),
- HConstants.CATALOG_FAMILY,
- Arrays.copyOfRange(HBaseTestingUtility.KEYS, 1,
HBaseTestingUtility.KEYS.length))) {
+ try (
+ Table table = HTU.createTable(TableName.valueOf(methodName + "_1"),
HConstants.CATALOG_FAMILY,
+ Arrays.copyOfRange(HBaseTestingUtility.KEYS, 1,
HBaseTestingUtility.KEYS.length))) {
verifyReplication(TableName.META_TABLE_NAME, numOfMetaReplica,
getMetaCells(table.getName()));
// Try delete.
HTU.deleteTableIfAny(table.getName());
@@ -575,8 +572,7 @@ public class TestMetaRegionReplicaReplicationEndpoint {
@Test
public void testHBaseMetaReplicaGets() throws Exception {
-
- TableName tn = TableName.valueOf(this.name.getMethodName());
+ TableName tn = TableName.valueOf(methodName);
final Region[] metaRegions = getAllRegions(TableName.META_TABLE_NAME,
numOfMetaReplica);
long[] readReqsForMetaReplicas = new long[numOfMetaReplica];
long[] readReqsForMetaReplicasAfterGet = new long[numOfMetaReplica];
diff --git
a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestRaceWhenCreatingReplicationSource.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestRaceWhenCreatingReplicationSource.java
index 53ee0d720d8..bb147c1a188 100644
---
a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestRaceWhenCreatingReplicationSource.java
+++
b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestRaceWhenCreatingReplicationSource.java
@@ -17,8 +17,8 @@
*/
package org.apache.hadoop.hbase.replication.regionserver;
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import java.io.IOException;
import java.io.UncheckedIOException;
@@ -27,7 +27,6 @@ import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.CellUtil;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.TableName;
@@ -46,22 +45,18 @@ import org.apache.hadoop.hbase.wal.WAL;
import org.apache.hadoop.hbase.wal.WAL.Entry;
import org.apache.hadoop.hbase.wal.WALFactory;
import org.apache.hadoop.hbase.wal.WALProvider;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
/**
* Testcase for HBASE-20624.
*/
-@Category({ ReplicationTests.class, MediumTests.class })
+@Tag(ReplicationTests.TAG)
+@Tag(MediumTests.TAG)
public class TestRaceWhenCreatingReplicationSource {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestRaceWhenCreatingReplicationSource.class);
-
private static final HBaseTestingUtility UTIL = new HBaseTestingUtility();
private static String PEER_ID = "1";
@@ -82,7 +77,7 @@ public class TestRaceWhenCreatingReplicationSource {
public static final class LocalReplicationEndpoint extends
BaseReplicationEndpoint {
- private static final UUID PEER_UUID = UTIL.getRandomUUID();
+ private static final UUID PEER_UUID = HBaseTestingUtility.getRandomUUID();
@Override
public UUID getPeerUUID() {
@@ -134,7 +129,7 @@ public class TestRaceWhenCreatingReplicationSource {
}
}
- @BeforeClass
+ @BeforeAll
public static void setUpBeforeClass() throws Exception {
UTIL.getConfiguration().set(WALFactory.WAL_PROVIDER, "multiwal");
// make sure that we will create a new group for the table
@@ -150,7 +145,7 @@ public class TestRaceWhenCreatingReplicationSource {
true);
}
- @AfterClass
+ @AfterAll
public static void tearDownAfterClass() throws Exception {
UTIL.shutdownMiniCluster();
}
diff --git
a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestRefreshPeerWhileRegionServerRestarts.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestRefreshPeerWhileRegionServerRestarts.java
index 267e85b2706..1fa3dcf74a6 100644
---
a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestRefreshPeerWhileRegionServerRestarts.java
+++
b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestRefreshPeerWhileRegionServerRestarts.java
@@ -17,14 +17,13 @@
*/
package org.apache.hadoop.hbase.replication.regionserver;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import java.io.IOException;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ForkJoinPool;
import java.util.concurrent.Future;
import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.master.replication.DisablePeerProcedure;
import org.apache.hadoop.hbase.procedure2.Procedure;
@@ -34,9 +33,8 @@ import
org.apache.hadoop.hbase.replication.ReplicationPeer.PeerState;
import org.apache.hadoop.hbase.replication.TestReplicationBase;
import org.apache.hadoop.hbase.testclassification.MasterTests;
import org.apache.hadoop.hbase.testclassification.MediumTests;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
import
org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.PeerModificationState;
@@ -44,13 +42,10 @@ import
org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.P
* This UT is used to make sure that we will not accidentally change the way
to generate online
* servers. See HBASE-25774 and HBASE-25032 for more details.
*/
-@Category({ MasterTests.class, MediumTests.class })
+@Tag(MasterTests.TAG)
+@Tag(MediumTests.TAG)
public class TestRefreshPeerWhileRegionServerRestarts extends
TestReplicationBase {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
-
HBaseClassTestRule.forClass(TestRefreshPeerWhileRegionServerRestarts.class);
-
private static CountDownLatch ARRIVE;
private static CountDownLatch RESUME;
diff --git
a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestRefreshRecoveredReplication.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestRefreshRecoveredReplication.java
index 93aa7130926..775ff9ef7ce 100644
---
a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestRefreshRecoveredReplication.java
+++
b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestRefreshRecoveredReplication.java
@@ -17,39 +17,33 @@
*/
package org.apache.hadoop.hbase.replication.regionserver;
-import static org.junit.Assert.assertEquals;
+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.Optional;
-import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.ColumnFamilyDescriptorBuilder;
import org.apache.hadoop.hbase.client.Put;
-import org.apache.hadoop.hbase.client.Result;
import org.apache.hadoop.hbase.client.ResultScanner;
import org.apache.hadoop.hbase.client.Scan;
import org.apache.hadoop.hbase.client.Table;
import org.apache.hadoop.hbase.client.TableDescriptor;
import org.apache.hadoop.hbase.client.TableDescriptorBuilder;
import org.apache.hadoop.hbase.regionserver.HRegionServer;
-import org.apache.hadoop.hbase.replication.TestReplicationBase;
+import org.apache.hadoop.hbase.replication.TestReplicationBaseNoBeforeAll;
import org.apache.hadoop.hbase.testclassification.MediumTests;
import org.apache.hadoop.hbase.testclassification.ReplicationTests;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.hbase.util.JVMClusterUtil.RegionServerThread;
-import org.junit.After;
-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.AfterEach;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -58,44 +52,36 @@ import
org.apache.hbase.thirdparty.org.apache.commons.collections4.CollectionUti
/**
* Testcase for HBASE-24871.
*/
-@Category({ ReplicationTests.class, MediumTests.class })
-public class TestRefreshRecoveredReplication extends TestReplicationBase {
-
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestRefreshRecoveredReplication.class);
+@Tag(ReplicationTests.TAG)
+@Tag(MediumTests.TAG)
+public class TestRefreshRecoveredReplication extends
TestReplicationBaseNoBeforeAll {
private static final Logger LOG =
LoggerFactory.getLogger(TestRefreshRecoveredReplication.class);
private static final int BATCH = 50;
- @Rule
- public TestName name = new TestName();
-
- private TableName tablename;
- private Table table1;
- private Table table2;
-
- @BeforeClass
+ @BeforeAll
public static void setUpBeforeClass() throws Exception {
// NUM_SLAVES1 is presumed 2 in below.
NUM_SLAVES1 = 2;
+ configureClusters(UTIL1, UTIL2);
// replicate slowly
- Configuration conf1 = UTIL1.getConfiguration();
- conf1.setInt(HConstants.REPLICATION_SOURCE_TOTAL_BUFFER_KEY, 100);
- TestReplicationBase.setUpBeforeClass();
+ CONF1.setInt(HConstants.REPLICATION_SOURCE_TOTAL_BUFFER_KEY, 100);
+ startClusters();
}
- @AfterClass
- public static void tearDownAfterClass() throws Exception {
- TestReplicationBase.tearDownAfterClass();
- }
+ private String testName;
+
+ private TableName tablename;
+ private Table table1;
+ private Table table2;
- @Before
- public void setup() throws Exception {
+ @BeforeEach
+ public void setup(TestInfo testInfo) throws Exception {
+ testName = testInfo.getTestMethod().get().getName();
setUpBase();
- tablename = TableName.valueOf(name.getMethodName());
+ tablename = TableName.valueOf(testName);
TableDescriptor table =
TableDescriptorBuilder.newBuilder(tablename).setColumnFamily(ColumnFamilyDescriptorBuilder
.newBuilder(famName).setScope(HConstants.REPLICATION_SCOPE_GLOBAL).build()).build();
@@ -108,7 +94,7 @@ public class TestRefreshRecoveredReplication extends
TestReplicationBase {
table2 = UTIL2.getConnection().getTable(tablename);
}
- @After
+ @AfterEach
public void teardown() throws Exception {
tearDownBase();
@@ -130,7 +116,7 @@ public class TestRefreshRecoveredReplication extends
TestReplicationBase {
Optional<RegionServerThread> server = rss.stream()
.filter(rst ->
CollectionUtils.isNotEmpty(rst.getRegionServer().getRegions(tablename)))
.findAny();
- Assert.assertTrue(server.isPresent());
+ assertTrue(server.isPresent());
HRegionServer otherServer = rss.get(0).getRegionServer() ==
server.get().getRegionServer()
? rss.get(1).getRegionServer()
: rss.get(0).getRegionServer();
@@ -159,9 +145,10 @@ public class TestRefreshRecoveredReplication extends
TestReplicationBase {
private int checkReplicationData() throws IOException {
int count = 0;
- ResultScanner results = table2.getScanner(new Scan().setCaching(BATCH));
- for (Result r : results) {
- count++;
+ try (ResultScanner results = table2.getScanner(new
Scan().setCaching(BATCH))) {
+ while (results.next() != null) {
+ count++;
+ }
}
return count;
}
diff --git
a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestRegionReplicaReplicationEndpoint.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestRegionReplicaReplicationEndpoint.java
index 9a03536f754..4afa382e7be 100644
---
a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestRegionReplicaReplicationEndpoint.java
+++
b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestRegionReplicaReplicationEndpoint.java
@@ -17,11 +17,11 @@
*/
package org.apache.hadoop.hbase.replication.regionserver;
-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 static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -37,7 +37,6 @@ import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.Cell.Type;
import org.apache.hadoop.hbase.CellBuilderFactory;
import org.apache.hadoop.hbase.CellBuilderType;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.HRegionLocation;
@@ -67,13 +66,12 @@ import org.apache.hadoop.hbase.wal.WAL.Entry;
import org.apache.hadoop.hbase.wal.WALEdit;
import org.apache.hadoop.hbase.wal.WALKeyImpl;
import org.apache.hadoop.hbase.zookeeper.ZKConfig;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-import org.junit.rules.TestName;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -84,13 +82,10 @@ import
org.apache.hbase.thirdparty.com.google.common.util.concurrent.Uninterrupt
* Tests RegionReplicaReplicationEndpoint class by setting up region replicas
and verifying async
* wal replication replays the edits to the secondary region in various
scenarios.
*/
-@Category({ FlakeyTests.class, LargeTests.class })
+@Tag(FlakeyTests.TAG)
+@Tag(LargeTests.TAG)
public class TestRegionReplicaReplicationEndpoint {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestRegionReplicaReplicationEndpoint.class);
-
private static final Logger LOG =
LoggerFactory.getLogger(TestRegionReplicaReplicationEndpoint.class);
@@ -98,10 +93,9 @@ public class TestRegionReplicaReplicationEndpoint {
private static final HBaseTestingUtility HTU = new HBaseTestingUtility();
- @Rule
- public TestName name = new TestName();
+ private String methodName;
- @BeforeClass
+ @BeforeAll
public static void beforeClass() throws Exception {
Configuration conf = HTU.getConfiguration();
conf.setFloat("hbase.regionserver.logroll.multiplier", 0.0003f);
@@ -121,11 +115,16 @@ public class TestRegionReplicaReplicationEndpoint {
HTU.startMiniCluster(NB_SERVERS);
}
- @AfterClass
+ @AfterAll
public static void afterClass() throws Exception {
HTU.shutdownMiniCluster();
}
+ @BeforeEach
+ public void before(TestInfo testInfo) {
+ methodName = testInfo.getTestMethod().get().getName();
+ }
+
@Test
public void testRegionReplicaReplicationPeerIsCreated() throws IOException,
ReplicationException {
// create a table with region replicas. Check whether the replication peer
is created
@@ -319,7 +318,7 @@ public class TestRegionReplicaReplicationEndpoint {
@Test
public void testRegionReplicaWithoutMemstoreReplication() throws Exception {
int regionReplication = 3;
- final TableName tableName = TableName.valueOf(name.getMethodName());
+ final TableName tableName = TableName.valueOf(methodName);
HTableDescriptor htd = HTU.createTableDescriptor(tableName);
htd.setRegionReplication(regionReplication);
htd.setRegionMemstoreReplication(false);
@@ -355,7 +354,7 @@ public class TestRegionReplicaReplicationEndpoint {
// does not test whether the replicas actually pick up flushed files and
apply compaction
// to their stores
int regionReplication = 3;
- final TableName tableName = TableName.valueOf(name.getMethodName());
+ final TableName tableName = TableName.valueOf(methodName);
HTableDescriptor htd = HTU.createTableDescriptor(tableName);
htd.setRegionReplication(regionReplication);
createOrEnableTableWithRetries(htd, true);
@@ -402,8 +401,8 @@ public class TestRegionReplicaReplicationEndpoint {
// tests having edits from a disabled or dropped table is handled
correctly by skipping those
// entries and further edits after the edits from dropped/disabled table
can be replicated
// without problems.
- final TableName tableName = TableName.valueOf(
- name.getMethodName() + "_drop_" + dropTable + "_disabledReplication_" +
disableReplication);
+ final TableName tableName = TableName
+ .valueOf(methodName + "_drop_" + dropTable + "_disabledReplication_" +
disableReplication);
HTableDescriptor htd = HTU.createTableDescriptor(tableName);
int regionReplication = 3;
htd.setRegionReplication(regionReplication);
diff --git
a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestRegionReplicaReplicationEndpointNoMaster.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestRegionReplicaReplicationEndpointNoMaster.java
index 91e04fe6e10..faee6fb8c4f 100644
---
a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestRegionReplicaReplicationEndpointNoMaster.java
+++
b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestRegionReplicaReplicationEndpointNoMaster.java
@@ -19,6 +19,7 @@ package org.apache.hadoop.hbase.replication.regionserver;
import static
org.apache.hadoop.hbase.regionserver.TestRegionServerNoMaster.closeRegion;
import static
org.apache.hadoop.hbase.regionserver.TestRegionServerNoMaster.openRegion;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -29,7 +30,6 @@ import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.atomic.AtomicLong;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.CellUtil;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.HRegionInfo;
@@ -62,14 +62,11 @@ import org.apache.hadoop.hbase.wal.WAL.Entry;
import org.apache.hadoop.hbase.wal.WALEdit;
import org.apache.hadoop.hbase.wal.WALKey;
import org.apache.hadoop.hbase.wal.WALKeyImpl;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
import org.apache.hbase.thirdparty.com.google.common.collect.Lists;
@@ -79,13 +76,10 @@ import
org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.ReplicateWA
* Tests RegionReplicaReplicationEndpoint. Unlike
TestRegionReplicaReplicationEndpoint this class
* contains lower level tests using callables.
*/
-@Category({ ReplicationTests.class, MediumTests.class })
+@Tag(ReplicationTests.TAG)
+@Tag(MediumTests.TAG)
public class TestRegionReplicaReplicationEndpointNoMaster {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
-
HBaseClassTestRule.forClass(TestRegionReplicaReplicationEndpointNoMaster.class);
-
private static final int NB_SERVERS = 2;
private static TableName tableName =
TableName.valueOf(TestRegionReplicaReplicationEndpointNoMaster.class.getSimpleName());
@@ -101,7 +95,7 @@ public class TestRegionReplicaReplicationEndpointNoMaster {
private static final HBaseTestingUtility HTU = new HBaseTestingUtility();
private static final byte[] f = HConstants.CATALOG_FAMILY;
- @BeforeClass
+ @BeforeAll
public static void beforeClass() throws Exception {
Configuration conf = HTU.getConfiguration();
conf.setBoolean(ServerRegionReplicaUtil.REGION_REPLICA_REPLICATION_CONF_KEY,
true);
@@ -137,22 +131,18 @@ public class TestRegionReplicaReplicationEndpointNoMaster
{
rs1 = HTU.getMiniHBaseCluster().getRegionServer(1);
}
- @AfterClass
+ @AfterAll
public static void afterClass() throws Exception {
HRegionServer.TEST_SKIP_REPORTING_TRANSITION = false;
table.close();
HTU.shutdownMiniCluster();
}
- @Before
+ @BeforeEach
public void before() throws Exception {
entries.clear();
}
- @After
- public void after() throws Exception {
- }
-
static ConcurrentLinkedQueue<Entry> entries = new ConcurrentLinkedQueue<>();
public static class WALEditCopro implements WALCoprocessor, WALObserver {
@@ -186,7 +176,7 @@ public class TestRegionReplicaReplicationEndpointNoMaster {
// load some data to primary
HTU.loadNumericRows(table, f, 0, 1000);
- Assert.assertEquals(1000, entries.size());
+ assertEquals(1000, entries.size());
// replay the edits to the secondary using replay callable
replicateUsingCallable(connection, entries);
@@ -226,7 +216,7 @@ public class TestRegionReplicaReplicationEndpointNoMaster {
// load some data to primary
HTU.loadNumericRows(table, f, 0, 1000);
- Assert.assertEquals(1000, entries.size());
+ assertEquals(1000, entries.size());
// replay the edits to the secondary using replay callable
replicateUsingCallable(connection, entries);
@@ -269,7 +259,7 @@ public class TestRegionReplicaReplicationEndpointNoMaster {
// load some data to primary
HTU.loadNumericRows(table, f, 0, 1000);
- Assert.assertEquals(1000, entries.size());
+ assertEquals(1000, entries.size());
// replay the edits to the secondary using replay callable
final String fakeWalGroupId = "fakeWALGroup";
replicator.replicate(
diff --git
a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestReplicationCompressedWAL.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestReplicationCompressedWAL.java
index 27c39cc0df2..c57d252bd8a 100644
---
a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestReplicationCompressedWAL.java
+++
b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestReplicationCompressedWAL.java
@@ -17,46 +17,37 @@
*/
package org.apache.hadoop.hbase.replication.regionserver;
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.fail;
import java.io.IOException;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.client.Get;
import org.apache.hadoop.hbase.client.Put;
import org.apache.hadoop.hbase.client.Result;
-import org.apache.hadoop.hbase.replication.TestReplicationBase;
+import org.apache.hadoop.hbase.replication.TestReplicationBaseNoBeforeAll;
import org.apache.hadoop.hbase.testclassification.MediumTests;
+import org.apache.hadoop.hbase.testclassification.ReplicationTests;
import org.apache.hadoop.hbase.util.Bytes;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-@Category(MediumTests.class)
-public class TestReplicationCompressedWAL extends TestReplicationBase {
-
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestReplicationCompressedWAL.class);
+@Tag(ReplicationTests.TAG)
+@Tag(MediumTests.TAG)
+public class TestReplicationCompressedWAL extends
TestReplicationBaseNoBeforeAll {
static final Logger LOG =
LoggerFactory.getLogger(TestReplicationCompressedWAL.class);
static final int NUM_BATCHES = 20;
static final int NUM_ROWS_PER_BATCH = 100;
- @BeforeClass
+ @BeforeAll
public static void setUpBeforeClass() throws Exception {
+ configureClusters(UTIL1, UTIL2);
CONF1.setBoolean(HConstants.ENABLE_WAL_COMPRESSION, true);
- TestReplicationBase.setUpBeforeClass();
- }
-
- @AfterClass
- public static void tearDownAfterClass() throws Exception {
- TestReplicationBase.tearDownAfterClass();
+ startClusters();
}
@Test
diff --git
a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestReplicationSink.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestReplicationSink.java
index 3c48c336ef9..108f13f81a8 100644
---
a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestReplicationSink.java
+++
b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestReplicationSink.java
@@ -17,7 +17,8 @@
*/
package org.apache.hadoop.hbase.replication.regionserver;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.fail;
import java.io.IOException;
import java.util.ArrayList;
@@ -37,7 +38,6 @@ import org.apache.hadoop.fs.FileUtil;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.CellUtil;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.HRegionInfo;
@@ -62,13 +62,11 @@ import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.hbase.util.CommonFSUtils;
import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
import org.apache.hadoop.hbase.util.HFileTestUtil;
-import org.junit.AfterClass;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -80,13 +78,10 @@ import
org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.UUID;
import org.apache.hadoop.hbase.shaded.protobuf.generated.WALProtos;
import org.apache.hadoop.hbase.shaded.protobuf.generated.WALProtos.WALKey;
-@Category({ ReplicationTests.class, LargeTests.class })
+@Tag(ReplicationTests.TAG)
+@Tag(LargeTests.TAG)
public class TestReplicationSink {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestReplicationSink.class);
-
private static final Logger LOG =
LoggerFactory.getLogger(TestReplicationSink.class);
private static final int BATCH_SIZE = 10;
@@ -122,10 +117,7 @@ public class TestReplicationSink {
protected static String hfileArchiveDir;
protected static String replicationClusterId;
- /**
- * @throws java.lang.Exception
- */
- @BeforeClass
+ @BeforeAll
public static void setUpBeforeClass() throws Exception {
TEST_UTIL.getConfiguration().set("hbase.replication.source.fs.conf.provider",
TestSourceFSConfigurationProvider.class.getCanonicalName());
@@ -141,19 +133,13 @@ public class TestReplicationSink {
replicationClusterId = "12345";
}
- /**
- * @throws java.lang.Exception
- */
- @AfterClass
+ @AfterAll
public static void tearDownAfterClass() throws Exception {
STOPPABLE.stop("Shutting down");
TEST_UTIL.shutdownMiniCluster();
}
- /**
- * @throws java.lang.Exception
- */
- @Before
+ @BeforeEach
public void setUp() throws Exception {
table1 = TEST_UTIL.deleteTableData(TABLE_NAME1);
table2 = TEST_UTIL.deleteTableData(TABLE_NAME2);
@@ -319,7 +305,7 @@ public class TestReplicationSink {
try {
SINK.replicateEntries(entries,
CellUtil.createCellScanner(cells.iterator()),
replicationClusterId, baseNamespaceDir, hfileArchiveDir);
- Assert.fail("Should re-throw TableNotFoundException.");
+ fail("Should re-throw TableNotFoundException.");
} catch (TableNotFoundException e) {
}
entries.clear();
@@ -333,7 +319,7 @@ public class TestReplicationSink {
try {
SINK.replicateEntries(entries,
CellUtil.createCellScanner(cells.iterator()),
replicationClusterId, baseNamespaceDir, hfileArchiveDir);
- Assert.fail("Should re-throw RetriesExhaustedException.");
+ fail("Should re-throw RetriesExhaustedException.");
} catch (RetriesExhaustedException e) {
} finally {
admin.enableTable(TABLE_NAME1);
@@ -437,7 +423,7 @@ public class TestReplicationSink {
try {
SINK.replicateEntries(entries,
CellUtil.createCellScanner(cells.iterator()),
replicationClusterId, baseNamespaceDir, hfileArchiveDir);
- Assert.fail("Should re-throw ArrayIndexOutOfBoundsException.");
+ fail("Should re-throw ArrayIndexOutOfBoundsException.");
} catch (ArrayIndexOutOfBoundsException e) {
errorCount++;
assertEquals(initialFailedBatches + errorCount,
SINK.getSinkMetrics().getFailedBatches());
@@ -452,7 +438,7 @@ public class TestReplicationSink {
try {
SINK.replicateEntries(entries,
CellUtil.createCellScanner(cells.iterator()),
replicationClusterId, baseNamespaceDir, hfileArchiveDir);
- Assert.fail("Should re-throw TableNotFoundException.");
+ fail("Should re-throw TableNotFoundException.");
} catch (TableNotFoundException e) {
errorCount++;
assertEquals(initialFailedBatches + errorCount,
SINK.getSinkMetrics().getFailedBatches());
@@ -470,7 +456,7 @@ public class TestReplicationSink {
try {
SINK.replicateEntries(entries,
CellUtil.createCellScanner(cells.iterator()),
replicationClusterId, baseNamespaceDir, hfileArchiveDir);
- Assert.fail("Should re-throw IOException.");
+ fail("Should re-throw IOException.");
} catch (IOException e) {
errorCount++;
assertEquals(initialFailedBatches + errorCount,
SINK.getSinkMetrics().getFailedBatches());
diff --git
a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestReplicationSinkManager.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestReplicationSinkManager.java
index 8cf8d12c250..ab82f189af8 100644
---
a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestReplicationSinkManager.java
+++
b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestReplicationSinkManager.java
@@ -17,34 +17,29 @@
*/
package org.apache.hadoop.hbase.replication.regionserver;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.Mockito.mock;
import java.util.List;
import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.ServerName;
import org.apache.hadoop.hbase.client.ClusterConnection;
import org.apache.hadoop.hbase.replication.HBaseReplicationEndpoint;
import
org.apache.hadoop.hbase.replication.regionserver.ReplicationSinkManager.SinkPeer;
import org.apache.hadoop.hbase.testclassification.ReplicationTests;
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.Lists;
import
org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.AdminService;
-@Category({ ReplicationTests.class, SmallTests.class })
+@Tag(ReplicationTests.TAG)
+@Tag(SmallTests.TAG)
public class TestReplicationSinkManager {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestReplicationSinkManager.class);
-
private static final String PEER_CLUSTER_ID = "PEER_CLUSTER_ID";
private ReplicationSinkManager sinkManager;
@@ -74,7 +69,7 @@ public class TestReplicationSinkManager {
}
}
- @Before
+ @BeforeEach
public void setUp() {
this.replicationEndpoint = new SetServersHBaseReplicationEndpoint();
sinkManager = new ReplicationSinkManager(mock(ClusterConnection.class),
PEER_CLUSTER_ID,
diff --git
a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestReplicationSource.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestReplicationSource.java
index 454b8387fa7..6b4760ea516 100644
---
a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestReplicationSource.java
+++
b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestReplicationSource.java
@@ -18,11 +18,11 @@
package org.apache.hadoop.hbase.replication.regionserver;
import static
org.apache.hadoop.hbase.wal.AbstractFSWALProvider.META_WAL_PROVIDER_ID;
-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 static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -42,7 +42,6 @@ import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.CellBuilderFactory;
import org.apache.hadoop.hbase.CellBuilderType;
import org.apache.hadoop.hbase.CompatibilitySingletonFactory;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.HConstants;
@@ -70,22 +69,18 @@ import org.apache.hadoop.hbase.wal.WALEdit;
import org.apache.hadoop.hbase.wal.WALFactory;
import org.apache.hadoop.hbase.wal.WALKeyImpl;
import org.apache.hadoop.hbase.wal.WALProvider;
-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.mockito.Mockito;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-@Category({ ReplicationTests.class, MediumTests.class })
+@Tag(ReplicationTests.TAG)
+@Tag(MediumTests.TAG)
public class TestReplicationSource {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestReplicationSource.class);
-
private static final Logger LOG =
LoggerFactory.getLogger(TestReplicationSource.class);
private final static HBaseTestingUtility TEST_UTIL = new
HBaseTestingUtility();
private final static HBaseTestingUtility TEST_UTIL_PEER = new
HBaseTestingUtility();
@@ -94,7 +89,7 @@ public class TestReplicationSource {
private static Path logDir;
private static Configuration conf = TEST_UTIL.getConfiguration();
- @BeforeClass
+ @BeforeAll
public static void setUpBeforeClass() throws Exception {
TEST_UTIL.startMiniDFSCluster(1);
FS = TEST_UTIL.getDFSCluster().getFileSystem();
@@ -109,7 +104,7 @@ public class TestReplicationSource {
}
}
- @AfterClass
+ @AfterAll
public static void tearDownAfterClass() throws Exception {
TEST_UTIL_PEER.shutdownMiniHBaseCluster();
TEST_UTIL.shutdownMiniHBaseCluster();
diff --git
a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestReplicationSourceLogQueue.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestReplicationSourceLogQueue.java
index 9d101b97217..4608100b42c 100644
---
a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestReplicationSourceLogQueue.java
+++
b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestReplicationSourceLogQueue.java
@@ -17,30 +17,25 @@
*/
package org.apache.hadoop.hbase.replication.regionserver;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.Mockito.mock;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.testclassification.ReplicationTests;
import org.apache.hadoop.hbase.testclassification.SmallTests;
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;
import org.mockito.Mockito;
-@Category({ SmallTests.class, ReplicationTests.class })
+@Tag(SmallTests.TAG)
+@Tag(ReplicationTests.TAG)
public class TestReplicationSourceLogQueue {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestReplicationSourceLogQueue.class);
-
- /*
+ /**
* Testing enqueue and dequeuing of wal and check age of oldest wal.
*/
@Test
diff --git
a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestReplicationSourceManager.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestReplicationSourceManager.java
index 268aa65ab18..2893a127839 100644
---
a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestReplicationSourceManager.java
+++
b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestReplicationSourceManager.java
@@ -17,11 +17,11 @@
*/
package org.apache.hadoop.hbase.replication.regionserver;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.IOException;
import java.lang.reflect.Field;
@@ -46,7 +46,6 @@ import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hbase.ChoreService;
import org.apache.hadoop.hbase.ClusterId;
import org.apache.hadoop.hbase.CoordinatedStateManager;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.HColumnDescriptor;
@@ -72,8 +71,6 @@ import
org.apache.hadoop.hbase.replication.ReplicationQueueStorage;
import org.apache.hadoop.hbase.replication.ReplicationSourceDummy;
import org.apache.hadoop.hbase.replication.ReplicationStorageFactory;
import org.apache.hadoop.hbase.replication.ZKReplicationPeerStorage;
-import org.apache.hadoop.hbase.testclassification.MediumTests;
-import org.apache.hadoop.hbase.testclassification.ReplicationTests;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.hbase.util.CommonFSUtils;
import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
@@ -86,14 +83,11 @@ import org.apache.hadoop.hbase.wal.WALKeyImpl;
import org.apache.hadoop.hbase.zookeeper.ZKClusterId;
import org.apache.hadoop.hbase.zookeeper.ZKUtil;
import org.apache.hadoop.hbase.zookeeper.ZKWatcher;
-import org.junit.After;
-import org.junit.AfterClass;
-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.AfterAll;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -108,13 +102,8 @@ import
org.apache.hadoop.hbase.shaded.protobuf.generated.WALProtos.BulkLoadDescr
* An abstract class that tests ReplicationSourceManager. Classes that extend
this class should set
* up the proper config for this class and initialize the proper cluster using
HBaseTestingUtility.
*/
-@Category({ ReplicationTests.class, MediumTests.class })
public abstract class TestReplicationSourceManager {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestReplicationSourceManager.class);
-
protected static final Logger LOG =
LoggerFactory.getLogger(TestReplicationSourceManager.class);
protected static Configuration conf;
@@ -219,7 +208,7 @@ public abstract class TestReplicationSourceManager {
.map(Replication::getReplicationManager).get();
}
- @AfterClass
+ @AfterAll
public static void tearDownAfterClass() throws Exception {
if (manager != null) {
manager.join();
@@ -227,23 +216,20 @@ public abstract class TestReplicationSourceManager {
utility.shutdownMiniCluster();
}
- @Rule
- public TestName testName = new TestName();
-
private void cleanLogDir() throws IOException {
fs.delete(logDir, true);
fs.delete(oldLogDir, true);
}
- @Before
- public void setUp() throws Exception {
- LOG.info("Start " + testName.getMethodName());
+ @BeforeEach
+ public void setUp(TestInfo testInfo) throws Exception {
+ LOG.info("Start " + testInfo.getTestMethod().get().getName());
cleanLogDir();
}
- @After
- public void tearDown() throws Exception {
- LOG.info("End " + testName.getMethodName());
+ @AfterEach
+ public void tearDown(TestInfo testInfo) throws Exception {
+ LOG.info("End " + testInfo.getTestMethod().get().getName());
cleanLogDir();
List<String> ids =
manager.getSources().stream().map(ReplicationSourceInterface::getPeerId)
.collect(Collectors.toList());
@@ -432,8 +418,8 @@ public abstract class TestReplicationSourceManager {
ReplicationSourceWALActionListener.scopeWALEdits(logKey, logEdit, conf);
// 4. Assert that no bulk load entry scopes are added if bulk load hfile
replication is disabled
- assertNull("No bulk load entries scope should be added if bulk load
replication is disabled.",
- logKey.getReplicationScopes());
+ assertNull(logKey.getReplicationScopes(),
+ "No bulk load entries scope should be added if bulk load replication is
disabled.");
}
@Test
@@ -452,11 +438,11 @@ public abstract class TestReplicationSourceManager {
NavigableMap<byte[], Integer> scopes = logKey.getReplicationScopes();
// Assert family with replication scope global is present in the key scopes
- assertTrue("This family scope is set to global, should be part of
replication key scopes.",
- scopes.containsKey(f1));
+ assertTrue(scopes.containsKey(f1),
+ "This family scope is set to global, should be part of replication key
scopes.");
// Assert family with replication scope local is not present in the key
scopes
- assertFalse("This family scope is set to local, should not be part of
replication key scopes",
- scopes.containsKey(f2));
+ assertFalse(scopes.containsKey(f2),
+ "This family scope is set to local, should not be part of replication
key scopes");
}
/**
diff --git
a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestReplicationSourceManagerJoin.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestReplicationSourceManagerJoin.java
index d7d23783eac..3362a223fbd 100644
---
a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestReplicationSourceManagerJoin.java
+++
b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestReplicationSourceManagerJoin.java
@@ -17,12 +17,11 @@
*/
package org.apache.hadoop.hbase.replication.regionserver;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.Optional;
import java.util.stream.Stream;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.ColumnFamilyDescriptorBuilder;
@@ -31,40 +30,34 @@ import org.apache.hadoop.hbase.client.Table;
import org.apache.hadoop.hbase.client.TableDescriptor;
import org.apache.hadoop.hbase.client.TableDescriptorBuilder;
import org.apache.hadoop.hbase.regionserver.HRegionServer;
-import org.apache.hadoop.hbase.replication.TestReplicationBase;
+import org.apache.hadoop.hbase.replication.TestReplicationBaseNoBeforeAll;
import org.apache.hadoop.hbase.testclassification.MediumTests;
import org.apache.hadoop.hbase.testclassification.ReplicationTests;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.hbase.util.JVMClusterUtil;
-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.BeforeAll;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestInfo;
-@Category({ ReplicationTests.class, MediumTests.class })
-public class TestReplicationSourceManagerJoin extends TestReplicationBase {
+@Tag(ReplicationTests.TAG)
+@Tag(MediumTests.TAG)
+public class TestReplicationSourceManagerJoin extends
TestReplicationBaseNoBeforeAll {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestReplicationSourceManagerJoin.class);
-
- @Rule
- public TestName testName = new TestName();
-
- @BeforeClass
+ @BeforeAll
public static void setUpBeforeClass() throws Exception {
// NUM_SLAVES1 is presumed 2 in below.
NUM_SLAVES1 = 2;
- TestReplicationBase.setUpBeforeClass();
+ configureClusters(UTIL1, UTIL2);
+ startClusters();
}
@Test
- public void testReplicationSourcesTerminate() throws Exception {
+ public void testReplicationSourcesTerminate(TestInfo testInfo) throws
Exception {
+ String testName = testInfo.getTestMethod().get().getName();
// Create table in source cluster only, let TableNotFoundException block
peer to avoid
// recovered source end.
- TableName tableName = TableName.valueOf(testName.getMethodName());
+ TableName tableName = TableName.valueOf(testName);
TableDescriptor td = TableDescriptorBuilder.newBuilder(tableName)
.setColumnFamily(ColumnFamilyDescriptorBuilder.newBuilder(famName)
.setScope(HConstants.REPLICATION_SCOPE_GLOBAL).build())
diff --git
a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestReplicationSourceManagerZkImpl.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestReplicationSourceManagerZkImpl.java
index b8a14881962..3dfa2ebca80 100644
---
a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestReplicationSourceManagerZkImpl.java
+++
b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestReplicationSourceManagerZkImpl.java
@@ -17,10 +17,9 @@
*/
package org.apache.hadoop.hbase.replication.regionserver;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.List;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.Server;
@@ -31,24 +30,20 @@ import
org.apache.hadoop.hbase.replication.ReplicationSourceDummy;
import org.apache.hadoop.hbase.replication.ReplicationStorageFactory;
import org.apache.hadoop.hbase.testclassification.MediumTests;
import org.apache.hadoop.hbase.testclassification.ReplicationTests;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
/**
* Tests the ReplicationSourceManager with ReplicationQueueZkImpl's and
* ReplicationQueuesClientZkImpl. Also includes extra tests outside of those in
* TestReplicationSourceManager that test ReplicationQueueZkImpl-specific
behaviors.
*/
-@Category({ ReplicationTests.class, MediumTests.class })
+@Tag(ReplicationTests.TAG)
+@Tag(MediumTests.TAG)
public class TestReplicationSourceManagerZkImpl extends
TestReplicationSourceManager {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestReplicationSourceManagerZkImpl.class);
-
- @BeforeClass
+ @BeforeAll
public static void setUpBeforeClass() throws Exception {
conf = HBaseConfiguration.create();
conf.set("replication.replicationsource.implementation",
diff --git
a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestReplicationThrottler.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestReplicationThrottler.java
index ce0f7a351e8..078c3bc2d84 100644
---
a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestReplicationThrottler.java
+++
b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestReplicationThrottler.java
@@ -17,25 +17,20 @@
*/
package org.apache.hadoop.hbase.replication.regionserver;
-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 org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.testclassification.ReplicationTests;
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.slf4j.Logger;
import org.slf4j.LoggerFactory;
-@Category({ ReplicationTests.class, SmallTests.class })
+@Tag(ReplicationTests.TAG)
+@Tag(SmallTests.TAG)
public class TestReplicationThrottler {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestReplicationThrottler.class);
-
private static final Logger LOG =
LoggerFactory.getLogger(TestReplicationThrottler.class);
/**
diff --git
a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestReplicationValueCompressedWAL.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestReplicationValueCompressedWAL.java
index 03b83964dcc..436e745d2cd 100644
---
a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestReplicationValueCompressedWAL.java
+++
b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestReplicationValueCompressedWAL.java
@@ -17,38 +17,29 @@
*/
package org.apache.hadoop.hbase.replication.regionserver;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.regionserver.wal.CompressionContext;
-import org.apache.hadoop.hbase.replication.TestReplicationBase;
+import org.apache.hadoop.hbase.replication.TestReplicationBaseNoBeforeAll;
import org.apache.hadoop.hbase.testclassification.MediumTests;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.apache.hadoop.hbase.testclassification.ReplicationTests;
+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(MediumTests.class)
-public class TestReplicationValueCompressedWAL extends TestReplicationBase {
-
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestReplicationValueCompressedWAL.class);
+@Tag(ReplicationTests.TAG)
+@Tag(MediumTests.TAG)
+public class TestReplicationValueCompressedWAL extends
TestReplicationBaseNoBeforeAll {
static final Logger LOG =
LoggerFactory.getLogger(TestReplicationValueCompressedWAL.class);
- @BeforeClass
+ @BeforeAll
public static void setUpBeforeClass() throws Exception {
+ configureClusters(UTIL1, UTIL2);
CONF1.setBoolean(HConstants.ENABLE_WAL_COMPRESSION, true);
CONF1.setBoolean(CompressionContext.ENABLE_WAL_VALUE_COMPRESSION, true);
- TestReplicationBase.setUpBeforeClass();
- }
-
- @AfterClass
- public static void tearDownAfterClass() throws Exception {
- TestReplicationBase.tearDownAfterClass();
+ startClusters();
}
@Test
diff --git
a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestReplicator.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestReplicator.java
index 4af4b219a9a..dca7b2bf521 100644
---
a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestReplicator.java
+++
b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestReplicator.java
@@ -17,50 +17,46 @@
*/
package org.apache.hadoop.hbase.replication.regionserver;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import java.io.IOException;
import java.util.List;
import java.util.concurrent.Callable;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.Waiter;
-import org.apache.hadoop.hbase.client.HBaseAdmin;
+import org.apache.hadoop.hbase.client.Admin;
import org.apache.hadoop.hbase.client.Put;
import org.apache.hadoop.hbase.ipc.RpcServer;
import org.apache.hadoop.hbase.replication.ReplicationPeerConfig;
-import org.apache.hadoop.hbase.replication.TestReplicationBase;
+import org.apache.hadoop.hbase.replication.TestReplicationBaseNoBeforeAll;
import org.apache.hadoop.hbase.testclassification.MediumTests;
+import org.apache.hadoop.hbase.testclassification.ReplicationTests;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.hbase.wal.WAL.Entry;
-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.BeforeAll;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.hbase.thirdparty.com.google.protobuf.ServiceException;
-@Category(MediumTests.class)
-public class TestReplicator extends TestReplicationBase {
-
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestReplicator.class);
+@Tag(ReplicationTests.TAG)
+@Tag(MediumTests.TAG)
+public class TestReplicator extends TestReplicationBaseNoBeforeAll {
static final Logger LOG = LoggerFactory.getLogger(TestReplicator.class);
static final int NUM_ROWS = 10;
- @BeforeClass
+ @BeforeAll
public static void setUpBeforeClass() throws Exception {
+ configureClusters(UTIL1, UTIL2);
// Set RPC size limit to 10kb (will be applied to both source and sink
clusters)
CONF1.setInt(RpcServer.MAX_REQUEST_SIZE, 1024 * 10);
- TestReplicationBase.setUpBeforeClass();
+ startClusters();
}
@Test
@@ -105,9 +101,9 @@ public class TestReplicator extends TestReplicationBase {
}
});
- assertEquals("We sent an incorrect number of batches", NUM_ROWS,
- ReplicationEndpointForTest.getBatchCount());
- assertEquals("We did not replicate enough rows", NUM_ROWS,
UTIL2.countRows(htable2));
+ assertEquals(NUM_ROWS, ReplicationEndpointForTest.getBatchCount(),
+ "We sent an incorrect number of batches");
+ assertEquals(NUM_ROWS, UTIL2.countRows(htable2), "We did not replicate
enough rows");
} finally {
admin.removePeer("testReplicatorBatching");
}
@@ -155,19 +151,14 @@ public class TestReplicator extends TestReplicationBase {
}
});
- assertEquals("We did not replicate enough rows", NUM_ROWS,
UTIL2.countRows(htable2));
+ assertEquals(NUM_ROWS, UTIL2.countRows(htable2), "We did not replicate
enough rows");
} finally {
admin.removePeer("testReplicatorWithErrors");
}
}
- @AfterClass
- public static void tearDownAfterClass() throws Exception {
- TestReplicationBase.tearDownAfterClass();
- }
-
private void truncateTable(HBaseTestingUtility util, TableName tablename)
throws IOException {
- HBaseAdmin admin = util.getHBaseAdmin();
+ Admin admin = util.getAdmin();
admin.disableTable(tableName);
admin.truncateTable(tablename, false);
}
diff --git
a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestSerialReplicationChecker.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestSerialReplicationChecker.java
index 54a67ce4d32..ebd2362f178 100644
---
a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestSerialReplicationChecker.java
+++
b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestSerialReplicationChecker.java
@@ -17,8 +17,8 @@
*/
package org.apache.hadoop.hbase.replication.regionserver;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.mock;
@@ -33,7 +33,6 @@ import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.Cell.Type;
import org.apache.hadoop.hbase.CellBuilderFactory;
import org.apache.hadoop.hbase.CellBuilderType;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.MetaTableAccessor;
@@ -54,26 +53,21 @@ import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
import org.apache.hadoop.hbase.wal.WAL.Entry;
import org.apache.hadoop.hbase.wal.WALKeyImpl;
-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.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
import org.apache.hbase.thirdparty.com.google.common.collect.ImmutableMap;
-@Category({ ReplicationTests.class, MediumTests.class })
+@Tag(ReplicationTests.TAG)
+@Tag(MediumTests.TAG)
public class TestSerialReplicationChecker {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestSerialReplicationChecker.class);
-
private static final HBaseTestingUtility UTIL = new HBaseTestingUtility();
private static String PEER_ID = "1";
@@ -86,12 +80,11 @@ public class TestSerialReplicationChecker {
private SerialReplicationChecker checker;
- @Rule
- public final TestName name = new TestName();
+ private String testName;
private TableName tableName;
- @BeforeClass
+ @BeforeAll
public static void setUpBeforeClass() throws Exception {
UTIL.startMiniCluster(1);
QUEUE_STORAGE =
ReplicationStorageFactory.getReplicationQueueStorage(UTIL.getZooKeeperWatcher(),
@@ -100,13 +93,14 @@ public class TestSerialReplicationChecker {
WAL_FILE_NAME);
}
- @AfterClass
+ @AfterAll
public static void tearDownAfterClass() throws Exception {
UTIL.shutdownMiniCluster();
}
- @Before
- public void setUp() throws IOException {
+ @BeforeEach
+ public void setUp(TestInfo testInfo) throws IOException {
+ testName = testInfo.getTestMethod().get().getName();
ReplicationSource source = mock(ReplicationSource.class);
when(source.getPeerId()).thenReturn(PEER_ID);
when(source.getReplicationQueueStorage()).thenReturn(QUEUE_STORAGE);
@@ -124,7 +118,7 @@ public class TestSerialReplicationChecker {
when(server.getConnection()).thenReturn(conn);
when(source.getServer()).thenReturn(server);
checker = new SerialReplicationChecker(UTIL.getConfiguration(), source);
- tableName = TableName.valueOf(name.getMethodName());
+ tableName = TableName.valueOf(testName);
}
private Entry createEntry(RegionInfo region, long seqId) {
diff --git
a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestSerialReplicationEndpoint.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestSerialReplicationEndpoint.java
index 7596ca6647a..3598e1412c2 100644
---
a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestSerialReplicationEndpoint.java
+++
b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestSerialReplicationEndpoint.java
@@ -17,6 +17,9 @@
*/
package org.apache.hadoop.hbase.replication.regionserver;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
@@ -26,7 +29,6 @@ import java.util.concurrent.Callable;
import java.util.concurrent.LinkedBlockingQueue;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.Cell;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.ServerName;
@@ -46,29 +48,24 @@ import
org.apache.hadoop.hbase.testclassification.ReplicationTests;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
import org.apache.hadoop.hbase.wal.WAL.Entry;
-import org.junit.AfterClass;
-import org.junit.Assert;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
import org.apache.hbase.thirdparty.com.google.common.collect.ImmutableList;
import org.apache.hbase.thirdparty.com.google.common.collect.ImmutableMap;
import org.apache.hbase.thirdparty.com.google.common.io.Closeables;
-@Category({ ReplicationTests.class, MediumTests.class })
+@Tag(ReplicationTests.TAG)
+@Tag(MediumTests.TAG)
public class TestSerialReplicationEndpoint {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestSerialReplicationEndpoint.class);
-
private static HBaseTestingUtility UTIL = new HBaseTestingUtility();
private static Configuration CONF;
private static Connection CONN;
- @BeforeClass
+ @BeforeAll
public static void setUp() throws Exception {
UTIL.startMiniCluster();
CONF = UTIL.getConfiguration();
@@ -76,7 +73,7 @@ public class TestSerialReplicationEndpoint {
CONN = UTIL.getConnection();
}
- @AfterClass
+ @AfterAll
public static void tearDown() throws Exception {
Closeables.close(CONN, true);
UTIL.shutdownMiniCluster();
@@ -118,7 +115,7 @@ public class TestSerialReplicationEndpoint {
Waiter.waitFor(CONF, 60000, () -> TestEndpoint.getEntries().size() >=
cellNum);
int index = 0;
- Assert.assertEquals(TestEndpoint.getEntries().size(), cellNum);
+ assertEquals(cellNum, TestEndpoint.getEntries().size());
if (!isSerial) {
Collections.sort(TestEndpoint.getEntries(), (a, b) -> {
long seqA = a.getKey().getSequenceId();
@@ -127,15 +124,14 @@ public class TestSerialReplicationEndpoint {
});
}
for (Entry entry : TestEndpoint.getEntries()) {
- Assert.assertEquals(entry.getKey().getTableName(), tableName);
- Assert.assertEquals(entry.getEdit().getCells().size(), 1);
+ assertEquals(tableName, entry.getKey().getTableName());
+ assertEquals(1, entry.getEdit().getCells().size());
Cell cell = entry.getEdit().getCells().get(0);
- Assert.assertArrayEquals(
- Bytes.copy(cell.getRowArray(), cell.getRowOffset(),
cell.getRowLength()),
- Bytes.toBytes(index));
+ assertArrayEquals(Bytes.toBytes(index),
+ Bytes.copy(cell.getRowArray(), cell.getRowOffset(),
cell.getRowLength()));
index++;
}
- Assert.assertEquals(index, cellNum);
+ assertEquals(cellNum, index);
}
@Test
diff --git
a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestWALEntrySinkFilter.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestWALEntrySinkFilter.java
index 438df0655e9..514f2315b08 100644
---
a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestWALEntrySinkFilter.java
+++
b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestWALEntrySinkFilter.java
@@ -17,15 +17,14 @@
*/
package org.apache.hadoop.hbase.replication.regionserver;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutorService;
-import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.Cell;
@@ -33,10 +32,8 @@ import org.apache.hadoop.hbase.CellBuilder;
import org.apache.hadoop.hbase.CellBuilderFactory;
import org.apache.hadoop.hbase.CellBuilderType;
import org.apache.hadoop.hbase.CellScanner;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.ServerName;
-import org.apache.hadoop.hbase.Stoppable;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.AdvancedScanResultConsumer;
import org.apache.hadoop.hbase.client.AsyncAdminBuilder;
@@ -57,13 +54,9 @@ import org.apache.hadoop.hbase.security.User;
import org.apache.hadoop.hbase.testclassification.ReplicationTests;
import org.apache.hadoop.hbase.testclassification.SmallTests;
import org.apache.hadoop.hbase.util.Bytes;
-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.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+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.protobuf.ByteString;
@@ -72,38 +65,14 @@ import
org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos;
/**
* Simple test of sink-side wal entry filter facility.
*/
-@Category({ ReplicationTests.class, SmallTests.class })
+@Tag(ReplicationTests.TAG)
+@Tag(SmallTests.TAG)
public class TestWALEntrySinkFilter {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestWALEntrySinkFilter.class);
-
- private static final Logger LOG =
LoggerFactory.getLogger(TestWALEntrySinkFilter.class);
- @Rule
- public TestName name = new TestName();
static final int BOUNDARY = 5;
static final AtomicInteger UNFILTERED = new AtomicInteger();
static final AtomicInteger FILTERED = new AtomicInteger();
- /**
- * Implemetentation of Stoppable to pass into ReplicationSink.
- */
- private static Stoppable STOPPABLE = new Stoppable() {
- private final AtomicBoolean stop = new AtomicBoolean(false);
-
- @Override
- public boolean isStopped() {
- return this.stop.get();
- }
-
- @Override
- public void stop(String why) {
- LOG.info("STOPPING BECAUSE: " + why);
- this.stop.set(true);
- }
- };
-
/**
* Test filter. Filter will filter out any write time that is <= 5
(BOUNDARY). We count how many
* items we filter out and we count how many cells make it through for
distribution way down below
@@ -111,7 +80,8 @@ public class TestWALEntrySinkFilter {
* our counting Table.
*/
@Test
- public void testWALEntryFilter() throws IOException {
+ public void testWALEntryFilter(TestInfo testInfo) throws IOException {
+ String testName = testInfo.getTestMethod().get().getName();
Configuration conf = HBaseConfiguration.create();
// Make it so our filter is instantiated on construction of
ReplicationSink.
conf.setClass(DummyConnectionRegistry.REGISTRY_IMPL_CONF_KEY,
DevNullConnectionRegistry.class,
@@ -126,8 +96,7 @@ public class TestWALEntrySinkFilter {
new ArrayList<>();
AdminProtos.WALEntry.Builder entryBuilder =
AdminProtos.WALEntry.newBuilder();
// Need a tablename.
- ByteString tableName =
-
ByteString.copyFromUtf8(TableName.valueOf(this.name.getMethodName()).toString());
+ ByteString tableName =
ByteString.copyFromUtf8(TableName.valueOf(testName).toString());
// Add WALEdit Cells to Cells List. The way edits arrive at the sink is
with protos
// describing the edit with all Cells from all edits aggregated in a
single CellScanner.
final List<Cell> cells = new ArrayList<>();
@@ -291,7 +260,7 @@ public class TestWALEntrySinkFilter {
for (Row action : actions) {
// Row is the index of the loop above where we make WALEntry and
Cells.
int row = Bytes.toInt(action.getRow());
- assertTrue("" + row, row > BOUNDARY);
+ assertTrue(row > BOUNDARY, "" + row);
UNFILTERED.incrementAndGet();
list.add(null);
}
diff --git
a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestWALEntryStreamCompressionReset.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestWALEntryStreamCompressionReset.java
index dda72f4304a..32acbef8681 100644
---
a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestWALEntryStreamCompressionReset.java
+++
b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestWALEntryStreamCompressionReset.java
@@ -17,8 +17,8 @@
*/
package org.apache.hadoop.hbase.replication.regionserver;
-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.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -35,7 +35,6 @@ import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.CellBuilderFactory;
import org.apache.hadoop.hbase.CellBuilderType;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.ServerName;
@@ -53,11 +52,10 @@ import org.apache.hadoop.hbase.util.Pair;
import org.apache.hadoop.hbase.wal.WAL;
import org.apache.hadoop.hbase.wal.WALEdit;
import org.apache.hadoop.hbase.wal.WALKeyImpl;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
import org.apache.hbase.thirdparty.com.google.common.io.ByteStreams;
@@ -67,13 +65,10 @@ import
org.apache.hbase.thirdparty.com.google.common.io.ByteStreams;
* This is used to confirm that we can work well when hitting EOFException in
the middle when
* reading a WAL entry, when compression is enabled. See HBASE-27621 for more
details.
*/
-@Category({ ReplicationTests.class, MediumTests.class })
+@Tag(ReplicationTests.TAG)
+@Tag(MediumTests.TAG)
public class TestWALEntryStreamCompressionReset {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestWALEntryStreamCompressionReset.class);
-
private static final HBaseTestingUtility UTIL = new HBaseTestingUtility();
private static TableName TABLE_NAME = TableName.valueOf("reset");
@@ -135,7 +130,7 @@ public class TestWALEntryStreamCompressionReset {
return Pair.newPair(path, offset);
}
- @BeforeClass
+ @BeforeAll
public static void setUp() throws Exception {
Configuration conf = UTIL.getConfiguration();
FS = UTIL.getTestFileSystem();
@@ -167,7 +162,7 @@ public class TestWALEntryStreamCompressionReset {
READER = new ReplicationSourceWALReader(FS, conf, LOG_QUEUE, 0, e -> e,
SOURCE, GROUP_ID);
}
- @AfterClass
+ @AfterAll
public static void tearDown() throws Exception {
READER.setReaderRunning(false);
READER.join();
diff --git
a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestWALEntryStreamDifferentCounts.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestWALEntryStreamDifferentCounts.java
index 3f151acceca..2cc1dfdd59f 100644
---
a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestWALEntryStreamDifferentCounts.java
+++
b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestWALEntryStreamDifferentCounts.java
@@ -17,53 +17,38 @@
*/
package org.apache.hadoop.hbase.replication.regionserver;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
+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 java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
import org.apache.hadoop.hbase.HConstants;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runners.Parameterized.Parameter;
-import org.junit.runners.Parameterized.Parameters;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.TestTemplate;
/**
* Try out different combinations of row count and KeyValue count
*/
public abstract class TestWALEntryStreamDifferentCounts extends
WALEntryStreamTestBase {
- @Parameter(0)
- public int nbRows;
+ protected int nbRows;
+ protected int walEditKVs;
+ protected boolean isCompressionEnabled;
- @Parameter(1)
- public int walEditKVs;
-
- @Parameter(2)
- public boolean isCompressionEnabled;
-
- @Parameters(name = "{index}: nbRows={0}, walEditKVs={1},
isCompressionEnabled={2}")
- public static Iterable<Object[]> data() {
- List<Object[]> params = new ArrayList<>();
- for (int nbRows : new int[] { 1500, 60000 }) {
- for (int walEditKVs : new int[] { 1, 100 }) {
- for (boolean isCompressionEnabled : new boolean[] { false, true }) {
- params.add(new Object[] { nbRows, walEditKVs, isCompressionEnabled
});
- }
- }
- }
- return params;
+ protected TestWALEntryStreamDifferentCounts(int nbRows, int walEditKVs,
+ boolean isCompressionEnabled) {
+ this.nbRows = nbRows;
+ this.walEditKVs = walEditKVs;
+ this.isCompressionEnabled = isCompressionEnabled;
}
- @Before
+ @BeforeEach
public void setUp() throws IOException {
CONF.setBoolean(HConstants.ENABLE_WAL_COMPRESSION, isCompressionEnabled);
initWAL();
}
- @Test
+ @TestTemplate
public void testDifferentCounts() throws Exception {
mvcc.advanceTo(1);
diff --git
a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestWALEntryStreamDifferentCountsAsyncFSWAL.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestWALEntryStreamDifferentCountsAsyncFSWAL.java
index 9dcb8a344b6..13bab98c187 100644
---
a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestWALEntryStreamDifferentCountsAsyncFSWAL.java
+++
b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestWALEntryStreamDifferentCountsAsyncFSWAL.java
@@ -17,27 +17,43 @@
*/
package org.apache.hadoop.hbase.replication.regionserver;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.stream.Stream;
+import org.apache.hadoop.hbase.HBaseParameterizedTestTemplate;
import org.apache.hadoop.hbase.testclassification.LargeTests;
import org.apache.hadoop.hbase.testclassification.ReplicationTests;
import org.apache.hadoop.hbase.wal.AbstractFSWALProvider;
import org.apache.hadoop.hbase.wal.AsyncFSWALProvider;
import org.apache.hadoop.hbase.wal.WALFactory;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.experimental.categories.Category;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.params.provider.Arguments;
-@RunWith(Parameterized.class)
-@Category({ ReplicationTests.class, LargeTests.class })
+@Tag(ReplicationTests.TAG)
+@Tag(LargeTests.TAG)
+@HBaseParameterizedTestTemplate(
+ name = "{index}: nbRows={0}, walEditKVs={1}, isCompressionEnabled={2}")
public class TestWALEntryStreamDifferentCountsAsyncFSWAL extends
TestWALEntryStreamDifferentCounts {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
-
HBaseClassTestRule.forClass(TestWALEntryStreamDifferentCountsAsyncFSWAL.class);
+ public TestWALEntryStreamDifferentCountsAsyncFSWAL(int nbRows, int
walEditKVs,
+ boolean isCompressionEnabled) {
+ super(nbRows, walEditKVs, isCompressionEnabled);
+ }
+
+ public static Stream<Arguments> parameters() {
+ List<Arguments> params = new ArrayList<>();
+ for (int nbRows : new int[] { 1500, 60000 }) {
+ for (int walEditKVs : new int[] { 1, 100 }) {
+ for (boolean isCompressionEnabled : new boolean[] { false, true }) {
+ params.add(Arguments.of(nbRows, walEditKVs, isCompressionEnabled));
+ }
+ }
+ }
+ return params.stream();
+ }
- @BeforeClass
+ @BeforeAll
public static void setUpBeforeClass() throws Exception {
TEST_UTIL.getConfiguration().setClass(WALFactory.WAL_PROVIDER,
AsyncFSWALProvider.class,
AbstractFSWALProvider.class);
diff --git
a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestWALEntryStreamDifferentCountsFSHLog.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestWALEntryStreamDifferentCountsFSHLog.java
index fb7c3d555d8..8c4f9eb46a4 100644
---
a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestWALEntryStreamDifferentCountsFSHLog.java
+++
b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestWALEntryStreamDifferentCountsFSHLog.java
@@ -17,27 +17,43 @@
*/
package org.apache.hadoop.hbase.replication.regionserver;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.stream.Stream;
+import org.apache.hadoop.hbase.HBaseParameterizedTestTemplate;
import org.apache.hadoop.hbase.testclassification.LargeTests;
import org.apache.hadoop.hbase.testclassification.ReplicationTests;
import org.apache.hadoop.hbase.wal.AbstractFSWALProvider;
import org.apache.hadoop.hbase.wal.FSHLogProvider;
import org.apache.hadoop.hbase.wal.WALFactory;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.experimental.categories.Category;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.params.provider.Arguments;
-@RunWith(Parameterized.class)
-@Category({ ReplicationTests.class, LargeTests.class })
+@Tag(ReplicationTests.TAG)
+@Tag(LargeTests.TAG)
+@HBaseParameterizedTestTemplate(
+ name = "{index}: nbRows={0}, walEditKVs={1}, isCompressionEnabled={2}")
public class TestWALEntryStreamDifferentCountsFSHLog extends
TestWALEntryStreamDifferentCounts {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestWALEntryStreamDifferentCountsFSHLog.class);
+ public TestWALEntryStreamDifferentCountsFSHLog(int nbRows, int walEditKVs,
+ boolean isCompressionEnabled) {
+ super(nbRows, walEditKVs, isCompressionEnabled);
+ }
+
+ public static Stream<Arguments> parameters() {
+ List<Arguments> params = new ArrayList<>();
+ for (int nbRows : new int[] { 1500, 60000 }) {
+ for (int walEditKVs : new int[] { 1, 100 }) {
+ for (boolean isCompressionEnabled : new boolean[] { false, true }) {
+ params.add(Arguments.of(nbRows, walEditKVs, isCompressionEnabled));
+ }
+ }
+ }
+ return params.stream();
+ }
- @BeforeClass
+ @BeforeAll
public static void setUpBeforeClass() throws Exception {
TEST_UTIL.getConfiguration().setClass(WALFactory.WAL_PROVIDER,
FSHLogProvider.class,
AbstractFSWALProvider.class);
diff --git
a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/WALEntryStreamTestBase.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/WALEntryStreamTestBase.java
index 253bc3039ae..f54deb01ebb 100644
---
a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/WALEntryStreamTestBase.java
+++
b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/WALEntryStreamTestBase.java
@@ -30,7 +30,6 @@ import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.KeyValue;
import org.apache.hadoop.hbase.ServerName;
import org.apache.hadoop.hbase.TableName;
-import org.apache.hadoop.hbase.TableNameTestRule;
import org.apache.hadoop.hbase.Waiter;
import org.apache.hadoop.hbase.client.RegionInfo;
import org.apache.hadoop.hbase.client.RegionInfoBuilder;
@@ -44,10 +43,10 @@ import org.apache.hadoop.hbase.wal.WALEdit;
import org.apache.hadoop.hbase.wal.WALFactory;
import org.apache.hadoop.hbase.wal.WALKeyImpl;
import org.apache.hadoop.hdfs.MiniDFSCluster;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Rule;
-import org.junit.rules.TestName;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.TestInfo;
import org.apache.hbase.thirdparty.com.google.common.io.Closeables;
@@ -119,11 +118,14 @@ public abstract class WALEntryStreamTestBase {
protected WAL log;
protected ReplicationSourceLogQueue logQueue;
protected PathWatcher pathWatcher;
-
- @Rule
- public TestName tn = new TestName();
+ protected String testName;
protected final MultiVersionConcurrencyControl mvcc = new
MultiVersionConcurrencyControl();
+ @BeforeEach
+ public void setUp(TestInfo testInfo) {
+ testName = testInfo.getTestMethod().get().getName();
+ }
+
protected static void startCluster() throws Exception {
CONF = TEST_UTIL.getConfiguration();
CONF.setLong("replication.source.sleepforretries", 10);
@@ -133,7 +135,7 @@ public abstract class WALEntryStreamTestBase {
fs = cluster.getFileSystem();
}
- @AfterClass
+ @AfterAll
public static void tearDownAfterClass() throws Exception {
TEST_UTIL.shutdownMiniCluster();
}
@@ -145,13 +147,12 @@ public abstract class WALEntryStreamTestBase {
metricsSource.clear();
logQueue = new ReplicationSourceLogQueue(CONF, metricsSource, source);
pathWatcher = new PathWatcher();
- final WALFactory wals =
- new WALFactory(CONF,
TableNameTestRule.cleanUpTestName(tn.getMethodName()));
+ final WALFactory wals = new WALFactory(CONF, testName.replaceAll("[\\[:]",
"_"));
wals.getWALProvider().addWALActionsListener(pathWatcher);
log = wals.getWAL(info);
}
- @After
+ @AfterEach
public void tearDown() throws Exception {
Closeables.close(log, true);
}