hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From li...@apache.org
Subject svn commit: r1584855 - in /hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase: UnstableTestSuite.java master/TestRegionPlacement.java
Date Fri, 04 Apr 2014 18:18:38 GMT
Author: liyin
Date: Fri Apr  4 18:18:38 2014
New Revision: 1584855

URL: http://svn.apache.org/r1584855
Log:
[HBASE-10907] Stabilize TestRegionPlacement

Author: elliott

Summary: Each test case in TestRegionPlacement wanted to be run in isolation but it wasn't.

Test Plan: mvn clean test -Dtest=TestRegionPlacement

Reviewers: liyintang, daviddeng, adela

Reviewed By: adela

CC: hbase-eng@

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

Task ID: 2747703

Modified:
    hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/UnstableTestSuite.java
    hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/master/TestRegionPlacement.java

Modified: hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/UnstableTestSuite.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/UnstableTestSuite.java?rev=1584855&r1=1584854&r2=1584855&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/UnstableTestSuite.java (original)
+++ hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/UnstableTestSuite.java Fri
Apr  4 18:18:38 2014
@@ -45,10 +45,9 @@ import org.junit.runners.Suite.SuiteClas
     TestLogRolling.class, TestHFileOutputFormat.class,
     TestProcessBasedCluster.class, TestRegionStateOnMasterFailure.class,
     TestScannerTimeout.class, TestWALReplay.class, TestThriftMetrics.class,
-    TestRegionPlacement.class, TestServerConfigFromClient.class,
-    TestRSLivenessOnMasterFailover.class, TestLogSplitOnMasterFailover.class,
-    TagRunner.class, TestHRegionServerFileSystemFailure.class,
-    TestFullLogReconstruction.class, TestSplitLogManager.class,
-    TestHLog.class })
+    TestServerConfigFromClient.class, TestRSLivenessOnMasterFailover.class,
+    TestLogSplitOnMasterFailover.class, TagRunner.class,
+    TestHRegionServerFileSystemFailure.class, TestFullLogReconstruction.class,
+    TestSplitLogManager.class, TestHLog.class })
 public class UnstableTestSuite {
 }

Modified: hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/master/TestRegionPlacement.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/master/TestRegionPlacement.java?rev=1584855&r1=1584854&r2=1584855&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/master/TestRegionPlacement.java
(original)
+++ hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/master/TestRegionPlacement.java
Fri Apr  4 18:18:38 2014
@@ -58,9 +58,9 @@ import org.apache.hadoop.hbase.regionser
 import org.apache.hadoop.hbase.regionserver.HRegionServer;
 import org.apache.hadoop.hbase.util.Bytes;
 import org.apache.hadoop.hbase.util.TagRunner;
-import org.apache.hadoop.hbase.util.TestTag;
 import org.apache.hadoop.hbase.util.Writables;
 import org.codehaus.jackson.map.ObjectMapper;
+import org.junit.After;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
 import org.junit.Test;
@@ -101,6 +101,22 @@ public class TestRegionPlacement {
     TEST_UTIL.shutdownMiniCluster();
   }
 
+  @After
+  public void cleanUpTables() throws IOException {
+    final HBaseAdmin admin = TEST_UTIL.getHBaseAdmin();
+    for(HTableDescriptor htd: admin.listTables()) {
+      try {
+        if (!htd.isMetaTable() ) {
+          admin.disableTable(htd.getName());
+          admin.deleteTable(htd.getName());
+        }
+      } catch (IOException ioe) {
+        // Ignored. so that we can try and remove all tables.
+      }
+    }
+  }
+
+
   @Test
   public void testLoadBalancerImpl() throws Exception {
     MiniHBaseCluster cluster = TEST_UTIL.getHBaseCluster();
@@ -117,12 +133,10 @@ public class TestRegionPlacement {
    *
    * @throws Exception
    */
-  // Marked as unstable and recorded in #2747703
-  @TestTag({ "unstable" })
   @Test(timeout = 360000)
   public void testPrimaryPlacement() throws Exception {
     // Create a table with REGION_NUM regions.
-    createTable("testRegionAssignment", REGION_NUM);
+    createTable("testPrimaryPlacement", REGION_NUM);
     AssignmentPlan plan = rp.getExistingAssignmentPlan();
     Map<Integer, Integer> expected = new HashMap<Integer, Integer>();
     // we expect 2 regionservers with 2 regions and 2 with 3 regions
@@ -131,7 +145,7 @@ public class TestRegionPlacement {
     assertTrue(verifyNumPrimaries(expected, plan));
 
     //create additional table with 5 regions
-    createTable("testTable2", 5);
+    createTable("testPrimaryPlacement2", 5);
     expected.clear();
     // after this we expect 3 regionservers with 4 regions and one with 3
     expected.put(4, 3);
@@ -140,7 +154,6 @@ public class TestRegionPlacement {
     assertTrue(verifyNumPrimaries(expected, plan));
   }
 
-
   public boolean verifyNumPrimaries(Map<Integer, Integer> expected, AssignmentPlan
plan) {
     Map<HServerAddress, List<HRegionInfo>> assignment = new HashMap<HServerAddress,
List<HRegionInfo>>();
     for (Entry<HRegionInfo, List<HServerAddress>> entry : plan.getAssignmentMap().entrySet())
{
@@ -167,13 +180,12 @@ public class TestRegionPlacement {
     return expected.equals(rswithNumRegions);
   }
 
-  // Marked as unstable and recored in #2747703
-  @TestTag({ "unstable" })
   @Test(timeout = 360000)
   public void testRegionPlacement() throws Exception {
     AssignmentPlan currentPlan;
-    // ONLY meta regions, ROOT and META, are assigned at beginning.
-    verifyRegionMovementNum(META_REGION_NUM);
+
+    // Reset all of the counters.
+    resetLastOpenedRegionCount();
 
     // Create a table with REGION_NUM regions.
     createTable("testRegionAssignment", REGION_NUM);
@@ -366,16 +378,24 @@ public class TestRegionPlacement {
       LOG.debug("There are " + regionMovement + "/" + expected +
           " regions moved after " + attempt + " attempts");
       Thread.sleep((++attempt) * sleep);
-    } while (regionMovement != expected && attempt <= retry);
+    } while (regionMovement < expected && attempt <= retry);
 
     // update the lastRegionOpenedCount
-    lastRegionOpenedCount = currentRegionOpened;
+    resetLastOpenedRegionCount(currentRegionOpened);
 
     assertEquals("There are only " + regionMovement + " instead of "
           + expected + " region movement for " + attempt + " attempts",
           regionMovement, expected);
   }
 
+  private void resetLastOpenedRegionCount() {
+    resetLastOpenedRegionCount(TEST_UTIL.getHBaseCluster().getMaster().getMetrics().getRegionsOpened());
+  }
+
+  private void resetLastOpenedRegionCount(int newCount) {
+    this.lastRegionOpenedCount = newCount;
+  }
+
   /**
    * Shuffle the assignment plan by switching two favored node positions.
    * @param plan The assignment plan



Mime
View raw message