MB-21534: test_access_scanner - handle clock wraparound 64/69364/3
authorDave Rigby <daver@couchbase.com>
Tue, 1 Nov 2016 11:40:06 +0000 (11:40 +0000)
committerDave Rigby <daver@couchbase.com>
Wed, 2 Nov 2016 14:59:26 +0000 (14:59 +0000)
test_access_scanner attempts to set the access log scanner runtime to
two hours in the future; however it doesn't check for wraparound
midnight.

Change-Id: I2851331a31773fe32221f3cf266f770f1ebefbaf
Reviewed-on: http://review.couchbase.org/69364
Reviewed-by: Trond Norbye <trond.norbye@gmail.com>
Tested-by: buildbot <build@couchbase.com>
tests/ep_testsuite.cc

index c073d74..5468006 100644 (file)
@@ -2765,10 +2765,11 @@ static enum test_result test_access_scanner(ENGINE_HANDLE *h,
     const time_t now = time(nullptr);
     struct tm tm_now;
     cb_gmtime_r(&now, &tm_now);
+    const auto two_hours_hence = (tm_now.tm_hour + 2) % 24;
 
     set_param(h, h1, protocol_binary_engine_param_flush, "alog_task_time",
-              (std::to_string(tm_now.tm_hour + 2)).c_str());
-    wait_for_stat_to_be(h, h1, "ep_alog_task_time", tm_now.tm_hour + 2);
+              std::to_string(two_hours_hence).c_str());
+    wait_for_stat_to_be(h, h1, "ep_alog_task_time", two_hours_hence);
 
     testHarness.reload_engine(&h, &h1,
                               testHarness.engine_path,