]> git-server-git.apps.pok.os.sepia.ceph.com Git - rocksdb.git/commitdiff
prevent stranded LATEST_BACKUP in BackupEngineTest.NoDeleteWithReadOnly (#8887)
authorAndrew Kryczka <andrewkr@fb.com>
Wed, 8 Sep 2021 20:37:59 +0000 (13:37 -0700)
committerFacebook GitHub Bot <facebook-github-bot@users.noreply.github.com>
Wed, 8 Sep 2021 20:39:01 +0000 (13:39 -0700)
Summary:
A "LATEST_BACKUP" file was left in the backup directory by
"BackupEngineTest.NoDeleteWithReadOnly" test, affecting future test
runs. In particular, it caused "BackupEngineTest.IOStats" to fail since
it relies on backup directory containing only data written by its
`BackupEngine`.

The fix is to promote "LATEST_BACKUP" to an explicitly managed file so
it is deleted in `BackupEngineTest` constructor if it exists.

Pull Request resolved: https://github.com/facebook/rocksdb/pull/8887

Test Plan:
below command used to fail. Now it passes:

```
$ TEST_TMPDIR=/dev/shm ./backupable_db_test --gtest_filter='BackupEngineTest.NoDeleteWithReadOnly:BackupEngineTest.IOStats'
```

Reviewed By: pdillinger

Differential Revision: D30812336

Pulled By: ajkr

fbshipit-source-id: 32dfbe1368ebdab872e610764bfea5daf9a2af09

utilities/backupable/backupable_db_test.cc

index fc515a36bf286b6ba54a497546d5b46684a2723e..2d4cfc1f043e244b70c5b70ebf25ffd73500011b 100644 (file)
@@ -616,6 +616,7 @@ class BackupEngineTest : public testing::Test {
     EXPECT_OK(Env::Default()->CreateDirIfMissing(backup_chroot));
     dbname_ = "/tempdb";
     backupdir_ = "/tempbk";
+    latest_backup_ = backupdir_ + "/LATEST_BACKUP";
 
     // set up envs
     db_chroot_env_.reset(NewChrootEnv(Env::Default(), db_chroot));
@@ -663,6 +664,10 @@ class BackupEngineTest : public testing::Test {
 
     // delete old files in db
     DestroyDB(dbname_, options_);
+
+    // delete old LATEST_BACKUP file, which some tests create for compatibility
+    // testing.
+    backup_chroot_env_->DeleteFile(latest_backup_).PermitUncheckedError();
   }
 
   DB* OpenDB() {
@@ -943,6 +948,7 @@ class BackupEngineTest : public testing::Test {
   // files
   std::string dbname_;
   std::string backupdir_;
+  std::string latest_backup_;
 
   // logger_ must be above backup_engine_ such that the engine's destructor,
   // which uses a raw pointer to the logger, executes first.
@@ -1853,7 +1859,7 @@ TEST_F(BackupEngineTest, NoDeleteWithReadOnly) {
     ASSERT_OK(backup_engine_->CreateNewBackup(db_.get(), !!(rnd.Next() % 2)));
   }
   CloseDBAndBackupEngine();
-  ASSERT_OK(file_manager_->WriteToFile(backupdir_ + "/LATEST_BACKUP", "4"));
+  ASSERT_OK(file_manager_->WriteToFile(latest_backup_, "4"));
 
   backupable_options_->destroy_old_data = false;
   BackupEngineReadOnly* read_only_backup_engine;