HBASE-15566 Add timeouts on TestMobFlushSnapshotFromClient and TestRegionMergeTransactionOnCluster

This commit is contained in:
stack 2016-03-30 13:23:20 -07:00
parent a71ce6e738
commit 21301a8a95
2 changed files with 21 additions and 23 deletions

View File

@ -18,14 +18,18 @@
package org.apache.hadoop.hbase.master.procedure; package org.apache.hadoop.hbase.master.procedure;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.io.IOException; import java.io.IOException;
import java.util.concurrent.CountDownLatch; import java.util.concurrent.CountDownLatch;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; 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.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.HRegionInfo; import org.apache.hadoop.hbase.HRegionInfo;
import org.apache.hadoop.hbase.HTableDescriptor; import org.apache.hadoop.hbase.HTableDescriptor;
@ -43,24 +47,24 @@ import org.apache.hadoop.hbase.protobuf.generated.MasterProcedureProtos.DeleteTa
import org.apache.hadoop.hbase.protobuf.generated.MasterProcedureProtos.DisableTableState; import org.apache.hadoop.hbase.protobuf.generated.MasterProcedureProtos.DisableTableState;
import org.apache.hadoop.hbase.protobuf.generated.MasterProcedureProtos.EnableTableState; import org.apache.hadoop.hbase.protobuf.generated.MasterProcedureProtos.EnableTableState;
import org.apache.hadoop.hbase.protobuf.generated.MasterProcedureProtos.TruncateTableState; import org.apache.hadoop.hbase.protobuf.generated.MasterProcedureProtos.TruncateTableState;
import org.apache.hadoop.hbase.testclassification.MasterTests;
import org.apache.hadoop.hbase.testclassification.LargeTests; import org.apache.hadoop.hbase.testclassification.LargeTests;
import org.apache.hadoop.hbase.testclassification.MasterTests;
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.ModifyRegionUtils; import org.apache.hadoop.hbase.util.ModifyRegionUtils;
import org.junit.After; import org.junit.After;
import org.junit.Before; import org.junit.Before;
import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
import org.junit.experimental.categories.Category; import org.junit.experimental.categories.Category;
import org.junit.rules.TestRule;
import org.mockito.Mockito; import org.mockito.Mockito;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
@Category({MasterTests.class, LargeTests.class}) @Category({MasterTests.class, LargeTests.class})
public class TestMasterFailoverWithProcedures { public class TestMasterFailoverWithProcedures {
private static final Log LOG = LogFactory.getLog(TestMasterFailoverWithProcedures.class); private static final Log LOG = LogFactory.getLog(TestMasterFailoverWithProcedures.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();
@ -91,7 +95,7 @@ public class TestMasterFailoverWithProcedures {
} }
} }
@Test(timeout=60000) @Test
public void testWalRecoverLease() throws Exception { public void testWalRecoverLease() throws Exception {
final ProcedureStore masterStore = getMasterProcedureExecutor().getStore(); final ProcedureStore masterStore = getMasterProcedureExecutor().getStore();
assertTrue("expected WALStore for this test", masterStore instanceof WALProcedureStore); assertTrue("expected WALStore for this test", masterStore instanceof WALProcedureStore);
@ -232,7 +236,7 @@ public class TestMasterFailoverWithProcedures {
// ========================================================================== // ==========================================================================
// Test Create Table // Test Create Table
// ========================================================================== // ==========================================================================
@Test(timeout=60000) @Test
public void testCreateWithFailover() throws Exception { public void testCreateWithFailover() throws Exception {
// TODO: Should we try every step? (master failover takes long time) // TODO: Should we try every step? (master failover takes long time)
// It is already covered by TestCreateTableProcedure // It is already covered by TestCreateTableProcedure
@ -265,7 +269,7 @@ public class TestMasterFailoverWithProcedures {
// ========================================================================== // ==========================================================================
// Test Delete Table // Test Delete Table
// ========================================================================== // ==========================================================================
@Test(timeout=60000) @Test
public void testDeleteWithFailover() throws Exception { public void testDeleteWithFailover() throws Exception {
// TODO: Should we try every step? (master failover takes long time) // TODO: Should we try every step? (master failover takes long time)
// It is already covered by TestDeleteTableProcedure // It is already covered by TestDeleteTableProcedure
@ -303,7 +307,7 @@ public class TestMasterFailoverWithProcedures {
// ========================================================================== // ==========================================================================
// Test Truncate Table // Test Truncate Table
// ========================================================================== // ==========================================================================
@Test(timeout=90000) @Test
public void testTruncateWithFailover() throws Exception { public void testTruncateWithFailover() throws Exception {
// TODO: Should we try every step? (master failover takes long time) // TODO: Should we try every step? (master failover takes long time)
// It is already covered by TestTruncateTableProcedure // It is already covered by TestTruncateTableProcedure
@ -364,7 +368,7 @@ public class TestMasterFailoverWithProcedures {
// ========================================================================== // ==========================================================================
// Test Disable Table // Test Disable Table
// ========================================================================== // ==========================================================================
@Test(timeout=60000) @Test
public void testDisableTableWithFailover() throws Exception { public void testDisableTableWithFailover() throws Exception {
// TODO: Should we try every step? (master failover takes long time) // TODO: Should we try every step? (master failover takes long time)
// It is already covered by TestDisableTableProcedure // It is already covered by TestDisableTableProcedure
@ -400,7 +404,7 @@ public class TestMasterFailoverWithProcedures {
// ========================================================================== // ==========================================================================
// Test Enable Table // Test Enable Table
// ========================================================================== // ==========================================================================
@Test(timeout=60000) @Test
public void testEnableTableWithFailover() throws Exception { public void testEnableTableWithFailover() throws Exception {
// TODO: Should we try every step? (master failover takes long time) // TODO: Should we try every step? (master failover takes long time)
// It is already covered by TestEnableTableProcedure // It is already covered by TestEnableTableProcedure
@ -492,23 +496,12 @@ public class TestMasterFailoverWithProcedures {
// ========================================================================== // ==========================================================================
// Helpers // Helpers
// ========================================================================== // ==========================================================================
private MasterProcedureEnv getMasterProcedureEnv() {
return getMasterProcedureExecutor().getEnvironment();
}
private ProcedureExecutor<MasterProcedureEnv> getMasterProcedureExecutor() { private ProcedureExecutor<MasterProcedureEnv> getMasterProcedureExecutor() {
return UTIL.getHBaseCluster().getMaster().getMasterProcedureExecutor(); return UTIL.getHBaseCluster().getMaster().getMasterProcedureExecutor();
} }
private FileSystem getFileSystem() {
return UTIL.getHBaseCluster().getMaster().getMasterFileSystem().getFileSystem();
}
private Path getRootDir() { private Path getRootDir() {
return UTIL.getHBaseCluster().getMaster().getMasterFileSystem().getRootDir(); return UTIL.getHBaseCluster().getMaster().getMasterFileSystem().getRootDir();
} }
private Path getTempDir() {
return UTIL.getHBaseCluster().getMaster().getMasterFileSystem().getTempDir();
}
} }

View File

@ -22,6 +22,7 @@ import java.io.IOException;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.CategoryBasedTimeout;
import org.apache.hadoop.hbase.HBaseTestingUtility; import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.TableName; import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.Table; import org.apache.hadoop.hbase.client.Table;
@ -29,7 +30,9 @@ import org.apache.hadoop.hbase.mob.MobConstants;
import org.apache.hadoop.hbase.testclassification.ClientTests; import org.apache.hadoop.hbase.testclassification.ClientTests;
import org.apache.hadoop.hbase.testclassification.LargeTests; import org.apache.hadoop.hbase.testclassification.LargeTests;
import org.junit.BeforeClass; import org.junit.BeforeClass;
import org.junit.Rule;
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
@ -42,6 +45,8 @@ import org.junit.experimental.categories.Category;
@Category({ClientTests.class, LargeTests.class}) @Category({ClientTests.class, LargeTests.class})
public class TestMobFlushSnapshotFromClient extends TestFlushSnapshotFromClient { public class TestMobFlushSnapshotFromClient extends 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();
@BeforeClass @BeforeClass
public static void setupCluster() throws Exception { public static void setupCluster() throws Exception {