From af7b67ec2c35d11cfbb4b5b10379f6f9541c7979 Mon Sep 17 00:00:00 2001 From: Ashish Singhi Date: Thu, 18 Jun 2015 16:22:36 +0530 Subject: [PATCH] HBASE-13659 Improve test run time for TestMetaWithReplicas class --- .../hadoop/hbase/client/TestMetaWithReplicas.java | 33 +++++++++++----------- 1 file changed, 16 insertions(+), 17 deletions(-) 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 354dc66..577ef58 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,12 +18,10 @@ */ package org.apache.hadoop.hbase.client; -import javax.annotation.Nullable; - -import java.io.IOException; 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.*; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; import java.util.Arrays; import java.util.Collection; @@ -43,20 +41,20 @@ import org.apache.hadoop.hbase.RegionLocations; import org.apache.hadoop.hbase.ServerName; import org.apache.hadoop.hbase.TableName; 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.master.ServerManager; import org.apache.hadoop.hbase.regionserver.StorefileRefresherChore; import org.apache.hadoop.hbase.testclassification.MediumTests; import org.apache.hadoop.hbase.util.Bytes; import org.apache.hadoop.hbase.util.HBaseFsck; -import org.apache.hadoop.hbase.util.HBaseFsckRepair; import org.apache.hadoop.hbase.util.HBaseFsck.ErrorReporter.ERROR_CODE; +import org.apache.hadoop.hbase.util.HBaseFsckRepair; import org.apache.hadoop.hbase.util.hbck.HbckTestingUtil; import org.apache.hadoop.hbase.zookeeper.LoadBalancerTracker; 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.AfterClass; +import org.junit.BeforeClass; import org.junit.Test; import org.junit.experimental.categories.Category; @@ -66,14 +64,15 @@ import org.junit.experimental.categories.Category; @Category(MediumTests.class) public class TestMetaWithReplicas { static final Log LOG = LogFactory.getLog(TestMetaWithReplicas.class); - private final HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility(); + private static final HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility(); - @Before - public void setup() throws Exception { - TEST_UTIL.getConfiguration().setInt("zookeeper.session.timeout", 30000); - TEST_UTIL.getConfiguration().setInt(HConstants.META_REPLICAS_NUM, 3); - TEST_UTIL.getConfiguration().setInt( - StorefileRefresherChore.REGIONSERVER_STOREFILE_REFRESH_PERIOD, 1000); + @BeforeClass + public static void setup() throws Exception { + Configuration conf = TEST_UTIL.getConfiguration(); + conf.setInt("zookeeper.session.timeout", 30000); + conf.setInt(HConstants.META_REPLICAS_NUM, 3); + conf.setInt(StorefileRefresherChore.REGIONSERVER_STOREFILE_REFRESH_PERIOD, 1000); + conf.setInt(ServerManager.WAIT_ON_REGIONSERVERS_MINTOSTART, 2); TEST_UTIL.startMiniCluster(3); // disable the balancer LoadBalancerTracker l = new LoadBalancerTracker(TEST_UTIL.getZooKeeperWatcher(), @@ -97,8 +96,8 @@ public class TestMetaWithReplicas { LOG.debug("All meta replicas assigned"); } - @After - public void tearDown() throws Exception { + @AfterClass + public static void tearDown() throws Exception { TEST_UTIL.shutdownMiniCluster(); } -- 1.9.2.msysgit.0