瀏覽代碼

ZOOKEEPER-1103. In QuorumTest, use the same "for ( .. try { break } catch { } )" pattern in testFollowersStartAfterLeaders as in testSessionMove. (Eugene Koontz via phunt)

git-svn-id: https://svn.apache.org/repos/asf/zookeeper/trunk@1138213 13f79535-47bb-0310-9956-ffa450edef68
Patrick D. Hunt 14 年之前
父節點
當前提交
556d062eb7
共有 2 個文件被更改,包括 18 次插入4 次删除
  1. 4 0
      CHANGES.txt
  2. 14 4
      src/java/test/org/apache/zookeeper/test/QuorumTest.java

+ 4 - 0
CHANGES.txt

@@ -236,6 +236,10 @@ BUGFIXES:
   ZOOKEEPER-1068. Documentation and default config suggest incorrect
   location for Zookeeper state (Roman Shaposhnik via phunt)
 
+  ZOOKEEPER-1103. In QuorumTest, use the same "for ( .. try { break }
+  catch { } )" pattern in testFollowersStartAfterLeaders as in
+  testSessionMove. (Eugene Koontz via phunt)
+
 IMPROVEMENTS:
   ZOOKEEPER-724. Improve junit test integration - log harness information 
   (phunt via mahadev)

+ 14 - 4
src/java/test/org/apache/zookeeper/test/QuorumTest.java

@@ -316,11 +316,21 @@ public class QuorumTest extends QuorumBase {
                 QuorumBase.waitForServerUp(
                         "127.0.0.1:" + qu.getPeer(2).clientPort,
                         CONNECTION_TIMEOUT));
-        Thread.sleep(1000);
 
-        // zk should have reconnected already
-        zk.create("/test", "test".getBytes(), ZooDefs.Ids.OPEN_ACL_UNSAFE,
-                CreateMode.PERSISTENT);
+
+        for (int i = 0; i < 30; i++) {
+            try {
+                zk.create("/test", "test".getBytes(), ZooDefs.Ids.OPEN_ACL_UNSAFE,
+                    CreateMode.PERSISTENT);
+                break;
+            } catch(KeeperException.ConnectionLossException e) {
+                Thread.sleep(1000);
+            }
+            // test fails if we still can't connect to the quorum after 30 seconds.
+            Assert.assertFalse("client could not connect to reestablished quorum: giving up after 30 seconds.",true);
+        }
+
+
         zk.close();
     }