You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kudu.apache.org by mp...@apache.org on 2016/12/06 17:02:17 UTC

kudu git commit: [ExternalMiniClusterITestBase] move some methods into .cc

Repository: kudu
Updated Branches:
  refs/heads/master 881cc8e98 -> 7959c7af7


[ExternalMiniClusterITestBase] move some methods into .cc

Separated implementation of the external mini-cluster methods into a
separate .cc file: those methods contain too much code to be candidates
for inlining.  Besides, this helps to have less header-wise dependencies
and avoid clang-tidy warnings like

  warning: function 'StopCluster' defined in a header file; function
    definitions in header files can lead to ODR violations
    [misc-definitions-in-headers]

This patch does not contain any functional changes.

Change-Id: I4e69794502d31dc43cc2eba6870c01c828b14da3
Reviewed-on: http://gerrit.cloudera.org:8080/5367
Reviewed-by: Mike Percy <mp...@apache.org>
Tested-by: Kudu Jenkins


Project: http://git-wip-us.apache.org/repos/asf/kudu/repo
Commit: http://git-wip-us.apache.org/repos/asf/kudu/commit/7959c7af
Tree: http://git-wip-us.apache.org/repos/asf/kudu/tree/7959c7af
Diff: http://git-wip-us.apache.org/repos/asf/kudu/diff/7959c7af

Branch: refs/heads/master
Commit: 7959c7af7032249755c9331892330f59e6b89faf
Parents: 881cc8e
Author: Alexey Serbin <as...@cloudera.com>
Authored: Mon Dec 5 15:05:48 2016 -0800
Committer: Mike Percy <mp...@apache.org>
Committed: Tue Dec 6 17:02:02 2016 +0000

----------------------------------------------------------------------
 src/kudu/integration-tests/CMakeLists.txt       |  1 +
 .../integration-tests/client_failover-itest.cc  |  1 +
 .../integration-tests/create-table-itest.cc     | 10 ++-
 src/kudu/integration-tests/delete_table-test.cc |  4 +
 .../external_mini_cluster-itest-base.cc         | 80 ++++++++++++++++++++
 .../external_mini_cluster-itest-base.h          | 67 ++++------------
 .../tablet_replacement-itest.cc                 |  2 +
 7 files changed, 111 insertions(+), 54 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kudu/blob/7959c7af/src/kudu/integration-tests/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/src/kudu/integration-tests/CMakeLists.txt b/src/kudu/integration-tests/CMakeLists.txt
