From eff9b82421df9f654f021b5a0d485b0a7c4e50bb Mon Sep 17 00:00:00 2001 From: ramkrishna Date: Fri, 22 Feb 2013 16:24:36 +0000 Subject: [PATCH] HBASE-7866 - TestSplitTransactionOnCluster.testSplitBeforeSettingSplittingInZK failed 3 times in a row (Ram) git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1449101 13f79535-47bb-0310-9956-ffa450edef68 --- .../TestSplitTransactionOnCluster.java | 28 +++++++++++++++++-- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestSplitTransactionOnCluster.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestSplitTransactionOnCluster.java index d7c34406930..fb4e9f27912 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestSplitTransactionOnCluster.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestSplitTransactionOnCluster.java @@ -743,15 +743,31 @@ public class TestSplitTransactionOnCluster { @Override int 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()); + 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) - .getRegionInfo().getEncodedName()); + // 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; + assertTrue("Should be instance of CreateSplittingNodeFailedException", + e instanceof SplittingNodeCreationFailedException ); + node = ZKAssign.getNodeName(regionServer.getZooKeeper(), regions.get(0).getRegionInfo() + .getEncodedName()); { assertTrue(ZKUtil.checkExists(regionServer.getZooKeeper(), node) == -1); } @@ -979,5 +995,11 @@ public class TestSplitTransactionOnCluster { } } + private static class SplittingNodeCreationFailedException extends IOException { + public SplittingNodeCreationFailedException () { + super(); + } + } + }