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 2017/10/23 18:10:19 UTC
kudu git commit: [tests] clean-up on cluster_itest_util
Repository: kudu
Updated Branches:
refs/heads/master ac18aca75 -> 407f55327
[tests] clean-up on cluster_itest_util
Updated signature of the AddServer(), RemoveServer(), and DeleteTablet()
methods to accommodate the majority of their use cases.
Also, changed the signature of the TSTabletManager::DeleteTablet() to be
more lightweight.
This changelist does not contain any functional modifications.
Change-Id: Icc5c85fb58750dec286a8ae546db955e3bd4073c
Reviewed-on: http://gerrit.cloudera.org:8080/8318
Tested-by: Kudu Jenkins
Reviewed-by: Dan Burkert <da...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/kudu/repo
Commit: http://git-wip-us.apache.org/repos/asf/kudu/commit/407f5532
Tree: http://git-wip-us.apache.org/repos/asf/kudu/tree/407f5532
Diff: http://git-wip-us.apache.org/repos/asf/kudu/diff/407f5532
Branch: refs/heads/master
Commit: 407f55327e34008929edabbceda3a16a349e9045
Parents: ac18aca
Author: Alexey Serbin <as...@cloudera.com>
Authored: Wed Oct 18 12:29:44 2017 -0700
Committer: Alexey Serbin <as...@cloudera.com>
Committed: Mon Oct 23 17:49:43 2017 +0000
----------------------------------------------------------------------
.../integration-tests/client_failover-itest.cc | 11 +-
.../integration-tests/cluster_itest_util.cc | 68 ++++----
src/kudu/integration-tests/cluster_itest_util.h | 19 ++-
.../integration-tests/delete_table-itest.cc | 59 +++----
.../integration-tests/delete_tablet-itest.cc | 8 +-
.../raft_config_change-itest.cc | 6 +-
.../integration-tests/raft_consensus-itest.cc | 41 ++---
.../raft_consensus_election-itest.cc | 7 +-
.../raft_consensus_nonvoter-itest.cc | 6 +-
src/kudu/integration-tests/tablet_copy-itest.cc | 165 +++++++++----------
.../tablet_copy_client_session-itest.cc | 9 +-
.../tablet_replacement-itest.cc | 21 ++-
.../tombstoned_voting-imc-itest.cc | 18 +-
.../tombstoned_voting-stress-test.cc | 4 +-
src/kudu/tools/kudu-admin-test.cc | 9 +-
src/kudu/tserver/tablet_service.cc | 2 +-
src/kudu/tserver/ts_tablet_manager.cc | 24 ++-
src/kudu/tserver/ts_tablet_manager.h | 10 +-
18 files changed, 227 insertions(+), 260 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/kudu/blob/407f5532/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 afbc786..47cedf4 100644
--- a/src/kudu/integration-tests/client_failover-itest.cc
+++ b/src/kudu/integration-tests/client_failover-itest.cc
@@ -15,7 +15,6 @@
// specific language governing permissions and limitations
// under the License.
-#include <cstdint>
#include <memory>
#include <ostream>
#include <set>
@@ -23,7 +22,6 @@
#include <unordered_map>
#include <vector>
-#include <boost/optional/optional.hpp>
#include <glog/logging.h>
#include <gtest/gtest.h>
@@ -58,6 +56,7 @@ using kudu::client::sp::shared_ptr;
using kudu::cluster::ExternalTabletServer;
using kudu::cluster::ScopedResumeExternalDaemon;
using kudu::itest::TServerDetails;
+using kudu::itest::DeleteTablet;
using kudu::tablet::TABLET_DATA_TOMBSTONED;
using std::set;
using std::string;
@@ -167,8 +166,7 @@ TEST_P(ClientFailoverParamITest, TestDeleteLeaderWhileScanning) {
// Delete the leader replica. This will cause the next scan to the same
// leader to get a TABLET_NOT_FOUND error.
- ASSERT_OK(itest::DeleteTablet(leader, tablet_id, TABLET_DATA_TOMBSTONED,
- boost::none, kTimeout));
+ ASSERT_OK(DeleteTablet(leader, tablet_id, TABLET_DATA_TOMBSTONED, kTimeout));
int old_leader_index = leader_index;
TServerDetails* old_leader = leader;
@@ -185,14 +183,13 @@ TEST_P(ClientFailoverParamITest, TestDeleteLeaderWhileScanning) {
// Do a config change to remove the old replica and add a new one.
// Cause the new replica to become leader, then do the scan again.
- ASSERT_OK(RemoveServer(leader, tablet_id, old_leader, boost::none, kTimeout));
+ ASSERT_OK(RemoveServer(leader, tablet_id, old_leader, kTimeout));
// Wait until the config is committed, otherwise AddServer() will fail.
ASSERT_OK(WaitUntilCommittedConfigOpIdIndexIs(workload.batches_completed() + 4, leader, tablet_id,
kTimeout));
TServerDetails* to_add = ts_map_[cluster_->tablet_server(missing_replica_index)->uuid()];
- ASSERT_OK(AddServer(leader, tablet_id, to_add, consensus::RaftPeerPB::VOTER,
- boost::none, kTimeout));
+ ASSERT_OK(AddServer(leader, tablet_id, to_add, consensus::RaftPeerPB::VOTER, kTimeout));
HostPort hp;
ASSERT_OK(HostPortFromPB(leader->registration.rpc_addresses(0), &hp));
ASSERT_OK(StartTabletCopy(to_add, tablet_id, leader->uuid(), hp, 1, kTimeout));
http://git-wip-us.apache.org/repos/asf/kudu/blob/407f5532/src/kudu/integration-tests/cluster_itest_util.cc
----------------------------------------------------------------------
diff --git a/src/kudu/integration-tests/cluster_itest_util.cc b/src/kudu/integration-tests/cluster_itest_util.cc
index ca4cb75..6da465b 100644
--- a/src/kudu/integration-tests/cluster_itest_util.cc
+++ b/src/kudu/integration-tests/cluster_itest_util.cc
@@ -14,6 +14,7 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+
#include "kudu/integration-tests/cluster_itest_util.h"
#include <algorithm>
@@ -22,7 +23,6 @@
#include <boost/optional/optional.hpp>
#include <glog/logging.h>
#include <glog/stl_logging.h>
-#include <gtest/gtest.h>
#include "kudu/client/schema.h"
#include "kudu/common/common.pb.h"
@@ -53,7 +53,6 @@
#include "kudu/util/net/sockaddr.h"
#include "kudu/util/pb_util.h"
#include "kudu/util/status.h"
-#include "kudu/util/test_macros.h"
namespace kudu {
namespace itest {
@@ -684,14 +683,10 @@ Status AddServer(const TServerDetails* leader,
const std::string& tablet_id,
const TServerDetails* replica_to_add,
consensus::RaftPeerPB::MemberType member_type,
- const boost::optional<int64_t>& cas_config_opid_index,
const MonoDelta& timeout,
+ const boost::optional<int64_t>& cas_config_index,
TabletServerErrorPB::Code* error_code) {
ChangeConfigRequestPB req;
- ChangeConfigResponsePB resp;
- RpcController rpc;
- rpc.set_timeout(timeout);
-
req.set_dest_uuid(leader->uuid());
req.set_tablet_id(tablet_id);
req.set_type(consensus::ADD_SERVER);
@@ -699,12 +694,18 @@ Status AddServer(const TServerDetails* leader,
peer->set_permanent_uuid(replica_to_add->uuid());
peer->set_member_type(member_type);
*peer->mutable_last_known_addr() = replica_to_add->registration.rpc_addresses(0);
- if (cas_config_opid_index) {
- req.set_cas_config_opid_index(*cas_config_opid_index);
+ if (cas_config_index) {
+ req.set_cas_config_opid_index(*cas_config_index);
}
+
+ ChangeConfigResponsePB resp;
+ RpcController rpc;
+ rpc.set_timeout(timeout);
RETURN_NOT_OK(leader->consensus_proxy->ChangeConfig(req, &resp, &rpc));
if (resp.has_error()) {
- if (error_code) *error_code = resp.error().code();
+ if (error_code) {
+ *error_code = resp.error().code();
+ }
return StatusFromPB(resp.error().status());
}
return Status::OK();
@@ -713,23 +714,22 @@ Status AddServer(const TServerDetails* leader,
Status RemoveServer(const TServerDetails* leader,
const std::string& tablet_id,
const TServerDetails* replica_to_remove,
- const boost::optional<int64_t>& cas_config_opid_index,
const MonoDelta& timeout,
+ const boost::optional<int64_t>& cas_config_index,
TabletServerErrorPB::Code* error_code) {
ChangeConfigRequestPB req;
- ChangeConfigResponsePB resp;
- RpcController rpc;
- rpc.set_timeout(timeout);
-
req.set_dest_uuid(leader->uuid());
req.set_tablet_id(tablet_id);
req.set_type(consensus::REMOVE_SERVER);
- if (cas_config_opid_index) {
- req.set_cas_config_opid_index(*cas_config_opid_index);
+ if (cas_config_index) {
+ req.set_cas_config_opid_index(*cas_config_index);
}
RaftPeerPB* peer = req.mutable_server();
peer->set_permanent_uuid(replica_to_remove->uuid());
+ ChangeConfigResponsePB resp;
+ RpcController rpc;
+ rpc.set_timeout(timeout);
RETURN_NOT_OK(leader->consensus_proxy->ChangeConfig(req, &resp, &rpc));
if (resp.has_error()) {
if (error_code) *error_code = resp.error().code();
@@ -934,21 +934,20 @@ Status WaitUntilTabletRunning(TServerDetails* ts,
Status DeleteTablet(const TServerDetails* ts,
const std::string& tablet_id,
const TabletDataState& delete_type,
- const boost::optional<int64_t>& cas_config_opid_index_less_or_equal,
const MonoDelta& timeout,
+ const boost::optional<int64_t>& cas_config_index,
tserver::TabletServerErrorPB::Code* error_code) {
DeleteTabletRequestPB req;
- DeleteTabletResponsePB resp;
- RpcController rpc;
- rpc.set_timeout(timeout);
-
req.set_dest_uuid(ts->uuid());
req.set_tablet_id(tablet_id);
req.set_delete_type(delete_type);
- if (cas_config_opid_index_less_or_equal) {
- req.set_cas_config_opid_index_less_or_equal(*cas_config_opid_index_less_or_equal);
+ if (cas_config_index) {
+ req.set_cas_config_opid_index_less_or_equal(*cas_config_index);
}
+ DeleteTabletResponsePB resp;
+ RpcController rpc;
+ rpc.set_timeout(timeout);
RETURN_NOT_OK(ts->tserver_admin_proxy->DeleteTablet(req, &resp, &rpc));
if (resp.has_error()) {
if (error_code) {
@@ -959,23 +958,24 @@ Status DeleteTablet(const TServerDetails* ts,
return Status::OK();
}
-void DeleteTabletWithRetries(const TServerDetails* ts,
- const string& tablet_id,
- TabletDataState delete_type,
- const boost::optional<int64_t>& config_opid_index,
- const MonoDelta& timeout) {
- MonoTime start(MonoTime::Now());
- MonoTime deadline = start + timeout;
+Status DeleteTabletWithRetries(const TServerDetails* ts,
+ const string& tablet_id,
+ TabletDataState delete_type,
+ const MonoDelta& timeout,
+ const boost::optional<int64_t>& cas_config_index) {
+ const MonoTime deadline = MonoTime::Now() + timeout;
Status s;
while (true) {
- s = DeleteTablet(ts, tablet_id, delete_type, config_opid_index, timeout);
- if (s.ok()) return;
+ s = DeleteTablet(ts, tablet_id, delete_type, timeout, cas_config_index);
+ if (s.ok()) {
+ return s;
+ }
if (deadline < MonoTime::Now()) {
break;
}
SleepFor(MonoDelta::FromMilliseconds(10));
}
- ASSERT_OK(s);
+ return s;
}
Status StartTabletCopy(const TServerDetails* ts,
http://git-wip-us.apache.org/repos/asf/kudu/blob/407f5532/src/kudu/integration-tests/cluster_itest_util.h
----------------------------------------------------------------------
diff --git a/src/kudu/integration-tests/cluster_itest_util.h b/src/kudu/integration-tests/cluster_itest_util.h
index 59276dd..c5b7ff8 100644
--- a/src/kudu/integration-tests/cluster_itest_util.h
+++ b/src/kudu/integration-tests/cluster_itest_util.h
@@ -273,8 +273,8 @@ Status AddServer(const TServerDetails* leader,
const std::string& tablet_id,
const TServerDetails* replica_to_add,
consensus::RaftPeerPB::MemberType member_type,
- const boost::optional<int64_t>& cas_config_opid_index,
const MonoDelta& timeout,
+ const boost::optional<int64_t>& cas_config_index = boost::none,
tserver::TabletServerErrorPB::Code* error_code = nullptr);
// Run a ConfigChange to REMOVE_SERVER on 'replica_to_remove'.
@@ -282,8 +282,8 @@ Status AddServer(const TServerDetails* leader,
Status RemoveServer(const TServerDetails* leader,
const std::string& tablet_id,
const TServerDetails* replica_to_remove,
- const boost::optional<int64_t>& cas_config_opid_index,
const MonoDelta& timeout,
+ const boost::optional<int64_t>& cas_config_index = boost::none,
tserver::TabletServerErrorPB::Code* error_code = nullptr);
// Get the list of tablets from the remote server.
@@ -350,21 +350,24 @@ Status WaitUntilTabletRunning(TServerDetails* ts,
const MonoDelta& timeout);
// Send a DeleteTablet() to the server at 'ts' of the specified 'delete_type'.
+// If set, the 'cas_config_index' corresponds to the
+// 'cas_config_opid_index_less_or_equal' field of the request.
Status DeleteTablet(const TServerDetails* ts,
const std::string& tablet_id,
const tablet::TabletDataState& delete_type,
- const boost::optional<int64_t>& cas_config_opid_index_less_or_equal,
const MonoDelta& timeout,
+ const boost::optional<int64_t>& cas_config_index = boost::none,
tserver::TabletServerErrorPB::Code* error_code = nullptr);
// Repeatedly try to delete the tablet, retrying on failure up to the
// specified timeout. Deletion can fail when other operations, such as
// bootstrap or tablet copy, are running.
-void DeleteTabletWithRetries(const TServerDetails* ts,
- const std::string& tablet_id,
- tablet::TabletDataState delete_type,
- const boost::optional<int64_t>& config_opid_index,
- const MonoDelta& timeout);
+Status DeleteTabletWithRetries(
+ const TServerDetails* ts,
+ const std::string& tablet_id,
+ tablet::TabletDataState delete_type,
+ const MonoDelta& timeout,
+ const boost::optional<int64_t>& cas_config_index = boost::none);
// Cause the remote to initiate tablet copy using the specified host as a
// source.
http://git-wip-us.apache.org/repos/asf/kudu/blob/407f5532/src/kudu/integration-tests/delete_table-itest.cc
----------------------------------------------------------------------
diff --git a/src/kudu/integration-tests/delete_table-itest.cc b/src/kudu/integration-tests/delete_table-itest.cc
index 41a96d1..605430a 100644
--- a/src/kudu/integration-tests/delete_table-itest.cc
+++ b/src/kudu/integration-tests/delete_table-itest.cc
@@ -90,6 +90,10 @@ using kudu::consensus::COMMITTED_OPID;
using kudu::consensus::ConsensusMetadataPB;
using kudu::consensus::ConsensusStatePB;
using kudu::consensus::RaftPeerPB;
+using kudu::itest::AddServer;
+using kudu::itest::DeleteTablet;
+using kudu::itest::DeleteTabletWithRetries;
+using kudu::itest::RemoveServer;
using kudu::itest::TServerDetails;
using kudu::pb_util::SecureDebugString;
using kudu::pb_util::SecureShortDebugString;
@@ -381,8 +385,8 @@ TEST_F(DeleteTableITest, TestAtomicDeleteTablet) {
Status s;
for (int i = 0; i < 100; i++) {
- s = itest::DeleteTablet(ts, tablet_id, TABLET_DATA_TOMBSTONED, opid_index, timeout,
- &error_code);
+ s = DeleteTablet(ts, tablet_id, TABLET_DATA_TOMBSTONED, timeout, opid_index,
+ &error_code);
if (error_code == TabletServerErrorPB::CAS_FAILED) break;
// If we didn't get the expected CAS_FAILED error, it's OK to get 'TABLET_NOT_RUNNING'
// because the "creating" maintenance state persists just slightly after it starts to
@@ -396,20 +400,16 @@ TEST_F(DeleteTableITest, TestAtomicDeleteTablet) {
ASSERT_STR_CONTAINS(s.ToString(), "of -2 but the committed config has opid_index of -1");
// Now use the "latest", which is -1.
- opid_index = -1;
- ASSERT_OK(itest::DeleteTablet(ts, tablet_id, TABLET_DATA_TOMBSTONED, opid_index, timeout,
- &error_code));
+ ASSERT_OK(DeleteTablet(ts, tablet_id, TABLET_DATA_TOMBSTONED, timeout, -1));
inspect_->CheckTabletDataStateOnTS(kTsIndex, tablet_id, { TABLET_DATA_TOMBSTONED });
// Now that the tablet is already tombstoned, our opid_index should be
// ignored (because it's impossible to check it).
- ASSERT_OK(itest::DeleteTablet(ts, tablet_id, TABLET_DATA_TOMBSTONED, -9999, timeout,
- &error_code));
+ ASSERT_OK(DeleteTablet(ts, tablet_id, TABLET_DATA_TOMBSTONED, timeout, -9999));
inspect_->CheckTabletDataStateOnTS(kTsIndex, tablet_id, { TABLET_DATA_TOMBSTONED });
// Same with TOMBSTONED -> DELETED.
- ASSERT_OK(itest::DeleteTablet(ts, tablet_id, TABLET_DATA_DELETED, -9999, timeout,
- &error_code));
+ ASSERT_OK(itest::DeleteTablet(ts, tablet_id, TABLET_DATA_DELETED, timeout, -9999));
inspect_->CheckTabletDataStateOnTS(kTsIndex, tablet_id, { TABLET_DATA_DELETED });
}
@@ -552,8 +552,7 @@ TEST_F(DeleteTableITest, TestAutoTombstoneAfterCrashDuringTabletCopy) {
string leader_uuid = GetLeaderUUID(cluster_->tablet_server(1)->uuid(), replicated_tablet_id);
TServerDetails* leader = DCHECK_NOTNULL(ts_map_[leader_uuid]);
TServerDetails* ts = ts_map_[cluster_->tablet_server(kTsIndex)->uuid()];
- ASSERT_OK(itest::AddServer(leader, replicated_tablet_id, ts, RaftPeerPB::VOTER,
- boost::none, timeout));
+ ASSERT_OK(AddServer(leader, replicated_tablet_id, ts, RaftPeerPB::VOTER, timeout));
NO_FATALS(WaitForTSToCrash(kTsIndex));
cluster_->tablet_server(kTsIndex)->Shutdown();
@@ -584,14 +583,13 @@ TEST_F(DeleteTableITest, TestAutoTombstoneAfterCrashDuringTabletCopy) {
// Now we want to test the case where crashed while copying over a previously-tombstoned tablet.
// So, we first remove the server, causing it to get tombstoned.
- ASSERT_OK(itest::RemoveServer(leader, replicated_tablet_id, ts, boost::none, timeout));
+ ASSERT_OK(RemoveServer(leader, replicated_tablet_id, ts, timeout));
NO_FATALS(WaitForTabletTombstonedOnTS(kTsIndex, replicated_tablet_id, CMETA_EXPECTED));
// ... and then add it back, with the fault runtime-enabled.
ASSERT_OK(cluster_->SetFlag(cluster_->tablet_server(kTsIndex),
"fault_crash_after_tc_files_fetched", "1.0"));
- ASSERT_OK(itest::AddServer(leader, replicated_tablet_id, ts, RaftPeerPB::VOTER,
- boost::none, timeout));
+ ASSERT_OK(AddServer(leader, replicated_tablet_id, ts, RaftPeerPB::VOTER, timeout));
NO_FATALS(WaitForTSToCrash(kTsIndex));
LOG(INFO) << "Test progress: crashed on attempt to copy over tombstoned";
@@ -674,7 +672,7 @@ TEST_F(DeleteTableITest, TestAutoTombstoneAfterTabletCopyRemoteFails) {
TServerDetails* leader = ts_map_[kLeaderUuid];
TServerDetails* ts = ts_map_[cluster_->tablet_server(0)->uuid()];
// The server may crash before responding to our RPC.
- Status s = itest::AddServer(leader, tablet_id, ts, RaftPeerPB::VOTER, boost::none, kTimeout);
+ Status s = AddServer(leader, tablet_id, ts, RaftPeerPB::VOTER, kTimeout);
ASSERT_TRUE(s.ok() || s.IsNetworkError()) << s.ToString();
NO_FATALS(WaitForTSToCrash(kLeaderIndex));
@@ -712,7 +710,7 @@ TEST_F(DeleteTableITest, TestAutoTombstoneAfterTabletCopyRemoteFails) {
// Now pause the other replicas and tombstone our replica again.
ASSERT_OK(cluster_->tablet_server(1)->Pause());
ASSERT_OK(cluster_->tablet_server(2)->Pause());
- ASSERT_OK(itest::DeleteTablet(ts, tablet_id, TABLET_DATA_TOMBSTONED, boost::none, kTimeout));
+ ASSERT_OK(DeleteTablet(ts, tablet_id, TABLET_DATA_TOMBSTONED, kTimeout));
NO_FATALS(WaitForTabletTombstonedOnTS(kTsIndex, tablet_id, CMETA_NOT_EXPECTED));
// Bring them back again, let them yet again Copy a new replica on top of our tombstoned replica.
@@ -786,7 +784,7 @@ TEST_F(DeleteTableITest, TestMergeConsensusMetadata) {
ASSERT_EQ(ts->uuid(), cmeta_pb.voted_for());
// Tombstone our special little guy, then shut him down.
- ASSERT_OK(itest::DeleteTablet(ts, tablet_id, TABLET_DATA_TOMBSTONED, boost::none, timeout));
+ ASSERT_OK(DeleteTablet(ts, tablet_id, TABLET_DATA_TOMBSTONED, timeout));
NO_FATALS(WaitForTabletTombstonedOnTS(kTsIndex, tablet_id, CMETA_EXPECTED));
cluster_->tablet_server(kTsIndex)->Shutdown();
@@ -819,8 +817,7 @@ TEST_F(DeleteTableITest, TestMergeConsensusMetadata) {
cluster_->tablet_server(2)->Shutdown();
// Delete with retries because the tablet might still be bootstrapping.
- NO_FATALS(itest::DeleteTabletWithRetries(ts, tablet_id,
- TABLET_DATA_TOMBSTONED, boost::none, timeout));
+ ASSERT_OK(DeleteTabletWithRetries(ts, tablet_id, TABLET_DATA_TOMBSTONED, timeout));
NO_FATALS(WaitForTabletTombstonedOnTS(kTsIndex, tablet_id, CMETA_EXPECTED));
// Shut down the tablet server so it won't vote while tombstoned.
@@ -911,7 +908,7 @@ TEST_F(DeleteTableITest, TestDeleteFollowerWithReplicatingTransaction) {
// Now tombstone the follower tablet. This should succeed even though there
// are uncommitted operations on the replica.
LOG(INFO) << "Tombstoning tablet " << tablet_id << " on TS " << ts->uuid();
- ASSERT_OK(itest::DeleteTablet(ts, tablet_id, TABLET_DATA_TOMBSTONED, boost::none, timeout));
+ ASSERT_OK(DeleteTablet(ts, tablet_id, TABLET_DATA_TOMBSTONED, timeout));
}
// Test that orphaned blocks are cleared from the superblock when a tablet is
@@ -971,8 +968,7 @@ TEST_F(DeleteTableITest, TestOrphanedBlocksClearedOnDelete) {
// Tombstone the follower and check that there are no rowsets or orphaned
// blocks retained in the superblock.
- ASSERT_OK(itest::DeleteTablet(follower_ts, tablet_id, TABLET_DATA_TOMBSTONED,
- boost::none, timeout));
+ ASSERT_OK(DeleteTablet(follower_ts, tablet_id, TABLET_DATA_TOMBSTONED, timeout));
NO_FATALS(WaitForTabletTombstonedOnTS(kFollowerIndex, tablet_id, CMETA_EXPECTED));
ASSERT_OK(inspect_->ReadTabletSuperBlockOnTS(kFollowerIndex, tablet_id, &superblock_pb));
ASSERT_EQ(0, superblock_pb.rowsets_size()) << SecureDebugString(superblock_pb);
@@ -1032,8 +1028,8 @@ TEST_F(DeleteTableITest, TestFDsNotLeakedOnTabletTombstone) {
// Tombstone the tablet and then ensure that lsof does not list any
// tablet-related paths.
ExternalTabletServer* ets = cluster_->tablet_server(0);
- ASSERT_OK(itest::DeleteTablet(ts_map_[ets->uuid()],
- tablet_id, TABLET_DATA_TOMBSTONED, boost::none, timeout));
+ ASSERT_OK(DeleteTablet(ts_map_[ets->uuid()],
+ tablet_id, TABLET_DATA_TOMBSTONED, timeout));
ASSERT_EQ(0, PrintOpenTabletFiles(ets->pid(), tablet_id));
// Restart the TS after deletion and then do the same lsof check again.
@@ -1062,8 +1058,8 @@ TEST_F(DeleteTableITest, TestWebPageForTombstonedTablet) {
// Tombstone the tablet.
ExternalTabletServer* ets = cluster_->tablet_server(0);
ASSERT_EVENTUALLY([&]() {
- ASSERT_OK(itest::DeleteTablet(ts_map_[ets->uuid()],
- tablet_id, TABLET_DATA_TOMBSTONED, boost::none, timeout));
+ ASSERT_OK(DeleteTablet(ts_map_[ets->uuid()], tablet_id,
+ TABLET_DATA_TOMBSTONED, timeout));
});
// Check the various web pages associated with the tablet, ensuring
@@ -1187,8 +1183,8 @@ TEST_F(DeleteTableITest, TestNoDeleteTombstonedTablets) {
ASSERT_NE(nullptr, to_remove);
// Do the config changes and wait for the master to delete the old node.
- ASSERT_OK(AddServer(leader, tablet_id, to_add, RaftPeerPB::VOTER, boost::none, kTimeout));
- ASSERT_OK(RemoveServer(leader, tablet_id, to_remove, boost::none, kTimeout));
+ ASSERT_OK(AddServer(leader, tablet_id, to_add, RaftPeerPB::VOTER, kTimeout));
+ ASSERT_OK(RemoveServer(leader, tablet_id, to_remove, kTimeout));
LOG(INFO) << "waiting for no data on ts...";
@@ -1404,7 +1400,7 @@ TEST_P(DeleteTableTombstonedParamTest, TestTabletTombstone) {
string tablet_id = tablets[0].tablet_status().tablet_id();
LOG(INFO) << "Tombstoning first tablet " << tablet_id << "...";
ASSERT_TRUE(inspect_->DoesConsensusMetaExistForTabletOnTS(kTsIndex, tablet_id)) << tablet_id;
- ASSERT_OK(itest::DeleteTablet(ts, tablet_id, TABLET_DATA_TOMBSTONED, boost::none, timeout));
+ ASSERT_OK(DeleteTablet(ts, tablet_id, TABLET_DATA_TOMBSTONED, timeout));
LOG(INFO) << "Waiting for first tablet to be tombstoned...";
NO_FATALS(WaitForTabletTombstonedOnTS(kTsIndex, tablet_id, CMETA_EXPECTED));
@@ -1421,7 +1417,7 @@ TEST_P(DeleteTableTombstonedParamTest, TestTabletTombstone) {
ASSERT_OK(cluster_->SetFlag(cluster_->tablet_server(kTsIndex), fault_flag, "1.0"));
tablet_id = tablets[1].tablet_status().tablet_id();
LOG(INFO) << "Tombstoning second tablet " << tablet_id << "...";
- ignore_result(itest::DeleteTablet(ts, tablet_id, TABLET_DATA_TOMBSTONED, boost::none, timeout));
+ ignore_result(DeleteTablet(ts, tablet_id, TABLET_DATA_TOMBSTONED, timeout));
NO_FATALS(WaitForTSToCrash(kTsIndex));
// Restart the tablet server and wait for the WALs to be deleted and for the
@@ -1456,8 +1452,7 @@ TEST_P(DeleteTableTombstonedParamTest, TestTabletTombstone) {
string tablet_id = tablet.tablet_status().tablet_id();
// We need retries here, since some of the tablets may still be
// bootstrapping after being restarted above.
- NO_FATALS(itest::DeleteTabletWithRetries(ts, tablet_id,
- TABLET_DATA_DELETED, boost::none, timeout));
+ ASSERT_OK(DeleteTabletWithRetries(ts, tablet_id, TABLET_DATA_DELETED, timeout));
}
ASSERT_OK(inspect_->WaitForNoDataOnTS(kTsIndex));
}
http://git-wip-us.apache.org/repos/asf/kudu/blob/407f5532/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 139bb11..a0e349a 100644
--- a/src/kudu/integration-tests/delete_tablet-itest.cc
+++ b/src/kudu/integration-tests/delete_tablet-itest.cc
@@ -23,7 +23,6 @@
#include <unordered_map>
#include <vector>
-#include <boost/optional/optional.hpp>
#include <gflags/gflags_declare.h>
#include <glog/stl_logging.h>
#include <gtest/gtest.h>
@@ -49,6 +48,7 @@ DECLARE_int64(fs_wal_dir_reserved_bytes);
using kudu::tablet::TABLET_DATA_DELETED;
using kudu::tablet::TabletReplica;
+using kudu::itest::DeleteTablet;
using std::atomic;
using std::string;
using std::thread;
@@ -110,8 +110,8 @@ TEST_F(DeleteTabletITest, TestDeleteFailedReplica) {
}
// We should still be able to delete the failed tablet.
- ASSERT_OK(itest::DeleteTablet(ts, tablet_replica->tablet_id(), tablet::TABLET_DATA_DELETED,
- boost::none, MonoDelta::FromSeconds(30)));
+ ASSERT_OK(DeleteTablet(ts, tablet_replica->tablet_id(), tablet::TABLET_DATA_DELETED,
+ MonoDelta::FromSeconds(30)));
ASSERT_EVENTUALLY([&] {
vector<scoped_refptr<TabletReplica>> tablet_replicas;
mts->server()->tablet_manager()->GetTabletReplicas(&tablet_replicas);
@@ -148,7 +148,7 @@ TEST_F(DeleteTabletITest, TestLeaderElectionDuringDeleteTablet) {
// Sequentially delete all of the tablets.
for (const string& tablet_id : tablet_ids) {
- ASSERT_OK(itest::DeleteTablet(ts, tablet_id, TABLET_DATA_DELETED, boost::none, kTimeout));
+ ASSERT_OK(DeleteTablet(ts, tablet_id, TABLET_DATA_DELETED, kTimeout));
}
// Wait until all tablets are deleted.
http://git-wip-us.apache.org/repos/asf/kudu/blob/407f5532/src/kudu/integration-tests/raft_config_change-itest.cc
----------------------------------------------------------------------
diff --git a/src/kudu/integration-tests/raft_config_change-itest.cc b/src/kudu/integration-tests/raft_config_change-itest.cc
index ae5bb88..0ba04b8 100644
--- a/src/kudu/integration-tests/raft_config_change-itest.cc
+++ b/src/kudu/integration-tests/raft_config_change-itest.cc
@@ -15,14 +15,12 @@
// specific language governing permissions and limitations
// under the License.
-#include <cstdint>
#include <memory>
#include <ostream>
#include <string>
#include <unordered_map>
#include <vector>
-#include <boost/optional/optional.hpp>
#include <glog/logging.h>
#include <gtest/gtest.h>
@@ -137,9 +135,7 @@ TEST_F(RaftConfigChangeITest, TestKudu2147) {
// Now that heartbeat injection is enabled, evict one follower and trigger
// an election on another follower immediately thereafter.
- ASSERT_OK(itest::RemoveServer(leader, tablet_id, followers[0],
- /*cas_config_opid_index=*/ boost::none,
- kTimeout));
+ ASSERT_OK(itest::RemoveServer(leader, tablet_id, followers[0], kTimeout));
// Immediately start an election on the remaining follower. This will cause
// the initial leader's term to rev and it will have to step down. When it
http://git-wip-us.apache.org/repos/asf/kudu/blob/407f5532/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 4c45849..1400906 100644
--- a/src/kudu/integration-tests/raft_consensus-itest.cc
+++ b/src/kudu/integration-tests/raft_consensus-itest.cc
@@ -24,7 +24,6 @@
#include <utility>
#include <vector>
-#include <boost/optional/optional.hpp>
#include <gflags/gflags_declare.h>
#include <glog/logging.h>
#include <glog/stl_logging.h>
@@ -1354,7 +1353,7 @@ TEST_F(RaftConsensusITest, TestAddRemoveServer) {
ASSERT_OK(WaitUntilCommittedOpIdIndexIs(1, leader_tserver, tablet_id_, kTimeout));
// Make sure the server rejects removal of itself from the configuration.
- Status s = RemoveServer(leader_tserver, tablet_id_, leader_tserver, boost::none, kTimeout);
+ Status s = RemoveServer(leader_tserver, tablet_id_, leader_tserver, kTimeout);
ASSERT_TRUE(s.IsInvalidArgument()) << "Should not be able to remove self from config: "
<< s.ToString();
@@ -1382,7 +1381,7 @@ TEST_F(RaftConsensusITest, TestAddRemoveServer) {
TServerDetails* tserver_to_remove = tservers[to_remove_idx];
LOG(INFO) << "Removing tserver with uuid " << tserver_to_remove->uuid();
- ASSERT_OK(RemoveServer(leader_tserver, tablet_id_, tserver_to_remove, boost::none, kTimeout));
+ ASSERT_OK(RemoveServer(leader_tserver, tablet_id_, tserver_to_remove, kTimeout));
ASSERT_EQ(1, active_tablet_servers.erase(tserver_to_remove->uuid()));
ASSERT_OK(WaitForServersToAgree(kTimeout, active_tablet_servers, tablet_id_, ++cur_log_index));
@@ -1401,8 +1400,8 @@ TEST_F(RaftConsensusITest, TestAddRemoveServer) {
TServerDetails* tserver_to_add = tservers[to_add_idx];
LOG(INFO) << "Adding tserver with uuid " << tserver_to_add->uuid();
- ASSERT_OK(AddServer(leader_tserver, tablet_id_, tserver_to_add, RaftPeerPB::VOTER, boost::none,
- kTimeout));
+ ASSERT_OK(AddServer(leader_tserver, tablet_id_, tserver_to_add,
+ RaftPeerPB::VOTER, kTimeout));
InsertOrDie(&active_tablet_servers, tserver_to_add->uuid(), tserver_to_add);
ASSERT_OK(WaitForServersToAgree(kTimeout, active_tablet_servers, tablet_id_, ++cur_log_index));
@@ -1451,7 +1450,7 @@ TEST_F(RaftConsensusITest, TestReplaceChangeConfigOperation) {
// Now try to replicate a ChangeConfig operation. This should get stuck and time out
// because the server can't replicate any operations.
Status s = RemoveServer(leader_tserver, tablet_id_, tservers[1],
- -1, MonoDelta::FromSeconds(1));
+ MonoDelta::FromSeconds(1), -1);
ASSERT_TRUE(s.IsTimedOut()) << s.ToString();
// Pause the leader, and restart the other servers.
@@ -1479,7 +1478,7 @@ TEST_F(RaftConsensusITest, TestReplaceChangeConfigOperation) {
// This acts as a regression test for KUDU-1338, in which aborting the original
// config change didn't properly unset the 'pending' configuration.
ASSERT_OK(RemoveServer(leader_tserver, tablet_id_, tservers[2],
- -1, MonoDelta::FromSeconds(5)));
+ MonoDelta::FromSeconds(5), -1));
NO_FATALS(InsertTestRowsRemoteThread(10, 10, 1, vector<CountDownLatch*>()));
}
@@ -1514,18 +1513,16 @@ TEST_F(RaftConsensusITest, TestAtomicAddRemoveServer) {
// Initial committed config should have opid_index == -1.
// Server should reject request to change config from opid other than this.
- int64_t invalid_committed_opid_index = 7;
TabletServerErrorPB::Code error_code;
Status s = RemoveServer(leader_tserver, tablet_id_, follower_ts,
- invalid_committed_opid_index, MonoDelta::FromSeconds(10),
- &error_code);
+ MonoDelta::FromSeconds(10), 7, &error_code);
ASSERT_EQ(TabletServerErrorPB::CAS_FAILED, error_code);
ASSERT_STR_CONTAINS(s.ToString(), "of 7 but the committed config has opid_index of -1");
// Specifying the correct committed opid index should work.
int64_t committed_opid_index = -1;
ASSERT_OK(RemoveServer(leader_tserver, tablet_id_, follower_ts,
- committed_opid_index, MonoDelta::FromSeconds(10)));
+ MonoDelta::FromSeconds(10), committed_opid_index));
ASSERT_EQ(1, active_tablet_servers.erase(follower_ts->uuid()));
ASSERT_OK(WaitForServersToAgree(MonoDelta::FromSeconds(10),
@@ -1533,10 +1530,8 @@ TEST_F(RaftConsensusITest, TestAtomicAddRemoveServer) {
// Now, add the server back. Again, specifying something other than the
// latest committed_opid_index should fail.
- invalid_committed_opid_index = -1; // The old one is no longer valid.
s = AddServer(leader_tserver, tablet_id_, follower_ts, RaftPeerPB::VOTER,
- invalid_committed_opid_index, MonoDelta::FromSeconds(10),
- &error_code);
+ MonoDelta::FromSeconds(10), -1, &error_code);
ASSERT_EQ(TabletServerErrorPB::CAS_FAILED, error_code);
ASSERT_STR_CONTAINS(s.ToString(), "of -1 but the committed config has opid_index of 2");
@@ -1544,7 +1539,7 @@ TEST_F(RaftConsensusITest, TestAtomicAddRemoveServer) {
// The previous config change op is the latest entry in the log.
committed_opid_index = cur_log_index;
ASSERT_OK(AddServer(leader_tserver, tablet_id_, follower_ts, RaftPeerPB::VOTER,
- committed_opid_index, MonoDelta::FromSeconds(10)));
+ MonoDelta::FromSeconds(10), committed_opid_index));
InsertOrDie(&active_tablet_servers, follower_ts->uuid(), follower_ts);
ASSERT_OK(WaitForServersToAgree(MonoDelta::FromSeconds(10),
@@ -1622,7 +1617,7 @@ TEST_F(RaftConsensusITest, TestConfigChangeUnderLoad) {
TServerDetails* tserver_to_remove = tservers[to_remove_idx];
LOG(INFO) << "Removing tserver with uuid " << tserver_to_remove->uuid();
- ASSERT_OK(RemoveServer(leader_tserver, tablet_id_, tserver_to_remove, boost::none,
+ ASSERT_OK(RemoveServer(leader_tserver, tablet_id_, tserver_to_remove,
MonoDelta::FromSeconds(10)));
ASSERT_EQ(1, active_tablet_servers.erase(tserver_to_remove->uuid()));
ASSERT_OK(WaitUntilCommittedConfigNumVotersIs(active_tablet_servers.size(),
@@ -1639,8 +1634,8 @@ TEST_F(RaftConsensusITest, TestConfigChangeUnderLoad) {
TServerDetails* tserver_to_add = tservers[to_add_idx];
LOG(INFO) << "Adding tserver with uuid " << tserver_to_add->uuid();
- ASSERT_OK(AddServer(leader_tserver, tablet_id_, tserver_to_add, RaftPeerPB::VOTER, boost::none,
- MonoDelta::FromSeconds(10)));
+ ASSERT_OK(AddServer(leader_tserver, tablet_id_, tserver_to_add,
+ RaftPeerPB::VOTER, MonoDelta::FromSeconds(10)));
InsertOrDie(&active_tablet_servers, tserver_to_add->uuid(), tserver_to_add);
ASSERT_OK(WaitUntilCommittedConfigNumVotersIs(active_tablet_servers.size(),
leader_tserver, tablet_id_,
@@ -1714,7 +1709,7 @@ TEST_F(RaftConsensusITest, TestMasterNotifiedOnConfigChange) {
// Change the config.
TServerDetails* tserver_to_add = tablet_servers_[uuid_to_add];
LOG(INFO) << "Adding tserver with uuid " << tserver_to_add->uuid();
- ASSERT_OK(AddServer(leader_ts, tablet_id_, tserver_to_add, RaftPeerPB::VOTER, boost::none,
+ ASSERT_OK(AddServer(leader_ts, tablet_id_, tserver_to_add, RaftPeerPB::VOTER,
timeout));
ASSERT_OK(WaitForServersToAgree(timeout, tablet_servers_, tablet_id_, 2));
@@ -1730,7 +1725,7 @@ TEST_F(RaftConsensusITest, TestMasterNotifiedOnConfigChange) {
// Change the config again.
LOG(INFO) << "Removing tserver with uuid " << tserver_to_add->uuid();
- ASSERT_OK(RemoveServer(leader_ts, tablet_id_, tserver_to_add, boost::none, timeout));
+ ASSERT_OK(RemoveServer(leader_ts, tablet_id_, tserver_to_add, timeout));
active_tablet_servers = tablet_servers_;
ASSERT_EQ(1, active_tablet_servers.erase(tserver_to_add->uuid()));
ASSERT_OK(WaitForServersToAgree(timeout, active_tablet_servers, tablet_id_, 3));
@@ -1903,7 +1898,7 @@ TEST_F(RaftConsensusITest, TestAutoCreateReplica) {
}
LOG(INFO) << "Adding tserver with uuid " << new_node->uuid() << " as VOTER...";
- ASSERT_OK(AddServer(leader, tablet_id_, new_node, RaftPeerPB::VOTER, boost::none,
+ ASSERT_OK(AddServer(leader, tablet_id_, new_node, RaftPeerPB::VOTER,
MonoDelta::FromSeconds(10)));
InsertOrDie(&active_tablet_servers, new_node->uuid(), new_node);
ASSERT_OK(WaitUntilCommittedConfigNumVotersIs(active_tablet_servers.size(),
@@ -2316,7 +2311,7 @@ TEST_F(RaftConsensusITest, TestChangeConfigRejectedUnlessNoopReplicated) {
// that have been committed yet.
Status s = RemoveServer(leader_ts, tablet_id_,
tablet_servers_[cluster_->tablet_server(1)->uuid()],
- boost::none, timeout);
+ timeout);
ASSERT_TRUE(!s.ok()) << s.ToString();
ASSERT_STR_CONTAINS(s.ToString(), "Leader has not yet committed an operation in its own term");
}
@@ -2356,7 +2351,7 @@ TEST_F(RaftConsensusITest, Test_KUDU_1735) {
// Run a config change. This will cause the other servers to crash with pending config
// change operations due to the above fault injection.
- ASSERT_OK(RemoveServer(leader_tserver, tablet_id_, tservers[1], boost::none, kTimeout));
+ ASSERT_OK(RemoveServer(leader_tserver, tablet_id_, tservers[1], kTimeout));
for (int i = 1; i < cluster_->num_tablet_servers(); i++) {
ASSERT_OK(external_tservers[i]->WaitForInjectedCrash(kTimeout));
}
http://git-wip-us.apache.org/repos/asf/kudu/blob/407f5532/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 23f5010..d537738 100644
--- a/src/kudu/integration-tests/raft_consensus_election-itest.cc
+++ b/src/kudu/integration-tests/raft_consensus_election-itest.cc
@@ -21,7 +21,6 @@
#include <unordered_set>
#include <vector>
-#include <boost/optional/optional.hpp>
#include <gflags/gflags_declare.h>
#include <glog/logging.h>
#include <gtest/gtest.h>
@@ -405,7 +404,7 @@ TEST_F(RaftConsensusElectionITest, ElectPendingVoter) {
// Now remove server 4 from the configuration.
TabletServerMap active_tablet_servers = tablet_servers_;
LOG(INFO) << "Removing tserver with uuid " << final_leader->uuid();
- ASSERT_OK(RemoveServer(initial_leader, tablet_id_, final_leader, boost::none,
+ ASSERT_OK(RemoveServer(initial_leader, tablet_id_, final_leader,
MonoDelta::FromSeconds(10)));
ASSERT_EQ(1, active_tablet_servers.erase(final_leader->uuid()));
int64_t cur_log_index = 2;
@@ -423,7 +422,7 @@ TEST_F(RaftConsensusElectionITest, ElectPendingVoter) {
// Now add server 4 back to the peers.
// This operation will time out on the client side.
LOG(INFO) << "Adding back Peer " << final_leader->uuid() << " and expecting timeout...";
- Status s = AddServer(initial_leader, tablet_id_, final_leader, RaftPeerPB::VOTER, boost::none,
+ Status s = AddServer(initial_leader, tablet_id_, final_leader, RaftPeerPB::VOTER,
MonoDelta::FromMilliseconds(100));
ASSERT_TRUE(s.IsTimedOut()) << "Expected AddServer() to time out. Result: " << s.ToString();
LOG(INFO) << "Timeout achieved.";
@@ -510,7 +509,7 @@ TEST_F(RaftConsensusElectionITest, TombstonedVoteAfterFailedTabletCopy) {
auto* leader_ts = tablet_servers_[leader_uuid];
auto* follower_ts = tablet_servers_[follower_uuid];
ASSERT_OK(itest::AddServer(leader_ts, tablet_id_, follower_ts, RaftPeerPB::VOTER,
- boost::none, kTimeout));
+ kTimeout));
ASSERT_OK(cluster_->tablet_server_by_uuid(follower_uuid)->WaitForInjectedCrash(kTimeout));
// Shut down the rest of the cluster, then only bring back the node we
http://git-wip-us.apache.org/repos/asf/kudu/blob/407f5532/src/kudu/integration-tests/raft_consensus_nonvoter-itest.cc
----------------------------------------------------------------------
diff --git a/src/kudu/integration-tests/raft_consensus_nonvoter-itest.cc b/src/kudu/integration-tests/raft_consensus_nonvoter-itest.cc
index fa32bb9..52109ac 100644
--- a/src/kudu/integration-tests/raft_consensus_nonvoter-itest.cc
+++ b/src/kudu/integration-tests/raft_consensus_nonvoter-itest.cc
@@ -21,7 +21,6 @@
#include <utility>
#include <vector>
-#include <boost/optional/optional.hpp>
#include <gflags/gflags_declare.h>
#include <gtest/gtest.h>
@@ -125,8 +124,7 @@ Status RaftConsensusNonVoterITest::AddReplica(const string& tablet_id,
// 'Illegal state: Leader has not yet committed an operation in its own term'.
RETURN_NOT_OK(WaitForOpFromCurrentTerm(leader, tablet_id,
consensus::COMMITTED_OPID, timeout));
- return AddServer(leader, tablet_id, replica, replica_type,
- boost::none, timeout);
+ return AddServer(leader, tablet_id, replica, replica_type, timeout);
}
Status RaftConsensusNonVoterITest::RemoveReplica(const string& tablet_id,
@@ -140,7 +138,7 @@ Status RaftConsensusNonVoterITest::RemoveReplica(const string& tablet_id,
// 'Illegal state: Leader has not yet committed an operation in its own term'.
RETURN_NOT_OK(WaitForOpFromCurrentTerm(leader, tablet_id,
consensus::COMMITTED_OPID, timeout));
- return RemoveServer(leader, tablet_id, replica, boost::none, timeout);
+ return RemoveServer(leader, tablet_id, replica, timeout);
}
// Ensure that adding a NON_VOTER replica is properly handled by the system:
http://git-wip-us.apache.org/repos/asf/kudu/blob/407f5532/src/kudu/integration-tests/tablet_copy-itest.cc
----------------------------------------------------------------------
diff --git a/src/kudu/integration-tests/tablet_copy-itest.cc b/src/kudu/integration-tests/tablet_copy-itest.cc
index a36e65e..97ff48e 100644
--- a/src/kudu/integration-tests/tablet_copy-itest.cc
+++ b/src/kudu/integration-tests/tablet_copy-itest.cc
@@ -28,7 +28,6 @@
#include <utility>
#include <vector>
-#include <boost/optional/optional.hpp>
#include <gflags/gflags.h>
#include <glog/logging.h>
#include <gtest/gtest.h>
@@ -102,8 +101,14 @@ using kudu::consensus::ConsensusMetadataManager;
using kudu::consensus::ConsensusMetadataPB;
using kudu::consensus::MakeOpId;
using kudu::consensus::RaftPeerPB;
+using kudu::itest::AddServer;
+using kudu::itest::DeleteTablet;
+using kudu::itest::FindTabletLeader;
+using kudu::itest::StartElection;
+using kudu::itest::StartTabletCopy;
using kudu::itest::TServerDetails;
using kudu::itest::WaitForNumTabletServers;
+using kudu::itest::WaitUntilTabletRunning;
using kudu::pb_util::SecureShortDebugString;
using kudu::tablet::TABLET_DATA_COPYING;
using kudu::tablet::TABLET_DATA_DELETED;
@@ -179,8 +184,8 @@ TEST_F(TabletCopyITest, TestRejectRogueLeader) {
// Wait until all replicas are up and running.
for (int i = 0; i < cluster_->num_tablet_servers(); i++) {
- ASSERT_OK(itest::WaitUntilTabletRunning(ts_map_[cluster_->tablet_server(i)->uuid()],
- tablet_id, timeout));
+ ASSERT_OK(WaitUntilTabletRunning(ts_map_[cluster_->tablet_server(i)->uuid()],
+ tablet_id, timeout));
}
LOG(INFO) << "loading data...";
@@ -188,7 +193,7 @@ TEST_F(TabletCopyITest, TestRejectRogueLeader) {
// Elect a leader for term 1, then run some data through the cluster.
int zombie_leader_index = 1;
string zombie_leader_uuid = cluster_->tablet_server(zombie_leader_index)->uuid();
- ASSERT_OK(itest::StartElection(ts_map_[zombie_leader_uuid], tablet_id, timeout));
+ ASSERT_OK(StartElection(ts_map_[zombie_leader_uuid], tablet_id, timeout));
workload.Start();
ASSERT_EVENTUALLY([&] {
ASSERT_GE(workload.rows_inserted(), 100);
@@ -200,10 +205,10 @@ TEST_F(TabletCopyITest, TestRejectRogueLeader) {
// Come out of the blue and try to initiate Tablet Copy from a running server while
// specifying an old term. That running server should reject the request.
// We are essentially masquerading as a rogue leader here.
- Status s = itest::StartTabletCopy(ts, tablet_id, zombie_leader_uuid,
- HostPort(cluster_->tablet_server(1)->bound_rpc_addr()),
- /*caller_term=*/ 0, // Say I'm from term 0.
- timeout);
+ Status s = StartTabletCopy(ts, tablet_id, zombie_leader_uuid,
+ HostPort(cluster_->tablet_server(1)->bound_rpc_addr()),
+ /*caller_term=*/ 0, // Say I'm from term 0.
+ timeout);
ASSERT_TRUE(s.IsInvalidArgument()) << s.ToString();
ASSERT_STR_CONTAINS(s.ToString(), "term 0, which is lower than last-logged term 1");
@@ -213,7 +218,7 @@ TEST_F(TabletCopyITest, TestRejectRogueLeader) {
// Trigger TS 2 to become leader of term 2.
int new_leader_index = 2;
string new_leader_uuid = cluster_->tablet_server(new_leader_index)->uuid();
- ASSERT_OK(itest::StartElection(ts_map_[new_leader_uuid], tablet_id, timeout));
+ ASSERT_OK(StartElection(ts_map_[new_leader_uuid], tablet_id, timeout));
ASSERT_OK(itest::WaitUntilLeader(ts_map_[new_leader_uuid], tablet_id, timeout));
LOG(INFO) << "successfully elected new leader";
@@ -240,7 +245,7 @@ TEST_F(TabletCopyITest, TestRejectRogueLeader) {
cluster_->tablet_server(new_leader_index)->Shutdown();
LOG(INFO) << "tombstoning original follower...";
- ASSERT_OK(itest::DeleteTablet(ts, tablet_id, TABLET_DATA_TOMBSTONED, boost::none, timeout));
+ ASSERT_OK(DeleteTablet(ts, tablet_id, TABLET_DATA_TOMBSTONED, timeout));
// Zombies!!! Resume the rogue zombie leader.
// He should attempt to tablet copy TS 0 but fail.
@@ -270,10 +275,10 @@ TEST_F(TabletCopyITest, TestRejectRogueLeader) {
// It's not necessarily part of the API but this could return faliure due to
// rejecting the remote. We intend to make that part async though, so ignoring
// this return value in this test.
- ignore_result(itest::StartTabletCopy(ts, tablet_id, zombie_leader_uuid,
- HostPort(zombie_ets->bound_rpc_addr()),
- /* caller_term=*/ 2, // Say I'm from term 2.
- timeout));
+ ignore_result(StartTabletCopy(ts, tablet_id, zombie_leader_uuid,
+ HostPort(zombie_ets->bound_rpc_addr()),
+ /* caller_term=*/ 2, // Say I'm from term 2.
+ timeout));
// Wait another few seconds to be sure the tablet copy is rejected.
deadline = MonoTime::Now() + MonoDelta::FromSeconds(5);
@@ -355,9 +360,7 @@ TEST_F(TabletCopyITest, TestListTabletsDuringTabletCopy) {
// Tombstone the tablet on the follower.
LOG(INFO) << "Tombstoning follower tablet " << tablet_id
<< " on TS " << follower_ts->uuid();
- ASSERT_OK(itest::DeleteTablet(follower_ts, tablet_id,
- TABLET_DATA_TOMBSTONED,
- boost::none, kTimeout));
+ ASSERT_OK(DeleteTablet(follower_ts, tablet_id, TABLET_DATA_TOMBSTONED, kTimeout));
// A new good copy should automatically get created via tablet copy.
ASSERT_OK(inspect_->WaitForTabletDataStateOnTS(
@@ -425,8 +428,7 @@ TEST_F(TabletCopyITest, TestDeleteTabletDuringTabletCopy) {
&meta));
// Tombstone the tablet on the remote!
- ASSERT_OK(itest::DeleteTablet(ts, tablet_id,
- TABLET_DATA_TOMBSTONED, boost::none, timeout));
+ ASSERT_OK(DeleteTablet(ts, tablet_id, TABLET_DATA_TOMBSTONED, timeout));
// Now finish copying!
ASSERT_OK(tc_client.FetchAll(nullptr /* no listener */));
@@ -468,14 +470,14 @@ TEST_F(TabletCopyITest, TestTabletCopyFollowerWithHigherTerm) {
// Wait until all replicas are up and running.
for (int i = 0; i < cluster_->num_tablet_servers(); i++) {
- ASSERT_OK(itest::WaitUntilTabletRunning(ts_map_[cluster_->tablet_server(i)->uuid()],
- tablet_id, timeout));
+ ASSERT_OK(WaitUntilTabletRunning(ts_map_[cluster_->tablet_server(i)->uuid()],
+ tablet_id, timeout));
}
// Elect a leader for term 1, then run some data through the cluster.
const int kLeaderIndex = 1;
TServerDetails* leader_ts = ts_map_[cluster_->tablet_server(kLeaderIndex)->uuid()];
- ASSERT_OK(itest::StartElection(leader_ts, tablet_id, timeout));
+ ASSERT_OK(StartElection(leader_ts, tablet_id, timeout));
workload.Start();
while (workload.rows_inserted() < 100) {
SleepFor(MonoDelta::FromMilliseconds(10));
@@ -488,7 +490,7 @@ TEST_F(TabletCopyITest, TestTabletCopyFollowerWithHigherTerm) {
// election on the follower. The election will fail asynchronously but we
// just wait until we see that its term has incremented.
ASSERT_OK(cluster_->tablet_server(kLeaderIndex)->Pause());
- ASSERT_OK(itest::StartElection(follower_ts, tablet_id, timeout));
+ ASSERT_OK(StartElection(follower_ts, tablet_id, timeout));
int64_t term = 0;
for (int i = 0; i < 1000; i++) {
consensus::ConsensusStatePB cstate;
@@ -500,8 +502,7 @@ TEST_F(TabletCopyITest, TestTabletCopyFollowerWithHigherTerm) {
ASSERT_EQ(2, term);
// Now tombstone the follower.
- ASSERT_OK(itest::DeleteTablet(follower_ts, tablet_id, TABLET_DATA_TOMBSTONED, boost::none,
- timeout));
+ ASSERT_OK(DeleteTablet(follower_ts, tablet_id, TABLET_DATA_TOMBSTONED, timeout));
// Restart the follower's TS so that the leader's TS won't get its queued
// vote request messages. This is a hack but seems to work.
@@ -572,8 +573,8 @@ TEST_F(TabletCopyITest, TestConcurrentTabletCopys) {
// Wait until all replicas are up and running.
for (int i = 0; i < cluster_->num_tablet_servers(); i++) {
for (const string& tablet_id : tablet_ids) {
- ASSERT_OK(itest::WaitUntilTabletRunning(ts_map_[cluster_->tablet_server(i)->uuid()],
- tablet_id, timeout));
+ ASSERT_OK(WaitUntilTabletRunning(ts_map_[cluster_->tablet_server(i)->uuid()],
+ tablet_id, timeout));
}
}
@@ -581,7 +582,7 @@ TEST_F(TabletCopyITest, TestConcurrentTabletCopys) {
const int kLeaderIndex = 1;
const string kLeaderUuid = cluster_->tablet_server(kLeaderIndex)->uuid();
for (const string& tablet_id : tablet_ids) {
- ASSERT_OK(itest::StartElection(ts_map_[kLeaderUuid], tablet_id, timeout));
+ ASSERT_OK(StartElection(ts_map_[kLeaderUuid], tablet_id, timeout));
}
TestWorkload workload(cluster_.get());
@@ -605,15 +606,15 @@ TEST_F(TabletCopyITest, TestConcurrentTabletCopys) {
for (const string& tablet_id : tablet_ids) {
LOG(INFO) << "Tombstoning tablet " << tablet_id << " on TS " << target_ts->uuid();
- ASSERT_OK(itest::DeleteTablet(target_ts, tablet_id, TABLET_DATA_TOMBSTONED, boost::none,
- MonoDelta::FromSeconds(10)));
+ ASSERT_OK(DeleteTablet(target_ts, tablet_id, TABLET_DATA_TOMBSTONED,
+ MonoDelta::FromSeconds(10)));
}
// Unpause the leader TS and wait for it to initiate Tablet Copy and replace the tombstoned
// tablets, in parallel.
ASSERT_OK(cluster_->tablet_server(kLeaderIndex)->Resume());
for (const string& tablet_id : tablet_ids) {
- ASSERT_OK(itest::WaitUntilTabletRunning(target_ts, tablet_id, timeout));
+ ASSERT_OK(WaitUntilTabletRunning(target_ts, tablet_id, timeout));
}
ClusterVerifier v(cluster_.get());
@@ -654,8 +655,8 @@ TEST_F(TabletCopyITest, TestDeleteLeaderDuringTabletCopyStressTest) {
// Wait until all replicas are up and running.
for (int i = 0; i < cluster_->num_tablet_servers(); i++) {
- ASSERT_OK(itest::WaitUntilTabletRunning(ts_map_[cluster_->tablet_server(i)->uuid()],
- tablet_id, timeout));
+ ASSERT_OK(WaitUntilTabletRunning(ts_map_[cluster_->tablet_server(i)->uuid()],
+ tablet_id, timeout));
}
int leader_index = -1;
@@ -684,8 +685,7 @@ TEST_F(TabletCopyITest, TestDeleteLeaderDuringTabletCopyStressTest) {
// Tombstone the follower.
LOG(INFO) << "Tombstoning follower tablet " << tablet_id << " on TS " << follower_ts->uuid();
- ASSERT_OK(itest::DeleteTablet(follower_ts, tablet_id, TABLET_DATA_TOMBSTONED, boost::none,
- timeout));
+ ASSERT_OK(DeleteTablet(follower_ts, tablet_id, TABLET_DATA_TOMBSTONED, timeout));
// Wait for tablet copy to start.
ASSERT_OK(inspect_->WaitForTabletDataStateOnTS(
@@ -695,8 +695,7 @@ TEST_F(TabletCopyITest, TestDeleteLeaderDuringTabletCopyStressTest) {
// Tombstone the leader.
LOG(INFO) << "Tombstoning leader tablet " << tablet_id << " on TS " << leader_ts->uuid();
- ASSERT_OK(itest::DeleteTablet(leader_ts, tablet_id, TABLET_DATA_TOMBSTONED, boost::none,
- timeout));
+ ASSERT_OK(DeleteTablet(leader_ts, tablet_id, TABLET_DATA_TOMBSTONED, timeout));
// Quiesce and rebuild to full strength. This involves electing a new
// leader from the remaining three, which requires a unanimous vote, and
@@ -794,13 +793,13 @@ TEST_F(TabletCopyITest, TestDisableTabletCopy_NoTightLoopWhenTabletDeleted) {
// Wait until all replicas are up and running.
for (int i = 0; i < cluster_->num_tablet_servers(); i++) {
- ASSERT_OK(itest::WaitUntilTabletRunning(ts_map_[cluster_->tablet_server(i)->uuid()],
- tablet_id, timeout));
+ ASSERT_OK(WaitUntilTabletRunning(ts_map_[cluster_->tablet_server(i)->uuid()],
+ tablet_id, timeout));
}
// Elect a leader (TS 0)
ExternalTabletServer* leader_ts = cluster_->tablet_server(0);
- ASSERT_OK(itest::StartElection(ts_map_[leader_ts->uuid()], tablet_id, timeout));
+ ASSERT_OK(StartElection(ts_map_[leader_ts->uuid()], tablet_id, timeout));
// Start writing, wait for some rows to be inserted.
workload.Start();
@@ -809,8 +808,7 @@ TEST_F(TabletCopyITest, TestDisableTabletCopy_NoTightLoopWhenTabletDeleted) {
}
// Tombstone the tablet on one of the servers (TS 1)
- ASSERT_OK(itest::DeleteTablet(replica_ts, tablet_id, TABLET_DATA_TOMBSTONED, boost::none,
- timeout));
+ ASSERT_OK(DeleteTablet(replica_ts, tablet_id, TABLET_DATA_TOMBSTONED, timeout));
// Ensure that, if we sleep for a second while still doing writes to the leader:
// a) we don't spew logs on the leader side
@@ -858,13 +856,13 @@ TEST_F(TabletCopyITest, TestSlowCopyDoesntFail) {
// Wait until all replicas are up and running.
for (int i = 0; i < cluster_->num_tablet_servers(); i++) {
- ASSERT_OK(itest::WaitUntilTabletRunning(ts_map_[cluster_->tablet_server(i)->uuid()],
- tablet_id, timeout));
+ ASSERT_OK(WaitUntilTabletRunning(ts_map_[cluster_->tablet_server(i)->uuid()],
+ tablet_id, timeout));
}
// Elect a leader (TS 0)
ExternalTabletServer* leader_ts = cluster_->tablet_server(0);
- ASSERT_OK(itest::StartElection(ts_map_[leader_ts->uuid()], tablet_id, timeout));
+ ASSERT_OK(StartElection(ts_map_[leader_ts->uuid()], tablet_id, timeout));
// Start writing, wait for some rows to be inserted.
workload.Start();
@@ -875,8 +873,7 @@ TEST_F(TabletCopyITest, TestSlowCopyDoesntFail) {
// Tombstone the follower.
LOG(INFO) << "Tombstoning follower tablet " << tablet_id << " on TS " << replica_ts->uuid();
- ASSERT_OK(itest::DeleteTablet(replica_ts, tablet_id, TABLET_DATA_TOMBSTONED, boost::none,
- timeout));
+ ASSERT_OK(DeleteTablet(replica_ts, tablet_id, TABLET_DATA_TOMBSTONED, timeout));
// Wait for tablet copy to start.
ASSERT_OK(inspect_->WaitForTabletDataStateOnTS(1, tablet_id,
@@ -917,23 +914,23 @@ TEST_F(TabletCopyITest, TestTabletCopyingDeletedTabletFails) {
// Wait until all replicas are up and running.
for (int i = 0; i < cluster_->num_tablet_servers(); i++) {
- ASSERT_OK(itest::WaitUntilTabletRunning(ts_map_[cluster_->tablet_server(i)->uuid()],
- tablet_id, kTimeout));
+ ASSERT_OK(WaitUntilTabletRunning(ts_map_[cluster_->tablet_server(i)->uuid()],
+ tablet_id, kTimeout));
}
// Elect a leader for term 1, then run some data through the cluster.
- ASSERT_OK(itest::StartElection(leader, tablet_id, kTimeout));
+ ASSERT_OK(StartElection(leader, tablet_id, kTimeout));
ASSERT_OK(WaitForServersToAgree(kTimeout, ts_map_, tablet_id, 1));
// Now delete the leader with TABLET_DATA_DELETED. We should not be able to
// bring back the leader after that until restarting the process.
- ASSERT_OK(itest::DeleteTablet(leader, tablet_id, TABLET_DATA_DELETED, boost::none, kTimeout));
+ ASSERT_OK(DeleteTablet(leader, tablet_id, TABLET_DATA_DELETED, kTimeout));
- Status s = itest::StartTabletCopy(leader, tablet_id,
- cluster_->tablet_server(1)->uuid(),
- HostPort(cluster_->tablet_server(1)->bound_rpc_addr()),
- 1, // We are in term 1.
- kTimeout);
+ Status s = StartTabletCopy(leader, tablet_id,
+ cluster_->tablet_server(1)->uuid(),
+ HostPort(cluster_->tablet_server(1)->bound_rpc_addr()),
+ 1, // We are in term 1.
+ kTimeout);
ASSERT_TRUE(s.IsIllegalState()) << s.ToString();
ASSERT_STR_CONTAINS(s.ToString(), "Cannot transition from state TABLET_DATA_DELETED");
@@ -942,11 +939,11 @@ TEST_F(TabletCopyITest, TestTabletCopyingDeletedTabletFails) {
cluster_->tablet_server(0)->Shutdown();
ASSERT_OK(cluster_->tablet_server(0)->Restart());
- ASSERT_OK(itest::StartTabletCopy(leader, tablet_id,
- cluster_->tablet_server(1)->uuid(),
- HostPort(cluster_->tablet_server(1)->bound_rpc_addr()),
- 1, // We are in term 1.
- kTimeout));
+ ASSERT_OK(StartTabletCopy(leader, tablet_id,
+ cluster_->tablet_server(1)->uuid(),
+ HostPort(cluster_->tablet_server(1)->bound_rpc_addr()),
+ 1, // We are in term 1.
+ kTimeout));
ASSERT_OK(WaitForServersToAgree(kTimeout, ts_map_, tablet_id, 1));
}
@@ -970,12 +967,12 @@ TEST_F(TabletCopyITest, TestTabletCopyClearsLastLoggedOpId) {
// Wait until all replicas are up and running.
for (int i = 0; i < cluster_->num_tablet_servers(); i++) {
- ASSERT_OK(itest::WaitUntilTabletRunning(ts_map_[cluster_->tablet_server(i)->uuid()],
- tablet_id, kTimeout));
+ ASSERT_OK(WaitUntilTabletRunning(ts_map_[cluster_->tablet_server(i)->uuid()],
+ tablet_id, kTimeout));
}
// Elect a leader for term 1, then generate some data to copy.
- ASSERT_OK(itest::StartElection(leader, tablet_id, kTimeout));
+ ASSERT_OK(StartElection(leader, tablet_id, kTimeout));
workload.Start();
const int kMinBatches = 10;
while (workload.batches_completed() < kMinBatches) {
@@ -990,7 +987,7 @@ TEST_F(TabletCopyITest, TestTabletCopyClearsLastLoggedOpId) {
ASSERT_FALSE(superblock_pb.has_tombstone_last_logged_opid());
// Now tombstone the leader.
- ASSERT_OK(itest::DeleteTablet(leader, tablet_id, TABLET_DATA_TOMBSTONED, boost::none, kTimeout));
+ ASSERT_OK(DeleteTablet(leader, tablet_id, TABLET_DATA_TOMBSTONED, kTimeout));
// We should end up with a last-logged opid in the superblock.
ASSERT_OK(inspect_->ReadTabletSuperBlockOnTS(leader_index, tablet_id, &superblock_pb));
@@ -1000,11 +997,11 @@ TEST_F(TabletCopyITest, TestTabletCopyClearsLastLoggedOpId) {
ASSERT_GT(last_logged_opid.index(), kMinBatches);
int follower_index = 1;
- ASSERT_OK(itest::StartTabletCopy(leader, tablet_id,
- cluster_->tablet_server(follower_index)->uuid(),
- cluster_->tablet_server(follower_index)->bound_rpc_hostport(),
- 1, // We are in term 1.
- kTimeout));
+ ASSERT_OK(StartTabletCopy(leader, tablet_id,
+ cluster_->tablet_server(follower_index)->uuid(),
+ cluster_->tablet_server(follower_index)->bound_rpc_hostport(),
+ 1, // We are in term 1.
+ kTimeout));
ASSERT_EVENTUALLY([&] {
// Ensure that the last-logged opid has been cleared from the superblock
@@ -1163,12 +1160,11 @@ TEST_P(TabletCopyFailureITest, TestTabletCopyNewReplicaFailureCanVote) {
// Allow retries in case the tablet leadership is unstable.
ASSERT_EVENTUALLY([&] {
TServerDetails* leader_ts;
- ASSERT_OK(itest::FindTabletLeader(ts_map_, tablet_id, kTimeout, &leader_ts));
+ ASSERT_OK(FindTabletLeader(ts_map_, tablet_id, kTimeout, &leader_ts));
ASSERT_OK(itest::WaitForOpFromCurrentTerm(leader_ts, tablet_id, COMMITTED_OPID, kTimeout));
// Adding a server will trigger a tablet copy.
- ASSERT_OK(itest::AddServer(leader_ts, tablet_id, new_replica_ts, RaftPeerPB::VOTER,
- boost::none, kTimeout));
+ ASSERT_OK(AddServer(leader_ts, tablet_id, new_replica_ts, RaftPeerPB::VOTER, kTimeout));
});
// Wait until the new replica has done its initial download, and has either
@@ -1236,12 +1232,12 @@ TEST_P(TabletCopyFailureITest, TestFailedTabletCopyRetainsLastLoggedOpId) {
// Wait until all replicas are up and running.
for (int i = 0; i < cluster_->num_tablet_servers(); i++) {
- ASSERT_OK(itest::WaitUntilTabletRunning(ts_map_[cluster_->tablet_server(i)->uuid()],
- tablet_id, kTimeout));
+ ASSERT_OK(WaitUntilTabletRunning(ts_map_[cluster_->tablet_server(i)->uuid()],
+ tablet_id, kTimeout));
}
// Elect a leader for term 1, then generate some data to copy.
- ASSERT_OK(itest::StartElection(first_leader, tablet_id, kTimeout));
+ ASSERT_OK(StartElection(first_leader, tablet_id, kTimeout));
workload.Start();
const int kMinBatches = 10;
ASSERT_EVENTUALLY([&] {
@@ -1251,8 +1247,7 @@ TEST_P(TabletCopyFailureITest, TestFailedTabletCopyRetainsLastLoggedOpId) {
ASSERT_OK(WaitForServersToAgree(kTimeout, ts_map_, tablet_id, 1));
// Tombstone the first leader.
- ASSERT_OK(itest::DeleteTablet(first_leader, tablet_id, TABLET_DATA_TOMBSTONED, boost::none,
- kTimeout));
+ ASSERT_OK(DeleteTablet(first_leader, tablet_id, TABLET_DATA_TOMBSTONED, kTimeout));
// We should end up with a last-logged opid in the superblock of the first leader.
tablet::TabletSuperBlockPB superblock_pb;
@@ -1266,7 +1261,7 @@ TEST_P(TabletCopyFailureITest, TestFailedTabletCopyRetainsLastLoggedOpId) {
// Elect a new leader.
int second_leader_index = 1;
TServerDetails* second_leader = ts_map_[cluster_->tablet_server(second_leader_index)->uuid()];
- ASSERT_OK(itest::StartElection(second_leader, tablet_id, kTimeout));
+ ASSERT_OK(StartElection(second_leader, tablet_id, kTimeout));
// The second leader will initiate a tablet copy on the first leader. Wait
// for it to fail (via crash or abort).
@@ -1567,9 +1562,7 @@ TEST_F(TabletCopyITest, TestTabletCopyMetrics) {
LOG(INFO) << "Tombstoning follower tablet " << tablet_id
<< " on TS " << follower_ts->uuid();
- ASSERT_OK(itest::DeleteTablet(follower_ts, tablet_id,
- TABLET_DATA_TOMBSTONED,
- boost::none, kTimeout));
+ ASSERT_OK(DeleteTablet(follower_ts, tablet_id, TABLET_DATA_TOMBSTONED, kTimeout));
// Wait for copying to start.
ASSERT_OK(inspect_->WaitForTabletDataStateOnTS(
@@ -1679,9 +1672,7 @@ TEST_F(TabletCopyITest, TestTabletStateMetricsDuringTabletCopy) {
});
// Tombstone the tablet on the follower.
- ASSERT_OK(itest::DeleteTablet(follower_ts, tablet_id,
- TABLET_DATA_TOMBSTONED,
- boost::none, kTimeout));
+ ASSERT_OK(DeleteTablet(follower_ts, tablet_id, TABLET_DATA_TOMBSTONED, kTimeout));
// State: 0 running tablets.
ASSERT_EVENTUALLY([&] {
@@ -1738,9 +1729,7 @@ TEST_F(TabletCopyITest, TestMetricsResetAfterRevival) {
ASSERT_GT(CountRowsInserted(cluster_->tablet_server(follower_index)), 0);
// Tombstone the tablet on the follower.
- ASSERT_OK(itest::DeleteTablet(follower_ts, tablet_id,
- TABLET_DATA_TOMBSTONED,
- boost::none, kTimeout));
+ ASSERT_OK(DeleteTablet(follower_ts, tablet_id, TABLET_DATA_TOMBSTONED, kTimeout));
});
// Wait for the tablet to be revived via tablet copy.
http://git-wip-us.apache.org/repos/asf/kudu/blob/407f5532/src/kudu/integration-tests/tablet_copy_client_session-itest.cc
----------------------------------------------------------------------
diff --git a/src/kudu/integration-tests/tablet_copy_client_session-itest.cc b/src/kudu/integration-tests/tablet_copy_client_session-itest.cc
index e24dcb0..14d05d4 100644
--- a/src/kudu/integration-tests/tablet_copy_client_session-itest.cc
+++ b/src/kudu/integration-tests/tablet_copy_client_session-itest.cc
@@ -25,7 +25,6 @@
#include <unordered_map>
#include <vector>
-#include <boost/optional/optional.hpp>
#include <glog/logging.h>
#include <gtest/gtest.h>
@@ -188,9 +187,9 @@ TEST_F(TabletCopyClientSessionITest, TestStartTabletCopyWhileSourceBootstrapping
// tablet copy operation completing, so we retry tablet deletion attempts.
// We want a clean deletion so only one thread wins, then we have to
// restart TS 1 to clear knowledge of the replica from memory.
- NO_FATALS(DeleteTabletWithRetries(ts1, tablet_id,
+ ASSERT_OK(DeleteTabletWithRetries(ts1, tablet_id,
TabletDataState::TABLET_DATA_DELETED,
- boost::none, kTimeout));
+ kTimeout));
cluster_->tablet_server(1)->Shutdown();
ASSERT_OK(cluster_->tablet_server(1)->Restart());
}
@@ -215,9 +214,9 @@ TEST_F(TabletCopyClientSessionITest, TestStartTabletCopy) {
};
for (int scenario = 0; scenario < kLast; scenario++) {
if (scenario == kTombstoned) {
- NO_FATALS(DeleteTabletWithRetries(ts1, tablet_id,
+ ASSERT_OK(DeleteTabletWithRetries(ts1, tablet_id,
TabletDataState::TABLET_DATA_TOMBSTONED,
- boost::none, kDefaultTimeout));
+ kDefaultTimeout));
}
// Run tablet copy.
http://git-wip-us.apache.org/repos/asf/kudu/blob/407f5532/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 8bdfd3d..29ead3c 100644
--- a/src/kudu/integration-tests/tablet_replacement-itest.cc
+++ b/src/kudu/integration-tests/tablet_replacement-itest.cc
@@ -15,7 +15,6 @@
// specific language governing permissions and limitations
// under the License.
-#include <cstdint>
#include <memory>
#include <ostream>
#include <string>
@@ -24,7 +23,6 @@
#include <vector>
#include <boost/bind.hpp>
-#include <boost/optional/optional.hpp>
#include <glog/logging.h>
#include <gtest/gtest.h>
@@ -53,6 +51,8 @@
#include "kudu/util/test_util.h"
using kudu::consensus::RaftPeerPB;
+using kudu::itest::AddServer;
+using kudu::itest::RemoveServer;
using kudu::itest::TServerDetails;
using kudu::tablet::TABLET_DATA_READY;
using kudu::tablet::TABLET_DATA_TOMBSTONED;
@@ -107,7 +107,7 @@ TEST_F(TabletReplacementITest, TestMasterTombstoneEvictedReplica) {
ASSERT_OK(itest::WaitUntilCommittedOpIdIndexIs(1, leader_ts, tablet_id, timeout));
// Remove a follower from the config.
- ASSERT_OK(itest::RemoveServer(leader_ts, tablet_id, follower_ts, boost::none, timeout));
+ ASSERT_OK(RemoveServer(leader_ts, tablet_id, follower_ts, timeout));
// Wait for the Master to tombstone the replica.
ASSERT_OK(inspect_->WaitForTabletDataStateOnTS(kFollowerIndex, tablet_id,
@@ -129,8 +129,8 @@ TEST_F(TabletReplacementITest, TestMasterTombstoneEvictedReplica) {
ASSERT_EQ(1, active_ts_map.erase(cluster_->tablet_server(i)->uuid()));
}
// This will time out, but should take effect.
- Status s = itest::AddServer(leader_ts, tablet_id, follower_ts, RaftPeerPB::VOTER,
- boost::none, MonoDelta::FromSeconds(5));
+ Status s = AddServer(leader_ts, tablet_id, follower_ts, RaftPeerPB::VOTER,
+ MonoDelta::FromSeconds(5));
ASSERT_TRUE(s.IsTimedOut());
ASSERT_OK(inspect_->WaitForTabletDataStateOnTS(kFollowerIndex, tablet_id, { TABLET_DATA_READY },
timeout));
@@ -259,7 +259,7 @@ TEST_F(TabletReplacementITest, TestMasterTombstoneOldReplicaOnReport) {
// Remove the follower from the config and wait for the Master to notice the
// config change.
- ASSERT_OK(itest::RemoveServer(leader_ts, tablet_id, follower_ts, boost::none, timeout));
+ ASSERT_OK(RemoveServer(leader_ts, tablet_id, follower_ts, timeout));
ASSERT_OK(itest::WaitForNumVotersInConfigOnMaster(cluster_->master_proxy(), tablet_id, 2,
timeout));
@@ -332,7 +332,7 @@ TEST_F(TabletReplacementITest, TestRemoteBoostrapWithPendingConfigChangeCommits)
return;
}
- MonoDelta timeout = MonoDelta::FromSeconds(30);
+ const MonoDelta timeout = MonoDelta::FromSeconds(30);
vector<string> ts_flags;
ts_flags.emplace_back("--enable_leader_failure_detection=false");
vector<string> master_flags;
@@ -395,11 +395,10 @@ TEST_F(TabletReplacementITest, TestRemoteBoostrapWithPendingConfigChangeCommits)
// Manually evict the server from the cluster, tombstone the replica, then
// add the replica back to the cluster. Without the fix for KUDU-1233, this
// will cause the replica to fail to start up.
- ASSERT_OK(itest::RemoveServer(leader_ts, tablet_id, ts_to_remove, boost::none, timeout));
+ ASSERT_OK(RemoveServer(leader_ts, tablet_id, ts_to_remove, timeout));
ASSERT_OK(itest::DeleteTablet(ts_to_remove, tablet_id, TABLET_DATA_TOMBSTONED,
- boost::none, timeout));
- ASSERT_OK(itest::AddServer(leader_ts, tablet_id, ts_to_remove, RaftPeerPB::VOTER,
- boost::none, timeout));
+ timeout));
+ ASSERT_OK(AddServer(leader_ts, tablet_id, ts_to_remove, RaftPeerPB::VOTER, timeout));
ASSERT_OK(itest::WaitUntilTabletRunning(ts_to_remove, tablet_id, timeout));
ClusterVerifier v(cluster_.get());
http://git-wip-us.apache.org/repos/asf/kudu/blob/407f5532/src/kudu/integration-tests/tombstoned_voting-imc-itest.cc
----------------------------------------------------------------------
diff --git a/src/kudu/integration-tests/tombstoned_voting-imc-itest.cc b/src/kudu/integration-tests/tombstoned_voting-imc-itest.cc
index 4b440f8..02c2208 100644
--- a/src/kudu/integration-tests/tombstoned_voting-imc-itest.cc
+++ b/src/kudu/integration-tests/tombstoned_voting-imc-itest.cc
@@ -43,7 +43,6 @@
#include "kudu/tserver/mini_tablet_server.h"
#include "kudu/tserver/tablet_server.h"
#include "kudu/tserver/ts_tablet_manager.h"
-#include "kudu/tserver/tserver.pb.h"
#include "kudu/util/env.h"
#include "kudu/util/monotime.h"
#include "kudu/util/status.h"
@@ -66,7 +65,6 @@ using kudu::itest::WaitForServersToAgree;
using kudu::tablet::TABLET_DATA_TOMBSTONED;
using kudu::tablet::TabletReplica;
using kudu::tablet::TabletStatePB;
-using kudu::tserver::TabletServerErrorPB;
using kudu::tserver::TSTabletManager;
using std::string;
using std::vector;
@@ -113,9 +111,8 @@ TEST_F(TombstonedVotingIMCITest, TestNoVoteAfterShutdown) {
// Tombstone TS1's replica.
LOG(INFO) << "Tombstoning ts1...";
- boost::optional<TabletServerErrorPB::Code> error_code;
- ASSERT_OK(ts_tablet_manager->DeleteTablet(tablet_id, TABLET_DATA_TOMBSTONED, boost::none,
- &error_code));
+ ASSERT_OK(ts_tablet_manager->DeleteTablet(tablet_id, TABLET_DATA_TOMBSTONED,
+ boost::none));
ASSERT_EQ(TabletStatePB::STOPPED, ts1_replica->state());
scoped_refptr<TabletReplica> ts0_replica;
@@ -190,8 +187,8 @@ TEST_F(TombstonedVotingIMCITest, TestVotingLogic) {
&last_logged_opid));
// Tombstone TS1 (actually, the tablet replica hosted on TS1).
- ASSERT_OK(itest::DeleteTablet(ts_map_[cluster_->mini_tablet_server(1)->uuid()], tablet_id,
- TABLET_DATA_TOMBSTONED, boost::none, kTimeout));
+ ASSERT_OK(DeleteTablet(ts_map_[cluster_->mini_tablet_server(1)->uuid()],
+ tablet_id, TABLET_DATA_TOMBSTONED, kTimeout));
// Loop this series of tests twice: the first time without restarting the TS,
// the 2nd time after a restart.
@@ -280,7 +277,7 @@ TEST_F(TombstonedVotingIMCITest, TestNoVoteIfTombstonedVotingDisabled) {
// Tombstone TS1 and try to get TS0 to vote for it.
TServerDetails* ts1 = ts_map_[cluster_->mini_tablet_server(1)->uuid()];
- ASSERT_OK(DeleteTablet(ts1, tablet_id, TABLET_DATA_TOMBSTONED, boost::none, kTimeout));
+ ASSERT_OK(DeleteTablet(ts1, tablet_id, TABLET_DATA_TOMBSTONED, kTimeout));
scoped_refptr<TabletReplica> ts0_replica;
ASSERT_OK(cluster_->mini_tablet_server(0)->server()->tablet_manager()->GetTabletReplica(
@@ -357,8 +354,7 @@ TEST_F(TombstonedVotingIMCITest, TestNoVoteIfNoLastLoggedOpId) {
ASSERT_EQ(tablet::FAILED, replica->state());
// Now tombstone the failed replica on TS0.
- ASSERT_OK(itest::DeleteTablet(ts_map_[ts0_uuid], tablet_id,
- TABLET_DATA_TOMBSTONED, boost::none, kTimeout));
+ ASSERT_OK(DeleteTablet(ts_map_[ts0_uuid], tablet_id, TABLET_DATA_TOMBSTONED, kTimeout));
// Wait until TS1 is running.
ASSERT_EVENTUALLY([&] {
@@ -428,7 +424,7 @@ TEST_P(TsRecoveryTombstonedIMCITest, TestTombstonedVoter) {
LOG(INFO) << "tombstoning replica on TS " << cluster_->mini_tablet_server(1)->uuid();
TServerDetails* ts1 = ts_map_[cluster_->mini_tablet_server(1)->uuid()];
- ASSERT_OK(DeleteTablet(ts1, tablet_id, TABLET_DATA_TOMBSTONED, boost::none, kTimeout));
+ ASSERT_OK(DeleteTablet(ts1, tablet_id, TABLET_DATA_TOMBSTONED, kTimeout));
if (to_restart == kRestart) {
LOG(INFO) << "restarting tombstoned TS " << cluster_->mini_tablet_server(1)->uuid();
http://git-wip-us.apache.org/repos/asf/kudu/blob/407f5532/src/kudu/integration-tests/tombstoned_voting-stress-test.cc
----------------------------------------------------------------------
diff --git a/src/kudu/integration-tests/tombstoned_voting-stress-test.cc b/src/kudu/integration-tests/tombstoned_voting-stress-test.cc
index 9a6c52e..f12ba59 100644
--- a/src/kudu/integration-tests/tombstoned_voting-stress-test.cc
+++ b/src/kudu/integration-tests/tombstoned_voting-stress-test.cc
@@ -25,7 +25,6 @@
#include <unordered_map>
#include <vector>
-#include <boost/optional/optional.hpp>
#include <gflags/gflags.h>
#include <glog/logging.h>
#include <gtest/gtest.h>
@@ -289,8 +288,7 @@ TEST_F(TombstonedVotingStressTest, TestTombstonedVotingUnderStress) {
// 1. Tombstone tablet.
LOG(INFO) << "tombstoning tablet...";
SetState(kTombstoning);
- ASSERT_OK(itest::DeleteTablet(ts1_ets, tablet_id_, TABLET_DATA_TOMBSTONED, boost::none,
- kTimeout));
+ ASSERT_OK(DeleteTablet(ts1_ets, tablet_id_, TABLET_DATA_TOMBSTONED, kTimeout));
SetState(kTombstoned);
// Loop on voting for a while in tombstoned state.
http://git-wip-us.apache.org/repos/asf/kudu/blob/407f5532/src/kudu/tools/kudu-admin-test.cc
----------------------------------------------------------------------
diff --git a/src/kudu/tools/kudu-admin-test.cc b/src/kudu/tools/kudu-admin-test.cc
index 696ba89..1506238 100644
--- a/src/kudu/tools/kudu-admin-test.cc
+++ b/src/kudu/tools/kudu-admin-test.cc
@@ -695,8 +695,7 @@ TEST_F(AdminCliTest, TestUnsafeChangeConfigLeaderWithPendingConfig) {
// Now try to replicate a ChangeConfig operation. This should get stuck and time out
// because the server can't replicate any operations.
Status s = RemoveServer(leader_ts, tablet_id_, followers[1],
- -1, MonoDelta::FromSeconds(2),
- nullptr);
+ MonoDelta::FromSeconds(2), -1);
ASSERT_TRUE(s.IsTimedOut());
LOG(INFO) << "Change Config Op timed out, Sending a Replace config "
@@ -795,8 +794,7 @@ TEST_F(AdminCliTest, TestUnsafeChangeConfigFollowerWithPendingConfig) {
// Now try to replicate a ChangeConfig operation. This should get stuck and time out
// because the server can't replicate any operations.
Status s = RemoveServer(leader_ts, tablet_id_, followers[1],
- -1, MonoDelta::FromSeconds(2),
- nullptr);
+ MonoDelta::FromSeconds(2), -1);
ASSERT_TRUE(s.IsTimedOut());
// Force leader to step down, best effort command since the leadership
@@ -899,8 +897,7 @@ TEST_F(AdminCliTest, TestUnsafeChangeConfigWithPendingConfigsOnWAL) {
// Now try to replicate a ChangeConfig operation. This should get stuck and time out
// because the server can't replicate any operations.
Status s = RemoveServer(leader_ts, tablet_id_, followers[1],
- -1, MonoDelta::FromSeconds(2),
- nullptr);
+ MonoDelta::FromSeconds(2), -1);
ASSERT_TRUE(s.IsTimedOut());
LOG(INFO) << "Change Config Op timed out, Sending a Replace config "
http://git-wip-us.apache.org/repos/asf/kudu/blob/407f5532/src/kudu/tserver/tablet_service.cc
----------------------------------------------------------------------
diff --git a/src/kudu/tserver/tablet_service.cc b/src/kudu/tserver/tablet_service.cc
index e3838c4..a250119 100644
--- a/src/kudu/tserver/tablet_service.cc
+++ b/src/kudu/tserver/tablet_service.cc
@@ -800,7 +800,7 @@ void TabletServiceAdminImpl::DeleteTablet(const DeleteTabletRequestPB* req,
if (req->has_cas_config_opid_index_less_or_equal()) {
cas_config_opid_index_less_or_equal = req->cas_config_opid_index_less_or_equal();
}
- boost::optional<TabletServerErrorPB::Code> error_code;
+ TabletServerErrorPB::Code error_code;
Status s = server_->tablet_manager()->DeleteTablet(req->tablet_id(),
delete_type,
cas_config_opid_index_less_or_equal,
http://git-wip-us.apache.org/repos/asf/kudu/blob/407f5532/src/kudu/tserver/ts_tablet_manager.cc
----------------------------------------------------------------------
diff --git a/src/kudu/tserver/ts_tablet_manager.cc b/src/kudu/tserver/ts_tablet_manager.cc
index ceb3641..56a9478 100644
--- a/src/kudu/tserver/ts_tablet_manager.cc
+++ b/src/kudu/tserver/ts_tablet_manager.cc
@@ -740,8 +740,8 @@ Status TSTabletManager::CreateAndRegisterTabletReplica(
Status TSTabletManager::DeleteTablet(
const string& tablet_id,
TabletDataState delete_type,
- const boost::optional<int64_t>& cas_config_opid_index_less_or_equal,
- boost::optional<TabletServerErrorPB::Code>* error_code) {
+ const boost::optional<int64_t>& cas_config_index,
+ TabletServerErrorPB::Code* error_code) {
if (delete_type != TABLET_DATA_DELETED && delete_type != TABLET_DATA_TOMBSTONED) {
return Status::InvalidArgument("DeleteTablet() requires an argument that is one of "
@@ -762,13 +762,17 @@ Status TSTabletManager::DeleteTablet(
RETURN_NOT_OK(CheckRunningUnlocked(error_code));
if (!LookupTabletUnlocked(tablet_id, &replica)) {
- *error_code = TabletServerErrorPB::TABLET_NOT_FOUND;
+ if (error_code) {
+ *error_code = TabletServerErrorPB::TABLET_NOT_FOUND;
+ }
return Status::NotFound("Tablet not found", tablet_id);
}
// Sanity check that the tablet's deletion isn't already in progress
Status s = StartTabletStateTransitionUnlocked(tablet_id, "deleting tablet", &deleter);
if (PREDICT_FALSE(!s.ok())) {
- *error_code = TabletServerErrorPB::TABLET_NOT_RUNNING;
+ if (error_code) {
+ *error_code = TabletServerErrorPB::TABLET_NOT_RUNNING;
+ }
return s;
}
}
@@ -785,17 +789,17 @@ Status TSTabletManager::DeleteTablet(
// restarting the tablet if the local replica committed a higher config change
// op during that time, or potentially something else more invasive.
shared_ptr<RaftConsensus> consensus = replica->shared_consensus();
- if (cas_config_opid_index_less_or_equal && !tablet_already_deleted) {
+ if (cas_config_index && !tablet_already_deleted) {
if (!consensus) {
*error_code = TabletServerErrorPB::TABLET_NOT_RUNNING;
return Status::IllegalState("Raft Consensus not available. Tablet shutting down");
}
RaftConfigPB committed_config = consensus->CommittedConfig();
- if (committed_config.opid_index() > *cas_config_opid_index_less_or_equal) {
+ if (committed_config.opid_index() > *cas_config_index) {
*error_code = TabletServerErrorPB::CAS_FAILED;
return Status::IllegalState(Substitute("Request specified cas_config_opid_index_less_or_equal"
" of $0 but the committed config has opid_index of $1",
- *cas_config_opid_index_less_or_equal,
+ *cas_config_index,
committed_config.opid_index()));
}
}
@@ -844,11 +848,13 @@ string TSTabletManager::LogPrefix(const string& tablet_id, FsManager *fs_manager
}
Status TSTabletManager::CheckRunningUnlocked(
- boost::optional<TabletServerErrorPB::Code>* error_code) const {
+ TabletServerErrorPB::Code* error_code) const {
if (state_ == MANAGER_RUNNING) {
return Status::OK();
}
- *error_code = TabletServerErrorPB::TABLET_NOT_RUNNING;
+ if (error_code) {
+ *error_code = TabletServerErrorPB::TABLET_NOT_RUNNING;
+ }
return Status::ServiceUnavailable(Substitute("Tablet Manager is not running: $0",
TSTabletManagerStatePB_Name(state_)));
}
http://git-wip-us.apache.org/repos/asf/kudu/blob/407f5532/src/kudu/tserver/ts_tablet_manager.h
----------------------------------------------------------------------
diff --git a/src/kudu/tserver/ts_tablet_manager.h b/src/kudu/tserver/ts_tablet_manager.h
index 88bebff..1b5f24d 100644
--- a/src/kudu/tserver/ts_tablet_manager.h
+++ b/src/kudu/tserver/ts_tablet_manager.h
@@ -124,15 +124,15 @@ class TSTabletManager : public tserver::TabletReplicaLookupIf {
// Delete the specified tablet.
// 'delete_type' must be one of TABLET_DATA_DELETED or TABLET_DATA_TOMBSTONED
// or else returns Status::IllegalArgument.
- // 'cas_config_opid_index_less_or_equal' is optionally specified to enable an
+ // 'cas_config_index' is optionally specified to enable an
// atomic DeleteTablet operation that only occurs if the latest committed
- // raft config change op has an opid_index equal to or less than the specified
+ // Raft config change op has an opid_index equal to or less than the specified
// value. If not, 'error_code' is set to CAS_FAILED and a non-OK Status is
// returned.
Status DeleteTablet(const std::string& tablet_id,
tablet::TabletDataState delete_type,
- const boost::optional<int64_t>& cas_config_opid_index_less_or_equal,
- boost::optional<TabletServerErrorPB::Code>* error_code);
+ const boost::optional<int64_t>& cas_config_index,
+ TabletServerErrorPB::Code* error_code = nullptr);
// Lookup the given tablet replica by its ID.
// Returns true if the tablet is found successfully.
@@ -221,7 +221,7 @@ class TSTabletManager : public tserver::TabletReplicaLookupIf {
}
// Returns Status::OK() iff state_ == MANAGER_RUNNING.
- Status CheckRunningUnlocked(boost::optional<TabletServerErrorPB::Code>* error_code) const;
+ Status CheckRunningUnlocked(TabletServerErrorPB::Code* error_code) const;
// Registers the start of a tablet state transition by inserting the tablet
// id and reason string into the transition_in_progress_ map.