From commits-return-8676-archive-asf-public=cust-asf.ponee.io@kudu.apache.org Wed Mar 25 20:08:00 2020 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [207.244.88.153]) by mx-eu-01.ponee.io (Postfix) with SMTP id F095918063D for ; Wed, 25 Mar 2020 21:07:59 +0100 (CET) Received: (qmail 80527 invoked by uid 500); 25 Mar 2020 20:07:59 -0000 Mailing-List: contact commits-help@kudu.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@kudu.apache.org Delivered-To: mailing list commits@kudu.apache.org Received: (qmail 80517 invoked by uid 99); 25 Mar 2020 20:07:59 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 25 Mar 2020 20:07:59 +0000 Received: by gitbox.apache.org (ASF Mail Server at gitbox.apache.org, from userid 33) id 246E6819F7; Wed, 25 Mar 2020 20:07:59 +0000 (UTC) Date: Wed, 25 Mar 2020 20:07:59 +0000 To: "commits@kudu.apache.org" Subject: [kudu] branch master updated: [clock] hybrid_clock-test to run in different environments MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Message-ID: <158516687909.6069.3162536448429323289@gitbox.apache.org> From: adar@apache.org X-Git-Host: gitbox.apache.org X-Git-Repo: kudu X-Git-Refname: refs/heads/master X-Git-Reftype: branch X-Git-Oldrev: 11d6686432b7ce980310447f4b8e44150d3f6f93 X-Git-Newrev: 2612fc77bb4be1da0fba090e004217821e116a49 X-Git-Rev: 2612fc77bb4be1da0fba090e004217821e116a49 X-Git-NotificationType: ref_changed_plus_diff X-Git-Multimail-Version: 1.5.dev Auto-Submitted: auto-generated This is an automated email from the ASF dual-hosted git repository. adar pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/kudu.git The following commit(s) were added to refs/heads/master by this push: new 2612fc7 [clock] hybrid_clock-test to run in different environments 2612fc7 is described below commit 2612fc77bb4be1da0fba090e004217821e116a49 Author: Alexey Serbin AuthorDate: Tue Mar 24 15:09:05 2020 -0700 [clock] hybrid_clock-test to run in different environments This patch updates two scenarios of the hybrid_clock-test to make the suite pass if run under: * containerized environments where ntp_adjtime() requires extra privileges (e.g., Docker prior to v 18.06.0-ce) * environments where the local clock is not NTP-synchronized For the TimeSourceAutoSelection scenario, it's about adding pre-conditions for those two particular cases. If the pre-conditions are not satisfied, the scenario is skipped. For the TestNtpDiagnostics scenario, it turns out it's possible to amend it a bit to allow for running in the environments referred above. Change-Id: Id5cee9f4a32c18c50fe54c01c7ed81c7e93c5fa7 Reviewed-on: http://gerrit.cloudera.org:8080/15551 Tested-by: Kudu Jenkins Reviewed-by: Grant Henke Reviewed-by: Adar Dembo --- src/kudu/clock/hybrid_clock-test.cc | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/src/kudu/clock/hybrid_clock-test.cc b/src/kudu/clock/hybrid_clock-test.cc index 80b1d57..3a94fdd 100644 --- a/src/kudu/clock/hybrid_clock-test.cc +++ b/src/kudu/clock/hybrid_clock-test.cc @@ -19,6 +19,7 @@ #include #include +#include #include #include #include @@ -465,7 +466,30 @@ TEST_F(HybridClockTest, SlowClockInitialisation) { TEST_F(HybridClockTest, TimeSourceAutoSelection) { FLAGS_time_source = "auto"; HybridClock clock(metric_entity_); - ASSERT_OK(clock.Init()); + const auto s = clock.Init(); + bool preconditions_satisfied = true; + if (!s.ok()) { + // In a testing environment where the auto-detected time source is 'system' + // (the local machine clock synchronized by the kernel NTP discipline), + // it doesn't make much sense running the test if corresponding system calls + // return an error (e.g., EPERM) or the clock is not synchronized. + // The code below is for a few cases like that: it's a set of cases seen + // so far in the wild. + if (s.IsRuntimeError()) { + 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"); + preconditions_satisfied = false; + } + } + if (!preconditions_satisfied) { + LOG(WARNING) << "preconditions are not satisfied, skipping the test"; + return; + } + + ASSERT_OK(s); Timestamp timestamp[2]; uint64_t max_error_usec[2]; ASSERT_OK(clock.NowWithError(×tamp[0], &max_error_usec[0])); @@ -477,7 +501,11 @@ TEST_F(HybridClockTest, TimeSourceAutoSelection) { TEST_F(HybridClockTest, TestNtpDiagnostics) { FLAGS_time_source = "system"; HybridClock clock(metric_entity_); - ASSERT_OK(clock.Init()); + + // Even if HybridClock's initialization failed, the point of this scenario + // is to verify that diagnostics run appropriate tools. By design, the set + // of tools run these purposes doesn't depend on the initialization status. + WARN_NOT_OK(clock.Init(), "clock initialization failed"); vector log; clock.time_service()->DumpDiagnostics(&log);