hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ecl...@apache.org
Subject [17/50] [abbrv] git commit: [master] Fix testNonCachedGetRegionLocation
Date Thu, 31 Jul 2014 22:07:53 GMT
[master] Fix testNonCachedGetRegionLocation

Summary: Move this case from `TestFromClientSide` to `TestGetRegionLocation`, `TEST_UTIL.useAssignmentLoadBalancer`
is called which fixes the problem.

Test Plan: `TestGetRegionLocation`

Reviewers: manukranthk, fan, gauravm, rshroff, elliott

Reviewed By: elliott

Subscribers: hbase-eng@

Differential Revision: https://phabricator.fb.com/D1372191

git-svn-id: svn+ssh://tubbs/svnhive/hadoop/branches/titan/VENDOR.hbase/hbase-trunk@42813 e7acf4d4-3532-417f-9e73-7a9ae25a1f51


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

Branch: refs/heads/0.89-fb
Commit: eae4c2636aff929264ad2ffddbebed5417f761b2
Parents: ae31cc5
Author: daviddeng <daviddeng@e7acf4d4-3532-417f-9e73-7a9ae25a1f51>
Authored: Wed Jun 11 21:35:52 2014 +0000
Committer: Elliott Clark <elliott@fb.com>
Committed: Thu Jul 31 14:44:22 2014 -0700

----------------------------------------------------------------------
 .../hadoop/hbase/client/TestFromClientSide.java | 51 ----------------
 .../regionserver/TestGetRegionLocation.java     | 61 ++++++++++++++++++++
 2 files changed, 61 insertions(+), 51 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/eae4c263/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide.java b/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide.java
index 2d4d0e3..c347154 100644
--- a/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide.java
+++ b/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide.java
@@ -21,7 +21,6 @@ package org.apache.hadoop.hbase.client;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertSame;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
@@ -4416,56 +4415,6 @@ public class TestFromClientSide {
     compactCFTable(1);
   }
 
-  /**
-   * Tests the non cached version of getRegionLocation by moving a region.
-   */
-  @Test(timeout = 180000)
-  public void testNonCachedGetRegionLocation() throws Exception {
-    // Test Initialization.
-    String tableName = "testNonCachedGetRegionLocation";
-    byte [] TABLE = Bytes.toBytes(tableName);
-    byte [] family1 = Bytes.toBytes("f1");
-    byte [] family2 = Bytes.toBytes("f2");
-    HTable table = TEST_UTIL.createTable(TABLE, new byte[][] {family1, family2}, 10);
-    HBaseAdmin admin = new HBaseAdmin(TEST_UTIL.getConfiguration());
-    Map <HRegionInfo, HServerAddress> regionsMap = table.getRegionsInfo();
-    assertEquals(1, regionsMap.size());
-    HRegionInfo regionInfo = regionsMap.keySet().iterator().next();
-    HServerAddress addrBefore = regionsMap.get(regionInfo);
-    // Verify region location before move.
-    HServerAddress addrCache =
-      table.getRegionLocation(regionInfo.getStartKey()).getServerAddress();
-    HServerAddress addrNoCache =
-      table.getRegionLocation(regionInfo.getStartKey(),
-          true).getServerAddress();
-
-    assertEquals(addrBefore.getPort(), addrCache.getPort());
-    assertEquals(addrBefore.getPort(), addrNoCache.getPort());
-
-    HServerAddress addrAfter = null;
-    // Now move the region to a different server.
-    for (int i = 0; i < SLAVES; i++) {
-      HRegionServer regionServer = TEST_UTIL.getHBaseCluster().getRegionServer(i);
-      HServerAddress addr = regionServer.getServerInfo().getServerAddress();
-      if (addr.getPort() != addrBefore.getPort()) {
-        TEST_UTIL.moveRegionAndAssignment(regionInfo, addr);
-        TEST_UTIL.waitForTableConsistent();
-        addrAfter = addr;
-        break;
-      }
-    }
-
-    // Verify the region was moved.
-    addrCache =
-      table.getRegionLocation(regionInfo.getStartKey()).getServerAddress();
-    addrNoCache =
-      table.getRegionLocation(regionInfo.getStartKey(),
-          true).getServerAddress();
-    assertNotNull(addrAfter);
-    assertTrue(addrAfter.getPort() != addrCache.getPort());
-    assertEquals(addrAfter.getPort(), addrNoCache.getPort());
-  }
-
   @Test(timeout = 180000)
   public void testAtomicRowMutation() throws Exception {
     LOG.info("Starting testAtomicRowMutation");

http://git-wip-us.apache.org/repos/asf/hbase/blob/eae4c263/src/test/java/org/apache/hadoop/hbase/regionserver/TestGetRegionLocation.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/hadoop/hbase/regionserver/TestGetRegionLocation.java
b/src/test/java/org/apache/hadoop/hbase/regionserver/TestGetRegionLocation.java
index de391c5..3d59361 100644
--- a/src/test/java/org/apache/hadoop/hbase/regionserver/TestGetRegionLocation.java
+++ b/src/test/java/org/apache/hadoop/hbase/regionserver/TestGetRegionLocation.java
@@ -20,6 +20,10 @@
 
 package org.apache.hadoop.hbase.regionserver;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.HashMap;
@@ -33,9 +37,11 @@ import org.apache.hadoop.hbase.HBaseTestingUtility;
 import org.apache.hadoop.hbase.HConstants;
 import org.apache.hadoop.hbase.HRegionInfo;
 import org.apache.hadoop.hbase.HRegionLocation;
+import org.apache.hadoop.hbase.HServerAddress;
 import org.apache.hadoop.hbase.HServerInfo;
 import org.apache.hadoop.hbase.MediumTests;
 import org.apache.hadoop.hbase.NotServingRegionException;
+import org.apache.hadoop.hbase.client.HTable;
 import org.apache.hadoop.hbase.client.RetriesExhaustedException;
 import org.apache.hadoop.hbase.client.TableServers;
 import org.apache.hadoop.hbase.ipc.HRegionInterface;
@@ -260,4 +266,59 @@ public class TestGetRegionLocation {
     }
   }
 
