diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestHCM.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestHCM.java index 4f1fa6b6bdf..41720be677d 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestHCM.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestHCM.java @@ -70,7 +70,7 @@ import org.apache.hadoop.hbase.master.HMaster; import org.apache.hadoop.hbase.regionserver.HRegionServer; import org.apache.hadoop.hbase.regionserver.Region; import org.apache.hadoop.hbase.regionserver.RegionServerStoppedException; -import org.apache.hadoop.hbase.testclassification.MediumTests; +import org.apache.hadoop.hbase.testclassification.LargeTests; import org.apache.hadoop.hbase.util.Bytes; import org.apache.hadoop.hbase.util.EnvironmentEdgeManager; import org.apache.hadoop.hbase.util.JVMClusterUtil; @@ -91,7 +91,7 @@ import com.google.common.collect.Lists; /** * This class is for testing HBaseConnectionManager features */ -@Category(MediumTests.class) +@Category({LargeTests.class}) public class TestHCM { @Rule public final TestRule timeout = CategoryBasedTimeout.builder() .withTimeout(this.getClass()) @@ -150,7 +150,7 @@ public class TestHCM { return HConnectionTestingUtility.getConnectionCount(); } - @Test (timeout=120000) + @Test public void testClusterConnection() throws IOException { ThreadPoolExecutor otherPool = new ThreadPoolExecutor(1, 1, 5, TimeUnit.SECONDS, @@ -213,7 +213,7 @@ public class TestHCM { * Naive test to check that HConnection#getAdmin returns a properly constructed HBaseAdmin object * @throws IOException Unable to construct admin */ - @Test (timeout=120000) + @Test public void testAdminFactory() throws IOException { Connection con1 = ConnectionFactory.createConnection(TEST_UTIL.getConfiguration()); Admin admin = con1.getAdmin(); @@ -285,12 +285,12 @@ public class TestHCM { * Test that we can handle connection close: it will trigger a retry, but the calls will * finish. */ - @Test (timeout=120000) + @Test public void testConnectionCloseAllowsInterrupt() throws Exception { testConnectionClose(true); } - @Test (timeout=120000) + @Test public void testConnectionNotAllowsInterrupt() throws Exception { testConnectionClose(false); } @@ -303,7 +303,7 @@ public class TestHCM { * succeeds. But the client won't wait that much, because 20 + 20 > 30, so the client * timeouted when the server answers. */ - @Test (timeout=120000) + @Test public void testOperationTimeout() throws Exception { HTableDescriptor hdt = TEST_UTIL.createTableDescriptor("HCM-testOperationTimeout"); hdt.addCoprocessor(SleepAndFailFirstTime.class.getName()); @@ -412,7 +412,7 @@ public class TestHCM { /** * Test that connection can become idle without breaking everything. */ - @Test (timeout=120000) + @Test public void testConnectionIdle() throws Exception { TableName tableName = TableName.valueOf("HCM-testConnectionIdle"); TEST_UTIL.createTable(tableName, FAM_NAM).close(); @@ -470,7 +470,7 @@ public class TestHCM { * notification. * @throws Exception */ - @Test (timeout=120000) + @Test public void testConnectionCut() throws Exception { TableName tableName = TableName.valueOf("HCM-testConnectionCut"); @@ -584,7 +584,7 @@ public class TestHCM { * that we really delete it. * @throws Exception */ - @Test (timeout=120000) + @Test public void testRegionCaching() throws Exception{ TEST_UTIL.createMultiRegionTable(TABLE_NAME, FAM_NAM).close(); Configuration conf = new Configuration(TEST_UTIL.getConfiguration()); @@ -770,7 +770,7 @@ public class TestHCM { * Test that Connection or Pool are not closed when managed externally * @throws Exception */ - @Test (timeout=120000) + @Test public void testConnectionManagement() throws Exception{ Table table0 = TEST_UTIL.createTable(TABLE_NAME1, FAM_NAM); Connection conn = ConnectionFactory.createConnection(TEST_UTIL.getConfiguration()); @@ -789,7 +789,7 @@ public class TestHCM { /** * Test that stale cache updates don't override newer cached values. */ - @Test(timeout = 60000) + @Test public void testCacheSeqNums() throws Exception{ HTable table = TEST_UTIL.createMultiRegionTable(TABLE_NAME2, FAM_NAM); Put put = new Put(ROW); @@ -837,7 +837,7 @@ public class TestHCM { * Make sure that {@link Configuration} instances that are essentially the * same map to the same {@link HConnection} instance. */ - @Test (timeout=120000) + @Test public void testConnectionSameness() throws Exception { Connection previousConnection = null; for (int i = 0; i < 2; i++) { @@ -869,7 +869,7 @@ public class TestHCM { * @deprecated Tests deprecated functionality. Remove in 1.0. */ @Deprecated - @Test (timeout=120000) + @Test public void testConnectionUniqueness() throws Exception { int zkmaxconnections = TEST_UTIL.getConfiguration(). getInt(HConstants.ZOOKEEPER_MAX_CLIENT_CNXNS, @@ -915,7 +915,7 @@ public class TestHCM { } } - @Test (timeout=120000) + @Test public void testClosing() throws Exception { Configuration configuration = new Configuration(TEST_UTIL.getConfiguration()); @@ -955,7 +955,7 @@ public class TestHCM { * Trivial test to verify that nobody messes with * {@link HConnectionManager#createConnection(Configuration)} */ - @Test (timeout=120000) + @Test public void testCreateConnection() throws Exception { Configuration configuration = TEST_UTIL.getConfiguration(); Connection c1 = ConnectionFactory.createConnection(configuration); @@ -975,7 +975,7 @@ public class TestHCM { * ZooKeeper quorum set. Other stuff like master address will be read * from ZK by the client. */ - @Test(timeout = 60000) + @Test public void testConnection() throws Exception{ // We create an empty config and add the ZK address. Configuration c = new Configuration(); @@ -1002,7 +1002,7 @@ public class TestHCM { return prevNumRetriesVal; } - @Test (timeout=30000) + @Test public void testMulti() throws Exception { HTable table = TEST_UTIL.createMultiRegionTable(TABLE_NAME3, FAM_NAM); try { @@ -1261,7 +1261,7 @@ public class TestHCM { pool.shutdownNow(); } - @Test(timeout = 60000) + @Test public void testConnectionRideOverClusterRestart() throws IOException, InterruptedException { Configuration config = new Configuration(TEST_UTIL.getConfiguration()); @@ -1284,4 +1284,3 @@ public class TestHCM { connection.close(); } } - diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestMetaWithReplicas.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestMetaWithReplicas.java index 1b9acac47cb..493013c87e7 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestMetaWithReplicas.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestMetaWithReplicas.java @@ -18,7 +18,10 @@ */ package org.apache.hadoop.hbase.client; -import javax.annotation.Nullable; +import static org.apache.hadoop.hbase.util.hbck.HbckTestingUtil.assertErrors; +import static org.apache.hadoop.hbase.util.hbck.HbckTestingUtil.doFsck; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; import java.io.IOException; import static org.apache.hadoop.hbase.util.hbck.HbckTestingUtil.assertErrors; @@ -30,10 +33,13 @@ import java.util.Collection; import java.util.List; import java.util.concurrent.ExecutorService; +import javax.annotation.Nullable; + import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hbase.Abortable; +import org.apache.hadoop.hbase.CategoryBasedTimeout; import org.apache.hadoop.hbase.HBaseTestingUtility; import org.apache.hadoop.hbase.HConstants; import org.apache.hadoop.hbase.HRegionInfo; @@ -46,7 +52,7 @@ import org.apache.hadoop.hbase.TableNotFoundException; import org.apache.hadoop.hbase.Waiter; import org.apache.hadoop.hbase.client.ConnectionManager.HConnectionImplementation; import org.apache.hadoop.hbase.regionserver.StorefileRefresherChore; -import org.apache.hadoop.hbase.testclassification.MediumTests; +import org.apache.hadoop.hbase.testclassification.LargeTests; import org.apache.hadoop.hbase.util.Bytes; import org.apache.hadoop.hbase.util.HBaseFsck; import org.apache.hadoop.hbase.util.HBaseFsckRepair; @@ -57,14 +63,20 @@ import org.apache.hadoop.hbase.zookeeper.ZKUtil; import org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher; import org.junit.After; import org.junit.Before; +import org.junit.Rule; import org.junit.Test; import org.junit.experimental.categories.Category; +import org.junit.rules.TestRule; /** * Tests the scenarios where replicas are enabled for the meta table */ -@Category(MediumTests.class) +@Category(LargeTests.class) public class TestMetaWithReplicas { + @Rule public final TestRule timeout = CategoryBasedTimeout.builder(). + withTimeout(this.getClass()). + withLookingForStuckThread(true). + build(); private static final Log LOG = LogFactory.getLog(TestMetaWithReplicas.class); private final HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility(); diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestRestoreSnapshotFromClient.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestRestoreSnapshotFromClient.java index 6f581920b1d..4837f81268a 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestRestoreSnapshotFromClient.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestRestoreSnapshotFromClient.java @@ -25,15 +25,15 @@ import java.io.IOException; import java.util.HashSet; import java.util.Set; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; +import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.Path; -import org.apache.hadoop.hbase.TableName; +import org.apache.hadoop.hbase.CategoryBasedTimeout; import org.apache.hadoop.hbase.HBaseTestingUtility; import org.apache.hadoop.hbase.HColumnDescriptor; import org.apache.hadoop.hbase.HConstants; import org.apache.hadoop.hbase.HTableDescriptor; import org.apache.hadoop.hbase.testclassification.LargeTests; +import org.apache.hadoop.hbase.TableName; import org.apache.hadoop.hbase.master.MasterFileSystem; import org.apache.hadoop.hbase.master.snapshot.SnapshotManager; import org.apache.hadoop.hbase.regionserver.NoSuchColumnFamilyException; @@ -45,15 +45,20 @@ import org.junit.After; import org.junit.AfterClass; import org.junit.Before; import org.junit.BeforeClass; +import org.junit.Rule; import org.junit.Test; import org.junit.experimental.categories.Category; +import org.junit.rules.TestRule; /** * Test restore snapshots from the client */ @Category(LargeTests.class) public class TestRestoreSnapshotFromClient { - private static final Log LOG = LogFactory.getLog(TestRestoreSnapshotFromClient.class); + @Rule public final TestRule timeout = CategoryBasedTimeout.builder() + .withTimeout(this.getClass()) + .withLookingForStuckThread(true) + .build(); private final static HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility();