Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 4DE18200CD3 for ; Thu, 13 Jul 2017 08:33:13 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 4C8AC16A347; Thu, 13 Jul 2017 06:33:13 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 7017F16A368 for ; Thu, 13 Jul 2017 08:33:12 +0200 (CEST) Received: (qmail 14597 invoked by uid 500); 13 Jul 2017 06:33:11 -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 14578 invoked by uid 99); 13 Jul 2017 06:33:11 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 13 Jul 2017 06:33:11 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 88554F3262; Thu, 13 Jul 2017 06:33:10 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: mpercy@apache.org To: commits@kudu.apache.org Date: Thu, 13 Jul 2017 06:33:12 -0000 Message-Id: <436798827cc842c49ccbbba5490737ef@git.apache.org> In-Reply-To: <3a5ee77ad0154dad8a9567da9ada0b45@git.apache.org> References: <3a5ee77ad0154dad8a9567da9ada0b45@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [3/3] kudu git commit: mini cluster: Test infrastructure improvements archived-at: Thu, 13 Jul 2017 06:33:13 -0000 mini cluster: Test infrastructure improvements This patch adds a couple small improvements to the MiniCluster infra. * Add base class helpers to MiniClusterITestBase to avoid code duplication, including StopCluster() and ts_map_ for convenience and consistency with ExternalMiniClusterITestBase. * Add ListTablets() helper function to MiniTabletServer. Change-Id: I6bc6a04b113e59243fb788fec15b9935c3dcf069 Reviewed-on: http://gerrit.cloudera.org:8080/6959 Tested-by: Kudu Jenkins Reviewed-by: Alexey Serbin Project: http://git-wip-us.apache.org/repos/asf/kudu/repo Commit: http://git-wip-us.apache.org/repos/asf/kudu/commit/b62608a8 Tree: http://git-wip-us.apache.org/repos/asf/kudu/tree/b62608a8 Diff: http://git-wip-us.apache.org/repos/asf/kudu/diff/b62608a8 Branch: refs/heads/master Commit: b62608a8e1fa1406f7ffcd7a35cd70c177c67b2c Parents: bbea22e Author: Mike Percy Authored: Sat May 20 22:04:46 2017 -0700 Committer: Mike Percy Committed: Thu Jul 13 06:32:50 2017 +0000 ---------------------------------------------------------------------- src/kudu/integration-tests/CMakeLists.txt | 1 + .../integration-tests/delete_tablet-itest.cc | 7 +-- .../internal_mini_cluster-itest-base.cc | 52 ++++++++++++++++++++ .../internal_mini_cluster-itest-base.h | 27 +++++----- src/kudu/tserver/mini_tablet_server.cc | 13 ++++- src/kudu/tserver/mini_tablet_server.h | 7 ++- 6 files changed, 82 insertions(+), 25 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/kudu/blob/b62608a8/src/kudu/integration-tests/CMakeLists.txt ---------------------------------------------------------------------- diff --git a/src/kudu/integration-tests/CMakeLists.txt b/src/kudu/integration-tests/CMakeLists.txt index bbe56f1..d13d396 100644 --- a/src/kudu/integration-tests/CMakeLists.txt +++ b/src/kudu/integration-tests/CMakeLists.txt @@ -26,6 +26,7 @@ set(INTEGRATION_TESTS_SRCS external_mini_cluster-itest-base.cc external_mini_cluster.cc external_mini_cluster_fs_inspector.cc + internal_mini_cluster-itest-base.cc internal_mini_cluster.cc log_verifier.cc mini_cluster.cc http://git-wip-us.apache.org/repos/asf/kudu/blob/b62608a8/src/kudu/integration-tests/delete_tablet-itest.cc ---------------------------------------------------------------------- diff --git a/src/kudu/integration-tests/delete_tablet-itest.cc b/src/kudu/integration-tests/delete_tablet-itest.cc index b7b2c85..c0ea6c3 100644 --- a/src/kudu/integration-tests/delete_tablet-itest.cc +++ b/src/kudu/integration-tests/delete_tablet-itest.cc @@ -45,13 +45,8 @@ TEST_F(DeleteTabletITest, TestDeleteFailedReplica) { workload.set_num_replicas(1); workload.Setup(); - std::unordered_map ts_map; - ValueDeleter del(&ts_map); - ASSERT_OK(itest::CreateTabletServerMap(cluster_->master_proxy(), - cluster_->messenger(), - &ts_map)); auto* mts = cluster_->mini_tablet_server(0); - auto* ts = ts_map[mts->uuid()]; + auto* ts = ts_map_[mts->uuid()]; scoped_refptr tablet_replica; ASSERT_EVENTUALLY([&] { http://git-wip-us.apache.org/repos/asf/kudu/blob/b62608a8/src/kudu/integration-tests/internal_mini_cluster-itest-base.cc ---------------------------------------------------------------------- diff --git a/src/kudu/integration-tests/internal_mini_cluster-itest-base.cc b/src/kudu/integration-tests/internal_mini_cluster-itest-base.cc new file mode 100644 index 0000000..c8775b4 --- /dev/null +++ b/src/kudu/integration-tests/internal_mini_cluster-itest-base.cc @@ -0,0 +1,52 @@ +// 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/internal_mini_cluster-itest-base.h" + +#include + +#include "kudu/gutil/stl_util.h" +#include "kudu/integration-tests/cluster_itest_util.h" + +namespace kudu { + +void MiniClusterITestBase::TearDown() { + StopCluster(); + KuduTest::TearDown(); +} + +void MiniClusterITestBase::StartCluster(int num_tablet_servers) { + InternalMiniClusterOptions opts; + opts.num_tablet_servers = num_tablet_servers; + cluster_.reset(new InternalMiniCluster(env_, opts)); + ASSERT_OK(cluster_->Start()); + ASSERT_OK(cluster_->CreateClient(nullptr, &client_)); + ASSERT_OK(itest::CreateTabletServerMap(cluster_->master_proxy(), + cluster_->messenger(), + &ts_map_)); +} + +void MiniClusterITestBase::StopCluster() { + if (!cluster_) return; + + cluster_->Shutdown(); + cluster_.reset(); + client_.reset(); + STLDeleteValues(&ts_map_); +} + +} // namespace kudu http://git-wip-us.apache.org/repos/asf/kudu/blob/b62608a8/src/kudu/integration-tests/internal_mini_cluster-itest-base.h ---------------------------------------------------------------------- diff --git a/src/kudu/integration-tests/internal_mini_cluster-itest-base.h b/src/kudu/integration-tests/internal_mini_cluster-itest-base.h index 5931cfd..0a69fb1 100644 --- a/src/kudu/integration-tests/internal_mini_cluster-itest-base.h +++ b/src/kudu/integration-tests/internal_mini_cluster-itest-base.h @@ -17,9 +17,9 @@ #pragma once +#include #include #include -#include #include @@ -29,28 +29,23 @@ namespace kudu { +namespace itest { +struct TServerDetails; +} + // Simple base utility class to provide a mini cluster with common setup // routines useful for integration tests. class MiniClusterITestBase : public KuduTest { public: - virtual void TearDown() OVERRIDE { - if (cluster_) { - cluster_->Shutdown(); - } - KuduTest::TearDown(); - } + void TearDown() override; protected: - void StartCluster(int num_tablet_servers = 3) { - InternalMiniClusterOptions opts; - opts.num_tablet_servers = num_tablet_servers; - cluster_.reset(new InternalMiniCluster(env_, opts)); - ASSERT_OK(cluster_->Start()); - ASSERT_OK(cluster_->CreateClient(nullptr, &client_)); - } - - gscoped_ptr cluster_; + void StartCluster(int num_tablet_servers = 3); + void StopCluster(); + + std::unique_ptr cluster_; client::sp::shared_ptr client_; + std::unordered_map ts_map_; }; } // namespace kudu http://git-wip-us.apache.org/repos/asf/kudu/blob/b62608a8/src/kudu/tserver/mini_tablet_server.cc ---------------------------------------------------------------------- diff --git a/src/kudu/tserver/mini_tablet_server.cc b/src/kudu/tserver/mini_tablet_server.cc index 1c77082..452281a 100644 --- a/src/kudu/tserver/mini_tablet_server.cc +++ b/src/kudu/tserver/mini_tablet_server.cc @@ -17,7 +17,6 @@ #include "kudu/tserver/mini_tablet_server.h" -#include #include #include @@ -26,6 +25,7 @@ #include "kudu/consensus/metadata.pb.h" #include "kudu/gutil/strings/substitute.h" #include "kudu/tablet/tablet-test-util.h" +#include "kudu/tablet/tablet_replica.h" #include "kudu/tserver/tablet_server.h" #include "kudu/tserver/ts_tablet_manager.h" #include "kudu/util/env_util.h" @@ -38,6 +38,7 @@ DECLARE_bool(rpc_server_allow_ephemeral_ports); using kudu::consensus::RaftConfigPB; using kudu::consensus::RaftPeerPB; +using kudu::tablet::TabletReplica; using std::pair; using std::string; using std::unique_ptr; @@ -137,6 +138,16 @@ Status MiniTabletServer::AddTestTablet(const std::string& table_id, schema_with_ids, partition.first, config, nullptr); } +vector MiniTabletServer::ListTablets() const { + vector tablet_ids; + vector> replicas; + server_->tablet_manager()->GetTabletReplicas(&replicas); + for (const auto& replica : replicas) { + tablet_ids.push_back(replica->tablet_id()); + } + return tablet_ids; +} + void MiniTabletServer::FailHeartbeats() { server_->set_fail_heartbeats_for_tests(true); } http://git-wip-us.apache.org/repos/asf/kudu/blob/b62608a8/src/kudu/tserver/mini_tablet_server.h ---------------------------------------------------------------------- diff --git a/src/kudu/tserver/mini_tablet_server.h b/src/kudu/tserver/mini_tablet_server.h index f2f0231..b60d7e8 100644 --- a/src/kudu/tserver/mini_tablet_server.h +++ b/src/kudu/tserver/mini_tablet_server.h @@ -19,16 +19,16 @@ #include #include +#include #include "kudu/common/schema.h" #include "kudu/gutil/macros.h" #include "kudu/tserver/tablet_server_options.h" #include "kudu/util/net/sockaddr.h" -#include "kudu/util/status.h" namespace kudu { - class FsManager; +class Status; namespace consensus { class RaftConfigPB; @@ -81,6 +81,9 @@ class MiniTabletServer { const Schema& schema, const consensus::RaftConfigPB& config); + // Return the ids of all non-tombstoned tablets on this server. + std::vector ListTablets() const; + // Create a RaftConfigPB which should be used to create a local-only // tablet on the given tablet server. consensus::RaftConfigPB CreateLocalConfig() const;