|
|
@ -461,6 +461,20 @@ class DBTest { |
|
|
|
} |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
bool DeleteAnSSTFile() { |
|
|
|
std::vector<std::string> filenames; |
|
|
|
ASSERT_OK(env_->GetChildren(dbname_, &filenames)); |
|
|
|
uint64_t number; |
|
|
|
FileType type; |
|
|
|
for (size_t i = 0; i < filenames.size(); i++) { |
|
|
|
if (ParseFileName(filenames[i], &number, &type) && type == kTableFile) { |
|
|
|
ASSERT_OK(env_->DeleteFile(TableFileName(dbname_, number))); |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
return false; |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
TEST(DBTest, Empty) { |
|
|
@ -1567,6 +1581,23 @@ TEST(DBTest, ManifestWriteError) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
TEST(DBTest, MissingSSTFile) { |
|
|
|
ASSERT_OK(Put("foo", "bar")); |
|
|
|
ASSERT_EQ("bar", Get("foo")); |
|
|
|
|
|
|
|
// Dump the memtable to disk.
|
|
|
|
dbfull()->TEST_CompactMemTable(); |
|
|
|
ASSERT_EQ("bar", Get("foo")); |
|
|
|
|
|
|
|
ASSERT_TRUE(DeleteAnSSTFile()); |
|
|
|
Options options = CurrentOptions(); |
|
|
|
options.paranoid_checks = true; |
|
|
|
Status s = TryReopen(&options); |
|
|
|
ASSERT_TRUE(!s.ok()); |
|
|
|
ASSERT_TRUE(s.ToString().find("issing") != std::string::npos) |
|
|
|
<< s.ToString(); |
|
|
|
} |
|
|
|
|
|
|
|
TEST(DBTest, FilesDeletedAfterCompaction) { |
|
|
|
ASSERT_OK(Put("foo", "v2")); |
|
|
|
Compact("a", "z"); |
|
|
|