Index: src/test/java/org/apache/hadoop/hbase/regionserver/TestSplitTransactionOnCluster.java =================================================================== --- src/test/java/org/apache/hadoop/hbase/regionserver/TestSplitTransactionOnCluster.java (revision 1445762) +++ src/test/java/org/apache/hadoop/hbase/regionserver/TestSplitTransactionOnCluster.java (working copy) @@ -631,7 +631,7 @@ @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 @@ @Override void createNodeSplitting(ZooKeeperWatcher zkw, HRegionInfo region, ServerName serverName) throws KeeperException, IOException { - throw new IOException(); + throw new CreateSplittingNodeFailedException(); } }; } + 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 incase the Split failed due to the existence of the znode in OPENED state. + // This will atleast 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 CreateSplittingNodeFailedException); + } + node = ZKAssign.getNodeName(regionServer.getZooKeeper(), regions.get(0) .getRegionInfo().getEncodedName()); // make sure the client is uptodate regionServer.getZooKeeper().sync(node); @@ -1047,5 +1068,17 @@ LOG.debug("Customised master executed."); } } + + private static class TransitionToSplittingFailedException extends IOException { + public TransitionToSplittingFailedException() { + super(); + } + } + + private static class CreateSplittingNodeFailedException extends IOException { + public CreateSplittingNodeFailedException() { + super(); + } + } }