+  /**
+   * Tests the non cached version of getRegionLocation by moving a region.
+   */
+  @Test(timeout = 180000)
+  public void testNonCachedGetRegionLocation() throws Exception {
+    // Test Initialization.
+    String tableName = "testNonCachedGetRegionLocation";
+    byte[] TABLE = Bytes.toBytes(tableName);
+    byte[] family1 = Bytes.toBytes("f1");
+    byte[] family2 = Bytes.toBytes("f2");
+    try (HTable table =
+        TEST_UTIL.createTable(TABLE, new byte[][] { family1, family2 }, 10)) {
+      Map<HRegionInfo, HServerAddress> regionsMap = table.getRegionsInfo();
+      assertEquals("Number of regions", 1, regionsMap.size());
+      HRegionInfo regionInfo = regionsMap.keySet().iterator().next();
+      HServerAddress addrBefore = regionsMap.get(regionInfo);
+      // Verify region location before move.
+      HServerAddress addrCache =
+          table.getRegionLocation(regionInfo.getStartKey()).getServerAddress();
+      HServerAddress addrNoCache =
+          table.getRegionLocation(regionInfo.getStartKey(), true)
+              .getServerAddress();
+
+      assertEquals("Port(cached)", addrBefore.getPort(), addrCache.getPort());
+      assertEquals("Port(no-cached)", addrBefore.getPort(),
+          addrNoCache.getPort());
+
+      HServerAddress addrAfter = null;
+      // Now move the region to a different server.
+      for (int i = 0; i < NUM_SLAVES; i++) {
+        HRegionServer regionServer =
+            TEST_UTIL.getHBaseCluster().getRegionServer(i);
+        HServerAddress addr = regionServer.getServerInfo().getServerAddress();
+        if (addr.getPort() != addrBefore.getPort()) {
+          TEST_UTIL.moveRegionAndAssignment(regionInfo, addr);
+          TEST_UTIL.waitForTableConsistent();
+          addrAfter = addr;
+          break;
+        }
+      }
+
+      // Verify the region was moved.
+      addrCache =
+          table.getRegionLocation(regionInfo.getStartKey()).getServerAddress();
+      addrNoCache =
+          table.getRegionLocation(regionInfo.getStartKey(), true)
+              .getServerAddress();
+      assertNotNull("Not server for destination", addrAfter);
+      assertTrue("Server is the same as before",
+          addrAfter.getPort() != addrCache.getPort());
+      assertEquals("Port after region mored", addrAfter.getPort(),
+          addrNoCache.getPort());
+    }
+  }
+
 }


Mime
View raw message