This is an automated email from the ASF dual-hosted git repository.
Apache9 pushed a commit to branch branch-3
in repository https://gitbox.apache.org/repos/asf/hbase.git
The following commit(s) were added to refs/heads/branch-3 by this push:
new d448e2a8389 HBASE-30188 Upgrade hbase-server to use junit5 Part20
(#8286)
d448e2a8389 is described below
commit d448e2a838958d6a93cc3843af83108e4e83987f
Author: Duo Zhang <[email protected]>
AuthorDate: Mon Jun 1 22:42:48 2026 +0800
HBASE-30188 Upgrade hbase-server to use junit5 Part20 (#8286)
Signed-off-by: Xiao Liu <[email protected]>
(cherry picked from commit 8ce9e3b53798b284c402875856518c0566f33949)
---
...point.java => ReplicationEndpointTestBase.java} | 80 ++-
...S.java => ReplicationKillMasterRSTestBase.java} | 21 +-
...nKillRS.java => ReplicationKillRSTestBase.java} | 6 +-
...RS.java => ReplicationKillSlaveRSTestBase.java} | 21 +-
.../hbase/replication/TestReplicationEndpoint.java | 633 +--------------------
.../replication/TestReplicationKillMasterRS.java | 30 +-
.../TestReplicationKillMasterRSCompressed.java | 21 +-
...ReplicationKillMasterRSWithSeparateOldWALs.java | 22 +-
.../replication/TestReplicationKillSlaveRS.java | 29 +-
...tReplicationKillSlaveRSWithSeparateOldWALs.java | 21 +-
.../replication/TestReplicationSyncUpTool.java | 75 ++-
.../replication/TestReplicationSyncUpToolBase.java | 8 +-
...estReplicationSyncUpToolWithBulkLoadedData.java | 47 +-
.../replication/master/TestLogCleanerBarrier.java | 19 +-
.../master/TestRecoverStandbyProcedure.java | 39 +-
.../master/TestReplicationLogCleaner.java | 27 +-
...estReplicationEndpointWithMultipleAsyncWAL.java | 23 +-
.../TestReplicationEndpointWithMultipleWAL.java | 23 +-
...KillMasterRSCompressedWithMultipleAsyncWAL.java | 25 +-
...ationKillMasterRSCompressedWithMultipleWAL.java | 25 +-
...tReplicationSyncUpToolWithMultipleAsyncWAL.java | 11 +-
.../TestReplicationSyncUpToolWithMultipleWAL.java | 11 +-
22 files changed, 238 insertions(+), 979 deletions(-)
diff --git
a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationEndpoint.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/ReplicationEndpointTestBase.java
similarity index 91%
copy from
hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationEndpoint.java
copy to
hbase-server/src/test/java/org/apache/hadoop/hbase/replication/ReplicationEndpointTestBase.java
index 057a9f3567f..449e7129f8f 100644
---
a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationEndpoint.java
+++
b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/ReplicationEndpointTestBase.java
@@ -17,6 +17,10 @@
*/
package org.apache.hadoop.hbase.replication;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+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.spy;
@@ -35,7 +39,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
import org.apache.hadoop.hbase.Cell;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
+import org.apache.hadoop.hbase.HBaseTestingUtil;
import org.apache.hadoop.hbase.KeyValue;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.Waiter;
@@ -53,8 +57,6 @@ import
org.apache.hadoop.hbase.replication.regionserver.MetricsReplicationSource
import
org.apache.hadoop.hbase.replication.regionserver.MetricsReplicationSourceSourceImpl;
import
org.apache.hadoop.hbase.replication.regionserver.MetricsReplicationTableSource;
import org.apache.hadoop.hbase.replication.regionserver.MetricsSource;
-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.EnvironmentEdgeManager;
import org.apache.hadoop.hbase.util.JVMClusterUtil.RegionServerThread;
@@ -66,44 +68,34 @@ import org.apache.hadoop.hbase.wal.WALEditInternalHelper;
import org.apache.hadoop.hbase.wal.WALKeyImpl;
import org.apache.hadoop.hbase.zookeeper.ZKConfig;
import org.apache.hadoop.metrics2.lib.DynamicMetricsRegistry;
-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.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Tests ReplicationSource and ReplicationEndpoint interactions
*/
-@Category({ ReplicationTests.class, MediumTests.class })
-public class TestReplicationEndpoint extends TestReplicationBase {
+public class ReplicationEndpointTestBase extends
TestReplicationBaseNoBeforeAll {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestReplicationEndpoint.class);
-
- private static final Logger LOG =
LoggerFactory.getLogger(TestReplicationEndpoint.class);
+ private static final Logger LOG =
LoggerFactory.getLogger(ReplicationEndpointTestBase.class);
static int numRegionServers;
- @BeforeClass
- public static void setUpBeforeClass() throws Exception {
- TestReplicationBase.setUpBeforeClass();
+ protected static void setUpBeforeClass() throws Exception {
+ configureClusters(UTIL1, UTIL2);
+ startClusters();
numRegionServers = UTIL1.getHBaseCluster().getRegionServerThreads().size();
}
- @AfterClass
- public static void tearDownAfterClass() throws Exception {
- TestReplicationBase.tearDownAfterClass();
+ @AfterAll
+ public static void assertStopped() {
// check stop is called
- Assert.assertTrue(ReplicationEndpointForTest.stoppedCount.get() > 0);
+ assertTrue(ReplicationEndpointForTest.stoppedCount.get() > 0);
}
- @Before
+ @BeforeEach
public void setup() throws Exception {
ReplicationEndpointForTest.contructedCount.set(0);
ReplicationEndpointForTest.startedCount.set(0);
@@ -161,7 +153,7 @@ public class TestReplicationEndpoint extends
TestReplicationBase {
}
});
- Assert.assertEquals(0, ReplicationEndpointForTest.replicateCount.get());
+ assertEquals(0, ReplicationEndpointForTest.replicateCount.get());
// now replicate some data.
doPut(Bytes.toBytes("row42"));
@@ -180,8 +172,8 @@ public class TestReplicationEndpoint extends
TestReplicationBase {
@Test
public void testReplicationEndpointReturnsFalseOnReplicate() throws
Exception {
- Assert.assertEquals(0, ReplicationEndpointForTest.replicateCount.get());
- Assert.assertTrue(!ReplicationEndpointReturningFalse.replicated.get());
+ assertEquals(0, ReplicationEndpointForTest.replicateCount.get());
+ assertTrue(!ReplicationEndpointReturningFalse.replicated.get());
int peerCount = hbaseAdmin.listReplicationPeers().size();
final String id = "testReplicationEndpointReturnsFalseOnReplicate";
hbaseAdmin.addReplicationPeer(id,
@@ -286,13 +278,13 @@ public class TestReplicationEndpoint extends
TestReplicationBase {
}
});
- Assert.assertNull(ReplicationEndpointWithWALEntryFilter.ex.get());
+ assertNull(ReplicationEndpointWithWALEntryFilter.ex.get());
// make sure our reflectively created filter is in the filter chain
- Assert.assertTrue(EverythingPassesWALEntryFilter.hasPassedAnEntry());
+ assertTrue(EverythingPassesWALEntryFilter.hasPassedAnEntry());
hbaseAdmin.removeReplicationPeer("testWALEntryFilterFromReplicationEndpoint");
}
- @Test(expected = IOException.class)
+ @Test
public void testWALEntryFilterAddValidation() throws Exception {
ReplicationPeerConfig rpc =
ReplicationPeerConfig.newBuilder().setClusterKey(ZKConfig.getZooKeeperClusterKey(CONF1))
@@ -301,10 +293,11 @@ public class TestReplicationEndpoint extends
TestReplicationBase {
.putConfiguration(BaseReplicationEndpoint.REPLICATION_WALENTRYFILTER_CONFIG_KEY,
"IAmNotARealWalEntryFilter")
.build();
- hbaseAdmin.addReplicationPeer("testWALEntryFilterAddValidation", rpc);
+ assertThrows(IOException.class,
+ () -> hbaseAdmin.addReplicationPeer("testWALEntryFilterAddValidation",
rpc));
}
- @Test(expected = IOException.class)
+ @Test
public void testWALEntryFilterUpdateValidation() throws Exception {
ReplicationPeerConfig rpc =
ReplicationPeerConfig.newBuilder().setClusterKey(ZKConfig.getZooKeeperClusterKey(CONF1))
@@ -313,7 +306,8 @@ public class TestReplicationEndpoint extends
TestReplicationBase {
.putConfiguration(BaseReplicationEndpoint.REPLICATION_WALENTRYFILTER_CONFIG_KEY,
"IAmNotARealWalEntryFilter")
.build();
-
hbaseAdmin.updateReplicationPeerConfig("testWALEntryFilterUpdateValidation",
rpc);
+ assertThrows(IOException.class,
+ () ->
hbaseAdmin.updateReplicationPeerConfig("testWALEntryFilterUpdateValidation",
rpc));
}
@Test
@@ -388,15 +382,15 @@ public class TestReplicationEndpoint extends
TestReplicationBase {
// after calling #setAgeOfLastShippedOpByTable
boolean containsRandomNewTable =
source.getSingleSourceSourceByTable().containsKey("RandomNewTable");
- Assert.assertEquals(false, containsRandomNewTable);
+ assertEquals(false, containsRandomNewTable);
source.updateTableLevelMetrics(createWALEntriesWithSize("RandomNewTable"));
containsRandomNewTable =
source.getSingleSourceSourceByTable().containsKey("RandomNewTable");
- Assert.assertEquals(true, containsRandomNewTable);
+ assertEquals(true, containsRandomNewTable);
MetricsReplicationTableSource msr =
source.getSingleSourceSourceByTable().get("RandomNewTable");
// age should be greater than zero we created the entry with time in the
past
- Assert.assertTrue(msr.getLastShippedAge() > 0);
- Assert.assertTrue(msr.getShippedBytes() > 0);
+ assertTrue(msr.getLastShippedAge() > 0);
+ assertTrue(msr.getShippedBytes() > 0);
}
@@ -437,15 +431,15 @@ public class TestReplicationEndpoint extends
TestReplicationBase {
if (ReplicationEndpointForTest.lastEntries == null) {
return; // first call
}
- Assert.assertEquals(1, ReplicationEndpointForTest.lastEntries.size());
+ assertEquals(1, ReplicationEndpointForTest.lastEntries.size());
List<Cell> cells =
ReplicationEndpointForTest.lastEntries.get(0).getEdit().getCells();
- Assert.assertEquals(1, cells.size());
- Assert.assertTrue(Bytes.equals(cells.get(0).getRowArray(),
cells.get(0).getRowOffset(),
+ assertEquals(1, cells.size());
+ assertTrue(Bytes.equals(cells.get(0).getRowArray(),
cells.get(0).getRowOffset(),
cells.get(0).getRowLength(), row, 0, row.length));
}
public static class ReplicationEndpointForTest extends
BaseReplicationEndpoint {
- static UUID uuid = UTIL1.getRandomUUID();
+ static UUID uuid = HBaseTestingUtil.getRandomUUID();
static AtomicInteger contructedCount = new AtomicInteger();
static AtomicInteger startedCount = new AtomicInteger();
static AtomicInteger stoppedCount = new AtomicInteger();
@@ -505,7 +499,7 @@ public class TestReplicationEndpoint extends
TestReplicationBase {
* <pre>
* create 't', 'f'
* add_peer '1', ENDPOINT_CLASSNAME =>
'org.apache.hadoop.hbase.replication.' + \
- * 'TestReplicationEndpoint$SleepingReplicationEndpointForTest'
+ * 'ReplicationEndpointTestBase$SleepingReplicationEndpointForTest'
* alter 't', {NAME=>'f', REPLICATION_SCOPE=>1}
* </pre>
*/
diff --git
a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationKillMasterRS.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/ReplicationKillMasterRSTestBase.java
similarity index 60%
copy from
hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationKillMasterRS.java
copy to
hbase-server/src/test/java/org/apache/hadoop/hbase/replication/ReplicationKillMasterRSTestBase.java
index 7720d42a6ed..21d044b2ebc 100644
---
a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationKillMasterRS.java
+++
b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/ReplicationKillMasterRSTestBase.java
@@ -17,30 +17,13 @@
*/
package org.apache.hadoop.hbase.replication;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
-import org.apache.hadoop.hbase.testclassification.LargeTests;
-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.Test;
/**
* Runs the TestReplicationKillRS test and selects the RS to kill in the
master cluster Do not add
* other tests in this class.
*/
-@Category({ ReplicationTests.class, LargeTests.class })
-public class TestReplicationKillMasterRS extends TestReplicationKillRS {
-
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestReplicationKillMasterRS.class);
-
- @BeforeClass
- public static void setUpBeforeClass() throws Exception {
- NUM_SLAVES1 = 2;
- TestReplicationBase.setUpBeforeClass();
- }
+public class ReplicationKillMasterRSTestBase extends ReplicationKillRSTestBase
{
@Test
public void killOneMasterRS() throws Exception {
diff --git
a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationKillRS.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/ReplicationKillRSTestBase.java
similarity index 95%
rename from
hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationKillRS.java
rename to
hbase-server/src/test/java/org/apache/hadoop/hbase/replication/ReplicationKillRSTestBase.java
index 9a4819b2c28..f30073675ce 100644
---
a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationKillRS.java
+++
b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/ReplicationKillRSTestBase.java
@@ -17,7 +17,7 @@
*/
package org.apache.hadoop.hbase.replication;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.fail;
import org.apache.hadoop.hbase.HBaseTestingUtil;
import org.apache.hadoop.hbase.UnknownScannerException;
@@ -31,9 +31,9 @@ import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public abstract class TestReplicationKillRS extends TestReplicationBase {
+public abstract class ReplicationKillRSTestBase extends
TestReplicationBaseNoBeforeAll {
- private static final Logger LOG =
LoggerFactory.getLogger(TestReplicationKillRS.class);
+ private static final Logger LOG =
LoggerFactory.getLogger(ReplicationKillRSTestBase.class);
/**
* Load up 1 tables over 2 region servers and kill a source during the
upload. The failover
diff --git
a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationKillSlaveRS.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/ReplicationKillSlaveRSTestBase.java
similarity index 60%
copy from
hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationKillSlaveRS.java
copy to
hbase-server/src/test/java/org/apache/hadoop/hbase/replication/ReplicationKillSlaveRSTestBase.java
index 6505a4a191d..4918bc0ed8c 100644
---
a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationKillSlaveRS.java
+++
b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/ReplicationKillSlaveRSTestBase.java
@@ -17,30 +17,13 @@
*/
package org.apache.hadoop.hbase.replication;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
-import org.apache.hadoop.hbase.testclassification.LargeTests;
-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.Test;
/**
* Runs the TestReplicationKillRS test and selects the RS to kill in the slave
cluster Do not add
* other tests in this class.
*/
-@Category({ ReplicationTests.class, LargeTests.class })
-public class TestReplicationKillSlaveRS extends TestReplicationKillRS {
-
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestReplicationKillSlaveRS.class);
-
- @BeforeClass
- public static void setUpBeforeClass() throws Exception {
- NUM_SLAVES2 = 2;
- TestReplicationBase.setUpBeforeClass();
- }
+public class ReplicationKillSlaveRSTestBase extends ReplicationKillRSTestBase {
@Test
public void killOneSlaveRS() throws Exception {
diff --git
a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationEndpoint.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationEndpoint.java
index 057a9f3567f..bd2090aacf2 100644
---
a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationEndpoint.java
+++
b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationEndpoint.java
@@ -17,634 +17,17 @@
*/
package org.apache.hadoop.hbase.replication;
-import static org.mockito.Mockito.doNothing;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.TreeMap;
-import java.util.UUID;
-import java.util.concurrent.CompletableFuture;
-import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.concurrent.atomic.AtomicInteger;
-import java.util.concurrent.atomic.AtomicReference;
-import org.apache.hadoop.hbase.Cell;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
-import org.apache.hadoop.hbase.KeyValue;
-import org.apache.hadoop.hbase.TableName;
-import org.apache.hadoop.hbase.Waiter;
-import org.apache.hadoop.hbase.client.Connection;
-import org.apache.hadoop.hbase.client.ConnectionFactory;
-import org.apache.hadoop.hbase.client.Put;
-import org.apache.hadoop.hbase.client.RegionInfo;
-import org.apache.hadoop.hbase.client.Table;
-import org.apache.hadoop.hbase.regionserver.HRegion;
-import
org.apache.hadoop.hbase.replication.regionserver.HBaseInterClusterReplicationEndpoint;
-import
org.apache.hadoop.hbase.replication.regionserver.MetricsReplicationGlobalSourceSource;
-import
org.apache.hadoop.hbase.replication.regionserver.MetricsReplicationGlobalSourceSourceImpl;
-import
org.apache.hadoop.hbase.replication.regionserver.MetricsReplicationSourceImpl;
-import
org.apache.hadoop.hbase.replication.regionserver.MetricsReplicationSourceSource;
-import
org.apache.hadoop.hbase.replication.regionserver.MetricsReplicationSourceSourceImpl;
-import
org.apache.hadoop.hbase.replication.regionserver.MetricsReplicationTableSource;
-import org.apache.hadoop.hbase.replication.regionserver.MetricsSource;
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.EnvironmentEdgeManager;
-import org.apache.hadoop.hbase.util.JVMClusterUtil.RegionServerThread;
-import org.apache.hadoop.hbase.util.Pair;
-import org.apache.hadoop.hbase.util.Threads;
-import org.apache.hadoop.hbase.wal.WAL.Entry;
-import org.apache.hadoop.hbase.wal.WALEdit;
-import org.apache.hadoop.hbase.wal.WALEditInternalHelper;
-import org.apache.hadoop.hbase.wal.WALKeyImpl;
-import org.apache.hadoop.hbase.zookeeper.ZKConfig;
-import org.apache.hadoop.metrics2.lib.DynamicMetricsRegistry;
-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.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Tests ReplicationSource and ReplicationEndpoint interactions
- */
-@Category({ ReplicationTests.class, MediumTests.class })
-public class TestReplicationEndpoint extends TestReplicationBase {
-
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestReplicationEndpoint.class);
-
- private static final Logger LOG =
LoggerFactory.getLogger(TestReplicationEndpoint.class);
-
- static int numRegionServers;
-
- @BeforeClass
- public static void setUpBeforeClass() throws Exception {
- TestReplicationBase.setUpBeforeClass();
- numRegionServers = UTIL1.getHBaseCluster().getRegionServerThreads().size();
- }
-
- @AfterClass
- public static void tearDownAfterClass() throws Exception {
- TestReplicationBase.tearDownAfterClass();
- // check stop is called
- Assert.assertTrue(ReplicationEndpointForTest.stoppedCount.get() > 0);
- }
-
- @Before
- public void setup() throws Exception {
- ReplicationEndpointForTest.contructedCount.set(0);
- ReplicationEndpointForTest.startedCount.set(0);
- ReplicationEndpointForTest.replicateCount.set(0);
- ReplicationEndpointReturningFalse.replicated.set(false);
- ReplicationEndpointForTest.lastEntries = null;
- final List<RegionServerThread> rsThreads =
UTIL1.getMiniHBaseCluster().getRegionServerThreads();
- for (RegionServerThread rs : rsThreads) {
- UTIL1.getAdmin().rollWALWriter(rs.getRegionServer().getServerName());
- }
- // Wait for all log roll to finish
- UTIL1.waitFor(3000, new Waiter.ExplainingPredicate<Exception>() {
- @Override
- public boolean evaluate() throws Exception {
- for (RegionServerThread rs : rsThreads) {
- if (!rs.getRegionServer().walRollRequestFinished()) {
- return false;
- }
- }
- return true;
- }
-
- @Override
- public String explainFailure() throws Exception {
- List<String> logRollInProgressRsList = new ArrayList<>();
- for (RegionServerThread rs : rsThreads) {
- if (!rs.getRegionServer().walRollRequestFinished()) {
- logRollInProgressRsList.add(rs.getRegionServer().toString());
- }
- }
- return "Still waiting for log roll on regionservers: " +
logRollInProgressRsList;
- }
- });
- }
-
- @Test
- public void testCustomReplicationEndpoint() throws Exception {
- // test installing a custom replication endpoint other than the default
one.
- hbaseAdmin.addReplicationPeer("testCustomReplicationEndpoint",
-
ReplicationPeerConfig.newBuilder().setClusterKey(ZKConfig.getZooKeeperClusterKey(CONF1))
-
.setReplicationEndpointImpl(ReplicationEndpointForTest.class.getName()).build());
-
- // check whether the class has been constructed and started
- Waiter.waitFor(CONF1, 60000, new Waiter.Predicate<Exception>() {
- @Override
- public boolean evaluate() throws Exception {
- return ReplicationEndpointForTest.contructedCount.get() >=
numRegionServers;
- }
- });
-
- Waiter.waitFor(CONF1, 60000, new Waiter.Predicate<Exception>() {
- @Override
- public boolean evaluate() throws Exception {
- return ReplicationEndpointForTest.startedCount.get() >=
numRegionServers;
- }
- });
-
- Assert.assertEquals(0, ReplicationEndpointForTest.replicateCount.get());
-
- // now replicate some data.
- doPut(Bytes.toBytes("row42"));
-
- Waiter.waitFor(CONF1, 60000, new Waiter.Predicate<Exception>() {
- @Override
- public boolean evaluate() throws Exception {
- return ReplicationEndpointForTest.replicateCount.get() >= 1;
- }
- });
-
- doAssert(Bytes.toBytes("row42"));
-
- hbaseAdmin.removeReplicationPeer("testCustomReplicationEndpoint");
- }
-
- @Test
- public void testReplicationEndpointReturnsFalseOnReplicate() throws
Exception {
- Assert.assertEquals(0, ReplicationEndpointForTest.replicateCount.get());
- Assert.assertTrue(!ReplicationEndpointReturningFalse.replicated.get());
- int peerCount = hbaseAdmin.listReplicationPeers().size();
- final String id = "testReplicationEndpointReturnsFalseOnReplicate";
- hbaseAdmin.addReplicationPeer(id,
-
ReplicationPeerConfig.newBuilder().setClusterKey(ZKConfig.getZooKeeperClusterKey(CONF1))
-
.setReplicationEndpointImpl(ReplicationEndpointReturningFalse.class.getName()).build());
- // This test is flakey and then there is so much stuff flying around in
here its, hard to
- // debug. Peer needs to be up for the edit to make it across. This wait on
- // peer count seems to be a hack that has us not progress till peer is up.
- if (hbaseAdmin.listReplicationPeers().size() <= peerCount) {
- LOG.info("Waiting on peercount to go up from " + peerCount);
- Threads.sleep(100);
- }
- // now replicate some data
- doPut(row);
-
- Waiter.waitFor(CONF1, 60000, new Waiter.Predicate<Exception>() {
- @Override
- public boolean evaluate() throws Exception {
- // Looks like replication endpoint returns false unless we put more
than 10 edits. We
- // only send over one edit.
- int count = ReplicationEndpointForTest.replicateCount.get();
- LOG.info("count=" + count);
- return ReplicationEndpointReturningFalse.replicated.get();
- }
- });
- if (ReplicationEndpointReturningFalse.ex.get() != null) {
- throw ReplicationEndpointReturningFalse.ex.get();
- }
-
-
hbaseAdmin.removeReplicationPeer("testReplicationEndpointReturnsFalseOnReplicate");
- }
-
- @Test
- public void testInterClusterReplication() throws Exception {
- final String id = "testInterClusterReplication";
-
- List<HRegion> regions = UTIL1.getHBaseCluster().getRegions(tableName);
- int totEdits = 0;
-
- // Make sure edits are spread across regions because we do region based
batching
- // before shipping edits.
- for (HRegion region : regions) {
- RegionInfo hri = region.getRegionInfo();
- byte[] row = hri.getStartKey();
- for (int i = 0; i < 100; i++) {
- if (row.length > 0) {
- Put put = new Put(row);
- put.addColumn(famName, row, row);
- region.put(put);
- totEdits++;
- }
- }
- }
-
- hbaseAdmin.addReplicationPeer(id,
-
ReplicationPeerConfig.newBuilder().setClusterKey(ZKConfig.getZooKeeperClusterKey(CONF2))
-
.setReplicationEndpointImpl(InterClusterReplicationEndpointForTest.class.getName())
- .build());
-
- final int numEdits = totEdits;
- Waiter.waitFor(CONF1, 30000, new Waiter.ExplainingPredicate<Exception>() {
- @Override
- public boolean evaluate() throws Exception {
- return InterClusterReplicationEndpointForTest.replicateCount.get() ==
numEdits;
- }
-
- @Override
- public String explainFailure() throws Exception {
- String failure = "Failed to replicate all edits, expected = " +
numEdits + " replicated = "
- + InterClusterReplicationEndpointForTest.replicateCount.get();
- return failure;
- }
- });
-
- hbaseAdmin.removeReplicationPeer("testInterClusterReplication");
- UTIL1.deleteTableData(tableName);
- }
-
- @Test
- public void testWALEntryFilterFromReplicationEndpoint() throws Exception {
- ReplicationPeerConfig rpc =
-
ReplicationPeerConfig.newBuilder().setClusterKey(ZKConfig.getZooKeeperClusterKey(CONF1))
-
.setReplicationEndpointImpl(ReplicationEndpointWithWALEntryFilter.class.getName())
- // test that we can create mutliple WALFilters reflectively
-
.putConfiguration(BaseReplicationEndpoint.REPLICATION_WALENTRYFILTER_CONFIG_KEY,
- EverythingPassesWALEntryFilter.class.getName() + ","
- + EverythingPassesWALEntryFilterSubclass.class.getName())
- .build();
-
- hbaseAdmin.addReplicationPeer("testWALEntryFilterFromReplicationEndpoint",
rpc);
- // now replicate some data.
- try (Connection connection = ConnectionFactory.createConnection(CONF1)) {
- doPut(connection, Bytes.toBytes("row1"));
- doPut(connection, row);
- doPut(connection, Bytes.toBytes("row2"));
- }
-
- Waiter.waitFor(CONF1, 60000, new Waiter.Predicate<Exception>() {
- @Override
- public boolean evaluate() throws Exception {
- return ReplicationEndpointForTest.replicateCount.get() >= 1;
- }
- });
-
- Assert.assertNull(ReplicationEndpointWithWALEntryFilter.ex.get());
- // make sure our reflectively created filter is in the filter chain
- Assert.assertTrue(EverythingPassesWALEntryFilter.hasPassedAnEntry());
-
hbaseAdmin.removeReplicationPeer("testWALEntryFilterFromReplicationEndpoint");
- }
-
- @Test(expected = IOException.class)
- public void testWALEntryFilterAddValidation() throws Exception {
- ReplicationPeerConfig rpc =
-
ReplicationPeerConfig.newBuilder().setClusterKey(ZKConfig.getZooKeeperClusterKey(CONF1))
-
.setReplicationEndpointImpl(ReplicationEndpointWithWALEntryFilter.class.getName())
- // test that we can create mutliple WALFilters reflectively
-
.putConfiguration(BaseReplicationEndpoint.REPLICATION_WALENTRYFILTER_CONFIG_KEY,
- "IAmNotARealWalEntryFilter")
- .build();
- hbaseAdmin.addReplicationPeer("testWALEntryFilterAddValidation", rpc);
- }
-
- @Test(expected = IOException.class)
- public void testWALEntryFilterUpdateValidation() throws Exception {
- ReplicationPeerConfig rpc =
-
ReplicationPeerConfig.newBuilder().setClusterKey(ZKConfig.getZooKeeperClusterKey(CONF1))
-
.setReplicationEndpointImpl(ReplicationEndpointWithWALEntryFilter.class.getName())
- // test that we can create mutliple WALFilters reflectively
-
.putConfiguration(BaseReplicationEndpoint.REPLICATION_WALENTRYFILTER_CONFIG_KEY,
- "IAmNotARealWalEntryFilter")
- .build();
-
hbaseAdmin.updateReplicationPeerConfig("testWALEntryFilterUpdateValidation",
rpc);
- }
-
- @Test
- public void testMetricsSourceBaseSourcePassThrough() {
- /*
- * The replication MetricsSource wraps a MetricsReplicationTableSourceImpl,
- * MetricsReplicationSourceSourceImpl and a
MetricsReplicationGlobalSourceSource, so that
- * metrics get written to both namespaces. Both of those classes wrap a
- * MetricsReplicationSourceImpl that implements BaseSource, which allows
for custom JMX metrics.
- * This test checks to make sure the BaseSource decorator logic on
MetricsSource actually calls
- * down through the two layers of wrapping to the actual BaseSource.
- */
- String id = "id";
- DynamicMetricsRegistry mockRegistry = mock(DynamicMetricsRegistry.class);
- MetricsReplicationSourceImpl singleRms =
mock(MetricsReplicationSourceImpl.class);
- when(singleRms.getMetricsRegistry()).thenReturn(mockRegistry);
- MetricsReplicationSourceImpl globalRms =
mock(MetricsReplicationSourceImpl.class);
- when(globalRms.getMetricsRegistry()).thenReturn(mockRegistry);
-
- MetricsReplicationSourceSource singleSourceSource =
- new MetricsReplicationSourceSourceImpl(singleRms, id);
- MetricsReplicationGlobalSourceSource globalSourceSource =
- new MetricsReplicationGlobalSourceSourceImpl(globalRms);
- MetricsReplicationGlobalSourceSource spyglobalSourceSource =
spy(globalSourceSource);
- doNothing().when(spyglobalSourceSource).incrFailedRecoveryQueue();
-
- Map<String, MetricsReplicationTableSource> singleSourceSourceByTable = new
HashMap<>();
- MetricsSource source =
- new MetricsSource(id, singleSourceSource, spyglobalSourceSource,
singleSourceSourceByTable);
-
- String gaugeName = "gauge";
- String singleGaugeName = "source.id." + gaugeName;
- String globalGaugeName = "source." + gaugeName;
- long delta = 1;
- String counterName = "counter";
- String singleCounterName = "source.id." + counterName;
- String globalCounterName = "source." + counterName;
- long count = 2;
- source.decGauge(gaugeName, delta);
- source.getMetricsContext();
- source.getMetricsDescription();
- source.getMetricsJmxContext();
- source.getMetricsName();
- source.incCounters(counterName, count);
- source.incGauge(gaugeName, delta);
- source.init();
- source.removeMetric(gaugeName);
- source.setGauge(gaugeName, delta);
- source.updateHistogram(counterName, count);
- source.incrFailedRecoveryQueue();
-
- verify(singleRms).decGauge(singleGaugeName, delta);
- verify(globalRms).decGauge(globalGaugeName, delta);
- verify(globalRms).getMetricsContext();
- verify(globalRms).getMetricsJmxContext();
- verify(globalRms).getMetricsName();
- verify(singleRms).incCounters(singleCounterName, count);
- verify(globalRms).incCounters(globalCounterName, count);
- verify(singleRms).incGauge(singleGaugeName, delta);
- verify(globalRms).incGauge(globalGaugeName, delta);
- verify(globalRms).init();
- verify(singleRms).removeMetric(singleGaugeName);
- verify(globalRms).removeMetric(globalGaugeName);
- verify(singleRms).setGauge(singleGaugeName, delta);
- verify(globalRms).setGauge(globalGaugeName, delta);
- verify(singleRms).updateHistogram(singleCounterName, count);
- verify(globalRms).updateHistogram(globalCounterName, count);
- verify(spyglobalSourceSource).incrFailedRecoveryQueue();
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Tag;
- // check singleSourceSourceByTable metrics.
- // singleSourceSourceByTable map entry will be created only
- // after calling #setAgeOfLastShippedOpByTable
- boolean containsRandomNewTable =
- source.getSingleSourceSourceByTable().containsKey("RandomNewTable");
- Assert.assertEquals(false, containsRandomNewTable);
- source.updateTableLevelMetrics(createWALEntriesWithSize("RandomNewTable"));
- containsRandomNewTable =
source.getSingleSourceSourceByTable().containsKey("RandomNewTable");
- Assert.assertEquals(true, containsRandomNewTable);
- MetricsReplicationTableSource msr =
source.getSingleSourceSourceByTable().get("RandomNewTable");
-
- // age should be greater than zero we created the entry with time in the
past
- Assert.assertTrue(msr.getLastShippedAge() > 0);
- Assert.assertTrue(msr.getShippedBytes() > 0);
-
- }
-
- private List<Pair<Entry, Long>> createWALEntriesWithSize(String tableName) {
- List<Pair<Entry, Long>> walEntriesWithSize = new ArrayList<>();
- byte[] a = new byte[] { 'a' };
- Entry entry = createEntry(tableName, null, a);
- walEntriesWithSize.add(new Pair<>(entry, 10L));
- return walEntriesWithSize;
- }
-
- private Entry createEntry(String tableName, TreeMap<byte[], Integer> scopes,
byte[]... kvs) {
- WALKeyImpl key1 = new WALKeyImpl(new byte[0], TableName.valueOf(tableName),
- EnvironmentEdgeManager.currentTime() - 1L, scopes);
- WALEdit edit1 = new WALEdit();
-
- for (byte[] kv : kvs) {
- WALEditInternalHelper.addExtendedCell(edit1, new KeyValue(kv, kv, kv));
- }
- return new Entry(key1, edit1);
- }
-
- private void doPut(byte[] row) throws IOException {
- try (Connection connection = ConnectionFactory.createConnection(CONF1)) {
- doPut(connection, row);
- }
- }
-
- private void doPut(final Connection connection, final byte[] row) throws
IOException {
- try (Table t = connection.getTable(tableName)) {
- Put put = new Put(row);
- put.addColumn(famName, row, row);
- t.put(put);
- }
- }
-
- private static void doAssert(byte[] row) throws Exception {
- if (ReplicationEndpointForTest.lastEntries == null) {
- return; // first call
- }
- Assert.assertEquals(1, ReplicationEndpointForTest.lastEntries.size());
- List<Cell> cells =
ReplicationEndpointForTest.lastEntries.get(0).getEdit().getCells();
- Assert.assertEquals(1, cells.size());
- Assert.assertTrue(Bytes.equals(cells.get(0).getRowArray(),
cells.get(0).getRowOffset(),
- cells.get(0).getRowLength(), row, 0, row.length));
- }
-
- public static class ReplicationEndpointForTest extends
BaseReplicationEndpoint {
- static UUID uuid = UTIL1.getRandomUUID();
- static AtomicInteger contructedCount = new AtomicInteger();
- static AtomicInteger startedCount = new AtomicInteger();
- static AtomicInteger stoppedCount = new AtomicInteger();
- static AtomicInteger replicateCount = new AtomicInteger();
- static volatile List<Entry> lastEntries = null;
-
- public ReplicationEndpointForTest() {
- replicateCount.set(0);
- contructedCount.incrementAndGet();
- }
-
- @Override
- public UUID getPeerUUID() {
- return uuid;
- }
-
- @Override
- public boolean replicate(ReplicateContext replicateContext) {
- replicateCount.incrementAndGet();
- lastEntries = new ArrayList<>(replicateContext.entries);
- return true;
- }
-
- @Override
- public void start() {
- startAsync();
- }
-
- @Override
- public void stop() {
- stopAsync();
- }
-
- @Override
- protected void doStart() {
- startedCount.incrementAndGet();
- notifyStarted();
- }
-
- @Override
- protected void doStop() {
- stoppedCount.incrementAndGet();
- notifyStopped();
- }
-
- @Override
- public boolean canReplicateToSameCluster() {
- return true;
- }
- }
-
- /**
- * Not used by unit tests, helpful for manual testing with replication.
- * <p>
- * Snippet for `hbase shell`:
- *
- * <pre>
- * create 't', 'f'
- * add_peer '1', ENDPOINT_CLASSNAME =>
'org.apache.hadoop.hbase.replication.' + \
- * 'TestReplicationEndpoint$SleepingReplicationEndpointForTest'
- * alter 't', {NAME=>'f', REPLICATION_SCOPE=>1}
- * </pre>
- */
- public static class SleepingReplicationEndpointForTest extends
ReplicationEndpointForTest {
- private long duration;
-
- public SleepingReplicationEndpointForTest() {
- super();
- }
-
- @Override
- public void init(Context context) throws IOException {
- super.init(context);
- if (this.ctx != null) {
- duration = this.ctx.getConfiguration()
- .getLong("hbase.test.sleep.replication.endpoint.duration.millis",
5000L);
- }
- }
-
- @Override
- public boolean replicate(ReplicateContext context) {
- try {
- Thread.sleep(duration);
- } catch (InterruptedException e) {
- Thread.currentThread().interrupt();
- return false;
- }
- return super.replicate(context);
- }
- }
-
- public static class InterClusterReplicationEndpointForTest
- extends HBaseInterClusterReplicationEndpoint {
-
- static AtomicInteger replicateCount = new AtomicInteger();
- static boolean failedOnce;
-
- public InterClusterReplicationEndpointForTest() {
- replicateCount.set(0);
- }
-
- @Override
- public boolean replicate(ReplicateContext replicateContext) {
- boolean success = super.replicate(replicateContext);
- if (success) {
- replicateCount.addAndGet(replicateContext.entries.size());
- }
- return success;
- }
-
- @Override
- protected CompletableFuture<Integer> asyncReplicate(List<Entry> entries,
int ordinal,
- int timeout) {
- // Fail only once, we don't want to slow down the test.
- if (failedOnce) {
- return CompletableFuture.completedFuture(ordinal);
- } else {
- failedOnce = true;
- CompletableFuture<Integer> future = new CompletableFuture<Integer>();
- future.completeExceptionally(new IOException("Sample Exception: Failed
to replicate."));
- return future;
- }
- }
- }
-
- public static class ReplicationEndpointReturningFalse extends
ReplicationEndpointForTest {
- static int COUNT = 10;
- static AtomicReference<Exception> ex = new AtomicReference<>(null);
- static AtomicBoolean replicated = new AtomicBoolean(false);
-
- @Override
- public boolean replicate(ReplicateContext replicateContext) {
- try {
- // check row
- doAssert(row);
- } catch (Exception e) {
- ex.set(e);
- }
-
- super.replicate(replicateContext);
- LOG.info("Replicated " + Bytes.toString(row) + ", count=" +
replicateCount.get());
-
- replicated.set(replicateCount.get() > COUNT); // first 10 times, we
return false
- return replicated.get();
- }
- }
-
- // return a WALEntry filter which only accepts "row", but not other rows
- public static class ReplicationEndpointWithWALEntryFilter extends
ReplicationEndpointForTest {
- static AtomicReference<Exception> ex = new AtomicReference<>(null);
-
- @Override
- public boolean replicate(ReplicateContext replicateContext) {
- try {
- super.replicate(replicateContext);
- doAssert(row);
- } catch (Exception e) {
- ex.set(e);
- }
- return true;
- }
-
- @Override
- public WALEntryFilter getWALEntryfilter() {
- return new ChainWALEntryFilter(super.getWALEntryfilter(), new
WALEntryFilter() {
- @Override
- public Entry filter(Entry entry) {
- ArrayList<Cell> cells = entry.getEdit().getCells();
- int size = cells.size();
- for (int i = size - 1; i >= 0; i--) {
- Cell cell = cells.get(i);
- if (
- !Bytes.equals(cell.getRowArray(), cell.getRowOffset(),
cell.getRowLength(), row, 0,
- row.length)
- ) {
- cells.remove(i);
- }
- }
- return entry;
- }
- });
- }
- }
-
- public static class EverythingPassesWALEntryFilter implements WALEntryFilter
{
- private static boolean passedEntry = false;
-
- @Override
- public Entry filter(Entry entry) {
- passedEntry = true;
- return entry;
- }
-
- public static boolean hasPassedAnEntry() {
- return passedEntry;
- }
- }
+@Tag(ReplicationTests.TAG)
+@Tag(MediumTests.TAG)
+public class TestReplicationEndpoint extends ReplicationEndpointTestBase {
- public static class EverythingPassesWALEntryFilterSubclass
- extends EverythingPassesWALEntryFilter {
+ @BeforeAll
+ public static void setUpBeforeAll() throws Exception {
+ ReplicationEndpointTestBase.setUpBeforeClass();
}
}
diff --git
a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationKillMasterRS.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationKillMasterRS.java
index 7720d42a6ed..2e8cfcecbcb 100644
---
a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationKillMasterRS.java
+++
b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationKillMasterRS.java
@@ -17,33 +17,19 @@
*/
package org.apache.hadoop.hbase.replication;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.testclassification.LargeTests;
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;
-/**
- * Runs the TestReplicationKillRS test and selects the RS to kill in the
master cluster Do not add
- * other tests in this class.
- */
-@Category({ ReplicationTests.class, LargeTests.class })
-public class TestReplicationKillMasterRS extends TestReplicationKillRS {
-
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestReplicationKillMasterRS.class);
+@Tag(ReplicationTests.TAG)
+@Tag(LargeTests.TAG)
+public class TestReplicationKillMasterRS extends
ReplicationKillMasterRSTestBase {
- @BeforeClass
+ @BeforeAll
public static void setUpBeforeClass() throws Exception {
NUM_SLAVES1 = 2;
- TestReplicationBase.setUpBeforeClass();
- }
-
- @Test
- public void killOneMasterRS() throws Exception {
- loadTableAndKillRS(UTIL1);
+ configureClusters(UTIL1, UTIL2);
+ startClusters();
}
}
diff --git
a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationKillMasterRSCompressed.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationKillMasterRSCompressed.java
index 7140d39adbf..dd7bf80267e 100644
---
a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationKillMasterRSCompressed.java
+++
b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationKillMasterRSCompressed.java
@@ -17,28 +17,25 @@
*/
package org.apache.hadoop.hbase.replication;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.testclassification.LargeTests;
import org.apache.hadoop.hbase.testclassification.ReplicationTests;
-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;
/**
* Run the same test as TestReplicationKillMasterRS but with WAL compression
enabled Do not add
* other tests in this class.
*/
-@Category({ ReplicationTests.class, LargeTests.class })
-public class TestReplicationKillMasterRSCompressed extends
TestReplicationKillMasterRS {
+@Tag(ReplicationTests.TAG)
+@Tag(LargeTests.TAG)
+public class TestReplicationKillMasterRSCompressed extends
ReplicationKillMasterRSTestBase {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestReplicationKillMasterRSCompressed.class);
-
- @BeforeClass
+ @BeforeAll
public static void setUpBeforeClass() throws Exception {
+ NUM_SLAVES1 = 2;
CONF1.setBoolean(HConstants.ENABLE_WAL_COMPRESSION, true);
- TestReplicationKillMasterRS.setUpBeforeClass();
+ configureClusters(UTIL1, UTIL2);
+ startClusters();
}
}
diff --git
a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationKillMasterRSWithSeparateOldWALs.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationKillMasterRSWithSeparateOldWALs.java
index a5e19c9f443..31f91b44c26 100644
---
a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationKillMasterRSWithSeparateOldWALs.java
+++
b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationKillMasterRSWithSeparateOldWALs.java
@@ -17,24 +17,22 @@
*/
package org.apache.hadoop.hbase.replication;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.testclassification.LargeTests;
import org.apache.hadoop.hbase.testclassification.ReplicationTests;
import org.apache.hadoop.hbase.wal.AbstractFSWALProvider;
-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;
-@Category({ ReplicationTests.class, LargeTests.class })
-public class TestReplicationKillMasterRSWithSeparateOldWALs extends
TestReplicationKillMasterRS {
+@Tag(ReplicationTests.TAG)
+@Tag(LargeTests.TAG)
+public class TestReplicationKillMasterRSWithSeparateOldWALs
+ extends ReplicationKillMasterRSTestBase {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
-
HBaseClassTestRule.forClass(TestReplicationKillMasterRSWithSeparateOldWALs.class);
-
- @BeforeClass
+ @BeforeAll
public static void setUpBeforeClass() throws Exception {
+ NUM_SLAVES1 = 2;
CONF1.setBoolean(AbstractFSWALProvider.SEPARATE_OLDLOGDIR, true);
- TestReplicationKillMasterRS.setUpBeforeClass();
+ configureClusters(UTIL1, UTIL2);
+ startClusters();
}
}
diff --git
a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationKillSlaveRS.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationKillSlaveRS.java
index 6505a4a191d..1b87129cf5d 100644
---
a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationKillSlaveRS.java
+++
b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationKillSlaveRS.java
@@ -17,33 +17,22 @@
*/
package org.apache.hadoop.hbase.replication;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.testclassification.LargeTests;
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;
/**
- * Runs the TestReplicationKillRS test and selects the RS to kill in the slave
cluster Do not add
- * other tests in this class.
+ *
*/
-@Category({ ReplicationTests.class, LargeTests.class })
-public class TestReplicationKillSlaveRS extends TestReplicationKillRS {
-
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestReplicationKillSlaveRS.class);
+@Tag(ReplicationTests.TAG)
+@Tag(LargeTests.TAG)
+public class TestReplicationKillSlaveRS extends ReplicationKillSlaveRSTestBase
{
- @BeforeClass
+ @BeforeAll
public static void setUpBeforeClass() throws Exception {
NUM_SLAVES2 = 2;
- TestReplicationBase.setUpBeforeClass();
- }
-
- @Test
- public void killOneSlaveRS() throws Exception {
- loadTableAndKillRS(UTIL2);
+ configureClusters(UTIL1, UTIL2);
+ startClusters();
}
}
diff --git
a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationKillSlaveRSWithSeparateOldWALs.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationKillSlaveRSWithSeparateOldWALs.java
index 3b0766f6ed9..f37442240b6 100644
---
a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationKillSlaveRSWithSeparateOldWALs.java
+++
b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationKillSlaveRSWithSeparateOldWALs.java
@@ -17,24 +17,21 @@
*/
package org.apache.hadoop.hbase.replication;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.testclassification.LargeTests;
import org.apache.hadoop.hbase.testclassification.ReplicationTests;
import org.apache.hadoop.hbase.wal.AbstractFSWALProvider;
-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;
-@Category({ ReplicationTests.class, LargeTests.class })
-public class TestReplicationKillSlaveRSWithSeparateOldWALs extends
TestReplicationKillSlaveRS {
+@Tag(ReplicationTests.TAG)
+@Tag(LargeTests.TAG)
+public class TestReplicationKillSlaveRSWithSeparateOldWALs extends
ReplicationKillSlaveRSTestBase {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
-
HBaseClassTestRule.forClass(TestReplicationKillSlaveRSWithSeparateOldWALs.class);
-
- @BeforeClass
+ @BeforeAll
public static void setUpBeforeClass() throws Exception {
+ NUM_SLAVES2 = 2;
CONF1.setBoolean(AbstractFSWALProvider.SEPARATE_OLDLOGDIR, true);
- TestReplicationKillSlaveRS.setUpBeforeClass();
+ configureClusters(UTIL1, UTIL2);
+ startClusters();
}
}
diff --git
a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationSyncUpTool.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationSyncUpTool.java
index 66de933832b..34ec4f77caa 100644
---
a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationSyncUpTool.java
+++
b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationSyncUpTool.java
@@ -18,11 +18,11 @@
package org.apache.hadoop.hbase.replication;
import static org.apache.hadoop.hbase.HBaseTestingUtil.countRows;
-import static
org.apache.hadoop.hbase.replication.TestReplicationBase.NB_RETRIES;
-import static
org.apache.hadoop.hbase.replication.TestReplicationBase.NB_ROWS_IN_BATCH;
-import static
org.apache.hadoop.hbase.replication.TestReplicationBase.SLEEP_TIME;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static
org.apache.hadoop.hbase.replication.TestReplicationBaseNoBeforeAll.NB_RETRIES;
+import static
org.apache.hadoop.hbase.replication.TestReplicationBaseNoBeforeAll.NB_ROWS_IN_BATCH;
+import static
org.apache.hadoop.hbase.replication.TestReplicationBaseNoBeforeAll.SLEEP_TIME;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.ArrayList;
import java.util.List;
@@ -31,7 +31,6 @@ import org.apache.hadoop.fs.FileAlreadyExistsException;
import org.apache.hadoop.fs.FileStatus;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.ServerName;
import org.apache.hadoop.hbase.client.Delete;
import org.apache.hadoop.hbase.client.Put;
@@ -40,19 +39,15 @@ 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.CommonFSUtils;
-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, LargeTests.class })
+@Tag(ReplicationTests.TAG)
+@Tag(LargeTests.TAG)
public class TestReplicationSyncUpTool extends TestReplicationSyncUpToolBase {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestReplicationSyncUpTool.class);
-
private static final Logger LOG =
LoggerFactory.getLogger(TestReplicationSyncUpTool.class);
/**
@@ -159,8 +154,8 @@ public class TestReplicationSyncUpTool extends
TestReplicationSyncUpToolBase {
for (int i = 0; i < NB_RETRIES; i++) {
int rowCountHt1TargetAtPeer1 = countRows(ht1TargetAtPeer1);
if (i == NB_RETRIES - 1) {
- assertEquals("t1_syncup has 101 rows on source, and 100 on slave1",
rowCountHt1Source - 1,
- rowCountHt1TargetAtPeer1);
+ assertEquals(rowCountHt1Source - 1, rowCountHt1TargetAtPeer1,
+ "t1_syncup has 101 rows on source, and 100 on slave1");
}
if (rowCountHt1Source - 1 == rowCountHt1TargetAtPeer1) {
break;
@@ -172,8 +167,8 @@ public class TestReplicationSyncUpTool extends
TestReplicationSyncUpToolBase {
for (int i = 0; i < NB_RETRIES; i++) {
int rowCountHt2TargetAtPeer1 = countRows(ht2TargetAtPeer1);
if (i == NB_RETRIES - 1) {
- assertEquals("t2_syncup has 201 rows on source, and 200 on slave1",
rowCountHt2Source - 1,
- rowCountHt2TargetAtPeer1);
+ assertEquals(rowCountHt2Source - 1, rowCountHt2TargetAtPeer1,
+ "t2_syncup has 201 rows on source, and 200 on slave1");
}
if (rowCountHt2Source - 1 == rowCountHt2TargetAtPeer1) {
break;
@@ -203,12 +198,12 @@ public class TestReplicationSyncUpTool extends
TestReplicationSyncUpToolBase {
ht2Source.delete(list);
int rowCount_ht1Source = countRows(ht1Source);
- assertEquals("t1_syncup has 51 rows on source, after remove 50 of the
replicated colfam", 51,
- rowCount_ht1Source);
+ assertEquals(51, rowCount_ht1Source,
+ "t1_syncup has 51 rows on source, after remove 50 of the replicated
colfam");
int rowCount_ht2Source = countRows(ht2Source);
- assertEquals("t2_syncup has 101 rows on source, after remove 100 of the
replicated colfam", 101,
- rowCount_ht2Source);
+ assertEquals(101, rowCount_ht2Source,
+ "t2_syncup has 101 rows on source, after remove 100 of the replicated
colfam");
List<ServerName> sourceRses =
UTIL1.getHBaseCluster().getRegionServerThreads().stream()
.map(rst ->
rst.getRegionServer().getServerName()).collect(Collectors.toList());
shutDownSourceHBaseCluster();
@@ -219,18 +214,18 @@ public class TestReplicationSyncUpTool extends
TestReplicationSyncUpToolBase {
// before sync up
int rowCountHt1TargetAtPeer1 = countRows(ht1TargetAtPeer1);
int rowCountHt2TargetAtPeer1 = countRows(ht2TargetAtPeer1);
- assertEquals("@Peer1 t1_syncup should still have 100 rows", 100,
rowCountHt1TargetAtPeer1);
- assertEquals("@Peer1 t2_syncup should still have 200 rows", 200,
rowCountHt2TargetAtPeer1);
+ assertEquals(100, rowCountHt1TargetAtPeer1, "@Peer1 t1_syncup should still
have 100 rows");
+ assertEquals(200, rowCountHt2TargetAtPeer1, "@Peer1 t2_syncup should still
have 200 rows");
syncUp(UTIL1);
// After sync up
rowCountHt1TargetAtPeer1 = countRows(ht1TargetAtPeer1);
rowCountHt2TargetAtPeer1 = countRows(ht2TargetAtPeer1);
- assertEquals("@Peer1 t1_syncup should be sync up and have 50 rows", 50,
- rowCountHt1TargetAtPeer1);
- assertEquals("@Peer1 t2_syncup should be sync up and have 100 rows", 100,
- rowCountHt2TargetAtPeer1);
+ assertEquals(50, rowCountHt1TargetAtPeer1,
+ "@Peer1 t1_syncup should be sync up and have 50 rows");
+ assertEquals(100, rowCountHt2TargetAtPeer1,
+ "@Peer1 t2_syncup should be sync up and have 100 rows");
// check we have recorded the dead region servers and also have an info
file
Path rootDir = CommonFSUtils.getRootDir(UTIL1.getConfiguration());
@@ -275,9 +270,9 @@ public class TestReplicationSyncUpTool extends
TestReplicationSyncUpToolBase {
ht2Source.put(p);
int rowCount_ht1Source = countRows(ht1Source);
- assertEquals("t1_syncup has 102 rows on source", 102, rowCount_ht1Source);
+ assertEquals(102, rowCount_ht1Source, "t1_syncup has 102 rows on source");
int rowCount_ht2Source = countRows(ht2Source);
- assertEquals("t2_syncup has 202 rows on source", 202, rowCount_ht2Source);
+ assertEquals(202, rowCount_ht2Source, "t2_syncup has 202 rows on source");
shutDownSourceHBaseCluster();
restartTargetHBaseCluster(1);
@@ -287,20 +282,20 @@ public class TestReplicationSyncUpTool extends
TestReplicationSyncUpToolBase {
// before sync up
int rowCountHt1TargetAtPeer1 = countRows(ht1TargetAtPeer1);
int rowCountHt2TargetAtPeer1 = countRows(ht2TargetAtPeer1);
- assertEquals("@Peer1 t1_syncup should be NOT sync up and have 50 rows", 50,
- rowCountHt1TargetAtPeer1);
- assertEquals("@Peer1 t2_syncup should be NOT sync up and have 100 rows",
100,
- rowCountHt2TargetAtPeer1);
+ assertEquals(50, rowCountHt1TargetAtPeer1,
+ "@Peer1 t1_syncup should be NOT sync up and have 50 rows");
+ assertEquals(100, rowCountHt2TargetAtPeer1,
+ "@Peer1 t2_syncup should be NOT sync up and have 100 rows");
syncUp(UTIL1);
// after sync up
rowCountHt1TargetAtPeer1 = countRows(ht1TargetAtPeer1);
rowCountHt2TargetAtPeer1 = countRows(ht2TargetAtPeer1);
- assertEquals("@Peer1 t1_syncup should be sync up and have 100 rows", 100,
- rowCountHt1TargetAtPeer1);
- assertEquals("@Peer1 t2_syncup should be sync up and have 200 rows", 200,
- rowCountHt2TargetAtPeer1);
+ assertEquals(100, rowCountHt1TargetAtPeer1,
+ "@Peer1 t1_syncup should be sync up and have 100 rows");
+ assertEquals(200, rowCountHt2TargetAtPeer1,
+ "@Peer1 t2_syncup should be sync up and have 200 rows");
}
/**
@@ -324,8 +319,8 @@ public class TestReplicationSyncUpTool extends
TestReplicationSyncUpToolBase {
try {
syncUp(UTIL1);
} catch (Exception e) {
- assertTrue("e should be a FileAlreadyExistsException",
- (e instanceof FileAlreadyExistsException));
+ assertTrue(e instanceof FileAlreadyExistsException,
+ "e should be a FileAlreadyExistsException");
}
FileStatus fileStatus2 = fs.getFileStatus(replicationInfoPath);
assertEquals(fileStatus1.getModificationTime(),
fileStatus2.getModificationTime());
diff --git
a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationSyncUpToolBase.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationSyncUpToolBase.java
index 9455cf56727..9b1981d65ab 100644
---
a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationSyncUpToolBase.java
+++
b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationSyncUpToolBase.java
@@ -32,8 +32,8 @@ import org.apache.hadoop.hbase.client.TableDescriptorBuilder;
import org.apache.hadoop.hbase.replication.regionserver.ReplicationSyncUp;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.util.ToolRunner;
-import org.junit.After;
-import org.junit.Before;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
import org.apache.hbase.thirdparty.com.google.common.io.Closeables;
@@ -66,7 +66,7 @@ public abstract class TestReplicationSyncUpToolBase {
protected void customizeClusterConf(Configuration conf) {
}
- @Before
+ @BeforeEach
public void setUp() throws Exception {
customizeClusterConf(UTIL1.getConfiguration());
customizeClusterConf(UTIL2.getConfiguration());
@@ -96,7 +96,7 @@ public abstract class TestReplicationSyncUpToolBase {
.setColumnFamily(ColumnFamilyDescriptorBuilder.of(NO_REP_FAMILY)).build();
}
- @After
+ @AfterEach
public void tearDown() throws Exception {
Closeables.close(ht1Source, true);
Closeables.close(ht2Source, true);
diff --git
a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationSyncUpToolWithBulkLoadedData.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationSyncUpToolWithBulkLoadedData.java
index e9acc1bc45e..543bbd71c78 100644
---
a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationSyncUpToolWithBulkLoadedData.java
+++
b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationSyncUpToolWithBulkLoadedData.java
@@ -18,10 +18,10 @@
package org.apache.hadoop.hbase.replication;
import static org.apache.hadoop.hbase.HBaseTestingUtil.countRows;
-import static
org.apache.hadoop.hbase.replication.TestReplicationBase.NB_RETRIES;
-import static
org.apache.hadoop.hbase.replication.TestReplicationBase.SLEEP_TIME;
-import static org.apache.hadoop.hbase.replication.TestReplicationBase.row;
-import static org.junit.Assert.assertEquals;
+import static
org.apache.hadoop.hbase.replication.TestReplicationBaseNoBeforeAll.NB_RETRIES;
+import static
org.apache.hadoop.hbase.replication.TestReplicationBaseNoBeforeAll.SLEEP_TIME;
+import static
org.apache.hadoop.hbase.replication.TestReplicationBaseNoBeforeAll.row;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import java.io.IOException;
import java.util.ArrayList;
@@ -33,7 +33,6 @@ import java.util.Set;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtil;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.TableName;
@@ -45,19 +44,15 @@ import
org.apache.hadoop.hbase.testclassification.ReplicationTests;
import org.apache.hadoop.hbase.tool.BulkLoadHFiles;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.hbase.util.HFileTestUtil;
-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, LargeTests.class })
+@Tag(ReplicationTests.TAG)
+@Tag(LargeTests.TAG)
public class TestReplicationSyncUpToolWithBulkLoadedData extends
TestReplicationSyncUpToolBase {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
-
HBaseClassTestRule.forClass(TestReplicationSyncUpToolWithBulkLoadedData.class);
-
private static final Logger LOG =
LoggerFactory.getLogger(TestReplicationSyncUpToolWithBulkLoadedData.class);
@@ -128,12 +123,12 @@ public class TestReplicationSyncUpToolWithBulkLoadedData
extends TestReplication
loadAndReplicateHFiles(false, randomHFileRangeListIterator);
int rowCount_ht1Source = countRows(ht1Source);
- assertEquals("t1_syncup has 206 rows on source, after bulk load of another
103 hfiles", 206,
- rowCount_ht1Source);
+ assertEquals(206, rowCount_ht1Source,
+ "t1_syncup has 206 rows on source, after bulk load of another 103
hfiles");
int rowCount_ht2Source = countRows(ht2Source);
- assertEquals("t2_syncup has 406 rows on source, after bulk load of another
203 hfiles", 406,
- rowCount_ht2Source);
+ assertEquals(406, rowCount_ht2Source,
+ "t2_syncup has 406 rows on source, after bulk load of another 203
hfiles");
shutDownSourceHBaseCluster();
restartTargetHBaseCluster(1);
@@ -143,8 +138,8 @@ public class TestReplicationSyncUpToolWithBulkLoadedData
extends TestReplication
// Before sync up
int rowCountHt1TargetAtPeer1 = countRows(ht1TargetAtPeer1);
int rowCountHt2TargetAtPeer1 = countRows(ht2TargetAtPeer1);
- assertEquals("@Peer1 t1_syncup should still have 100 rows", 100,
rowCountHt1TargetAtPeer1);
- assertEquals("@Peer1 t2_syncup should still have 200 rows", 200,
rowCountHt2TargetAtPeer1);
+ assertEquals(100, rowCountHt1TargetAtPeer1, "@Peer1 t1_syncup should still
have 100 rows");
+ assertEquals(200, rowCountHt2TargetAtPeer1, "@Peer1 t2_syncup should still
have 200 rows");
// Run sync up tool
syncUp(UTIL1);
@@ -152,10 +147,10 @@ public class TestReplicationSyncUpToolWithBulkLoadedData
extends TestReplication
// After syun up
rowCountHt1TargetAtPeer1 = countRows(ht1TargetAtPeer1);
rowCountHt2TargetAtPeer1 = countRows(ht2TargetAtPeer1);
- assertEquals("@Peer1 t1_syncup should be sync up and have 200 rows", 200,
- rowCountHt1TargetAtPeer1);
- assertEquals("@Peer1 t2_syncup should be sync up and have 400 rows", 400,
- rowCountHt2TargetAtPeer1);
+ assertEquals(200, rowCountHt1TargetAtPeer1,
+ "@Peer1 t1_syncup should be sync up and have 200 rows");
+ assertEquals(400, rowCountHt2TargetAtPeer1,
+ "@Peer1 t2_syncup should be sync up and have 400 rows");
}
private void loadAndReplicateHFiles(boolean verifyReplicationOnSlave,
@@ -212,7 +207,7 @@ public class TestReplicationSyncUpToolWithBulkLoadedData
extends TestReplication
Table source, byte[][][] hfileRanges, int numOfRows) throws Exception {
Path dir = UTIL1.getDataTestDirOnTestFS(testName);
FileSystem fs = UTIL1.getTestFileSystem();
- dir = dir.makeQualified(fs);
+ dir = dir.makeQualified(fs.getUri(), fs.getWorkingDirectory());
Path familyDir = new Path(dir, Bytes.toString(fam));
int hfileIdx = 0;
@@ -232,7 +227,7 @@ public class TestReplicationSyncUpToolWithBulkLoadedData
extends TestReplication
Table source, byte[][][] hfileRanges, int numOfRows) throws Exception {
Path dir = UTIL2.getDataTestDirOnTestFS(testName);
FileSystem fs = UTIL2.getTestFileSystem();
- dir = dir.makeQualified(fs);
+ dir = dir.makeQualified(fs.getUri(), fs.getWorkingDirectory());
Path familyDir = new Path(dir, Bytes.toString(fam));
int hfileIdx = 0;
@@ -253,7 +248,7 @@ public class TestReplicationSyncUpToolWithBulkLoadedData
extends TestReplication
for (int i = 0; i < NB_RETRIES; i++) {
int rowCountHt2TargetAtPeer1 = countRows(target);
if (i == NB_RETRIES - 1) {
- assertEquals(msg, expectedCount, rowCountHt2TargetAtPeer1);
+ assertEquals(expectedCount, rowCountHt2TargetAtPeer1, msg);
}
if (expectedCount == rowCountHt2TargetAtPeer1) {
break;
diff --git
a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/master/TestLogCleanerBarrier.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/master/TestLogCleanerBarrier.java
index 06cb85523d3..58da76fb542 100644
---
a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/master/TestLogCleanerBarrier.java
+++
b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/master/TestLogCleanerBarrier.java
@@ -17,24 +17,19 @@
*/
package org.apache.hadoop.hbase.replication.master;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertThrows;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.testclassification.MasterTests;
import org.apache.hadoop.hbase.testclassification.SmallTests;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
-@Category({ MasterTests.class, SmallTests.class })
+@Tag(MasterTests.TAG)
+@Tag(SmallTests.TAG)
public class TestLogCleanerBarrier {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestLogCleanerBarrier.class);
-
@Test
public void test() {
ReplicationLogCleanerBarrier barrier = new ReplicationLogCleanerBarrier();
diff --git
a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/master/TestRecoverStandbyProcedure.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/master/TestRecoverStandbyProcedure.java
index 1b7b6c81749..520cf18a8c5 100644
---
a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/master/TestRecoverStandbyProcedure.java
+++
b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/master/TestRecoverStandbyProcedure.java
@@ -17,8 +17,8 @@
*/
package org.apache.hadoop.hbase.replication.master;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import java.io.IOException;
import java.util.List;
@@ -27,7 +27,6 @@ import java.util.stream.IntStream;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtil;
import org.apache.hadoop.hbase.KeyValue;
import org.apache.hadoop.hbase.TableName;
@@ -56,23 +55,19 @@ import org.apache.hadoop.hbase.wal.WAL.Entry;
import org.apache.hadoop.hbase.wal.WALEdit;
import org.apache.hadoop.hbase.wal.WALEditInternalHelper;
import org.apache.hadoop.hbase.wal.WALKeyImpl;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-@Category({ MasterTests.class, LargeTests.class })
+@Tag(MasterTests.TAG)
+@Tag(LargeTests.TAG)
public class TestRecoverStandbyProcedure {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestRecoverStandbyProcedure.class);
-
private static final Logger LOG =
LoggerFactory.getLogger(TestRecoverStandbyProcedure.class);
private static final TableName tableName =
TableName.valueOf("TestRecoverStandbyProcedure");
@@ -103,7 +98,7 @@ public class TestRecoverStandbyProcedure {
private static Configuration conf;
- @BeforeClass
+ @BeforeAll
public static void setupCluster() throws Exception {
UTIL.startMiniCluster(RS_NUMBER);
UTIL.getHBaseCluster().waitForActiveAndReadyMaster();
@@ -114,21 +109,17 @@ public class TestRecoverStandbyProcedure {
procExec = master.getMasterProcedureExecutor();
}
- @AfterClass
+ @AfterAll
public static void cleanupTest() throws Exception {
- try {
- UTIL.shutdownMiniCluster();
- } catch (Exception e) {
- LOG.warn("failure shutting down cluster", e);
- }
+ UTIL.shutdownMiniCluster();
}
- @Before
+ @BeforeEach
public void setupBeforeTest() throws IOException {
UTIL.createTable(tableName, family);
}
- @After
+ @AfterEach
public void tearDownAfterTest() throws IOException {
try (Admin admin = UTIL.getAdmin()) {
if (admin.isTableEnabled(tableName)) {
diff --git
a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/master/TestReplicationLogCleaner.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/master/TestReplicationLogCleaner.java
index 487ae63a6d3..4e17ff48106 100644
---
a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/master/TestReplicationLogCleaner.java
+++
b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/master/TestReplicationLogCleaner.java
@@ -19,9 +19,9 @@ package org.apache.hadoop.hbase.replication.master;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.emptyIterable;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -37,7 +37,6 @@ import java.util.stream.Stream;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileStatus;
import org.apache.hadoop.fs.Path;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.ServerName;
import org.apache.hadoop.hbase.client.AsyncClusterConnection;
@@ -58,22 +57,18 @@ import
org.apache.hadoop.hbase.testclassification.MasterTests;
import org.apache.hadoop.hbase.testclassification.SmallTests;
import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
import org.apache.hadoop.hbase.wal.AbstractFSWALProvider;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
import org.apache.hbase.thirdparty.com.google.common.collect.ImmutableMap;
-@Category({ MasterTests.class, SmallTests.class })
+@Tag(MasterTests.TAG)
+@Tag(SmallTests.TAG)
public class TestReplicationLogCleaner {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestReplicationLogCleaner.class);
-
private static final Configuration CONF = HBaseConfiguration.create();
private MasterServices services;
@@ -82,7 +77,7 @@ public class TestReplicationLogCleaner {
private ReplicationPeerManager rpm;
- @Before
+ @BeforeEach
public void setUp() throws ReplicationException {
services = mock(MasterServices.class);
when(services.getReplicationLogCleanerBarrier()).thenReturn(new
ReplicationLogCleanerBarrier());
@@ -110,7 +105,7 @@ public class TestReplicationLogCleaner {
cleaner.init(params);
}
- @After
+ @AfterEach
public void tearDown() {
cleaner.postClean();
}
diff --git
a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/multiwal/TestReplicationEndpointWithMultipleAsyncWAL.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/multiwal/TestReplicationEndpointWithMultipleAsyncWAL.java
index d3a947fb240..ad82b2fca59 100644
---
a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/multiwal/TestReplicationEndpointWithMultipleAsyncWAL.java
+++
b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/multiwal/TestReplicationEndpointWithMultipleAsyncWAL.java
@@ -17,27 +17,22 @@
*/
package org.apache.hadoop.hbase.replication.multiwal;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
-import org.apache.hadoop.hbase.replication.TestReplicationEndpoint;
+import org.apache.hadoop.hbase.replication.ReplicationEndpointTestBase;
import org.apache.hadoop.hbase.testclassification.MediumTests;
import org.apache.hadoop.hbase.testclassification.ReplicationTests;
import org.apache.hadoop.hbase.wal.RegionGroupingProvider;
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;
-@Category({ ReplicationTests.class, MediumTests.class })
-public class TestReplicationEndpointWithMultipleAsyncWAL extends
TestReplicationEndpoint {
+@Tag(ReplicationTests.TAG)
+@Tag(MediumTests.TAG)
+public class TestReplicationEndpointWithMultipleAsyncWAL extends
ReplicationEndpointTestBase {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
-
HBaseClassTestRule.forClass(TestReplicationEndpointWithMultipleAsyncWAL.class);
-
- @BeforeClass
- public static void setUpBeforeClass() throws Exception {
+ @BeforeAll
+ public static void setUpBeforeAll() throws Exception {
CONF1.set(WALFactory.WAL_PROVIDER, "multiwal");
CONF1.set(RegionGroupingProvider.DELEGATE_PROVIDER, "asyncfs");
- TestReplicationEndpoint.setUpBeforeClass();
+ ReplicationEndpointTestBase.setUpBeforeClass();
}
}
diff --git
a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/multiwal/TestReplicationEndpointWithMultipleWAL.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/multiwal/TestReplicationEndpointWithMultipleWAL.java
index a882c504399..504c98d182a 100644
---
a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/multiwal/TestReplicationEndpointWithMultipleWAL.java
+++
b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/multiwal/TestReplicationEndpointWithMultipleWAL.java
@@ -17,27 +17,22 @@
*/
package org.apache.hadoop.hbase.replication.multiwal;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
-import org.apache.hadoop.hbase.replication.TestReplicationEndpoint;
+import org.apache.hadoop.hbase.replication.ReplicationEndpointTestBase;
import org.apache.hadoop.hbase.testclassification.MediumTests;
import org.apache.hadoop.hbase.testclassification.ReplicationTests;
import org.apache.hadoop.hbase.wal.RegionGroupingProvider;
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;
-@Category({ ReplicationTests.class, MediumTests.class })
-public class TestReplicationEndpointWithMultipleWAL extends
TestReplicationEndpoint {
+@Tag(ReplicationTests.TAG)
+@Tag(MediumTests.TAG)
+public class TestReplicationEndpointWithMultipleWAL extends
ReplicationEndpointTestBase {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestReplicationEndpointWithMultipleWAL.class);
-
- @BeforeClass
- public static void setUpBeforeClass() throws Exception {
+ @BeforeAll
+ public static void setUpBeforeAll() throws Exception {
CONF1.set(WALFactory.WAL_PROVIDER, "multiwal");
CONF1.set(RegionGroupingProvider.DELEGATE_PROVIDER, "filesystem");
- TestReplicationEndpoint.setUpBeforeClass();
+ ReplicationEndpointTestBase.setUpBeforeClass();
}
}
diff --git
a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/multiwal/TestReplicationKillMasterRSCompressedWithMultipleAsyncWAL.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/multiwal/TestReplicationKillMasterRSCompressedWithMultipleAsyncWAL.java
index 623e4c28cd0..2f8cae29402 100644
---
a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/multiwal/TestReplicationKillMasterRSCompressedWithMultipleAsyncWAL.java
+++
b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/multiwal/TestReplicationKillMasterRSCompressedWithMultipleAsyncWAL.java
@@ -17,28 +17,27 @@
*/
package org.apache.hadoop.hbase.replication.multiwal;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
-import
org.apache.hadoop.hbase.replication.TestReplicationKillMasterRSCompressed;
+import org.apache.hadoop.hbase.HConstants;
+import org.apache.hadoop.hbase.replication.ReplicationKillMasterRSTestBase;
import org.apache.hadoop.hbase.testclassification.LargeTests;
import org.apache.hadoop.hbase.testclassification.ReplicationTests;
import org.apache.hadoop.hbase.wal.RegionGroupingProvider;
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;
-@Category({ ReplicationTests.class, LargeTests.class })
+@Tag(ReplicationTests.TAG)
+@Tag(LargeTests.TAG)
public class TestReplicationKillMasterRSCompressedWithMultipleAsyncWAL
- extends TestReplicationKillMasterRSCompressed {
+ extends ReplicationKillMasterRSTestBase {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
-
HBaseClassTestRule.forClass(TestReplicationKillMasterRSCompressedWithMultipleAsyncWAL.class);
-
- @BeforeClass
+ @BeforeAll
public static void setUpBeforeClass() throws Exception {
+ NUM_SLAVES1 = 2;
CONF1.set(WALFactory.WAL_PROVIDER, "multiwal");
CONF1.set(RegionGroupingProvider.DELEGATE_PROVIDER, "asyncfs");
- TestReplicationKillMasterRSCompressed.setUpBeforeClass();
+ CONF1.setBoolean(HConstants.ENABLE_WAL_COMPRESSION, true);
+ configureClusters(UTIL1, UTIL2);
+ startClusters();
}
}
diff --git
a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/multiwal/TestReplicationKillMasterRSCompressedWithMultipleWAL.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/multiwal/TestReplicationKillMasterRSCompressedWithMultipleWAL.java
index 54921520b1c..d9ebd1d623b 100644
---
a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/multiwal/TestReplicationKillMasterRSCompressedWithMultipleWAL.java
+++
b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/multiwal/TestReplicationKillMasterRSCompressedWithMultipleWAL.java
@@ -17,28 +17,27 @@
*/
package org.apache.hadoop.hbase.replication.multiwal;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
-import
org.apache.hadoop.hbase.replication.TestReplicationKillMasterRSCompressed;
+import org.apache.hadoop.hbase.HConstants;
+import org.apache.hadoop.hbase.replication.ReplicationKillMasterRSTestBase;
import org.apache.hadoop.hbase.testclassification.LargeTests;
import org.apache.hadoop.hbase.testclassification.ReplicationTests;
import org.apache.hadoop.hbase.wal.RegionGroupingProvider;
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;
-@Category({ ReplicationTests.class, LargeTests.class })
+@Tag(ReplicationTests.TAG)
+@Tag(LargeTests.TAG)
public class TestReplicationKillMasterRSCompressedWithMultipleWAL
- extends TestReplicationKillMasterRSCompressed {
+ extends ReplicationKillMasterRSTestBase {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
-
HBaseClassTestRule.forClass(TestReplicationKillMasterRSCompressedWithMultipleWAL.class);
-
- @BeforeClass
+ @BeforeAll
public static void setUpBeforeClass() throws Exception {
+ NUM_SLAVES1 = 2;
CONF1.set(WALFactory.WAL_PROVIDER, "multiwal");
CONF1.set(RegionGroupingProvider.DELEGATE_PROVIDER, "filesystem");
- TestReplicationKillMasterRSCompressed.setUpBeforeClass();
+ CONF1.setBoolean(HConstants.ENABLE_WAL_COMPRESSION, true);
+ configureClusters(UTIL1, UTIL2);
+ startClusters();
}
}
diff --git
a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/multiwal/TestReplicationSyncUpToolWithMultipleAsyncWAL.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/multiwal/TestReplicationSyncUpToolWithMultipleAsyncWAL.java
index 83cd41773ca..f8de4560006 100644
---
a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/multiwal/TestReplicationSyncUpToolWithMultipleAsyncWAL.java
+++
b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/multiwal/TestReplicationSyncUpToolWithMultipleAsyncWAL.java
@@ -18,22 +18,17 @@
package org.apache.hadoop.hbase.replication.multiwal;
import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.replication.TestReplicationSyncUpTool;
import org.apache.hadoop.hbase.testclassification.LargeTests;
import org.apache.hadoop.hbase.testclassification.ReplicationTests;
import org.apache.hadoop.hbase.wal.RegionGroupingProvider;
import org.apache.hadoop.hbase.wal.WALFactory;
-import org.junit.ClassRule;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.Tag;
-@Category({ ReplicationTests.class, LargeTests.class })
+@Tag(ReplicationTests.TAG)
+@Tag(LargeTests.TAG)
public class TestReplicationSyncUpToolWithMultipleAsyncWAL extends
TestReplicationSyncUpTool {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
-
HBaseClassTestRule.forClass(TestReplicationSyncUpToolWithMultipleAsyncWAL.class);
-
@Override
protected void customizeClusterConf(Configuration conf) {
conf.set(WALFactory.WAL_PROVIDER, "multiwal");
diff --git
a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/multiwal/TestReplicationSyncUpToolWithMultipleWAL.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/multiwal/TestReplicationSyncUpToolWithMultipleWAL.java
index 673b841430e..6883c48cc8d 100644
---
a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/multiwal/TestReplicationSyncUpToolWithMultipleWAL.java
+++
b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/multiwal/TestReplicationSyncUpToolWithMultipleWAL.java
@@ -18,22 +18,17 @@
package org.apache.hadoop.hbase.replication.multiwal;
import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.replication.TestReplicationSyncUpTool;
import org.apache.hadoop.hbase.testclassification.LargeTests;
import org.apache.hadoop.hbase.testclassification.ReplicationTests;
import org.apache.hadoop.hbase.wal.RegionGroupingProvider;
import org.apache.hadoop.hbase.wal.WALFactory;
-import org.junit.ClassRule;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.Tag;
-@Category({ ReplicationTests.class, LargeTests.class })
+@Tag(ReplicationTests.TAG)
+@Tag(LargeTests.TAG)
public class TestReplicationSyncUpToolWithMultipleWAL extends
TestReplicationSyncUpTool {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
-
HBaseClassTestRule.forClass(TestReplicationSyncUpToolWithMultipleWAL.class);
-
@Override
protected void customizeClusterConf(Configuration conf) {
conf.set(WALFactory.WAL_PROVIDER, "multiwal");