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
This commit is contained in:
sdong 2016-04-15 14:34:53 -07:00
parent 4b6833aec1
commit cea8ed9702
2 changed files with 8 additions and 3 deletions

View File

@ -1468,8 +1468,13 @@ Status BackupEngineImpl::GarbageCollect() {
// delete obsolete shared files
std::vector<std::string> shared_children;
{
auto s = backup_env_->GetChildren(GetAbsolutePath(GetSharedFileRel()),
&shared_children);
auto shared_path = GetAbsolutePath(GetSharedFileRel());
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()) {
return s;
}

View File

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