mirror of https://github.com/facebook/rocksdb.git
Fix unit test failure caused by delaying deleting obsolete files.
Summary:
A previous commit 4c107587ed
introduced
the idea that some version updates might not delete obsolete files.
This means that if a unit test blindly counts the number of files
in the db directory it might not represent the true state of the database.
Use GetLiveFiles() insteads to count the number of live files in the database.
Test Plan:
make check
This commit is contained in:
parent
70c42bf05f
commit
de7689b1d7
|
@ -385,6 +385,13 @@ class DBTest {
|
|||
return static_cast<int>(files.size());
|
||||
}
|
||||
|
||||
int CountLiveFiles() {
|
||||
std::vector<std::string> files;
|
||||
uint64_t manifest_file_size;
|
||||
db_->GetLiveFiles(files, &manifest_file_size);
|
||||
return files.size();
|
||||
}
|
||||
|
||||
uint64_t Size(const Slice& start, const Slice& limit) {
|
||||
Range r(start, limit);
|
||||
uint64_t size;
|
||||
|
@ -1631,12 +1638,12 @@ TEST(DBTest, NonWritableFileSystem)
|
|||
TEST(DBTest, FilesDeletedAfterCompaction) {
|
||||
ASSERT_OK(Put("foo", "v2"));
|
||||
Compact("a", "z");
|
||||
const int num_files = CountFiles();
|
||||
const int num_files = CountLiveFiles();
|
||||
for (int i = 0; i < 10; i++) {
|
||||
ASSERT_OK(Put("foo", "v2"));
|
||||
Compact("a", "z");
|
||||
}
|
||||
ASSERT_EQ(CountFiles(), num_files);
|
||||
ASSERT_EQ(CountLiveFiles(), num_files);
|
||||
}
|
||||
|
||||
TEST(DBTest, BloomFilter) {
|
||||
|
|
Loading…
Reference in New Issue