Skip to content

Commit

Permalink
[clock] fix HybridClockTest.TimeSourceAutoSelection
Browse files Browse the repository at this point in the history
It was reported that HybridClockTest.TimeSourceAutoSelection scenario
had failed with the following message:

  src/kudu/clock/hybrid_clock-test.cc:501: Failure
  Value of: s.ToString()
  Expected: has substring "Error reading clock. Clock considered unsynchronized"
  Actual: "Service unavailable: timed out waiting for clock synchronisation: wallclock is not synchronized: no valid NTP responses yet" (of type std::string)

This patch addresses the issue, updating the pattern of the expected
error message to account for the string output by the built-in NTP
clock as well.

Change-Id: Ie30ca383f50db1f62e140da5181e9a406367f7bd
Reviewed-on: http://gerrit.cloudera.org:8080/20324
Tested-by: Alexey Serbin <alexey@apache.org>
Reviewed-by: Mahesh Reddy <mreddy@cloudera.com>
Reviewed-by: Yifan Zhang <chinazhangyifan@163.com>
(cherry picked from commit ebf0a64)
Reviewed-on: http://gerrit.cloudera.org:8080/20335
Tested-by: Yingchun Lai <laiyingchun@apache.org>
  • Loading branch information
alexeyserbin committed Aug 9, 2023
1 parent 34243b3 commit b3fe319
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/kudu/clock/hybrid_clock-test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -497,8 +497,15 @@ TEST_F(HybridClockTest, TimeSourceAutoSelection) {
ASSERT_STR_CONTAINS(s.ToString(), "Operation not permitted");
preconditions_satisfied = false;
} else if (s.IsServiceUnavailable()) {
ASSERT_STR_CONTAINS(
s.ToString(), "Error reading clock. Clock considered unsynchronized");
// For the effective time source auto-selected, the pattern for the error
// message below covers the 'builtin' and the 'system' cases
// correspondingly. The only other possible case left is 'system_unsync':
// if the 'system_unsync' time source is auto-selected, there shouldn't be
// any clock synchronization error unless the --inject_unsync_time_errors
// flag is set to 'true', which isn't the case in this test scenario.
static const string kErrMsgPattern = "(wallclock is not synchronized|"
"Error reading clock\\. Clock considered unsynchronized)";
ASSERT_STR_MATCHES(s.ToString(), kErrMsgPattern);
preconditions_satisfied = false;
}
}
Expand Down

0 comments on commit b3fe319

Please sign in to comment.