wait_for_flusher_to_settle: Use wait_for_stat_to_be() 11/69011/5
authorDave Rigby <daver@couchbase.com>
Fri, 14 Oct 2016 16:04:34 +0000 (17:04 +0100)
committerDave Rigby <daver@couchbase.com>
Mon, 31 Oct 2016 14:49:40 +0000 (14:49 +0000)
wait_for_stat_to_be() records the last value (in current) which makes
it easier to debug issues when values arn't as expected. Additionally
this simplifies the code in wait_for_flusher_to_settle.

Change-Id: I601ab4e8b605c937a86b802746cad691ac659308
Reviewed-on: http://review.couchbase.org/69011
Tested-by: buildbot <build@couchbase.com>
Reviewed-by: Daniel Owen <owend@couchbase.com>
Reviewed-by: Trond Norbye <trond.norbye@gmail.com>
tests/ep_test_apis.cc

index 14ef0a9..41eab2d 100644 (file)
@@ -1365,21 +1365,15 @@ bool wait_for_warmup_complete(ENGINE_HANDLE *h, ENGINE_HANDLE_V1 *h1) {
 }
 
 void wait_for_flusher_to_settle(ENGINE_HANDLE *h, ENGINE_HANDLE_V1 *h1) {
-    const useconds_t initial_sleepTime = 128;
-    useconds_t sleepTime = initial_sleepTime;
-    while (get_int_stat(h, h1, "ep_queue_size") > 0) {
-        decayingSleep(&sleepTime);
-    }
+
+    wait_for_stat_to_be(h, h1, "ep_queue_size", 0);
 
     // We also need to to wait for any outstanding flushes to disk to
     // complete - specifically so when in full eviction mode we have
     // waited for the item counts in each vBucket to be synced with
     // the number of items on disk. See
     // EventuallyPersistentStore::commit().
-    sleepTime = initial_sleepTime;
-    while (get_int_stat(h, h1, "ep_flusher_todo") > 0) {
-        decayingSleep(&sleepTime);
-    }
+    wait_for_stat_to_be(h, h1, "ep_flusher_todo", 0);
 }
 
 void wait_for_rollback_to_finish(ENGINE_HANDLE *h, ENGINE_HANDLE_V1 *h1) {