hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From zhang...@apache.org
Subject hbase git commit: HBASE-13295 TestInfoServers hung
Date Fri, 27 Mar 2015 04:05:50 GMT
Repository: hbase
Updated Branches:
  refs/heads/master 306c44156 -> a78effcdc


HBASE-13295 TestInfoServers hung


Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/a78effcd
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/a78effcd
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/a78effcd

Branch: refs/heads/master
Commit: a78effcdc619bd4a6037d722a80e8289e4a8b15b
Parents: 306c441
Author: zhangduo <zhangduo@wandoujia.com>
Authored: Fri Mar 20 09:32:16 2015 +0800
Committer: zhangduo <zhangduo@wandoujia.com>
Committed: Fri Mar 27 11:58:17 2015 +0800

----------------------------------------------------------------------
 .../apache/hadoop/hbase/TestInfoServers.java    | 68 ++++++++------------
 1 file changed, 28 insertions(+), 40 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/a78effcd/hbase-server/src/test/java/org/apache/hadoop/hbase/TestInfoServers.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/TestInfoServers.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/TestInfoServers.java
index a72b151..8ac3556 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/TestInfoServers.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/TestInfoServers.java
@@ -18,15 +18,16 @@
  */
 package org.apache.hadoop.hbase;
 
+import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
 
-import java.io.BufferedInputStream;
 import java.io.IOException;
+import java.io.InputStream;
 import java.net.URL;
 
+import org.apache.commons.io.IOUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.hadoop.hbase.client.HTable;
 import org.apache.hadoop.hbase.testclassification.MediumTests;
 import org.apache.hadoop.hbase.testclassification.MiscTests;
 import org.apache.hadoop.hbase.util.Bytes;
@@ -54,6 +55,9 @@ public class TestInfoServers {
     //We need to make sure that the server can be started as read only.
     UTIL.getConfiguration().setBoolean("hbase.master.ui.readonly", true);
     UTIL.startMiniCluster();
+    if (!UTIL.getHBaseCluster().waitForActiveAndReadyMaster(30000)) {
+      throw new RuntimeException("Active master not ready");
+    }
   }
 
   @AfterClass
@@ -69,12 +73,10 @@ public class TestInfoServers {
     // give the cluster time to start up
     UTIL.getConnection().getTable(TableName.META_TABLE_NAME).close();
     int port = UTIL.getHBaseCluster().getMaster().getInfoServer().getPort();
-    assertContainsContent(new URL("http://localhost:" + port +
-        "/index.html"), "master-status");
-    port = UTIL.getHBaseCluster().getRegionServerThreads().get(0).getRegionServer().
-      getInfoServer().getPort();
-    assertContainsContent(new URL("http://localhost:" + port +
-        "/index.html"), "rs-status");
+    assertContainsContent(new URL("http://localhost:" + port + "/index.html"), "master-status");
+    port = UTIL.getHBaseCluster().getRegionServerThreads().get(0).getRegionServer()
+        .getInfoServer().getPort();
+    assertContainsContent(new URL("http://localhost:" + port + "/index.html"), "rs-status");
   }
 
   /**
@@ -86,15 +88,11 @@ public class TestInfoServers {
    */
   @Test
   public void testInfoServersStatusPages() throws Exception {
-    // give the cluster time to start up
-    UTIL.getConnection().getTable(TableName.META_TABLE_NAME).close();
     int port = UTIL.getHBaseCluster().getMaster().getInfoServer().getPort();
-    assertContainsContent(new URL("http://localhost:" + port +
-        "/master-status"), "meta");
-    port = UTIL.getHBaseCluster().getRegionServerThreads().get(0).getRegionServer().
-      getInfoServer().getPort();
-    assertContainsContent(new URL("http://localhost:" + port +
-        "/rs-status"), "meta");
+    assertContainsContent(new URL("http://localhost:" + port + "/master-status"), "meta");
+    port = UTIL.getHBaseCluster().getRegionServerThreads().get(0).getRegionServer()
+        .getInfoServer().getPort();
+    assertContainsContent(new URL("http://localhost:" + port + "/rs-status"), "meta");
   }
 
   @Test
@@ -102,44 +100,34 @@ public class TestInfoServers {
     TableName tableName = TableName.valueOf("testMasterServerReadOnly");
     byte[] cf = Bytes.toBytes("d");
     UTIL.createTable(tableName, cf);
-    UTIL.getConnection().getTable(tableName).close();
+    UTIL.waitTableAvailable(tableName);
     int port = UTIL.getHBaseCluster().getMaster().getInfoServer().getPort();
+    assertDoesNotContainContent(new URL("http://localhost:" + port + "/table.jsp?name=" +
tableName
+        + "&action=split&key="), "Table action request accepted");
     assertDoesNotContainContent(
-      new URL("http://localhost:" + port + "/table.jsp?name=" + tableName + "&action=split&key="),
-      "Table action request accepted");
-    assertDoesNotContainContent(
-      new URL("http://localhost:" + port + "/table.jsp?name=" + tableName),
-      "Actions:");
+      new URL("http://localhost:" + port + "/table.jsp?name=" + tableName), "Actions:");
   }
 
-  private void assertContainsContent(final URL u, final String expected)
-  throws IOException {
+  private void assertContainsContent(final URL u, final String expected) throws IOException
{
     LOG.info("Testing " + u.toString() + " has " + expected);
     String content = getUrlContent(u);
-    assertTrue("expected=" + expected + ", content=" + content,
-      content.contains(expected));
+    assertTrue("expected=" + expected + ", content=" + content, content.contains(expected));
   }
 
-
-
-  private void assertDoesNotContainContent(final URL u, final String expected)
-      throws IOException {
-    LOG.info("Testing " + u.toString() + " has " + expected);
+  private void assertDoesNotContainContent(final URL u, final String expected) throws IOException
{
+    LOG.info("Testing " + u.toString() + " does not have " + expected);
     String content = getUrlContent(u);
-    assertTrue("Does Not Contain =" + expected + ", content=" + content,
-        !content.contains(expected));
+    assertFalse("Does Not Contain =" + expected + ", content=" + content,
+      content.contains(expected));
   }
 
   private String getUrlContent(URL u) throws IOException {
     java.net.URLConnection c = u.openConnection();
+    c.setConnectTimeout(2000);
+    c.setReadTimeout(2000);
     c.connect();
-    StringBuilder sb = new StringBuilder();
-    BufferedInputStream bis = new BufferedInputStream(c.getInputStream());
-    byte [] bytes = new byte[1024];
-    for (int read = -1; (read = bis.read(bytes)) != -1;) {
-      sb.append(new String(bytes, 0, read));
+    try (InputStream in = c.getInputStream()) {
+      return IOUtils.toString(in);
     }
-    bis.close();
-    return sb.toString();
   }
 }


Mime
View raw message