kudu-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ale...@apache.org
Subject [2/2] kudu git commit: [test] use LocationInfo in ts_itest_base
Date Thu, 11 Oct 2018 18:15:44 GMT
[test] use LocationInfo in ts_itest_base

Added LocationInfo parameter into TabletServerIntegrationTestBase
methods: BuildAndStart() and CreateCluster().
In addition, I did some minor refactoring to use move semantics
for the parameters of the methods mentioned above.

Change-Id: If6fb1f583e43b9e64e3c396b7be1977546e71347
Reviewed-on: http://gerrit.cloudera.org:8080/11643
Reviewed-by: Will Berkeley <wdberkeley@gmail.com>
Tested-by: Alexey Serbin <aserbin@cloudera.com>


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

Branch: refs/heads/master
Commit: c8dd7b53fc380289e0191da30394ffe127e9de9f
Parents: 3ff4711
Author: Alexey Serbin <aserbin@cloudera.com>
Authored: Tue Oct 9 18:57:52 2018 -0700
Committer: Alexey Serbin <aserbin@cloudera.com>
Committed: Thu Oct 11 18:15:11 2018 +0000

----------------------------------------------------------------------
 src/kudu/integration-tests/linked_list-test.cc  |  3 +-
 .../integration-tests/raft_consensus-itest.cc   |  3 +-
 .../raft_consensus_election-itest.cc            |  3 +-
 src/kudu/integration-tests/ts_itest-base.cc     | 35 ++++++++++----------
 src/kudu/integration-tests/ts_itest-base.h      | 19 ++++++-----
 5 files changed, 35 insertions(+), 28 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kudu/blob/c8dd7b53/src/kudu/integration-tests/linked_list-test.cc
----------------------------------------------------------------------
diff --git a/src/kudu/integration-tests/linked_list-test.cc b/src/kudu/integration-tests/linked_list-test.cc
index 4434474..4fa43f6 100644
--- a/src/kudu/integration-tests/linked_list-test.cc
+++ b/src/kudu/integration-tests/linked_list-test.cc
@@ -131,7 +131,8 @@ class LinkedListTest : public tserver::TabletServerIntegrationTestBase
{
       ts_flags.emplace_back("--log_segment_size_mb=1");
     }
 
-    NO_FATALS(CreateCluster("linked-list-cluster", ts_flags, common_flags));
+    NO_FATALS(CreateCluster("linked-list-cluster",
+                            std::move(ts_flags), std::move(common_flags)));
     ResetClientAndTester();
     ASSERT_OK(tester_->CreateLinkedListTable());
     WaitForTSAndReplicas();

