You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by ra...@apache.org on 2013/02/22 17:29:46 UTC

svn commit: r1449106 - /hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/regionserver/TestSplitTransactionOnCluster.java

Author: ramkrishna
Date: Fri Feb 22 16:29:46 2013
New Revision: 1449106

URL: http://svn.apache.org/r1449106
Log:
HBASE-7866-TestSplitTransactionOnCluster.testSplitBeforeSettingSplittingInZK failed 3 times in a row (Ram)


Modified:
    hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/regionserver/TestSplitTransactionOnCluster.java

Modified: hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/regionserver/TestSplitTransactionOnCluster.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/regionserver/TestSplitTransactionOnCluster.java?rev=1449106&r1=1449105&r2=1449106&view=diff
==============================================================================
--- hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/regionserver/TestSplitTransactionOnCluster.java (original)
+++ hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/regionserver/TestSplitTransactionOnCluster.java Fri Feb 22 16:29:46 2013
@@ -631,7 +631,7 @@ public class TestSplitTransactionOnClust
         @Override
         int transitionNodeSplitting(ZooKeeperWatcher zkw, HRegionInfo parent,
             ServerName serverName, int version) throws KeeperException, IOException {
-          throw new IOException();
+          throw new TransitionToSplittingFailedException();
         }
       };
     } else {
@@ -639,14 +639,35 @@ public class TestSplitTransactionOnClust
         @Override
         void createNodeSplitting(ZooKeeperWatcher zkw, HRegionInfo region, ServerName serverName)
             throws KeeperException, IOException {
-          throw new IOException();
+          throw new SplittingNodeCreationFailedException ();
         }
       };
     }
+    String node = ZKAssign.getNodeName(regionServer.getZooKeeper(), regions.get(0)
+        .getRegionInfo().getEncodedName());
+    // make sure the client is uptodate
+    regionServer.getZooKeeper().sync(node);
+    for (int i = 0; i < 100; i++) {
+      // We expect the znode to be deleted by this time. Here the znode could be in OPENED state and the 
+      // master has not yet deleted the znode.
+      if (ZKUtil.checkExists(regionServer.getZooKeeper(), node) != -1) {
+        Thread.sleep(100);
+      }
+    }
+    
     try {
       st.execute(regionServer, regionServer);
     } catch (IOException e) {
-      String node = ZKAssign.getNodeName(regionServer.getZooKeeper(), regions.get(0)
+      // check for the specific instance in case the Split failed due to the existence of the znode in OPENED state.
+      // This will at least make the test to fail;
+      if (nodeCreated) {
+        assertTrue("Should be instance of TransitionToSplittingFailedException",
+            e instanceof TransitionToSplittingFailedException);
+      } else {
+        assertTrue("Should be instance of CreateSplittingNodeFailedException",
+            e instanceof SplittingNodeCreationFailedException );
+      }
+      node = ZKAssign.getNodeName(regionServer.getZooKeeper(), regions.get(0)
           .getRegionInfo().getEncodedName());
       // make sure the client is uptodate
       regionServer.getZooKeeper().sync(node);
@@ -1047,5 +1068,17 @@ public class TestSplitTransactionOnClust
       LOG.debug("Customised master executed.");
     }
   }
+  
+  private static class TransitionToSplittingFailedException extends IOException {
+    public TransitionToSplittingFailedException() {
+      super();
+    }
+  }
+
+  private static class SplittingNodeCreationFailedException  extends IOException {
+    public SplittingNodeCreationFailedException () {
+      super();
+    }
+  }
 }