You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by st...@apache.org on 2011/11/28 19:22:19 UTC

svn commit: r1207491 - in /hbase/trunk: CHANGES.txt src/test/java/org/apache/hadoop/hbase/client/TestHCM.java

Author: stack
Date: Mon Nov 28 18:22:18 2011
New Revision: 1207491

URL: http://svn.apache.org/viewvc?rev=1207491&view=rev
Log:
HBASE-4877 TestHCM failing sporadically on jenkins and always for me on an ubuntu machine

Modified:
    hbase/trunk/CHANGES.txt
    hbase/trunk/src/test/java/org/apache/hadoop/hbase/client/TestHCM.java

Modified: hbase/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hbase/trunk/CHANGES.txt?rev=1207491&r1=1207490&r2=1207491&view=diff
==============================================================================
--- hbase/trunk/CHANGES.txt (original)
+++ hbase/trunk/CHANGES.txt Mon Nov 28 18:22:18 2011
@@ -447,6 +447,8 @@ Release 0.92.0 - Unreleased
    HBASE-4739  Master dying while going to close a region can leave it in transition
                forever (Gao Jinchao)
    HBASE-4855  SplitLogManager hangs on cluster restart due to batch.installed doubly counted
+   HBASE-4877  TestHCM failing sporadically on jenkins and always for me on an
+               ubuntu machine
 
   TESTS
    HBASE-4450  test for number of blocks read: to serve as baseline for expected

Modified: hbase/trunk/src/test/java/org/apache/hadoop/hbase/client/TestHCM.java
URL: http://svn.apache.org/viewvc/hbase/trunk/src/test/java/org/apache/hadoop/hbase/client/TestHCM.java?rev=1207491&r1=1207490&r2=1207491&view=diff
==============================================================================
--- hbase/trunk/src/test/java/org/apache/hadoop/hbase/client/TestHCM.java (original)
+++ hbase/trunk/src/test/java/org/apache/hadoop/hbase/client/TestHCM.java Mon Nov 28 18:22:18 2011
@@ -178,31 +178,46 @@ public class TestHCM {
    */
   @Test
   public void testConnectionUniqueness() throws Exception {
+    int zkmaxconnections = TEST_UTIL.getConfiguration().
+      getInt(HConstants.ZOOKEEPER_MAX_CLIENT_CNXNS,
+        HConstants.DEFAULT_ZOOKEPER_MAX_CLIENT_CNXNS);
+    // Test up to a max that is < the maximum number of zk connections.  If we
+    // go above zk connections, we just fall into cycle where we are failing
+    // to set up a session and test runs for a long time.
+    int maxConnections = Math.min(zkmaxconnections - 1, 20);
+    List<HConnection> connections = new ArrayList<HConnection>();
     HConnection previousConnection = null;
-    for (int i = 0; i < HConnectionManager.MAX_CACHED_HBASE_INSTANCES + 10; i++) {
-      // set random key to differentiate the connection from previous ones
-      Configuration configuration = TEST_UTIL.getConfiguration();
-      configuration.set("some_key", String.valueOf(_randy.nextInt()));
-      configuration.set(HConstants.HBASE_CLIENT_INSTANCE_ID,
-          String.valueOf(_randy.nextInt()));
-      LOG.info("The hash code of the current configuration is: "
-          + configuration.hashCode());
-      HConnection currentConnection = HConnectionManager
-          .getConnection(configuration);
-      if (previousConnection != null) {
-        assertTrue("Got the same connection even though its key changed!",
-            previousConnection != currentConnection);
+    try {
+      for (int i = 0; i < maxConnections; i++) {
+        // set random key to differentiate the connection from previous ones
+        Configuration configuration = TEST_UTIL.getConfiguration();
+        configuration.set("some_key", String.valueOf(_randy.nextInt()));
+        configuration.set(HConstants.HBASE_CLIENT_INSTANCE_ID,
+            String.valueOf(_randy.nextInt()));
+        LOG.info("The hash code of the current configuration is: "
+            + configuration.hashCode());
+        HConnection currentConnection =
+          HConnectionManager.getConnection(configuration);
+        if (previousConnection != null) {
+          assertTrue("Got the same connection even though its key changed!",
+              previousConnection != currentConnection);
+        }
+        // change the configuration, so that it is no longer reachable from the
+        // client's perspective. However, since its part of the LRU doubly linked
+        // list, it will eventually get thrown out, at which time it should also
+        // close the corresponding {@link HConnection}.
+        configuration.set("other_key", String.valueOf(_randy.nextInt()));
+
+        previousConnection = currentConnection;
+        LOG.info("The current HConnectionManager#HBASE_INSTANCES cache size is: "
+            + getHConnectionManagerCacheSize());
+        Thread.sleep(50);
+      }
+    } finally {
+      for (HConnection c: connections) {
+        // Clean up connections made so we don't interfere w/ subsequent tests.
+        HConnectionManager.deleteConnection(c.getConfiguration(), true);
       }
-      // change the configuration, so that it is no longer reachable from the
-      // client's perspective. However, since its part of the LRU doubly linked
-      // list, it will eventually get thrown out, at which time it should also
-      // close the corresponding {@link HConnection}.
-      configuration.set("other_key", String.valueOf(_randy.nextInt()));
-
-      previousConnection = currentConnection;
-      LOG.info("The current HConnectionManager#HBASE_INSTANCES cache size is: "
-          + getHConnectionManagerCacheSize());
-      Thread.sleep(50);
     }
   }