hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject svn commit: r1455328 - /hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterMetricsWrapper.java
Date Mon, 11 Mar 2013 21:06:00 GMT
Author: stack
Date: Mon Mar 11 21:06:00 2013
New Revision: 1455328

URL: http://svn.apache.org/r1455328
Log:
HBASE-8068 TestMasterMetricsWrapper failed in 0.95 #60 jenkins

Modified:
    hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterMetricsWrapper.java

Modified: hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterMetricsWrapper.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterMetricsWrapper.java?rev=1455328&r1=1455327&r2=1455328&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterMetricsWrapper.java
(original)
+++ hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterMetricsWrapper.java
Mon Mar 11 21:06:00 2013
@@ -17,12 +17,15 @@
  */
 package org.apache.hadoop.hbase.master;
 
-import junit.framework.Assert;
+import static org.junit.Assert.*;
 
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.hbase.HBaseTestingUtility;
 import org.apache.hadoop.hbase.master.HMaster;
 import org.apache.hadoop.hbase.MediumTests;
 import org.apache.hadoop.hbase.master.MetricsMasterWrapperImpl;
+import org.apache.hadoop.hbase.util.Threads;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
 import org.junit.Test;
@@ -30,9 +33,9 @@ import org.junit.experimental.categories
 
 @Category(MediumTests.class)
 public class TestMasterMetricsWrapper {
+  private static final Log LOG = LogFactory.getLog(TestMasterMetricsWrapper.class);
 
-  private static final HBaseTestingUtility TEST_UTIL =
-      new HBaseTestingUtility();
+  private static final HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility();
 
   @BeforeClass
   public static void setup() throws Exception {
@@ -44,31 +47,32 @@ public class TestMasterMetricsWrapper {
     TEST_UTIL.shutdownMiniCluster();
   }
 
-  @Test
+  @Test (timeout = 30000)
   public void testInfo() {
     HMaster master = TEST_UTIL.getHBaseCluster().getMaster();
     MetricsMasterWrapperImpl info = new MetricsMasterWrapperImpl(master);
-    Assert.assertEquals(master.getAverageLoad(), info.getAverageLoad());
-    Assert.assertEquals(master.getClusterId(), info.getClusterId());
-    Assert.assertEquals(master.getMasterActiveTime(),
-        info.getActiveTime());
-    Assert.assertEquals(master.getMasterStartTime(),
-        info.getStartTime());
-    Assert.assertEquals(master.getCoprocessors().length,
-        info.getCoprocessors().length);
-    Assert.assertEquals(master.getServerManager().getOnlineServersList().size(),
-        info.getRegionServers());
-    Assert.assertTrue(info.getRegionServers() == 4);
+    assertEquals(master.getAverageLoad(), info.getAverageLoad(), 0);
+    assertEquals(master.getClusterId(), info.getClusterId());
+    assertEquals(master.getMasterActiveTime(), info.getActiveTime());
+    assertEquals(master.getMasterStartTime(), info.getStartTime());
+    assertEquals(master.getCoprocessors().length, info.getCoprocessors().length);
+    assertEquals(master.getServerManager().getOnlineServersList().size(), info.getRegionServers());
+    assertTrue(info.getRegionServers() == 4);
 
     String zkServers = info.getZookeeperQuorum();
-    Assert.assertEquals(zkServers.split(",").length,
-        TEST_UTIL.getZkCluster().getZooKeeperServerNum());
-
-    TEST_UTIL.getMiniHBaseCluster().stopRegionServer(3, false);
-    TEST_UTIL.getMiniHBaseCluster().waitOnRegionServer(3);
-    Assert.assertTrue(info.getRegionServers() == 3);
-    Assert.assertTrue(info.getDeadRegionServers() == 1);
+    assertEquals(zkServers.split(",").length, TEST_UTIL.getZkCluster().getZooKeeperServerNum());
 
+    final int index = 3;
+    LOG.info("Stopping " + TEST_UTIL.getMiniHBaseCluster().getRegionServer(index));
+    TEST_UTIL.getMiniHBaseCluster().stopRegionServer(index, false);
+    TEST_UTIL.getMiniHBaseCluster().waitOnRegionServer(index);
+    // We stopped the regionserver but could take a while for the master to notice it so
hang here
+    // until it does... then move forward to see if metrics wrapper notices.
+    while (TEST_UTIL.getHBaseCluster().getMaster().getServerManager().getOnlineServers().size()
!=
+        index) {
+      Threads.sleep(10);
+    }
+    assertTrue(info.getRegionServers() == 3);
+    assertTrue(info.getDeadRegionServers() == 1);
   }
-
-}
+}
\ No newline at end of file



Mime
View raw message