HBASE-12180 Fix and reenable TestRegionReplicaReplicationEndpoint

This commit is contained in:
Enis Soztutar 2015-03-05 14:59:38 -08:00
parent 4570451f7c
commit be2ad98b1c
1 changed files with 18 additions and 30 deletions

View File

@ -39,9 +39,7 @@ import org.apache.hadoop.hbase.Waiter;
import org.apache.hadoop.hbase.client.ClusterConnection; import org.apache.hadoop.hbase.client.ClusterConnection;
import org.apache.hadoop.hbase.client.Connection; import org.apache.hadoop.hbase.client.Connection;
import org.apache.hadoop.hbase.client.ConnectionFactory; import org.apache.hadoop.hbase.client.ConnectionFactory;
import org.apache.hadoop.hbase.client.HConnection; import org.apache.hadoop.hbase.client.RegionLocator;
import org.apache.hadoop.hbase.client.HConnectionManager;
import org.apache.hadoop.hbase.client.RpcRetryingCaller;
import org.apache.hadoop.hbase.client.RpcRetryingCallerImpl; import org.apache.hadoop.hbase.client.RpcRetryingCallerImpl;
import org.apache.hadoop.hbase.client.Table; import org.apache.hadoop.hbase.client.Table;
import org.apache.hadoop.hbase.client.replication.ReplicationAdmin; import org.apache.hadoop.hbase.client.replication.ReplicationAdmin;
@ -59,7 +57,6 @@ import org.apache.hadoop.hbase.zookeeper.ZKUtil;
import org.apache.log4j.Level; import org.apache.log4j.Level;
import org.junit.AfterClass; import org.junit.AfterClass;
import org.junit.BeforeClass; import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test; import org.junit.Test;
import org.junit.experimental.categories.Category; import org.junit.experimental.categories.Category;
@ -84,7 +81,6 @@ public class TestRegionReplicaReplicationEndpoint {
@BeforeClass @BeforeClass
public static void beforeClass() throws Exception { public static void beforeClass() throws Exception {
/*
Configuration conf = HTU.getConfiguration(); Configuration conf = HTU.getConfiguration();
conf.setFloat("hbase.regionserver.logroll.multiplier", 0.0003f); conf.setFloat("hbase.regionserver.logroll.multiplier", 0.0003f);
conf.setInt("replication.source.size.capacity", 10240); conf.setInt("replication.source.size.capacity", 10240);
@ -98,20 +94,17 @@ public class TestRegionReplicaReplicationEndpoint {
conf.setLong(HConstants.THREAD_WAKE_FREQUENCY, 100); conf.setLong(HConstants.THREAD_WAKE_FREQUENCY, 100);
conf.setInt("replication.stats.thread.period.seconds", 5); conf.setInt("replication.stats.thread.period.seconds", 5);
conf.setBoolean("hbase.tests.use.shortcircuit.reads", false); conf.setBoolean("hbase.tests.use.shortcircuit.reads", false);
conf.setInt(HConstants.HBASE_CLIENT_RETRIES_NUMBER, 3); // less number of retries is needed conf.setInt(HConstants.HBASE_CLIENT_RETRIES_NUMBER, 5); // less number of retries is needed
conf.setInt("hbase.client.serverside.retries.multiplier", 1); conf.setInt("hbase.client.serverside.retries.multiplier", 1);
HTU.startMiniCluster(NB_SERVERS);*/ HTU.startMiniCluster(NB_SERVERS);
} }
@AfterClass @AfterClass
public static void afterClass() throws Exception { public static void afterClass() throws Exception {
/*
HTU.shutdownMiniCluster(); HTU.shutdownMiniCluster();
*/
} }
@Ignore("To be fixed before 1.0")
@Test @Test
public void testRegionReplicaReplicationPeerIsCreated() throws IOException, ReplicationException { public void testRegionReplicaReplicationPeerIsCreated() throws IOException, ReplicationException {
// create a table with region replicas. Check whether the replication peer is created // create a table with region replicas. Check whether the replication peer is created
@ -167,7 +160,7 @@ public class TestRegionReplicaReplicationEndpoint {
// load the data to the table // load the data to the table
HTU.loadNumericRows(table, HBaseTestingUtility.fam1, 0, 1000); HTU.loadNumericRows(table, HBaseTestingUtility.fam1, 0, 1000);
verifyReplication(tableName, regionReplication, 0, 6000); verifyReplication(tableName, regionReplication, 0, 1000);
} finally { } finally {
table.close(); table.close();
@ -197,7 +190,7 @@ public class TestRegionReplicaReplicationEndpoint {
for (int i = 1; i < regionReplication; i++) { for (int i = 1; i < regionReplication; i++) {
final HRegion region = regions[i]; final HRegion region = regions[i];
// wait until all the data is replicated to all secondary regions // wait until all the data is replicated to all secondary regions
Waiter.waitFor(HTU.getConfiguration(), 60000, new Waiter.Predicate<Exception>() { Waiter.waitFor(HTU.getConfiguration(), 90000, new Waiter.Predicate<Exception>() {
@Override @Override
public boolean evaluate() throws Exception { public boolean evaluate() throws Exception {
LOG.info("verifying replication for region replica:" + region.getRegionInfo()); LOG.info("verifying replication for region replica:" + region.getRegionInfo());
@ -215,26 +208,22 @@ public class TestRegionReplicaReplicationEndpoint {
} }
} }
@Ignore("To be fixed before 1.0") @Test(timeout = 240000)
@Test(timeout = 60000)
public void testRegionReplicaReplicationWith2Replicas() throws Exception { public void testRegionReplicaReplicationWith2Replicas() throws Exception {
testRegionReplicaReplication(2); testRegionReplicaReplication(2);
} }
@Ignore("To be fixed before 1.0") @Test(timeout = 240000)
@Test(timeout = 60000)
public void testRegionReplicaReplicationWith3Replicas() throws Exception { public void testRegionReplicaReplicationWith3Replicas() throws Exception {
testRegionReplicaReplication(3); testRegionReplicaReplication(3);
} }
@Ignore("To be fixed before 1.0") @Test(timeout = 240000)
@Test(timeout = 60000)
public void testRegionReplicaReplicationWith10Replicas() throws Exception { public void testRegionReplicaReplicationWith10Replicas() throws Exception {
testRegionReplicaReplication(10); testRegionReplicaReplication(10);
} }
@Ignore("To be fixed before 1.0") @Test (timeout = 240000)
@Test (timeout = 60000)
public void testRegionReplicaReplicationForFlushAndCompaction() throws Exception { public void testRegionReplicaReplicationForFlushAndCompaction() throws Exception {
// Tests a table with region replication 3. Writes some data, and causes flushes and // Tests a table with region replication 3. Writes some data, and causes flushes and
// compactions. Verifies that the data is readable from the replicas. Note that this // compactions. Verifies that the data is readable from the replicas. Note that this
@ -262,21 +251,19 @@ public class TestRegionReplicaReplicationEndpoint {
HTU.compact(tableName, false); HTU.compact(tableName, false);
} }
verifyReplication(tableName, regionReplication, 0, 6000); verifyReplication(tableName, regionReplication, 0, 1000);
} finally { } finally {
table.close(); table.close();
connection.close(); connection.close();
} }
} }
@Ignore("To be fixed before 1.0") @Test (timeout = 240000)
@Test (timeout = 60000)
public void testRegionReplicaReplicationIgnoresDisabledTables() throws Exception { public void testRegionReplicaReplicationIgnoresDisabledTables() throws Exception {
testRegionReplicaReplicationIgnoresDisabledTables(false); testRegionReplicaReplicationIgnoresDisabledTables(false);
} }
@Ignore("To be fixed before 1.0") @Test (timeout = 240000)
@Test (timeout = 60000)
public void testRegionReplicaReplicationIgnoresDroppedTables() throws Exception { public void testRegionReplicaReplicationIgnoresDroppedTables() throws Exception {
testRegionReplicaReplicationIgnoresDisabledTables(true); testRegionReplicaReplicationIgnoresDisabledTables(true);
} }
@ -305,7 +292,7 @@ public class TestRegionReplicaReplicationEndpoint {
// now that the replication is disabled, write to the table to be dropped, then drop the table. // now that the replication is disabled, write to the table to be dropped, then drop the table.
HConnection connection = HConnectionManager.createConnection(HTU.getConfiguration()); Connection connection = ConnectionFactory.createConnection(HTU.getConfiguration());
Table table = connection.getTable(tableName); Table table = connection.getTable(tableName);
Table tableToBeDisabled = connection.getTable(toBeDisabledTable); Table tableToBeDisabled = connection.getTable(toBeDisabledTable);
@ -318,9 +305,9 @@ public class TestRegionReplicaReplicationEndpoint {
RegionReplicaReplicationEndpoint.RegionReplicaSinkWriter sinkWriter = RegionReplicaReplicationEndpoint.RegionReplicaSinkWriter sinkWriter =
new RegionReplicaReplicationEndpoint.RegionReplicaSinkWriter(sink, new RegionReplicaReplicationEndpoint.RegionReplicaSinkWriter(sink,
(ClusterConnection) connection, (ClusterConnection) connection,
Executors.newSingleThreadExecutor(), 1000); Executors.newSingleThreadExecutor(), Integer.MAX_VALUE);
RegionLocator rl = connection.getRegionLocator(toBeDisabledTable);
HRegionLocation hrl = connection.locateRegion(toBeDisabledTable, HConstants.EMPTY_BYTE_ARRAY); HRegionLocation hrl = rl.getRegionLocation(HConstants.EMPTY_BYTE_ARRAY);
byte[] encodedRegionName = hrl.getRegionInfo().getEncodedNameAsBytes(); byte[] encodedRegionName = hrl.getRegionInfo().getEncodedNameAsBytes();
Entry entry = new Entry( Entry entry = new Entry(
@ -346,11 +333,12 @@ public class TestRegionReplicaReplicationEndpoint {
// now enable the replication // now enable the replication
admin.enablePeer(ServerRegionReplicaUtil.getReplicationPeerId()); admin.enablePeer(ServerRegionReplicaUtil.getReplicationPeerId());
verifyReplication(tableName, regionReplication, 0, 6000); verifyReplication(tableName, regionReplication, 0, 1000);
} finally { } finally {
admin.close(); admin.close();
table.close(); table.close();
rl.close();
tableToBeDisabled.close(); tableToBeDisabled.close();
HTU.deleteTableIfAny(toBeDisabledTable); HTU.deleteTableIfAny(toBeDisabledTable);
connection.close(); connection.close();