MB-23990: Fix intermittent hangs in unit test 08/78508/3
authorPremkumar Thangamani <premkumar.thangamani@couchbase.com>
Wed, 24 May 2017 02:28:14 +0000 (19:28 -0700)
committerTrond Norbye <trond.norbye@gmail.com>
Wed, 24 May 2017 22:07:46 +0000 (22:07 +0000)
In some scenarios, the io complete notification reached before we start
waiting for it via the condition variable. This results in the test
hanging forever. Now we track the no.of notifications and wait
accordingly

Change-Id: Id9d9404892e111d7d60760d0e9ce727b474c0997
Reviewed-on: http://review.couchbase.org/78508
Reviewed-by: Dave Rigby <daver@couchbase.com>
Tested-by: Build Bot <build@couchbase.com>
tests/ep_testsuite_dcp.cc

index 20b3293..ea83f3c 100644 (file)
@@ -952,6 +952,9 @@ static void dcp_waiting_step(ENGINE_HANDLE *h, ENGINE_HANDLE_V1 *h1,
     bool pending_marker_ack = false;
     uint64_t marker_end = 0;
     uint64_t num_mutations = 0;
+    uint64_t num_io_processed = 0;
+    struct mock_connstruct* c = nullptr;
+
     std::unique_ptr<dcp_message_producers> producers(get_dcp_producers(h, h1));
 
     do {
@@ -999,7 +1002,11 @@ static void dcp_waiting_step(ENGINE_HANDLE *h, ENGINE_HANDLE_V1 *h1,
                        the api expects the cookie to be locked before
                        calling it */
                     wait_started = true;
-                    testHarness.waitfor_cookie(cookie);
+                    c = (struct mock_connstruct*)cookie;
+                    if (num_io_processed == c->num_io_notifications) {
+                        testHarness.waitfor_cookie(cookie);
+                    }
+                    num_io_processed = c->num_io_notifications;
                     testHarness.unlock_cookie(cookie);
                     break;
                 default: