浏览代码

ZOOKEEPER-211 Not all Mock tests are working

git-svn-id: https://svn.apache.org/repos/asf/hadoop/zookeeper/trunk@718832 13f79535-47bb-0310-9956-ffa450edef68
Patrick D. Hunt 16 年之前
父节点
当前提交
4a9ba5da6e
共有 5 个文件被更改,包括 29 次插入15 次删除
  1. 7 5
      CHANGES.txt
  2. 10 3
      src/c/tests/TestOperations.cc
  3. 2 2
      src/c/tests/TestWatchers.cc
  4. 1 1
      src/c/tests/TestZookeeperClose.cc
  5. 9 4
      src/c/tests/ZKMocks.cc

+ 7 - 5
CHANGES.txt

@@ -5,16 +5,18 @@ Non-backward compatible changes:
 Backward compatibile changes:
 
 BUGFIXES: 
-   ZOOKEEPER-223. change default level in root logger to INFO. (pat via
-mahadev) 
+   ZOOKEEPER-211 Not all Mock tests are working (ben via phunt)
+
+   ZOOKEEPER-223. change default level in root logger to INFO.
+   (pat via mahadev) 
    
    ZOOKEEPER-212. fix the snapshot to be asynchronous. (mahadev and ben)
 
    ZOOKEEPER-213. fix programmer guide C api docs to be  in sync with latest
-zookeeper.h (pat via mahadev)
+   zookeeper.h (pat via mahadev)
 
-   ZOOKEEPER-219. fix events.poll timeout in watcher test to be longer. (pat
-via mahadev)
+   ZOOKEEPER-219. fix events.poll timeout in watcher test to be longer.
+   (pat via mahadev)
    
    ZOOKEEPER-217. Fix errors in config to be thrown as Exceptions. (mahadev)
 

+ 10 - 3
src/c/tests/TestOperations.cc

@@ -32,10 +32,10 @@ class Zookeeper_operations : public CPPUNIT_NS::TestFixture
     CPPUNIT_TEST(testTimeoutCausedByWatches1);
     CPPUNIT_TEST(testTimeoutCausedByWatches2);
 #else    
-    //CPPUNIT_TEST(testAsyncWatcher1);
+    CPPUNIT_TEST(testAsyncWatcher1);
     CPPUNIT_TEST(testAsyncGetOperation);
 #endif
-    //CPPUNIT_TEST(testOperationsAndDisconnectConcurrently1);
+    CPPUNIT_TEST(testOperationsAndDisconnectConcurrently1);
     CPPUNIT_TEST(testOperationsAndDisconnectConcurrently2);
     CPPUNIT_TEST(testConcurrentOperations1);
     CPPUNIT_TEST_SUITE_END();
@@ -380,6 +380,12 @@ public:
             for(i=0;i<reps_;i++){
                 char buf;
                 int size=sizeof(buf);
+
+                if (i % 10 == 0) {
+                    // We need to pause every once in a while so we don't
+                    // get too far ahead and finish before the disconnect
+	            millisleep(1);
+                }
                 svr_->addOperationResponse(new ZooGetResponse("1",1));
                 rc_=zoo_get(zh_,"/x/y/z",0,&buf,&size,0);
                 if(rc_!=ZOK){
@@ -535,7 +541,8 @@ public:
             
             TestJobManager jmgr(TestConcurrentOpWithDisconnectJob(&zkServer,zh),10);
             jmgr.startJobsImmediately();
-            millisleep(1);
+            // let everything startup before we shutdown the server
+            millisleep(4);
             // reconnect attempts will start failing immediately 
             zkServer.setServerDown(0);
             // next recv call will return 0

+ 2 - 2
src/c/tests/TestWatchers.cc

@@ -27,11 +27,11 @@ class Zookeeper_watchers : public CPPUNIT_NS::TestFixture
     CPPUNIT_TEST_SUITE(Zookeeper_watchers);
     CPPUNIT_TEST(testDefaultSessionWatcher1);
     CPPUNIT_TEST(testDefaultSessionWatcher2);
-    //CPPUNIT_TEST(testObjectSessionWatcher1);
+    CPPUNIT_TEST(testObjectSessionWatcher1);
     CPPUNIT_TEST(testObjectSessionWatcher2);
     CPPUNIT_TEST(testNodeWatcher1);
     CPPUNIT_TEST(testChildWatcher1);
-    //CPPUNIT_TEST(testChildWatcher2);
+    CPPUNIT_TEST(testChildWatcher2);
     CPPUNIT_TEST_SUITE_END();
 
     static void watcher(zhandle_t *, int, int, const char *,void*){}

+ 1 - 1
src/c/tests/TestZookeeperClose.cc

@@ -34,7 +34,7 @@ class Zookeeper_close : public CPPUNIT_NS::TestFixture
 #endif
     CPPUNIT_TEST(testCloseUnconnected);
     CPPUNIT_TEST(testCloseUnconnected1);
-    //CPPUNIT_TEST(testCloseConnected1);
+    CPPUNIT_TEST(testCloseConnected1);
     CPPUNIT_TEST(testCloseFromWatcher1);
     CPPUNIT_TEST_SUITE_END();
     zhandle_t *zh;

+ 9 - 4
src/c/tests/ZKMocks.cc

@@ -468,9 +468,6 @@ void ZookeeperServer::notifyBufferSent(const std::string& buffer){
             int64_t sessId=sessionExpired?req->sessionId+1:req->sessionId;
             sessionExpired=false;
             addRecvResponse(new HandshakeResponse(sessId));            
-            Element e = Element(new ZooStatResponse,0);
-            e.first->setXID(-8);
-            addRecvResponse(e);
             return;
         }
         // not a connect request -- fall thru
@@ -480,7 +477,15 @@ void ZookeeperServer::notifyBufferSent(const std::string& buffer){
     RequestHeader rh;
     deserialize_RequestHeader(ia,"hdr",&rh);
     // notify the "server" a client request has arrived
-    onMessageReceived(rh,ia);
+    if (rh.xid == -8) {
+        Element e = Element(new ZooStatResponse,0);
+        e.first->setXID(-8);
+        addRecvResponse(e);
+        close_buffer_iarchive(&ia);
+        return;
+    } else {
+        onMessageReceived(rh,ia);
+    }
     close_buffer_iarchive(&ia);
     if(rh.type==CLOSE_OP){
         ++closeSent;