You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kudu.apache.org by al...@apache.org on 2017/11/08 18:35:15 UTC
kudu git commit: [hybrid_clock-test] adapt the test for OS X
Repository: kudu
Updated Branches:
refs/heads/master 9748fd2c8 -> 28fdec405
[hybrid_clock-test] adapt the test for OS X
Fixed linkage breakage on OS X: adapted the hybrid_clock-test for OS X.
Change-Id: I50a4b139eb6b0b5c79bce48eedb24bc7c445970c
Reviewed-on: http://gerrit.cloudera.org:8080/8488
Tested-by: Alexey Serbin <as...@cloudera.com>
Reviewed-by: Todd Lipcon <to...@apache.org>
Reviewed-by: Dan Burkert <da...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/kudu/repo
Commit: http://git-wip-us.apache.org/repos/asf/kudu/commit/28fdec40
Tree: http://git-wip-us.apache.org/repos/asf/kudu/tree/28fdec40
Diff: http://git-wip-us.apache.org/repos/asf/kudu/diff/28fdec40
Branch: refs/heads/master
Commit: 28fdec4053c86f08f410d0ef460e4c82a78f9e1c
Parents: 9748fd2
Author: Alexey Serbin <as...@cloudera.com>
Authored: Mon Nov 6 19:08:57 2017 -0800
Committer: Alexey Serbin <as...@cloudera.com>
Committed: Wed Nov 8 18:34:40 2017 +0000
----------------------------------------------------------------------
src/kudu/clock/hybrid_clock-test.cc | 8 +++-----
src/kudu/clock/system_ntp.cc | 9 +++------
src/kudu/clock/system_unsync_time.cc | 14 ++++++++++++++
3 files changed, 20 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/kudu/blob/28fdec40/src/kudu/clock/hybrid_clock-test.cc
----------------------------------------------------------------------
diff --git a/src/kudu/clock/hybrid_clock-test.cc b/src/kudu/clock/hybrid_clock-test.cc
index 0524a84..8857b32 100644
--- a/src/kudu/clock/hybrid_clock-test.cc
+++ b/src/kudu/clock/hybrid_clock-test.cc
@@ -41,7 +41,7 @@
#include "kudu/util/test_util.h"
#include "kudu/util/thread.h"
-DECLARE_bool(inject_adjtimex_errors);
+DECLARE_bool(inject_unsync_time_errors);
DECLARE_string(time_source);
namespace kudu {
@@ -310,7 +310,6 @@ TEST_F(HybridClockTest, TestGetPhysicalComponentDifference) {
ASSERT_EQ(-100, negative_delta.ToMicroseconds());
}
-
TEST_F(HybridClockTest, TestRideOverNtpInterruption) {
Timestamp timestamps[3];
uint64_t max_error_usec[3];
@@ -321,7 +320,7 @@ TEST_F(HybridClockTest, TestRideOverNtpInterruption) {
// Try to read the clock again a second later, but with an error
// injected. It should extrapolate from the first read.
SleepFor(MonoDelta::FromSeconds(1));
- FLAGS_inject_adjtimex_errors = true;
+ FLAGS_inject_unsync_time_errors = true;
clock_->NowWithError(×tamps[1], &max_error_usec[1]);
// The new clock reading should be a second or longer from the
@@ -339,13 +338,12 @@ TEST_F(HybridClockTest, TestRideOverNtpInterruption) {
// Now restore the ability to read the system clock, and
// read it again.
- FLAGS_inject_adjtimex_errors = false;
+ FLAGS_inject_unsync_time_errors = false;
clock_->NowWithError(×tamps[2], &max_error_usec[2]);
ASSERT_LT(timestamps[0].ToUint64(), timestamps[1].ToUint64());
ASSERT_LT(timestamps[1].ToUint64(), timestamps[2].ToUint64());
}
-
} // namespace clock
} // namespace kudu
http://git-wip-us.apache.org/repos/asf/kudu/blob/28fdec40/src/kudu/clock/system_ntp.cc
----------------------------------------------------------------------
diff --git a/src/kudu/clock/system_ntp.cc b/src/kudu/clock/system_ntp.cc
index ff2c2a6..770a3fa 100644
--- a/src/kudu/clock/system_ntp.cc
+++ b/src/kudu/clock/system_ntp.cc
@@ -23,18 +23,15 @@
#include <cerrno>
#include <ostream>
-#include <gflags/gflags.h>
+#include <gflags/gflags_declare.h>
#include <glog/logging.h>
#include "kudu/gutil/port.h"
#include "kudu/util/errno.h"
-#include "kudu/util/flag_tags.h"
#include "kudu/util/logging.h"
#include "kudu/util/status.h"
-DEFINE_bool(inject_adjtimex_errors, false,
- "If true, will return a fake 'unsynchronized' status from NTP.");
-TAG_FLAG(inject_adjtimex_errors, unsafe);
+DECLARE_bool(inject_unsync_time_errors);
namespace kudu {
namespace clock {
@@ -49,7 +46,7 @@ Status CallAdjTime(timex* tx) {
// Set mode to 0 to query the current time.
tx->modes = 0;
int rc = ntp_adjtime(tx);
- if (PREDICT_FALSE(FLAGS_inject_adjtimex_errors)) {
+ if (PREDICT_FALSE(FLAGS_inject_unsync_time_errors)) {
rc = TIME_ERROR;
}
switch (rc) {
http://git-wip-us.apache.org/repos/asf/kudu/blob/28fdec40/src/kudu/clock/system_unsync_time.cc
----------------------------------------------------------------------
diff --git a/src/kudu/clock/system_unsync_time.cc b/src/kudu/clock/system_unsync_time.cc
index 453a2b2..12da925 100644
--- a/src/kudu/clock/system_unsync_time.cc
+++ b/src/kudu/clock/system_unsync_time.cc
@@ -19,9 +19,17 @@
#include <ostream>
+#include <gflags/gflags.h>
#include <glog/logging.h>
+#include "kudu/gutil/port.h"
#include "kudu/gutil/walltime.h"
+#include "kudu/util/flag_tags.h"
+
+DEFINE_bool(inject_unsync_time_errors, false,
+ "If true, both Init() and WalltimeWithError() return "
+ "'clock considered unsynchronized' error.");
+TAG_FLAG(inject_unsync_time_errors, unsafe);
namespace kudu {
namespace clock {
@@ -30,10 +38,16 @@ Status SystemUnsyncTime::Init() {
LOG(WARNING) << "NTP support is disabled. Clock error bounds will not "
<< "be accurate. This configuration is not suitable for "
<< "distributed clusters.";
+ if (PREDICT_FALSE(FLAGS_inject_unsync_time_errors)) {
+ return Status::ServiceUnavailable("Error reading clock. Clock considered unsynchronized");
+ }
return Status::OK();
}
Status SystemUnsyncTime::WalltimeWithError(uint64_t* now_usec, uint64_t* error_usec) {
+ if (PREDICT_FALSE(FLAGS_inject_unsync_time_errors)) {
+ return Status::ServiceUnavailable("Error reading clock. Clock considered unsynchronized");
+ }
*now_usec = GetCurrentTimeMicros();
*error_usec = 0;
return Status::OK();