http://git-wip-us.apache.org/repos/asf/kudu/blob/c8dd7b53/src/kudu/integration-tests/raft_consensus-itest.cc
----------------------------------------------------------------------
diff --git a/src/kudu/integration-tests/raft_consensus-itest.cc b/src/kudu/integration-tests/raft_consensus-itest.cc
index 20c3c7b..e18ef75 100644
--- a/src/kudu/integration-tests/raft_consensus-itest.cc
+++ b/src/kudu/integration-tests/raft_consensus-itest.cc
@@ -538,7 +538,8 @@ void RaftConsensusITest::CreateClusterForCrashyNodesTests() {
   // log area.
   ts_flags.emplace_back("--log_preallocate_segments=false");
 
-  NO_FATALS(CreateCluster("raft_consensus-itest-crashy-nodes-cluster", ts_flags, {}));
+  NO_FATALS(CreateCluster("raft_consensus-itest-crashy-nodes-cluster",
+                          std::move(ts_flags)));
 }
 
 void RaftConsensusITest::DoTestCrashyNodes(TestWorkload* workload, int max_rows_to_insert)
{

http://git-wip-us.apache.org/repos/asf/kudu/blob/c8dd7b53/src/kudu/integration-tests/raft_consensus_election-itest.cc
----------------------------------------------------------------------
diff --git a/src/kudu/integration-tests/raft_consensus_election-itest.cc b/src/kudu/integration-tests/raft_consensus_election-itest.cc
index 3debfb5..86b7763 100644
--- a/src/kudu/integration-tests/raft_consensus_election-itest.cc
+++ b/src/kudu/integration-tests/raft_consensus_election-itest.cc
@@ -19,6 +19,7 @@
 #include <ostream>
 #include <string>
 #include <unordered_set>
+#include <utility>
 #include <vector>
 
 #include <gflags/gflags_declare.h>
@@ -106,7 +107,7 @@ void RaftConsensusElectionITest::CreateClusterForChurnyElectionsTests(
 
   ts_flags.insert(ts_flags.end(), extra_ts_flags.cbegin(), extra_ts_flags.cend());
 
-  NO_FATALS(CreateCluster("raft_consensus-itest-cluster", ts_flags, {}));
+  NO_FATALS(CreateCluster("raft_consensus-itest-cluster", std::move(ts_flags)));
 }
 
 void RaftConsensusElectionITest::DoTestChurnyElections(TestWorkload* workload,

http://git-wip-us.apache.org/repos/asf/kudu/blob/c8dd7b53/src/kudu/integration-tests/ts_itest-base.cc
----------------------------------------------------------------------
diff --git a/src/kudu/integration-tests/ts_itest-base.cc b/src/kudu/integration-tests/ts_itest-base.cc
index cd2f238..09449b7 100644
--- a/src/kudu/integration-tests/ts_itest-base.cc
+++ b/src/kudu/integration-tests/ts_itest-base.cc
@@ -70,6 +70,7 @@ DEFINE_int32(num_replicas, 3, "Number of replicas per tablet server");
 using kudu::client::sp::shared_ptr;
 using kudu::itest::TServerDetails;
 using kudu::cluster::ExternalTabletServer;
+using kudu::cluster::LocationInfo;
 using std::pair;
 using std::set;
 using std::string;
@@ -84,8 +85,7 @@ namespace tserver {
 
 static const int kMaxRetries = 20;
 
-TabletServerIntegrationTestBase::
-TabletServerIntegrationTestBase()
+TabletServerIntegrationTestBase::TabletServerIntegrationTestBase()
     : random_(SeedRandom()) {
 }
 
@@ -105,10 +105,10 @@ void TabletServerIntegrationTestBase::AddExtraFlags(
 }
 
 void TabletServerIntegrationTestBase::CreateCluster(
-    const string& cluster_root_path,
-    const vector<string>& non_default_ts_flags,
-    const vector<string>& non_default_master_flags,
-    uint32_t num_data_dirs) {
+    const std::string& data_root_path,
+    vector<string> non_default_ts_flags,
+    vector<string> non_default_master_flags,
+    cluster::LocationInfo location_info) {
 
   LOG(INFO) << "Starting cluster with:";
   LOG(INFO) << "--------------";
@@ -118,8 +118,8 @@ void TabletServerIntegrationTestBase::CreateCluster(
 
   cluster::ExternalMiniClusterOptions opts;
   opts.num_tablet_servers = FLAGS_num_tablet_servers;
-  opts.cluster_root = GetTestPath(cluster_root_path);
-  opts.num_data_dirs = num_data_dirs;
+  opts.cluster_root = GetTestPath(data_root_path);
+  opts.location_info = std::move(location_info);
 
   // Enable exactly once semantics for tests.
 
@@ -131,12 +131,12 @@ void TabletServerIntegrationTestBase::CreateCluster(
         Substitute("--consensus_rpc_timeout_ms=$0",
                    FLAGS_consensus_rpc_timeout_ms));
   } else {
-    for (const string& flag : non_default_ts_flags) {
-      opts.extra_tserver_flags.push_back(flag);
+    for (auto& flag : non_default_ts_flags) {
+      opts.extra_tserver_flags.emplace_back(std::move(flag));
     }
   }
-  for (const string& flag : non_default_master_flags) {
-    opts.extra_master_flags.push_back(flag);
+  for (auto& flag : non_default_master_flags) {
+    opts.extra_master_flags.emplace_back(std::move(flag));
   }
 
   AddExtraFlags(FLAGS_ts_flags, &opts.extra_tserver_flags);
@@ -536,12 +536,13 @@ void TabletServerIntegrationTestBase::CreateTable(const string&
table_id) {
   ASSERT_OK(client_->OpenTable(table_id, &table_));
 }
 
-// Starts an external cluster with a single tablet and a number of replicas equal
-// to 'FLAGS_num_replicas'. The caller can pass 'ts_flags' to specify non-default
-// flags to pass to the tablet servers.
 void TabletServerIntegrationTestBase::BuildAndStart(
-    const vector<string>& ts_flags, const vector<string>& master_flags)
{
-  NO_FATALS(CreateCluster("raft_consensus-itest-cluster", ts_flags, master_flags));
+    vector<string> ts_flags,
+    vector<string> master_flags,
+    LocationInfo location_info) {
+  NO_FATALS(CreateCluster("raft_consensus-itest-cluster",
+                          std::move(ts_flags), std::move(master_flags),
+                          std::move(location_info)));
   NO_FATALS(CreateClient(&client_));
   NO_FATALS(CreateTable());
   WaitForTSAndReplicas();

http://git-wip-us.apache.org/repos/asf/kudu/blob/c8dd7b53/src/kudu/integration-tests/ts_itest-base.h
----------------------------------------------------------------------
diff --git a/src/kudu/integration-tests/ts_itest-base.h b/src/kudu/integration-tests/ts_itest-base.h
index ce41df4..4cea4a3 100644
--- a/src/kudu/integration-tests/ts_itest-base.h
+++ b/src/kudu/integration-tests/ts_itest-base.h
@@ -53,9 +53,9 @@ class TabletServerIntegrationTestBase : public TabletServerTestBase {
                      std::vector<std::string>* flags);
 
   void CreateCluster(const std::string& data_root_path,
-                     const std::vector<std::string>& non_default_ts_flags,
-                     const std::vector<std::string>& non_default_master_flags,
-                     uint32_t num_data_dirs = 1);
+                     std::vector<std::string> non_default_ts_flags = {},
+                     std::vector<std::string> non_default_master_flags = {},
+                     cluster::LocationInfo location_info = {});
 
   // Creates TSServerDetails instance for each TabletServer and stores them
   // in 'tablet_servers_'.
@@ -116,11 +116,14 @@ class TabletServerIntegrationTestBase : public TabletServerTestBase
{
   // Create a table with a single tablet, with 'num_replicas'.
   void CreateTable(const std::string& table_id = kTableId);
 
-  // Starts an external cluster with a single tablet and a number of replicas equal
-  // to 'FLAGS_num_replicas'. The caller can pass 'ts_flags' to specify non-default
-  // flags to pass to the tablet servers.
-  void BuildAndStart(const std::vector<std::string>& ts_flags = {},
-                     const std::vector<std::string>& master_flags = {});
+  // Starts an external cluster with a single tablet and a number of replicas
+  // equal to 'FLAGS_num_replicas'. The caller can pass 'ts_flags' and
+  // 'master_flags' to specify non-default flags to pass to the tablet servers
+  // and masters respectively. For location-aware tests scenarios, location
+  // mapping rules can be passed using the 'location_info' parameter.
+  void BuildAndStart(std::vector<std::string> ts_flags = {},
+                     std::vector<std::string> master_flags = {},
+                     cluster::LocationInfo location_info = {});
 
   void AssertAllReplicasAgree(int expected_result_count);
 


Mime
View raw message