瀏覽代碼

ZOOKEEPER-1478. Small bug in QuorumTest.testFollowersStartAfterLeader( ) (Alexander Shraer via fpj, breed, phunt)

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

+ 3 - 0
CHANGES.txt

@@ -284,6 +284,9 @@ BUGFIXES:
   ZOOKEEPER-1553. Findbugs configuration is missing some dependencies
   (Sean Busbey via phunt)
 
+  ZOOKEEPER-1478. Small bug in QuorumTest.testFollowersStartAfterLeader( )
+  (Alexander Shraer via fpj, breed, phunt)
+
 IMPROVEMENTS:
 
   ZOOKEEPER-1170. Fix compiler (eclipse) warnings: unused imports,

+ 7 - 13
src/java/test/org/apache/zookeeper/test/QuorumTest.java

@@ -22,6 +22,7 @@ import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.concurrent.Semaphore;
 import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
 
 import org.apache.zookeeper.AsyncCallback;
 import org.apache.zookeeper.CreateMode;
@@ -311,22 +312,15 @@ public class QuorumTest extends ZKTestCase {
         // break the quorum
         qu.shutdown(index);
 
+        // Wait until we disconnect to proceed
+        watcher.waitForDisconnected(CONNECTION_TIMEOUT);
+        
         // try to reestablish the quorum
         qu.start(index);
-        Assert.assertTrue("quorum reestablishment failed",
-                QuorumBase.waitForServerUp(
-                        "127.0.0.1:" + qu.getPeer(2).clientPort,
-                        CONNECTION_TIMEOUT));
 
-        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.
+        try{
+            watcher.waitForConnected(30000);      
+        } catch(TimeoutException e) {
             Assert.fail("client could not connect to reestablished quorum: giving up after 30+ seconds.");
         }