From ca00cbeed21c639622b86967d82a70338689b347 Mon Sep 17 00:00:00 2001 From: Guanghao Date: Wed, 29 May 2019 14:09:16 +0800 Subject: [PATCH] HBASE-22488 Cleanup the explicit timeout value for test methods --- .../hadoop/hbase/http/log/TestLogLevel.java | 14 ++++----- .../TestSnapshotTemporaryDirectory.java | 29 ++++++++++++------- .../coprocessor/TestMetaTableMetrics.java | 2 +- ...estMasterHandlerFullWhenTransitRegion.java | 2 +- .../master/TestMasterMetricsWrapper.java | 2 +- .../hbase/master/TestMasterNoCluster.java | 4 +-- .../hbase/master/cleaner/TestLogsCleaner.java | 4 +-- .../hadoop/hbase/quotas/TestQuotaState.java | 2 +- .../hbase/regionserver/TestWALLockup.java | 2 +- .../throttle/TestStoreHotnessProtector.java | 2 +- .../security/access/TestAccessController.java | 4 +-- 11 files changed, 38 insertions(+), 29 deletions(-) diff --git a/hbase-http/src/test/java/org/apache/hadoop/hbase/http/log/TestLogLevel.java b/hbase-http/src/test/java/org/apache/hadoop/hbase/http/log/TestLogLevel.java index 1cfe23ed8dcb..5b86f9125653 100644 --- a/hbase-http/src/test/java/org/apache/hadoop/hbase/http/log/TestLogLevel.java +++ b/hbase-http/src/test/java/org/apache/hadoop/hbase/http/log/TestLogLevel.java @@ -185,7 +185,7 @@ public static void tearDown() { * Test client command line options. Does not validate server behavior. * @throws Exception if commands return unexpected results. */ - @Test(timeout=120000) + @Test public void testCommandOptions() throws Exception { final String className = this.getClass().getName(); @@ -379,7 +379,7 @@ private void setLevel(String protocol, String authority, String newLevel) * * @throws Exception if client can't set log level to INFO. */ - @Test(timeout=60000) + @Test public void testInfoLogLevel() throws Exception { testDynamicLogLevel(LogLevel.PROTOCOL_HTTP, LogLevel.PROTOCOL_HTTP, true, "INFO"); } @@ -389,7 +389,7 @@ public void testInfoLogLevel() throws Exception { * * @throws Exception if client can't set log level to ERROR. */ - @Test(timeout=60000) + @Test public void testErrorLogLevel() throws Exception { testDynamicLogLevel(LogLevel.PROTOCOL_HTTP, LogLevel.PROTOCOL_HTTP, true, "ERROR"); } @@ -400,7 +400,7 @@ public void testErrorLogLevel() throws Exception { * @throws Exception if http client can't access http server, * or http client can access https server. */ - @Test(timeout=60000) + @Test public void testLogLevelByHttp() throws Exception { testDynamicLogLevel(LogLevel.PROTOCOL_HTTP, LogLevel.PROTOCOL_HTTP, false); try { @@ -419,7 +419,7 @@ public void testLogLevelByHttp() throws Exception { * @throws Exception if http client can't access http server, * or http client can access https server. */ - @Test(timeout=60000) + @Test public void testLogLevelByHttpWithSpnego() throws Exception { testDynamicLogLevel(LogLevel.PROTOCOL_HTTP, LogLevel.PROTOCOL_HTTP, true); try { @@ -438,7 +438,7 @@ public void testLogLevelByHttpWithSpnego() throws Exception { * @throws Exception if https client can't access https server, * or https client can access http server. */ - @Test(timeout=60000) + @Test public void testLogLevelByHttps() throws Exception { testDynamicLogLevel(LogLevel.PROTOCOL_HTTPS, LogLevel.PROTOCOL_HTTPS, false); @@ -459,7 +459,7 @@ public void testLogLevelByHttps() throws Exception { * @throws Exception if https client can't access https server, * or https client can access http server. */ - @Test(timeout=60000) + @Test public void testLogLevelByHttpsWithSpnego() throws Exception { testDynamicLogLevel(LogLevel.PROTOCOL_HTTPS, LogLevel.PROTOCOL_HTTPS, true); diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestSnapshotTemporaryDirectory.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestSnapshotTemporaryDirectory.java index a8561d0aecae..b1def754f0b6 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestSnapshotTemporaryDirectory.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestSnapshotTemporaryDirectory.java @@ -100,7 +100,8 @@ public class TestSnapshotTemporaryDirectory { * * @throws Exception on failure */ - @BeforeClass public static void setupCluster() throws Exception { + @BeforeClass + public static void setupCluster() throws Exception { setupConf(UTIL.getConfiguration()); UTIL.startMiniCluster(NUM_RS); admin = UTIL.getHBaseAdmin(); @@ -124,7 +125,8 @@ private static void setupConf(Configuration conf) { conf.set(SnapshotDescriptionUtils.SNAPSHOT_WORKING_DIR, "file://" + new Path(TEMP_DIR, ".tmpDir").toUri()); } - @Before public void setup() throws Exception { + @Before + public void setup() throws Exception { HTableDescriptor htd = new HTableDescriptor(TABLE_NAME); htd.setRegionReplication(getNumReplicas()); UTIL.createTable(htd, new byte[][] { TEST_FAM }, UTIL.getConfiguration()); @@ -134,13 +136,15 @@ protected int getNumReplicas() { return 1; } - @After public void tearDown() throws Exception { + @After + public void tearDown() throws Exception { UTIL.deleteTable(TABLE_NAME); SnapshotTestingUtils.deleteAllSnapshots(UTIL.getHBaseAdmin()); SnapshotTestingUtils.deleteArchiveDirectory(UTIL); } - @AfterClass public static void cleanupTest() { + @AfterClass + public static void cleanupTest() { try { UTIL.shutdownMiniCluster(); FileUtils.deleteDirectory(new File(TEMP_DIR)); @@ -149,7 +153,8 @@ protected int getNumReplicas() { } } - @Test(timeout = 180000) public void testRestoreDisabledSnapshot() + @Test + public void testRestoreDisabledSnapshot() throws IOException, InterruptedException { long tid = System.currentTimeMillis(); TableName tableName = TableName.valueOf("testtb-" + tid); @@ -215,7 +220,8 @@ protected int getNumReplicas() { SnapshotTestingUtils.verifyReplicasCameOnline(tableName, admin, getNumReplicas()); } - @Test(timeout = 180000) public void testRestoreEnabledSnapshot() + @Test + public void testRestoreEnabledSnapshot() throws IOException, InterruptedException { long tid = System.currentTimeMillis(); TableName tableName = TableName.valueOf("testtb-" + tid); @@ -282,7 +288,8 @@ protected int getNumReplicas() { * * @throws Exception if snapshot does not complete successfully */ - @Test(timeout = 300000) public void testOfflineTableSnapshot() throws Exception { + @Test + public void testOfflineTableSnapshot() throws Exception { Admin admin = UTIL.getHBaseAdmin(); // make sure we don't fail on listing snapshots SnapshotTestingUtils.assertNoSnapshots(admin); @@ -336,7 +343,8 @@ protected int getNumReplicas() { * * @throws Exception if snapshot does not complete successfully */ - @Test(timeout = 180000) public void testSnapshotCloneContents() throws Exception { + @Test + public void testSnapshotCloneContents() throws Exception { // make sure we don't fail on listing snapshots SnapshotTestingUtils.assertNoSnapshots(admin); @@ -372,7 +380,8 @@ protected int getNumReplicas() { admin.close(); } - @Test(timeout = 180000) public void testOfflineTableSnapshotWithEmptyRegion() throws Exception { + @Test + public void testOfflineTableSnapshotWithEmptyRegion() throws Exception { // test with an empty table with one region // make sure we don't fail on listing snapshots @@ -417,7 +426,7 @@ protected int getNumReplicas() { } // Ensures that the snapshot is transferred to the proper completed snapshot directory - @Test(timeout = 180000) + @Test public void testEnsureTemporaryDirectoryTransfer() throws Exception { Admin admin = UTIL.getAdmin(); TableName tableName2 = TableName.valueOf("testListTableSnapshots"); diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestMetaTableMetrics.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestMetaTableMetrics.java index 82ce709bd365..16db86db89dd 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestMetaTableMetrics.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestMetaTableMetrics.java @@ -232,7 +232,7 @@ public void test() throws IOException, InterruptedException { assertEquals(5L, putWithClientMetricsCount); } - @Test(timeout = 30000) + @Test public void testConcurrentAccess() { try { tablename = Bytes.toBytes("hbase:meta"); diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterHandlerFullWhenTransitRegion.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterHandlerFullWhenTransitRegion.java index e136cdd286ff..e41054e98b4e 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterHandlerFullWhenTransitRegion.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterHandlerFullWhenTransitRegion.java @@ -63,7 +63,7 @@ public static void setUp() throws Exception { UTIL.createTable(TableName.valueOf(TABLENAME), "fa"); } - @Test(timeout = 30000) + @Test public void test() throws Exception { RegionInfo regionInfo = UTIL.getAdmin().getRegions(TableName.valueOf(TABLENAME)).get(0); //See HBASE-21754 diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterMetricsWrapper.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterMetricsWrapper.java index 1f0323e7c9fd..c11386a6c944 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterMetricsWrapper.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterMetricsWrapper.java @@ -116,7 +116,7 @@ public void testQuotaSnapshotConversion() { /** * tests online and offline region number */ - @Test (timeout=30000) + @Test public void testOfflineRegion() throws Exception { HMaster master = TEST_UTIL.getHBaseCluster().getMaster(); MetricsMasterWrapperImpl info = new MetricsMasterWrapperImpl(master); diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterNoCluster.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterNoCluster.java index e73ba753759a..74d05482d1ea 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterNoCluster.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterNoCluster.java @@ -309,7 +309,7 @@ public ClusterConnection getConnection() { } } - @Test(timeout = 60000) + @Test public void testMasterInitWithSameClientServerZKQuorum() throws Exception { Configuration conf = new Configuration(TESTUTIL.getConfiguration()); conf.set(HConstants.CLIENT_ZOOKEEPER_QUORUM, HConstants.LOCALHOST); @@ -320,7 +320,7 @@ public void testMasterInitWithSameClientServerZKQuorum() throws Exception { master.join(); } - @Test(timeout = 60000) + @Test public void testMasterInitWithObserverModeClientZKQuorum() throws Exception { Configuration conf = new Configuration(TESTUTIL.getConfiguration()); Assert.assertFalse(Boolean.getBoolean(HConstants.CLIENT_ZOOKEEPER_OBSERVER_MODE)); diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/cleaner/TestLogsCleaner.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/cleaner/TestLogsCleaner.java index 4d254a03bddc..b02704b14e22 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/cleaner/TestLogsCleaner.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/cleaner/TestLogsCleaner.java @@ -223,7 +223,7 @@ public void testLogCleaning() throws Exception { } } - @Test(timeout=10000) + @Test public void testZooKeeperAbortDuringGetListOfReplicators() throws Exception { ReplicationLogCleaner cleaner = new ReplicationLogCleaner(); @@ -270,7 +270,7 @@ public Object answer(InvocationOnMock invocation) throws Throwable { * When zk is working both files should be returned * @throws Exception from ZK watcher */ - @Test(timeout=10000) + @Test public void testZooKeeperNormal() throws Exception { ReplicationLogCleaner cleaner = new ReplicationLogCleaner(); diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestQuotaState.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestQuotaState.java index 73b253c9b0ff..4c359f0d1bc8 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestQuotaState.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestQuotaState.java @@ -203,7 +203,7 @@ public void testQuotaStateUpdateTableThrottle() { assertNoopLimiter(quotaInfo.getTableLimiter(UNKNOWN_TABLE_NAME)); } - @Test(timeout = 60000) + @Test public void testTableThrottleWithBatch() { final TableName TABLE_A = TableName.valueOf("TableA"); final int TABLE_A_THROTTLE_1 = 3; diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestWALLockup.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestWALLockup.java index 0e20252166be..0d748e443fb4 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestWALLockup.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestWALLockup.java @@ -314,7 +314,7 @@ public void run() { * If below is broken, we will see this test timeout because RingBufferEventHandler was stuck in * attainSafePoint. Everyone will wait for sync to finish forever. See HBASE-14317. */ - @Test (timeout=30000) + @Test public void testRingBufferEventHandlerStuckWhenSyncFailed() throws IOException, InterruptedException { diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/throttle/TestStoreHotnessProtector.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/throttle/TestStoreHotnessProtector.java index 67ac1c352165..218b41d9c61b 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/throttle/TestStoreHotnessProtector.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/throttle/TestStoreHotnessProtector.java @@ -53,7 +53,7 @@ public class TestStoreHotnessProtector { @ClassRule public static final HBaseClassTestRule CLASS_RULE = HBaseClassTestRule.forClass(TestStoreHotnessProtector.class); - @Test(timeout = 60000) + @Test public void testPreparePutCounter() throws Exception { ExecutorService executorService = Executors.newFixedThreadPool(10); diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestAccessController.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestAccessController.java index 523b82f595fd..31f2adf790e7 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestAccessController.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestAccessController.java @@ -3180,7 +3180,7 @@ public Object run() throws Exception { verifyDenied(action, USER_CREATE, USER_RW, USER_RO, USER_NONE, USER_OWNER, USER_ADMIN); } - @Test(timeout = 180000) + @Test public void testGetUserPermissions() throws Throwable { Connection conn = null; try { @@ -3308,7 +3308,7 @@ public void testGetUserPermissions() throws Throwable { } } - @Test(timeout = 180000) + @Test public void testHasPermission() throws Throwable { Connection conn = null; try {