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 f96dbe5dc17..cd84293caed 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 @@ -1,5 +1,4 @@ -/* - * +/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information @@ -28,6 +27,8 @@ import java.util.List; import java.util.NavigableMap; import java.util.TreeMap; import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.fs.FileSystem; +import org.apache.hadoop.fs.Path; import org.apache.hadoop.hbase.HBaseConfiguration; import org.apache.hadoop.hbase.HBaseTestingUtility; import org.apache.hadoop.hbase.HConstants; @@ -58,6 +59,9 @@ import org.junit.BeforeClass; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.apache.hbase.thirdparty.com.google.common.collect.ImmutableList; +import org.apache.hbase.thirdparty.com.google.common.collect.ImmutableMap; + /** * This class is only a base for other integration-level replication tests. * Do not add tests here. @@ -99,6 +103,10 @@ public class TestReplicationBase { return false; } + protected boolean isSyncPeer() { + 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 @@ -245,9 +253,19 @@ public class TestReplicationBase { @Before public void setUpBase() throws Exception { if (!peerExist(PEER_ID2)) { - ReplicationPeerConfig rpc = ReplicationPeerConfig.newBuilder() - .setClusterKey(utility2.getClusterKey()).setSerial(isSerialPeer()).build(); - hbaseAdmin.addReplicationPeer(PEER_ID2, rpc); + ReplicationPeerConfigBuilder builder = ReplicationPeerConfig.newBuilder() + .setClusterKey(utility2.getClusterKey()).setSerial(isSerialPeer()); + if (isSyncPeer()) { + FileSystem fs2 = utility2.getTestFileSystem(); + // The remote wal dir is not important as we do not use it in DA state, here we only need to + // confirm that a sync peer in DA state can still replicate data to remote cluster + // asynchronously. + builder.setReplicateAllUserTables(false) + .setTableCFsMap(ImmutableMap.of(tableName, ImmutableList.of())) + .setRemoteWALDir(new Path("/RemoteWAL") + .makeQualified(fs2.getUri(), fs2.getWorkingDirectory()).toUri().toString()); + } + hbaseAdmin.addReplicationPeer(PEER_ID2, builder.build()); } } diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationChangingPeerRegionservers.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationChangingPeerRegionservers.java index b94b443dda3..5c967422848 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationChangingPeerRegionservers.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationChangingPeerRegionservers.java @@ -62,22 +62,28 @@ public class TestReplicationChangingPeerRegionservers extends TestReplicationBas private static final Logger LOG = LoggerFactory.getLogger(TestReplicationChangingPeerRegionservers.class); - @Parameter + @Parameter(0) public boolean serialPeer; + @Parameter(1) + public boolean syncPeer; + @Override protected boolean isSerialPeer() { return serialPeer; } - @Parameters(name = "{index}: serialPeer={0}") - public static List parameters() { - return ImmutableList.of(true, false); + @Override + protected boolean isSyncPeer() { + return syncPeer; + } + + @Parameters(name = "{index}: serialPeer={0}, syncPeer={1}") + public static List parameters() { + return ImmutableList.of(new Object[] { false, false }, new Object[] { false, true }, + new Object[] { true, false }, new Object[] { true, true }); } - /** - * @throws java.lang.Exception - */ @Before public void setUp() throws Exception { // Starting and stopping replication can make us miss new logs, diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationSmallTestsSync.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationSmallTestsSync.java new file mode 100644 index 00000000000..9ca0044d31b --- /dev/null +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationSmallTestsSync.java @@ -0,0 +1,40 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +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.ClassRule; +import org.junit.experimental.categories.Category; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; + +@RunWith(Parameterized.class) +@Category({ ReplicationTests.class, LargeTests.class }) +public class TestReplicationSmallTestsSync extends TestReplicationSmallTests { + + @ClassRule + public static final HBaseClassTestRule CLASS_RULE = + HBaseClassTestRule.forClass(TestReplicationSmallTestsSync.class); + + @Override + protected boolean isSyncPeer() { + return true; + } +}