@ -636,16 +636,6 @@ TEST(BackupableDBTest, CorruptionsTest) {
ASSERT_TRUE ( file_manager_ - > FileExists ( backupdir_ + " /meta/2 " ) ) ;
ASSERT_TRUE ( file_manager_ - > FileExists ( backupdir_ + " /meta/2 " ) ) ;
s = restore_db_ - > RestoreDBFromBackup ( 2 , dbname_ , dbname_ ) ;
s = restore_db_ - > RestoreDBFromBackup ( 2 , dbname_ , dbname_ ) ;
ASSERT_TRUE ( ! s . ok ( ) ) ;
ASSERT_TRUE ( ! s . ok ( ) ) ;
ASSERT_OK ( restore_db_ - > DeleteBackup ( 2 ) ) ;
CloseRestoreDB ( ) ;
AssertBackupConsistency ( 0 , 0 , keys_iteration * 1 , keys_iteration * 5 ) ;
// new backup should be 2!
OpenBackupableDB ( ) ;
FillDB ( db_ . get ( ) , keys_iteration * 1 , keys_iteration * 2 ) ;
ASSERT_OK ( db_ - > CreateNewBackup ( ! ! ( rnd . Next ( ) % 2 ) ) ) ;
CloseBackupableDB ( ) ;
AssertBackupConsistency ( 2 , 0 , keys_iteration * 2 , keys_iteration * 5 ) ;
// make sure that no corrupt backups have actually been deleted!
// make sure that no corrupt backups have actually been deleted!
ASSERT_TRUE ( file_manager_ - > FileExists ( backupdir_ + " /meta/1 " ) ) ;
ASSERT_TRUE ( file_manager_ - > FileExists ( backupdir_ + " /meta/1 " ) ) ;
@ -660,18 +650,29 @@ TEST(BackupableDBTest, CorruptionsTest) {
ASSERT_TRUE ( file_manager_ - > FileExists ( backupdir_ + " /private/5 " ) ) ;
ASSERT_TRUE ( file_manager_ - > FileExists ( backupdir_ + " /private/5 " ) ) ;
// delete the corrupt backups and then make sure they're actually deleted
// delete the corrupt backups and then make sure they're actually deleted
OpenBackupableDB ( ) ;
ASSERT_OK ( restore_db_ - > DeleteBackup ( 5 ) ) ;
ASSERT_OK ( db_ - > DeleteBackup ( 5 ) ) ;
ASSERT_OK ( restore_ db_- > DeleteBackup ( 4 ) ) ;
ASSERT_OK ( db_ - > DeleteBackup ( 4 ) ) ;
ASSERT_OK ( restore_ db_- > DeleteBackup ( 3 ) ) ;
ASSERT_OK ( db_ - > DeleteBackup ( 3 ) ) ;
ASSERT_OK ( restore_ db_- > DeleteBackup ( 2 ) ) ;
( void ) db_ - > GarbageCollect ( ) ;
( void ) restore_ db_- > GarbageCollect ( ) ;
ASSERT_TRUE ( file_manager_ - > FileExists ( backupdir_ + " /meta/5 " ) = = false ) ;
ASSERT_TRUE ( file_manager_ - > FileExists ( backupdir_ + " /meta/5 " ) = = false ) ;
ASSERT_TRUE ( file_manager_ - > FileExists ( backupdir_ + " /private/5 " ) = = false ) ;
ASSERT_TRUE ( file_manager_ - > FileExists ( backupdir_ + " /private/5 " ) = = false ) ;
ASSERT_TRUE ( file_manager_ - > FileExists ( backupdir_ + " /meta/4 " ) = = false ) ;
ASSERT_TRUE ( file_manager_ - > FileExists ( backupdir_ + " /meta/4 " ) = = false ) ;
ASSERT_TRUE ( file_manager_ - > FileExists ( backupdir_ + " /private/4 " ) = = false ) ;
ASSERT_TRUE ( file_manager_ - > FileExists ( backupdir_ + " /private/4 " ) = = false ) ;
ASSERT_TRUE ( file_manager_ - > FileExists ( backupdir_ + " /meta/3 " ) = = false ) ;
ASSERT_TRUE ( file_manager_ - > FileExists ( backupdir_ + " /meta/3 " ) = = false ) ;
ASSERT_TRUE ( file_manager_ - > FileExists ( backupdir_ + " /private/3 " ) = = false ) ;
ASSERT_TRUE ( file_manager_ - > FileExists ( backupdir_ + " /private/3 " ) = = false ) ;
ASSERT_TRUE ( file_manager_ - > FileExists ( backupdir_ + " /meta/2 " ) = = false ) ;
ASSERT_TRUE ( file_manager_ - > FileExists ( backupdir_ + " /private/2 " ) = = false ) ;
CloseRestoreDB ( ) ;
AssertBackupConsistency ( 0 , 0 , keys_iteration * 1 , keys_iteration * 5 ) ;
// new backup should be 2!
OpenBackupableDB ( ) ;
FillDB ( db_ . get ( ) , keys_iteration * 1 , keys_iteration * 2 ) ;
ASSERT_OK ( db_ - > CreateNewBackup ( ! ! ( rnd . Next ( ) % 2 ) ) ) ;
CloseBackupableDB ( ) ;
CloseBackupableDB ( ) ;
AssertBackupConsistency ( 2 , 0 , keys_iteration * 2 , keys_iteration * 5 ) ;
}
}
// open DB, write, close DB, backup, restore, repeat
// open DB, write, close DB, backup, restore, repeat