MB-22235: Drift thresholds don't get updated from set_param 00/72100/3
authorJim Walker <jim@couchbase.com>
Mon, 9 Jan 2017 14:13:39 +0000 (14:13 +0000)
committerDave Rigby <daver@couchbase.com>
Tue, 17 Jan 2017 09:12:14 +0000 (09:12 +0000)
Need to plug the change value listener into the bucket config
object.

Test updated to look at the vbucket's threshold values

Change-Id: Id515d71fe551474e93ff5113148ff8411ed739fb
Reviewed-on: http://review.couchbase.org/72100
Well-Formed: buildbot <build@couchbase.com>
Tested-by: buildbot <build@couchbase.com>
Reviewed-by: Dave Rigby <daver@couchbase.com>
src/vbucketmap.cc
tests/ep_testsuite_xdcr.cc

index f388481..db91f19 100644 (file)
@@ -41,6 +41,11 @@ VBucketMap::VBucketMap(Configuration &config,
         bucketCreation[i].store(false);
         persistenceSeqnos[i].store(0);
     }
+
+    config.addValueChangedListener("hlc_drift_ahead_threshold_us",
+                                    new VBucketConfigChangeListener(*this));
+    config.addValueChangedListener("hlc_drift_behind_threshold_us",
+                                    new VBucketConfigChangeListener(*this));
 }
 
 VBucketMap::~VBucketMap() {
index e223691..cc3702a 100644 (file)
@@ -1785,23 +1785,36 @@ static enum test_result test_del_with_meta_and_check_drift_stats(ENGINE_HANDLE *
 
 static enum test_result test_setting_drift_threshold(ENGINE_HANDLE *h, ENGINE_HANDLE_V1 *h1) {
 
-    std::vector<std::pair<std::string, std::string> > configData =
-        {{"ep_hlc_drift_ahead_threshold_us", "hlc_drift_ahead_threshold_us"},
-         {"ep_hlc_drift_behind_threshold_us", "hlc_drift_behind_threshold_us"}};
-
-    std::vector<std::pair<std::string, uint64_t> > values =
-        {{"0", 0}, {"1", 1}, {"-1", -1}, {"-0", 0},
-         {"18446744073709551615", 18446744073709551615ull}};
+    std::vector<std::tuple<std::string, std::string, std::string> > configData =
+        {std::make_tuple("ep_hlc_drift_ahead_threshold_us",
+                         "hlc_drift_ahead_threshold_us",
+                         "vb_0:drift_ahead_threshold"),
+         std::make_tuple("ep_hlc_drift_behind_threshold_us",
+                         "hlc_drift_behind_threshold_us",
+                         "vb_0:drift_behind_threshold")};
+
+    std::vector<std::pair<std::string, std::chrono::microseconds> > values = {
+        {"0", std::chrono::microseconds(0)},
+        {"1", std::chrono::microseconds(1)},
+        {"-1", std::chrono::microseconds(-1)},
+        {"-0", std::chrono::microseconds(0)},
+        {"18446744073709551615",
+         std::chrono::microseconds(18446744073709551615ull)}};
 
     for (auto data : values) {
         for (auto conf : configData) {
             check(set_param(h, h1, protocol_binary_engine_param_vbucket,
-                    conf.second.data(), data.first.data()),
+                     std::get<1>(conf).c_str(), data.first.data()),
                 "Expected set_param success");
 
-            checkeq(data.second,
-                    get_ull_stat(h, h1, conf.first.data(), nullptr),
+            checkeq(data.second.count(),
+                    int64_t(get_ull_stat(h, h1, std::get<0>(conf).c_str(), nullptr)),
                     "Expected the stat to change to the new value");
+
+            // The VB stat values are in nanoseconds
+            checkeq(std::chrono::nanoseconds(data.second).count(),
+                    int64_t(get_ull_stat(h, h1, std::get<2>(conf).c_str(), "vbucket-details 0")),
+                    "Expected the VB stats to change to the new value");
         }
     }
     return SUCCESS;