HBASE-15276 TestFlushSnapshotFromClient hung

This commit is contained in:
stack 2016-02-16 12:58:22 -08:00
parent e3aa71fb76
commit bb881eb80d
1 changed files with 19 additions and 24 deletions

View File

@ -34,6 +34,7 @@ import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path; import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hbase.CategoryBasedTimeout;
import org.apache.hadoop.hbase.HBaseTestingUtility; import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.HConstants; import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.HRegionInfo; import org.apache.hadoop.hbase.HRegionInfo;
@ -52,9 +53,10 @@ import org.junit.After;
import org.junit.AfterClass; import org.junit.AfterClass;
import org.junit.Before; import org.junit.Before;
import org.junit.BeforeClass; import org.junit.BeforeClass;
import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
import org.junit.Ignore;
import org.junit.experimental.categories.Category; import org.junit.experimental.categories.Category;
import org.junit.rules.TestRule;
/** /**
* Test creating/using/deleting snapshots from the client * Test creating/using/deleting snapshots from the client
@ -67,12 +69,15 @@ import org.junit.experimental.categories.Category;
@Category({RegionServerTests.class, LargeTests.class}) @Category({RegionServerTests.class, LargeTests.class})
public class TestFlushSnapshotFromClient { public class TestFlushSnapshotFromClient {
private static final Log LOG = LogFactory.getLog(TestFlushSnapshotFromClient.class); private static final Log LOG = LogFactory.getLog(TestFlushSnapshotFromClient.class);
@Rule public final TestRule timeout = CategoryBasedTimeout.builder().withTimeout(this.getClass()).
withLookingForStuckThread(true).build();
protected static final HBaseTestingUtility UTIL = new HBaseTestingUtility(); protected static final HBaseTestingUtility UTIL = new HBaseTestingUtility();
protected static final int NUM_RS = 2; protected static final int NUM_RS = 2;
protected static final byte[] TEST_FAM = Bytes.toBytes("fam"); protected static final byte[] TEST_FAM = Bytes.toBytes("fam");
protected static final TableName TABLE_NAME = TableName.valueOf("test"); protected static final TableName TABLE_NAME = TableName.valueOf("test");
protected final int DEFAULT_NUM_ROWS = 100; protected final int DEFAULT_NUM_ROWS = 100;
protected Admin admin = null;
@BeforeClass @BeforeClass
public static void setupCluster() throws Exception { public static void setupCluster() throws Exception {
@ -100,6 +105,7 @@ public class TestFlushSnapshotFromClient {
@Before @Before
public void setup() throws Exception { public void setup() throws Exception {
createTable(); createTable();
this.admin = UTIL.getConnection().getAdmin();
} }
protected void createTable() throws Exception { protected void createTable() throws Exception {
@ -109,8 +115,8 @@ public class TestFlushSnapshotFromClient {
@After @After
public void tearDown() throws Exception { public void tearDown() throws Exception {
UTIL.deleteTable(TABLE_NAME); UTIL.deleteTable(TABLE_NAME);
SnapshotTestingUtils.deleteAllSnapshots(this.admin);
SnapshotTestingUtils.deleteAllSnapshots(UTIL.getHBaseAdmin()); this.admin.close();
SnapshotTestingUtils.deleteArchiveDirectory(UTIL); SnapshotTestingUtils.deleteArchiveDirectory(UTIL);
} }
@ -127,9 +133,8 @@ public class TestFlushSnapshotFromClient {
* Test simple flush snapshotting a table that is online * Test simple flush snapshotting a table that is online
* @throws Exception * @throws Exception
*/ */
@Test (timeout=300000) @Test
public void testFlushTableSnapshot() throws Exception { public void testFlushTableSnapshot() throws Exception {
Admin admin = UTIL.getHBaseAdmin();
// make sure we don't fail on listing snapshots // make sure we don't fail on listing snapshots
SnapshotTestingUtils.assertNoSnapshots(admin); SnapshotTestingUtils.assertNoSnapshots(admin);
@ -160,9 +165,8 @@ public class TestFlushSnapshotFromClient {
* Test snapshotting a table that is online without flushing * Test snapshotting a table that is online without flushing
* @throws Exception * @throws Exception
*/ */
@Test(timeout=30000) @Test
public void testSkipFlushTableSnapshot() throws Exception { public void testSkipFlushTableSnapshot() throws Exception {
Admin admin = UTIL.getHBaseAdmin();
// make sure we don't fail on listing snapshots // make sure we don't fail on listing snapshots
SnapshotTestingUtils.assertNoSnapshots(admin); SnapshotTestingUtils.assertNoSnapshots(admin);
@ -200,9 +204,8 @@ public class TestFlushSnapshotFromClient {
* Test simple flush snapshotting a table that is online * Test simple flush snapshotting a table that is online
* @throws Exception * @throws Exception
*/ */
@Test (timeout=300000) @Test
public void testFlushTableSnapshotWithProcedure() throws Exception { public void testFlushTableSnapshotWithProcedure() throws Exception {
Admin admin = UTIL.getHBaseAdmin();
// make sure we don't fail on listing snapshots // make sure we don't fail on listing snapshots
SnapshotTestingUtils.assertNoSnapshots(admin); SnapshotTestingUtils.assertNoSnapshots(admin);
@ -234,9 +237,8 @@ public class TestFlushSnapshotFromClient {
SnapshotTestingUtils.confirmSnapshotValid(UTIL, snapshots.get(0), TABLE_NAME, TEST_FAM); SnapshotTestingUtils.confirmSnapshotValid(UTIL, snapshots.get(0), TABLE_NAME, TEST_FAM);
} }
@Test (timeout=300000) @Test
public void testSnapshotFailsOnNonExistantTable() throws Exception { public void testSnapshotFailsOnNonExistantTable() throws Exception {
Admin admin = UTIL.getHBaseAdmin();
// make sure we don't fail on listing snapshots // make sure we don't fail on listing snapshots
SnapshotTestingUtils.assertNoSnapshots(admin); SnapshotTestingUtils.assertNoSnapshots(admin);
TableName tableName = TableName.valueOf("_not_a_table"); TableName tableName = TableName.valueOf("_not_a_table");
@ -263,9 +265,8 @@ public class TestFlushSnapshotFromClient {
} }
} }
@Test(timeout = 300000) @Test
public void testAsyncFlushSnapshot() throws Exception { public void testAsyncFlushSnapshot() throws Exception {
Admin admin = UTIL.getHBaseAdmin();
SnapshotDescription snapshot = SnapshotDescription.newBuilder().setName("asyncSnapshot") SnapshotDescription snapshot = SnapshotDescription.newBuilder().setName("asyncSnapshot")
.setTable(TABLE_NAME.getNameAsString()) .setTable(TABLE_NAME.getNameAsString())
.setType(SnapshotDescription.Type.FLUSH) .setType(SnapshotDescription.Type.FLUSH)
@ -284,10 +285,9 @@ public class TestFlushSnapshotFromClient {
SnapshotTestingUtils.assertOneSnapshotThatMatches(admin, snapshot); SnapshotTestingUtils.assertOneSnapshotThatMatches(admin, snapshot);
} }
@Test (timeout=300000) @Test
public void testSnapshotStateAfterMerge() throws Exception { public void testSnapshotStateAfterMerge() throws Exception {
int numRows = DEFAULT_NUM_ROWS; int numRows = DEFAULT_NUM_ROWS;
Admin admin = UTIL.getHBaseAdmin();
// make sure we don't fail on listing snapshots // make sure we don't fail on listing snapshots
SnapshotTestingUtils.assertNoSnapshots(admin); SnapshotTestingUtils.assertNoSnapshots(admin);
// load the table so we have some data // load the table so we have some data
@ -335,10 +335,9 @@ public class TestFlushSnapshotFromClient {
UTIL.deleteTable(cloneBeforeMergeName); UTIL.deleteTable(cloneBeforeMergeName);
} }
@Test (timeout=300000) @Test
public void testTakeSnapshotAfterMerge() throws Exception { public void testTakeSnapshotAfterMerge() throws Exception {
int numRows = DEFAULT_NUM_ROWS; int numRows = DEFAULT_NUM_ROWS;
Admin admin = UTIL.getHBaseAdmin();
// make sure we don't fail on listing snapshots // make sure we don't fail on listing snapshots
SnapshotTestingUtils.assertNoSnapshots(admin); SnapshotTestingUtils.assertNoSnapshots(admin);
// load the table so we have some data // load the table so we have some data
@ -382,10 +381,9 @@ public class TestFlushSnapshotFromClient {
/** /**
* Basic end-to-end test of simple-flush-based snapshots * Basic end-to-end test of simple-flush-based snapshots
*/ */
@Test (timeout=300000) @Test
public void testFlushCreateListDestroy() throws Exception { public void testFlushCreateListDestroy() throws Exception {
LOG.debug("------- Starting Snapshot test -------------"); LOG.debug("------- Starting Snapshot test -------------");
Admin admin = UTIL.getHBaseAdmin();
// make sure we don't fail on listing snapshots // make sure we don't fail on listing snapshots
SnapshotTestingUtils.assertNoSnapshots(admin); SnapshotTestingUtils.assertNoSnapshots(admin);
// load the table so we have some data // load the table so we have some data
@ -403,12 +401,11 @@ public class TestFlushSnapshotFromClient {
* same table currently running and that concurrent snapshots on different tables can both * same table currently running and that concurrent snapshots on different tables can both
* succeed concurretly. * succeed concurretly.
*/ */
@Test(timeout=300000) @Test
public void testConcurrentSnapshottingAttempts() throws IOException, InterruptedException { public void testConcurrentSnapshottingAttempts() throws IOException, InterruptedException {
final TableName TABLE2_NAME = TableName.valueOf(TABLE_NAME + "2"); final TableName TABLE2_NAME = TableName.valueOf(TABLE_NAME + "2");
int ssNum = 20; int ssNum = 20;
Admin admin = UTIL.getHBaseAdmin();
// make sure we don't fail on listing snapshots // make sure we don't fail on listing snapshots
SnapshotTestingUtils.assertNoSnapshots(admin); SnapshotTestingUtils.assertNoSnapshots(admin);
// create second testing table // create second testing table
@ -428,7 +425,6 @@ public class TestFlushSnapshotFromClient {
@Override @Override
public void run() { public void run() {
try { try {
Admin admin = UTIL.getHBaseAdmin();
LOG.info("Submitting snapshot request: " + ClientSnapshotDescriptionUtils.toString(ss)); LOG.info("Submitting snapshot request: " + ClientSnapshotDescriptionUtils.toString(ss));
admin.takeSnapshotAsync(ss); admin.takeSnapshotAsync(ss);
} catch (Exception e) { } catch (Exception e) {
@ -505,7 +501,6 @@ public class TestFlushSnapshotFromClient {
private void waitRegionsAfterMerge(final long numRegionsAfterMerge) private void waitRegionsAfterMerge(final long numRegionsAfterMerge)
throws IOException, InterruptedException { throws IOException, InterruptedException {
Admin admin = UTIL.getHBaseAdmin();
// Verify that there's one region less // Verify that there's one region less
long startTime = System.currentTimeMillis(); long startTime = System.currentTimeMillis();
while (admin.getTableRegions(TABLE_NAME).size() != numRegionsAfterMerge) { while (admin.getTableRegions(TABLE_NAME).size() != numRegionsAfterMerge) {