hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject hbase git commit: HBASE-12563 After Starting up mini hbase cluster, Real Configuration of Cluster never set to HBaseTestingUtility (Talat UYARER)
Date Wed, 26 Nov 2014 16:00:13 GMT
Repository: hbase
Updated Branches:
  refs/heads/branch-1 c55d57461 -> 2e9597ffb


HBASE-12563 After Starting up mini hbase cluster, Real Configuration of Cluster never set
to HBaseTestingUtility (Talat UYARER)


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

Branch: refs/heads/branch-1
Commit: 2e9597ffb790cf23699f1f85777403b436c96ab9
Parents: c55d574
Author: stack <stack@apache.org>
Authored: Wed Nov 26 07:59:26 2014 -0800
Committer: stack <stack@apache.org>
Committed: Wed Nov 26 08:00:00 2014 -0800

----------------------------------------------------------------------
 .../hadoop/hbase/HBaseTestingUtility.java       |  6 +++-
 .../apache/hadoop/hbase/TestInfoServers.java    | 37 +++++++++++++++-----
 2 files changed, 33 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/2e9597ff/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java
index efe27e2..8dcb99c 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java
@@ -907,6 +907,10 @@ public class HBaseTestingUtility extends HBaseCommonTestingUtility {
     Configuration c = new Configuration(this.conf);
     this.hbaseCluster =
         new MiniHBaseCluster(c, numMasters, numSlaves, masterClass, regionserverClass);
+    // Cluster confguration should set HbaseTestingUtility Conf
+    MiniHBaseCluster miniHBaseCluster = (MiniHBaseCluster) this.hbaseCluster;
+    this.conf = miniHBaseCluster.getMaster().getConfiguration();
+
     // Don't leave here till we've done a successful scan of the hbase:meta
     Table t = new HTable(c, TableName.META_TABLE_NAME);
     ResultScanner s = t.getScanner(new Scan());
@@ -918,7 +922,7 @@ public class HBaseTestingUtility extends HBaseCommonTestingUtility {
 
     getHBaseAdmin(); // create immediately the hbaseAdmin
     LOG.info("Minicluster is up");
-    return (MiniHBaseCluster)this.hbaseCluster;
+    return miniHBaseCluster;
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/hbase/blob/2e9597ff/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 b6742ff..631807b 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,6 +18,7 @@
  */
 package org.apache.hadoop.hbase;
 
+import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 
 import java.io.BufferedInputStream;
@@ -44,11 +45,10 @@ public class TestInfoServers {
 
   @BeforeClass
   public static void beforeClass() throws Exception {
-    // The info servers do not run in tests by default.
-    // Set them to ephemeral ports so they will start
+    // The info servers do not run in tests by default.   
+    // Set them to ephemeral ports so they will start   
     UTIL.getConfiguration().setInt(HConstants.MASTER_INFO_PORT, 0);
-    UTIL.getConfiguration().setInt(HConstants.REGIONSERVER_INFO_PORT, 0);
-
+    
     //We need to make sure that the server can be started as read only.
     UTIL.getConfiguration().setBoolean("hbase.master.ui.readonly", true);
     UTIL.startMiniCluster();
@@ -60,17 +60,36 @@ public class TestInfoServers {
   }
 
   /**
+   * Test for checking master info port of cluster whether same with the port of
+   * TestHBaseTestingUtility's getConfiguration .
+   * 
+   * @throws Exception
+   */
+  @Test
+  public void testMasterInfoServerPort() throws Exception {
+    String confPort = UTIL.getConfiguration().get(HConstants.MASTER_INFO_PORT);
+    String masterPort =
+        UTIL.getHBaseCluster().getMaster().getConfiguration().get(HConstants.MASTER_INFO_PORT);
+    String regionPort =
+        UTIL.getHBaseCluster().getRegionServerThreads().get(0).getRegionServer().getConfiguration()
+            .get(HConstants.MASTER_INFO_PORT);
+
+    assertEquals(confPort, masterPort);
+    assertEquals(confPort, regionPort);
+  }
+  
+  /**
    * @throws Exception
    */
   @Test
   public void testInfoServersRedirect() throws Exception {
     // give the cluster time to start up
     new HTable(UTIL.getConfiguration(), TableName.META_TABLE_NAME).close();
-    int port = UTIL.getHBaseCluster().getMaster().getInfoServer().getPort();
+    String port = UTIL.getConfiguration().get(HConstants.MASTER_INFO_PORT);
     assertContainsContent(new URL("http://localhost:" + port +
         "/index.html"), "master-status");
     port = UTIL.getHBaseCluster().getRegionServerThreads().get(0).getRegionServer().
-      getInfoServer().getPort();
+        getConfiguration().get(HConstants.REGIONSERVER_INFO_PORT);
     assertContainsContent(new URL("http://localhost:" + port +
         "/index.html"), "rs-status");
   }
@@ -86,11 +105,11 @@ public class TestInfoServers {
   public void testInfoServersStatusPages() throws Exception {
     // give the cluster time to start up
     new HTable(UTIL.getConfiguration(), TableName.META_TABLE_NAME).close();
-    int port = UTIL.getHBaseCluster().getMaster().getInfoServer().getPort();
+    String port = UTIL.getConfiguration().get(HConstants.MASTER_INFO_PORT);
     assertContainsContent(new URL("http://localhost:" + port +
         "/master-status"), "meta");
     port = UTIL.getHBaseCluster().getRegionServerThreads().get(0).getRegionServer().
-      getInfoServer().getPort();
+        getConfiguration().get(HConstants.REGIONSERVER_INFO_PORT);
     assertContainsContent(new URL("http://localhost:" + port +
         "/rs-status"), "meta");
   }
@@ -101,7 +120,7 @@ public class TestInfoServers {
     byte[] cf = Bytes.toBytes("d");
     UTIL.createTable(tableName, cf);
     new HTable(UTIL.getConfiguration(), tableName).close();
-    int port = UTIL.getHBaseCluster().getMaster().getInfoServer().getPort();
+    String port = UTIL.getConfiguration().get(HConstants.MASTER_INFO_PORT);
     assertDoesNotContainContent(
       new URL("http://localhost:" + port + "/table.jsp?name=" + tableName + "&action=split&key="),
       "Table action request accepted");


Mime
View raw message