src/yb/tablet/tablet-metadata-test.cc
// Test that loading & storing the superblock results in an equivalent file.
Test that loading & storing the superblock results in an equivalent file.
Test that loading & storing the superblock results in an equivalent file .
TEST_F(TestRaftGroupMetadata, TestLoadFromSuperBlock) {
  QLWriteRequestPB req;
  BuildPartialRow(0, 0, "foo", &req);
  ASSERT_OK(writer_->Write(&req));
  ASSERT_OK(harness_->tablet()->Flush(tablet::FlushMode::kSync));
  BuildPartialRow(1, 1, "bar", &req);
  ASSERT_OK(writer_->Write(&req));
  ASSERT_OK(harness_->tablet()->Flush(tablet::FlushMode::kSync));
  harness_->tablet()->StartShutdown();
  harness_->tablet()->CompleteShutdown();
  RaftGroupMetadata* meta = harness_->tablet()->metadata();
  RaftGroupReplicaSuperBlockPB superblock_pb_1;
  meta->ToSuperBlock(&superblock_pb_1);
  ASSERT_OK(meta->ReplaceSuperBlock(superblock_pb_1));
  RaftGroupReplicaSuperBlockPB superblock_pb_2;
  meta->ToSuperBlock(&superblock_pb_2);
  ASSERT_EQ(superblock_pb_1.SerializeAsString(),
            superblock_pb_2.SerializeAsString())
    << superblock_pb_1.DebugString()
    << superblock_pb_2.DebugString();
  LOG(INFO) << "Superblocks match:\n"
            << superblock_pb_1.DebugString();
}
TEST_F ( TestRaftGroupMetadata , TestLoadFromSuperBlock ) { QLWriteRequestPB req ; BuildPartialRow ( 0 , 0 , " " , & req ) ; ASSERT_OK ( writer_ -> Write ( & req ) ) ; ASSERT_OK ( harness_ -> tablet ( ) -> Flush ( tablet :: FlushMode :: kSync ) ) ; BuildPartialRow ( 1 , 1 , " " , & req ) ; ASSERT_OK ( writer_ -> Write ( & req ) ) ; ASSERT_OK ( harness_ -> tablet ( ) -> Flush ( tablet :: FlushMode :: kSync ) ) ; harness_ -> tablet ( ) -> StartShutdown ( ) ; harness_ -> tablet ( ) -> CompleteShutdown ( ) ; RaftGroupMetadata * meta = harness_ -> tablet ( ) -> metadata ( ) ; RaftGroupReplicaSuperBlockPB superblock_pb_1 ; meta -> ToSuperBlock ( & superblock_pb_1 ) ; ASSERT_OK ( meta -> ReplaceSuperBlock ( superblock_pb_1 ) ) ; RaftGroupReplicaSuperBlockPB superblock_pb_2 ; meta -> ToSuperBlock ( & superblock_pb_2 ) ; ASSERT_EQ ( superblock_pb_1 . SerializeAsString ( ) , superblock_pb_2 . SerializeAsString ( ) ) << superblock_pb_1 . DebugString ( ) << superblock_pb_2 . DebugString ( ) ; LOG ( INFO ) << " \n " << superblock_pb_1 . DebugString ( ) ; }
Test that loading & storing the superblock results in an equivalent file.
Test that loading & storing the superblock results in an equivalent file .
// Write some data to the tablet and flush. // Create one more row. Write and flush. // Shut down the tablet. // Dump the superblock to a PB. Save the PB to the side. // Load the superblock PB back into the RaftGroupMetadata. // Dump the tablet metadata to a superblock PB again, and save it. // Compare the 2 dumped superblock PBs.