Fix backupable_db_test test cases that can't run by itself

Summary:
Several of backupable_db_test fails if running standalone, because of directory missing. Fix it by:
(1) garbage collector skips shared directory if it doesn't exit
(2) BackupableDBTest.Issue921Test to create the parent directory of the backup directory fist.

Test Plan: Run the tests individually and make sure they pass

Subscribers: leveldb, andrewkr, dhruba

Differential Revision: https://reviews.facebook.net/D56829
main
sdong 9 years ago
parent 4b6833aec1
commit cea8ed9702
  1. 9
      utilities/backupable/backupable_db.cc
  2. 2
      utilities/backupable/backupable_db_test.cc

@ -1468,8 +1468,13 @@ Status BackupEngineImpl::GarbageCollect() {
// delete obsolete shared files // delete obsolete shared files
std::vector<std::string> shared_children; std::vector<std::string> shared_children;
{ {
auto s = backup_env_->GetChildren(GetAbsolutePath(GetSharedFileRel()), auto shared_path = GetAbsolutePath(GetSharedFileRel());
&shared_children); auto s = backup_env_->FileExists(shared_path);
if (s.ok()) {
s = backup_env_->GetChildren(shared_path, &shared_children);
} else if (s.IsNotFound()) {
s = Status::OK();
}
if (!s.ok()) { if (!s.ok()) {
return s; return s;
} }

@ -1341,8 +1341,8 @@ TEST_F(BackupableDBTest, ChangeManifestDuringBackupCreation) {
TEST_F(BackupableDBTest, Issue921Test) { TEST_F(BackupableDBTest, Issue921Test) {
BackupEngine* backup_engine; BackupEngine* backup_engine;
backupable_options_->share_table_files = false; backupable_options_->share_table_files = false;
env_->CreateDirIfMissing(backupable_options_->backup_dir);
backupable_options_->backup_dir += "/new_dir"; backupable_options_->backup_dir += "/new_dir";
ASSERT_OK(BackupEngine::Open(env_, *backupable_options_, &backup_engine)); ASSERT_OK(BackupEngine::Open(env_, *backupable_options_, &backup_engine));
delete backup_engine; delete backup_engine;

Loading…
Cancel
Save