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 2021/02/26 22:14:06 UTC

[kudu] branch master updated: [client-test] more robust TestRetrieveAuthzTokenInParallel

This is an automated email from the ASF dual-hosted git repository.

alexey 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 38bad95  [client-test] more robust TestRetrieveAuthzTokenInParallel
38bad95 is described below

commit 38bad954c2d903a8a61ddd728f8c58dc00412925
Author: Alexey Serbin <al...@apache.org>
AuthorDate: Thu Feb 25 19:30:01 2021 -0800

    [client-test] more robust TestRetrieveAuthzTokenInParallel
    
    I saw a flakiness in the ClientTest.TestRetrieveAuthzTokenInParallel
    scenario, where about 25 out of 256 runs failed when running with
    --stress_cpu_threads=16:
    
      src/kudu/client/client-test.cc:6923: Failure
      Expected: (num_reqs) < (kThreads), actual: 21 vs 20
    
    This patch addresses the issue by:
      * skipping the scenario when --stress_cpu_threads is not zero
      * skipping the scenario when running at single-core CPU machines
      * limiting the number of threads up to the number of CPU cores
    
    Change-Id: I0afa5ae72ccb96a218b6c6ff026ad88a70dea4f7
    Reviewed-on: http://gerrit.cloudera.org:8080/17128
    Tested-by: Alexey Serbin <as...@cloudera.com>
    Reviewed-by: Hao Hao <ha...@cloudera.com>
    Reviewed-by: Andrew Wong <aw...@cloudera.com>
---
 src/kudu/client/client-test.cc | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/src/kudu/client/client-test.cc b/src/kudu/client/client-test.cc
index ff4ca1f..b844ec9 100644
--- a/src/kudu/client/client-test.cc
+++ b/src/kudu/client/client-test.cc
@@ -86,6 +86,7 @@
 #include "kudu/gutil/stringprintf.h"
 #include "kudu/gutil/strings/join.h"
 #include "kudu/gutil/strings/substitute.h"
+#include "kudu/gutil/sysinfo.h"
 #include "kudu/integration-tests/cluster_itest_util.h"
 #include "kudu/integration-tests/data_gen_util.h"
 #include "kudu/master/catalog_manager.h"
@@ -165,6 +166,7 @@ DECLARE_int32(scanner_gc_check_interval_us);
 DECLARE_int32(scanner_inject_latency_on_each_batch_ms);
 DECLARE_int32(scanner_max_batch_size_bytes);
 DECLARE_int32(scanner_ttl_ms);
+DECLARE_int32(stress_cpu_threads);
 DECLARE_int32(table_locations_ttl_ms);
 DECLARE_int32(txn_status_manager_inject_latency_load_from_tablet_ms);
 DECLARE_int64(live_row_count_for_testing);
@@ -6908,16 +6910,26 @@ TEST_F(ClientTest, TestCacheAuthzTokens) {
 // Test to ensure that we don't send calls to retrieve authz tokens when one is
 // already in-flight for the same table ID.
 TEST_F(ClientTest, TestRetrieveAuthzTokenInParallel) {
-  const int kThreads = 20;
+  const auto kThreads = base::NumCPUs();
+  if (kThreads < 2) {
+    LOG(WARNING) << "no sense to run at a single CPU core";
+    GTEST_SKIP();
+  }
+  if (FLAGS_stress_cpu_threads > 0) {
+    LOG(WARNING) << "test is not designed to run with --stress_cpu_threads";
+    GTEST_SKIP();
+  }
+
   const MonoDelta kTimeout = MonoDelta::FromSeconds(30);
   vector<Synchronizer> syncs(kThreads);
   vector<thread> threads;
   Barrier barrier(kThreads);
+  const auto deadline = MonoTime::Now() + kTimeout;
   for (auto& s : syncs) {
     threads.emplace_back([&] {
       barrier.Wait();
-      client_->data_->RetrieveAuthzTokenAsync(client_table_.get(), s.AsStatusCallback(),
-                                              MonoTime::Now() + kTimeout);
+      client_->data_->RetrieveAuthzTokenAsync(
+          client_table_.get(), s.AsStatusCallback(), deadline);
     });
   }
   for (int i = 0 ; i < kThreads; i++) {