MB-21867: test_item_pager: Retry on ENOMEM when fetching items 15/70515/2
authorDave Rigby <daver@couchbase.com>
Thu, 1 Dec 2016 16:24:51 +0000 (16:24 +0000)
committerDave Rigby <daver@couchbase.com>
Mon, 5 Dec 2016 11:47:25 +0000 (11:47 +0000)
Change-Id: I9031ca1ff51aed609144ccf141897354138c2f88
Reviewed-on: http://review.couchbase.org/70515
Tested-by: buildbot <build@couchbase.com>
Reviewed-by: Daniel Owen <owend@couchbase.com>
tests/ep_testsuite.cc

index 86a0dbf..69b965f 100644 (file)
@@ -4612,9 +4612,15 @@ static enum test_result test_item_pager(ENGINE_HANDLE *h, ENGINE_HANDLE_V1 *h1)
         std::string key(ss.str());
 
         item *i;
-        checkeq(ENGINE_SUCCESS,
-                h1->get(h, NULL, &i, key.c_str(), key.length(), 0),
-                "Failed to get value.");
+        // Given we're in a high watermark scenario, may (temporarily) fail
+        // to allocate memory for the response, so retry in that case.
+        ENGINE_ERROR_CODE result;
+        do {
+            result = h1->get(h, nullptr, &i, key.c_str(), key.length(), 0);
+        } while (result == ENGINE_ENOMEM);
+
+        checkeq(ENGINE_SUCCESS, result,
+                "Failed to get value after hitting high watermark.");
         h1->release(h, NULL, i);
     }