瀏覽代碼

ZOOKEEPER-413. two flaws need addressing in the c tests that can cause false positive failures (phunt via mahadev)

git-svn-id: https://svn.apache.org/repos/asf/hadoop/zookeeper/trunk@903061 13f79535-47bb-0310-9956-ffa450edef68
Mahadev Konar 15 年之前
父節點
當前提交
ae541ace94
共有 3 個文件被更改,包括 29 次插入8 次删除
  1. 3 0
      CHANGES.txt
  2. 4 1
      src/c/tests/TestOperations.cc
  3. 22 7
      src/c/tests/TestWatchers.cc

+ 3 - 0
CHANGES.txt

@@ -209,6 +209,9 @@ BUGFIXES:
 
   ZOOKEEPER-656. SledgeHammer test - thread.run() deprecated (kay kay via mahadev)
 
+  ZOOKEEPER-413. two flaws need addressing in the c tests that can cause false
+  positive failures (phunt via mahadev)
+
 IMPROVEMENTS:
   ZOOKEEPER-473. cleanup junit tests to eliminate false positives due to
   "socket reuse" and failure to close client (phunt via mahadev)

+ 4 - 1
src/c/tests/TestOperations.cc

@@ -122,7 +122,10 @@ public:
         // process the send queue
         rc=zookeeper_interest(zh,&fd,&interest,&tv);
         CPPUNIT_ASSERT_EQUAL((int)ZOK,rc);
-        while((rc=zookeeper_process(zh,interest))==ZOK) millisleep(100); //printf("%d\n", rc);
+        while((rc=zookeeper_process(zh,interest))==ZOK) {
+          millisleep(100);
+          //printf("%d\n", rc);
+        }
         //printf("RC = %d", rc);
         CPPUNIT_ASSERT_EQUAL((int)ZNOTHING,rc);
 

+ 22 - 7
src/c/tests/TestWatchers.cc

@@ -21,6 +21,7 @@
 
 #include "ZKMocks.h"
 #include "CollectionUtil.h"
+#include "Util.h"
 
 class Zookeeper_watchers : public CPPUNIT_NS::TestFixture
 {
@@ -269,7 +270,9 @@ public:
         CPPUNIT_ASSERT_EQUAL((int)ZOK,rc);
         
         // this will process the response and activate the watcher
-        while((rc=zookeeper_process(zh,ZOOKEEPER_READ))==ZOK);
+        while((rc=zookeeper_process(zh,ZOOKEEPER_READ))==ZOK) {
+          millisleep(100);
+        }
         CPPUNIT_ASSERT_EQUAL((int)ZNOTHING,rc);
 
         // disconnect now
@@ -317,14 +320,18 @@ public:
         CPPUNIT_ASSERT_EQUAL((int)ZOK,rc);
         
         // this will process the response and activate the watcher
-        while((rc=zookeeper_process(zh,ZOOKEEPER_READ))==ZOK);
+        while((rc=zookeeper_process(zh,ZOOKEEPER_READ))==ZOK) {
+          millisleep(100);
+        }
         CPPUNIT_ASSERT_EQUAL((int)ZNOTHING,rc);
 
         // we are all set now; let's trigger the watches
         zkServer.addRecvResponse(new ZNodeEvent(ZOO_CHANGED_EVENT,"/a/b/c"));
         zkServer.addRecvResponse(new ZNodeEvent(ZOO_CHANGED_EVENT,"/x/y/z"));
         // make sure all watchers have been processed
-        while((rc=zookeeper_process(zh,ZOOKEEPER_READ))==ZOK);
+        while((rc=zookeeper_process(zh,ZOOKEEPER_READ))==ZOK) {
+          millisleep(100);
+        }
         CPPUNIT_ASSERT_EQUAL((int)ZNOTHING,rc);
         
         CPPUNIT_ASSERT_EQUAL(1,wobject1.counter_);
@@ -365,13 +372,17 @@ public:
         CPPUNIT_ASSERT_EQUAL((int)ZOK,rc);
         
         // this will process the response and activate the watcher
-        while((rc=zookeeper_process(zh,ZOOKEEPER_READ))==ZOK);
+        while((rc=zookeeper_process(zh,ZOOKEEPER_READ))==ZOK) {
+          millisleep(100);
+        }
         CPPUNIT_ASSERT_EQUAL((int)ZNOTHING,rc);
 
         // we are all set now; let's trigger the watches
         zkServer.addRecvResponse(new ZNodeEvent(ZOO_DELETED_EVENT,"/a"));
         // make sure the watchers have been processed
-        while((rc=zookeeper_process(zh,ZOOKEEPER_READ))==ZOK);
+        while((rc=zookeeper_process(zh,ZOOKEEPER_READ))==ZOK) {
+          millisleep(100);
+        }
         CPPUNIT_ASSERT_EQUAL((int)ZNOTHING,rc);
 
         CPPUNIT_ASSERT_EQUAL(1,wobject1.counter_);
@@ -411,13 +422,17 @@ public:
         CPPUNIT_ASSERT_EQUAL((int)ZOK,rc);
         
         // this will process the response and activate the watcher
-        while((rc=zookeeper_process(zh,ZOOKEEPER_READ))==ZOK);
+        while((rc=zookeeper_process(zh,ZOOKEEPER_READ))==ZOK) {
+          millisleep(100);
+        }
         CPPUNIT_ASSERT_EQUAL((int)ZNOTHING,rc);
 
         // we are all set now; let's trigger the watches
         zkServer.addRecvResponse(new ZNodeEvent(ZOO_CHILD_EVENT,"/a"));
         // make sure the watchers have been processed
-        while((rc=zookeeper_process(zh,ZOOKEEPER_READ))==ZOK);
+        while((rc=zookeeper_process(zh,ZOOKEEPER_READ))==ZOK) {
+          millisleep(100);
+        }
         CPPUNIT_ASSERT_EQUAL((int)ZNOTHING,rc);
 
         CPPUNIT_ASSERT_EQUAL(0,wobject1.counter_);