HBASE-22297 Fix TestRegionMergeTransitionOnCluster and TestSplitTransactionOnCluster

Signed-off-by: Michael Stack <stack@apache.org>
This commit is contained in:
zhangduo 2019-04-23 22:22:39 +08:00
parent 127bef4d10
commit c8391809fc
2 changed files with 11 additions and 11 deletions

View File

@ -26,7 +26,6 @@ import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicBoolean;
import org.apache.commons.lang3.RandomUtils; import org.apache.commons.lang3.RandomUtils;
import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.conf.Configuration;
@ -63,6 +62,7 @@ import org.apache.hadoop.hbase.testclassification.LargeTests;
import org.apache.hadoop.hbase.testclassification.RegionServerTests; import org.apache.hadoop.hbase.testclassification.RegionServerTests;
import org.apache.hadoop.hbase.util.Bytes; import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.hbase.util.FSUtils; import org.apache.hadoop.hbase.util.FSUtils;
import org.apache.hadoop.hbase.util.FutureUtils;
import org.apache.hadoop.hbase.util.JVMClusterUtil.RegionServerThread; import org.apache.hadoop.hbase.util.JVMClusterUtil.RegionServerThread;
import org.apache.hadoop.hbase.util.Pair; import org.apache.hadoop.hbase.util.Pair;
import org.apache.hadoop.hbase.util.PairOfSameType; import org.apache.hadoop.hbase.util.PairOfSameType;
@ -312,7 +312,6 @@ public class TestRegionMergeTransactionOnCluster {
LOG.info("Starting " + name.getMethodName()); LOG.info("Starting " + name.getMethodName());
final TableName tableName = TableName.valueOf(name.getMethodName()); final TableName tableName = TableName.valueOf(name.getMethodName());
final Admin admin = TEST_UTIL.getAdmin(); final Admin admin = TEST_UTIL.getAdmin();
final int syncWaitTimeout = 10 * 60000; // 10min
try { try {
// Create table and load data. // Create table and load data.
@ -326,8 +325,8 @@ public class TestRegionMergeTransactionOnCluster {
am.offlineRegion(b); am.offlineRegion(b);
try { try {
// Merge offline region. Region a is offline here // Merge offline region. Region a is offline here
admin.mergeRegionsAsync(a.getEncodedNameAsBytes(), b.getEncodedNameAsBytes(), false) FutureUtils.get(
.get(syncWaitTimeout, TimeUnit.MILLISECONDS); admin.mergeRegionsAsync(a.getEncodedNameAsBytes(), b.getEncodedNameAsBytes(), false));
fail("Offline regions should not be able to merge"); fail("Offline regions should not be able to merge");
} catch (DoNotRetryRegionException ie) { } catch (DoNotRetryRegionException ie) {
System.out.println(ie); System.out.println(ie);
@ -336,21 +335,21 @@ public class TestRegionMergeTransactionOnCluster {
try { try {
// Merge the same region: b and b. // Merge the same region: b and b.
admin.mergeRegionsAsync(b.getEncodedNameAsBytes(), b.getEncodedNameAsBytes(), true); FutureUtils
.get(admin.mergeRegionsAsync(b.getEncodedNameAsBytes(), b.getEncodedNameAsBytes(), true));
fail("A region should not be able to merge with itself, even forcifully"); fail("A region should not be able to merge with itself, even forcifully");
} catch (IOException ie) { } catch (IOException ie) {
assertTrue("Exception should mention regions not online", assertTrue("Exception should mention regions not online",
StringUtils.stringifyException(ie).contains("region to itself") StringUtils.stringifyException(ie).contains("region to itself") &&
&& ie instanceof MergeRegionException); ie instanceof MergeRegionException);
} }
try { try {
// Merge unknown regions // Merge unknown regions
admin.mergeRegionsAsync(Bytes.toBytes("-f1"), Bytes.toBytes("-f2"), true); FutureUtils.get(admin.mergeRegionsAsync(Bytes.toBytes("-f1"), Bytes.toBytes("-f2"), true));
fail("Unknown region could not be merged"); fail("Unknown region could not be merged");
} catch (IOException ie) { } catch (IOException ie) {
assertTrue("UnknownRegionException should be thrown", assertTrue("UnknownRegionException should be thrown", ie instanceof UnknownRegionException);
ie instanceof UnknownRegionException);
} }
table.close(); table.close();
} finally { } finally {

View File

@ -90,6 +90,7 @@ import org.apache.hadoop.hbase.testclassification.RegionServerTests;
import org.apache.hadoop.hbase.util.Bytes; import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.hbase.util.EnvironmentEdgeManager; import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
import org.apache.hadoop.hbase.util.FSUtils; import org.apache.hadoop.hbase.util.FSUtils;
import org.apache.hadoop.hbase.util.FutureUtils;
import org.apache.hadoop.hbase.util.HBaseFsck; import org.apache.hadoop.hbase.util.HBaseFsck;
import org.apache.hadoop.hbase.util.JVMClusterUtil.RegionServerThread; import org.apache.hadoop.hbase.util.JVMClusterUtil.RegionServerThread;
import org.apache.hadoop.hbase.util.Threads; import org.apache.hadoop.hbase.util.Threads;
@ -328,7 +329,7 @@ public class TestSplitTransactionOnCluster {
// We don't roll back here anymore. Instead we fail-fast on construction of the // We don't roll back here anymore. Instead we fail-fast on construction of the
// split transaction. Catch the exception instead. // split transaction. Catch the exception instead.
try { try {
this.admin.splitRegionAsync(hri.getRegionName()); FutureUtils.get(this.admin.splitRegionAsync(hri.getRegionName()));
fail(); fail();
} catch (DoNotRetryRegionException e) { } catch (DoNotRetryRegionException e) {
// Expected // Expected