index 113edf9..5f7671d 100644
--- a/src/kudu/integration-tests/CMakeLists.txt
+++ b/src/kudu/integration-tests/CMakeLists.txt
@@ -18,6 +18,7 @@
 set(INTEGRATION_TESTS_SRCS
   cluster_itest_util.cc
   cluster_verifier.cc
+  external_mini_cluster-itest-base.cc
   external_mini_cluster.cc
   external_mini_cluster_fs_inspector.cc
   log_verifier.cc

http://git-wip-us.apache.org/repos/asf/kudu/blob/7959c7af/src/kudu/integration-tests/client_failover-itest.cc
----------------------------------------------------------------------
diff --git a/src/kudu/integration-tests/client_failover-itest.cc b/src/kudu/integration-tests/client_failover-itest.cc
index 5a275f2..0066d2f 100644
--- a/src/kudu/integration-tests/client_failover-itest.cc
+++ b/src/kudu/integration-tests/client_failover-itest.cc
@@ -23,6 +23,7 @@
 #include "kudu/client/client-test-util.h"
 #include "kudu/common/wire_protocol.h"
 #include "kudu/gutil/map-util.h"
+#include "kudu/integration-tests/cluster_itest_util.h"
 #include "kudu/integration-tests/external_mini_cluster-itest-base.h"
 #include "kudu/integration-tests/test_workload.h"
 

http://git-wip-us.apache.org/repos/asf/kudu/blob/7959c7af/src/kudu/integration-tests/create-table-itest.cc
----------------------------------------------------------------------
diff --git a/src/kudu/integration-tests/create-table-itest.cc b/src/kudu/integration-tests/create-table-itest.cc
index 18ca093..81c1f7f 100644
--- a/src/kudu/integration-tests/create-table-itest.cc
+++ b/src/kudu/integration-tests/create-table-itest.cc
@@ -15,17 +15,21 @@
 // specific language governing permissions and limitations
 // under the License.
 
-#include <gflags/gflags.h>
-#include <glog/stl_logging.h>
-#include <gtest/gtest.h>
 #include <map>
 #include <memory>
 #include <set>
 #include <string>
 
+#include <gflags/gflags.h>
+#include <glog/stl_logging.h>
+#include <gtest/gtest.h>
+
 #include "kudu/client/client-test-util.h"
 #include "kudu/common/wire_protocol-test-util.h"
 #include "kudu/integration-tests/external_mini_cluster-itest-base.h"
+#include "kudu/master/master.pb.h"
+#include "kudu/master/master.proxy.h"
+#include "kudu/rpc/rpc_controller.h"
 #include "kudu/util/metrics.h"
 
 using std::multimap;

http://git-wip-us.apache.org/repos/asf/kudu/blob/7959c7af/src/kudu/integration-tests/delete_table-test.cc
----------------------------------------------------------------------
diff --git a/src/kudu/integration-tests/delete_table-test.cc b/src/kudu/integration-tests/delete_table-test.cc
index 7ad0a3c..9b8589f 100644
--- a/src/kudu/integration-tests/delete_table-test.cc
+++ b/src/kudu/integration-tests/delete_table-test.cc
@@ -27,13 +27,17 @@
 #include "kudu/gutil/stl_util.h"
 #include "kudu/gutil/strings/split.h"
 #include "kudu/gutil/strings/substitute.h"
+#include "kudu/integration-tests/cluster_itest_util.h"
 #include "kudu/integration-tests/cluster_verifier.h"
 #include "kudu/integration-tests/external_mini_cluster-itest-base.h"
 #include "kudu/integration-tests/test_workload.h"
+#include "kudu/rpc/rpc_controller.h"
 #include "kudu/tablet/tablet.pb.h"
 #include "kudu/tserver/tserver.pb.h"
+#include "kudu/tserver/tserver_admin.pb.h"
 #include "kudu/util/curl_util.h"
 #include "kudu/util/metrics.h"
+#include "kudu/util/pstack_watcher.h"
 #include "kudu/util/subprocess.h"
 
 using kudu::client::KuduClient;

http://git-wip-us.apache.org/repos/asf/kudu/blob/7959c7af/src/kudu/integration-tests/external_mini_cluster-itest-base.cc
----------------------------------------------------------------------
diff --git a/src/kudu/integration-tests/external_mini_cluster-itest-base.cc b/src/kudu/integration-tests/external_mini_cluster-itest-base.cc
new file mode 100644
index 0000000..134d590
--- /dev/null
+++ b/src/kudu/integration-tests/external_mini_cluster-itest-base.cc
@@ -0,0 +1,80 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#include "kudu/integration-tests/external_mini_cluster-itest-base.h"
+
+#include <string>
+#include <vector>
+
+#include <glog/logging.h>
+#include <gtest/gtest.h>
+
+#include "kudu/client/client.h"
+#include "kudu/gutil/stl_util.h"
+#include "kudu/integration-tests/cluster_itest_util.h"
+#include "kudu/integration-tests/external_mini_cluster.h"
+#include "kudu/integration-tests/external_mini_cluster_fs_inspector.h"
+#include "kudu/util/pstack_watcher.h"
+
+namespace kudu {
+
+void ExternalMiniClusterITestBase::TearDown() {
+  if (!cluster_) {
+    return;
+  }
+
+  if (HasFatalFailure()) {
+    LOG(INFO) << "Found fatal failure";
+    for (int i = 0; i < cluster_->num_tablet_servers(); i++) {
+      if (!cluster_->tablet_server(i)->IsProcessAlive()) {
+        LOG(INFO) << "Tablet server " << i
+                  << " is not running. Cannot dump its stacks.";
+        continue;
+      }
+      LOG(INFO) << "Attempting to dump stacks of TS " << i
+                << " with UUID " << cluster_->tablet_server(i)->uuid()
+                << " and pid " << cluster_->tablet_server(i)->pid();
+      WARN_NOT_OK(PstackWatcher::DumpPidStacks(cluster_->tablet_server(i)->pid()),
+                  "Couldn't dump stacks");
+    }
+  }
+  cluster_->Shutdown();
+  STLDeleteValues(&ts_map_);
+
+  KuduTest::TearDown();
+}
+
+void ExternalMiniClusterITestBase::StartCluster(
+    const std::vector<std::string>& extra_ts_flags,
+    const std::vector<std::string>& extra_master_flags,
+    int num_tablet_servers) {
+  ExternalMiniClusterOptions opts;
+  opts.num_tablet_servers = num_tablet_servers;
+  opts.extra_master_flags = extra_master_flags;
+  opts.extra_tserver_flags = extra_ts_flags;
+  // fsync causes flakiness on EC2.
+  opts.extra_tserver_flags.push_back("--never_fsync");
+  cluster_.reset(new ExternalMiniCluster(opts));
+  ASSERT_OK(cluster_->Start());
+  inspect_.reset(new itest::ExternalMiniClusterFsInspector(cluster_.get()));
+  ASSERT_OK(itest::CreateTabletServerMap(cluster_->master_proxy().get(),
+                                         cluster_->messenger(),
+                                         &ts_map_));
+  ASSERT_OK(cluster_->CreateClient(nullptr, &client_));
+}
+
+} // namespace kudu

http://git-wip-us.apache.org/repos/asf/kudu/blob/7959c7af/src/kudu/integration-tests/external_mini_cluster-itest-base.h
----------------------------------------------------------------------
diff --git a/src/kudu/integration-tests/external_mini_cluster-itest-base.h b/src/kudu/integration-tests/external_mini_cluster-itest-base.h
index d1c2167..c76c931 100644
--- a/src/kudu/integration-tests/external_mini_cluster-itest-base.h
+++ b/src/kudu/integration-tests/external_mini_cluster-itest-base.h
@@ -15,78 +15,43 @@
 // specific language governing permissions and limitations
 // under the License.
 
-#ifndef KUDU_INTEGRATION_TESTS_EXTERNAL_MINI_CLUSTER_ITEST_BASE_H_
-#define KUDU_INTEGRATION_TESTS_EXTERNAL_MINI_CLUSTER_ITEST_BASE_H_
+#pragma once
 
-#include <gtest/gtest.h>
+#include <memory>
 #include <string>
 #include <unordered_map>
 #include <vector>
 
-#include "kudu/client/client.h"
-#include "kudu/gutil/stl_util.h"
-#include "kudu/integration-tests/cluster_itest_util.h"
+#include "kudu/client/shared_ptr.h"
 #include "kudu/integration-tests/external_mini_cluster.h"
 #include "kudu/integration-tests/external_mini_cluster_fs_inspector.h"
-#include "kudu/util/pstack_watcher.h"
 #include "kudu/util/test_util.h"
 
 namespace kudu {
 
+namespace client {
+class KuduClient;
+}
+
+namespace itest {
+struct TServerDetails;
+}
+
 // Simple base utility class to provide an external mini cluster with common
 // setup routines useful for integration tests.
 class ExternalMiniClusterITestBase : public KuduTest {
  public:
-  virtual void TearDown() OVERRIDE {
-    if (cluster_) {
-      if (HasFatalFailure()) {
-        LOG(INFO) << "Found fatal failure";
-        for (int i = 0; i < cluster_->num_tablet_servers(); i++) {
-          if (!cluster_->tablet_server(i)->IsProcessAlive()) {
-            LOG(INFO) << "Tablet server " << i << " is not running. Cannot dump its stacks.";
-            continue;
-          }
-          LOG(INFO) << "Attempting to dump stacks of TS " << i
-                    << " with UUID " << cluster_->tablet_server(i)->uuid()
-                    << " and pid " << cluster_->tablet_server(i)->pid();
-          WARN_NOT_OK(PstackWatcher::DumpPidStacks(cluster_->tablet_server(i)->pid()),
-                      "Couldn't dump stacks");
-        }
-      }
-      cluster_->Shutdown();
-    }
-    KuduTest::TearDown();
-    STLDeleteValues(&ts_map_);
-  }
+  void TearDown() override;
 
  protected:
-  void StartCluster(const std::vector<std::string>& extra_ts_flags = std::vector<std::string>(),
-                    const std::vector<std::string>& extra_master_flags = std::vector<std::string>(),
+  void StartCluster(const std::vector<std::string>& extra_ts_flags = {},
+                    const std::vector<std::string>& extra_master_flags = {},
                     int num_tablet_servers = 3);
 
-  gscoped_ptr<ExternalMiniCluster> cluster_;
-  gscoped_ptr<itest::ExternalMiniClusterFsInspector> inspect_;
+  std::unique_ptr<ExternalMiniCluster> cluster_;
+  std::unique_ptr<itest::ExternalMiniClusterFsInspector> inspect_;
   client::sp::shared_ptr<client::KuduClient> client_;
   std::unordered_map<std::string, itest::TServerDetails*> ts_map_;
 };
 
-void ExternalMiniClusterITestBase::StartCluster(const std::vector<std::string>& extra_ts_flags,
-                                                const std::vector<std::string>& extra_master_flags,
-                                                int num_tablet_servers) {
-  ExternalMiniClusterOptions opts;
-  opts.num_tablet_servers = num_tablet_servers;
-  opts.extra_master_flags = extra_master_flags;
-  opts.extra_tserver_flags = extra_ts_flags;
-  opts.extra_tserver_flags.push_back("--never_fsync"); // fsync causes flakiness on EC2.
-  cluster_.reset(new ExternalMiniCluster(opts));
-  ASSERT_OK(cluster_->Start());
-  inspect_.reset(new itest::ExternalMiniClusterFsInspector(cluster_.get()));
-  ASSERT_OK(itest::CreateTabletServerMap(cluster_->master_proxy().get(),
-                                         cluster_->messenger(),
-                                         &ts_map_));
-  ASSERT_OK(cluster_->CreateClient(nullptr, &client_));
-}
-
 } // namespace kudu
-
-#endif // KUDU_INTEGRATION_TESTS_EXTERNAL_MINI_CLUSTER_ITEST_BASE_H_

http://git-wip-us.apache.org/repos/asf/kudu/blob/7959c7af/src/kudu/integration-tests/tablet_replacement-itest.cc
----------------------------------------------------------------------
diff --git a/src/kudu/integration-tests/tablet_replacement-itest.cc b/src/kudu/integration-tests/tablet_replacement-itest.cc
index 8324cea..bdf386d 100644
--- a/src/kudu/integration-tests/tablet_replacement-itest.cc
+++ b/src/kudu/integration-tests/tablet_replacement-itest.cc
@@ -26,8 +26,10 @@
 #include "kudu/common/wire_protocol-test-util.h"
 #include "kudu/gutil/strings/substitute.h"
 #include "kudu/integration-tests/external_mini_cluster-itest-base.h"
+#include "kudu/integration-tests/cluster_itest_util.h"
 #include "kudu/integration-tests/cluster_verifier.h"
 #include "kudu/integration-tests/test_workload.h"
+#include "kudu/tserver/tserver.pb.h"
 
 using kudu::consensus::RaftPeerPB;
 using kudu::itest::TServerDetails;