kudu-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dral...@apache.org
Subject [1/2] kudu git commit: block placement: test DataDirGroups on old servers
Date Wed, 07 Jun 2017 14:19:16 GMT
Repository: kudu
Updated Branches:
  refs/heads/master cdf0fee49 -> 10aeb2877


block placement: test DataDirGroups on old servers

This patch adds a test ensuring that servers that ran before commit
732ee211a31335a1b146428b15887d1f26468a3a (whose tablet metadata
files do not have DataDirGroupPBs) will create DataDirGroupPBs upon
starting up.

The test creates a tablet, removes the DataDirGroupPB on-disk, and
restarts the server, ensuring a new group is created.

Change-Id: Id27d7a248c129299fb451ce90519fc16c0a105e4
Reviewed-on: http://gerrit.cloudera.org:8080/7088
Tested-by: Kudu Jenkins
Reviewed-by: David Ribeiro Alves <davidralves@gmail.com>


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

Branch: refs/heads/master
Commit: 851e8470ef0b7a5859c7af968af3f67d52cda495
Parents: cdf0fee
Author: Andrew Wong <awong@cloudera.com>
Authored: Mon Jun 5 12:11:41 2017 -0700
Committer: David Ribeiro Alves <davidralves@gmail.com>
Committed: Wed Jun 7 13:47:21 2017 +0000

----------------------------------------------------------------------
 src/kudu/tserver/tablet_server-test.cc | 33 +++++++++++++++++++++++++++--
 1 file changed, 31 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kudu/blob/851e8470/src/kudu/tserver/tablet_server-test.cc
----------------------------------------------------------------------
diff --git a/src/kudu/tserver/tablet_server-test.cc b/src/kudu/tserver/tablet_server-test.cc
index 4aa6417..1cedc97 100644
--- a/src/kudu/tserver/tablet_server-test.cc
+++ b/src/kudu/tserver/tablet_server-test.cc
@@ -19,6 +19,7 @@
 #include <memory>
 #include <sstream>
 
+#include <google/protobuf/util/message_differencer.h>
 #include <zlib.h>
 
 #include "kudu/consensus/log-test-base.h"
@@ -36,8 +37,7 @@
 #include "kudu/util/url-coding.h"
 #include "kudu/util/zlib.h"
 
-using kudu::consensus::RaftConfigPB;
-using kudu::consensus::RaftPeerPB;
+using google::protobuf::util::MessageDifferencer;
 using kudu::rpc::Messenger;
 using kudu::rpc::MessengerBuilder;
 using kudu::rpc::RpcController;
@@ -45,6 +45,7 @@ using kudu::server::Clock;
 using kudu::server::HybridClock;
 using kudu::tablet::Tablet;
 using kudu::tablet::TabletReplica;
+using kudu::tablet::TabletSuperBlockPB;
 using std::shared_ptr;
 using std::string;
 using std::unique_ptr;
@@ -2454,5 +2455,33 @@ TEST_F(TabletServerTest, TestFailedDnsResolution) {
   usleep(100 * 1000);
 }
 
+TEST_F(TabletServerTest, TestDataDirGroupsCreated) {
+  // Get the original superblock.
+  TabletSuperBlockPB superblock;
+  tablet_replica_->tablet()->metadata()->ToSuperBlock(&superblock);
+  DataDirGroupPB orig_group = superblock.data_dir_group();
+
+  // Remove the DataDirGroupPB on-disk.
+  superblock.clear_data_dir_group();
+  ASSERT_FALSE(superblock.has_data_dir_group());
+  string tablet_meta_path = JoinPathSegments(GetTestPath("TabletServerTest-fsroot"), "tablet-meta");
+  string pb_path = JoinPathSegments(tablet_meta_path, tablet_replica_->tablet_id());
+  ASSERT_OK(pb_util::WritePBContainerToPath(Env::Default(),
+      pb_path, superblock, pb_util::OVERWRITE, pb_util::SYNC));
+
+  // Verify that the on-disk copy has its DataDirGroup missing.
+  ASSERT_OK(tablet_replica_->tablet()->metadata()->ReadSuperBlockFromDisk(&superblock));
+  ASSERT_FALSE(superblock.has_data_dir_group());
+
+  // Restart the server and check that a new group is created. By default, the
+  // group will be created with all data directories and should be identical to
+  // the original one.
+  ASSERT_OK(ShutdownAndRebuildTablet());
+  tablet_replica_->tablet()->metadata()->ToSuperBlock(&superblock);
+  DataDirGroupPB new_group = superblock.data_dir_group();
+  MessageDifferencer md;
+  ASSERT_TRUE(md.Compare(orig_group, new_group));
+}
+
 } // namespace tserver
 } // namespace kudu


Mime
View raw message