Whole DBTest to skip fsync (#7049)

Summary:
After https://github.com/facebook/rocksdb/pull/7036, we still see extra DBTest that can timeout when running 10 or 20 in parallel. Expand skip-fsync mode in whole DBTest. Still preserve other tests from doing this mode to be conservative.
Pull Request resolved: https://github.com/facebook/rocksdb/pull/7049

Test Plan: Run all existing files.

Reviewed By: pdillinger

Differential Revision: D22301700

fbshipit-source-id: f9a9e3b3b26ce640665a47cb8bff33ba0c89b565
This commit is contained in:
sdong 2020-07-01 19:36:15 -07:00 committed by Facebook GitHub Bot
parent b5bae48c8a
commit 4f1534bdb0
45 changed files with 97 additions and 63 deletions

View File

@ -41,7 +41,8 @@ class DBBlobIndexTest : public DBTestBase {
Tier::kImmutableMemtables, Tier::kImmutableMemtables,
Tier::kL0SstFile, Tier::kLnSstFile}; Tier::kL0SstFile, Tier::kLnSstFile};
DBBlobIndexTest() : DBTestBase("/db_blob_index_test") {} DBBlobIndexTest()
: DBTestBase("/db_blob_index_test", /*env_do_fsync=*/true) {}
ColumnFamilyHandle* cfh() { return dbfull()->DefaultColumnFamily(); } ColumnFamilyHandle* cfh() { return dbfull()->DefaultColumnFamily(); }

View File

@ -27,7 +27,7 @@ namespace ROCKSDB_NAMESPACE {
class DBBasicTest : public DBTestBase { class DBBasicTest : public DBTestBase {
public: public:
DBBasicTest() : DBTestBase("/db_basic_test") {} DBBasicTest() : DBTestBase("/db_basic_test", /*env_do_fsync=*/true) {}
}; };
TEST_F(DBBasicTest, OpenWhenOpen) { TEST_F(DBBasicTest, OpenWhenOpen) {
@ -2352,7 +2352,7 @@ class DBBasicTestMultiGet : public DBTestBase {
DBBasicTestMultiGet(std::string test_dir, int num_cfs, bool compressed_cache, DBBasicTestMultiGet(std::string test_dir, int num_cfs, bool compressed_cache,
bool uncompressed_cache, bool _compression_enabled, bool uncompressed_cache, bool _compression_enabled,
bool _fill_cache, uint32_t compression_parallel_threads) bool _fill_cache, uint32_t compression_parallel_threads)
: DBTestBase(test_dir) { : DBTestBase(test_dir, /*env_do_fsync=*/true) {
compression_enabled_ = _compression_enabled; compression_enabled_ = _compression_enabled;
fill_cache_ = _fill_cache; fill_cache_ = _fill_cache;

View File

@ -32,7 +32,8 @@ class DBBlockCacheTest : public DBTestBase {
const size_t kNumBlocks = 10; const size_t kNumBlocks = 10;
const size_t kValueSize = 100; const size_t kValueSize = 100;
DBBlockCacheTest() : DBTestBase("/db_block_cache_test") {} DBBlockCacheTest()
: DBTestBase("/db_block_cache_test", /*env_do_fsync=*/true) {}
BlockBasedTableOptions GetTableOptions() { BlockBasedTableOptions GetTableOptions() {
BlockBasedTableOptions table_options; BlockBasedTableOptions table_options;

View File

@ -23,7 +23,8 @@ using BFP = BloomFilterPolicy;
class DBBloomFilterTest : public DBTestBase { class DBBloomFilterTest : public DBTestBase {
public: public:
DBBloomFilterTest() : DBTestBase("/db_bloom_filter_test") {} DBBloomFilterTest()
: DBTestBase("/db_bloom_filter_test", /*env_do_fsync=*/true) {}
}; };
class DBBloomFilterTestWithParam : public DBTestBase, class DBBloomFilterTestWithParam : public DBTestBase,
@ -36,7 +37,8 @@ class DBBloomFilterTestWithParam : public DBTestBase,
uint32_t format_version_; uint32_t format_version_;
public: public:
DBBloomFilterTestWithParam() : DBTestBase("/db_bloom_filter_tests") {} DBBloomFilterTestWithParam()
: DBTestBase("/db_bloom_filter_tests", /*env_do_fsync=*/true) {}
~DBBloomFilterTestWithParam() override {} ~DBBloomFilterTestWithParam() override {}
@ -1039,7 +1041,7 @@ class DBBloomFilterTestVaryPrefixAndFormatVer
public: public:
DBBloomFilterTestVaryPrefixAndFormatVer() DBBloomFilterTestVaryPrefixAndFormatVer()
: DBTestBase("/db_bloom_filter_tests") {} : DBTestBase("/db_bloom_filter_tests", /*env_do_fsync=*/true) {}
~DBBloomFilterTestVaryPrefixAndFormatVer() override {} ~DBBloomFilterTestVaryPrefixAndFormatVer() override {}

View File

@ -21,7 +21,8 @@ static std::string NEW_VALUE = "NewValue";
class DBTestCompactionFilter : public DBTestBase { class DBTestCompactionFilter : public DBTestBase {
public: public:
DBTestCompactionFilter() : DBTestBase("/db_compaction_filter_test") {} DBTestCompactionFilter()
: DBTestBase("/db_compaction_filter_test", /*env_do_fsync=*/true) {}
}; };
// Param variant of DBTestBase::ChangeCompactOptions // Param variant of DBTestBase::ChangeCompactOptions

View File

@ -25,14 +25,16 @@ namespace ROCKSDB_NAMESPACE {
class DBCompactionTest : public DBTestBase { class DBCompactionTest : public DBTestBase {
public: public:
DBCompactionTest() : DBTestBase("/db_compaction_test") {} DBCompactionTest()
: DBTestBase("/db_compaction_test", /*env_do_fsync=*/true) {}
}; };
class DBCompactionTestWithParam class DBCompactionTestWithParam
: public DBTestBase, : public DBTestBase,
public testing::WithParamInterface<std::tuple<uint32_t, bool>> { public testing::WithParamInterface<std::tuple<uint32_t, bool>> {
public: public:
DBCompactionTestWithParam() : DBTestBase("/db_compaction_test") { DBCompactionTestWithParam()
: DBTestBase("/db_compaction_test", /*env_do_fsync=*/true) {
max_subcompactions_ = std::get<0>(GetParam()); max_subcompactions_ = std::get<0>(GetParam());
exclusive_manual_compaction_ = std::get<1>(GetParam()); exclusive_manual_compaction_ = std::get<1>(GetParam());
} }
@ -4753,7 +4755,8 @@ INSTANTIATE_TEST_CASE_P(DBCompactionDirectIOTest, DBCompactionDirectIOTest,
class CompactionPriTest : public DBTestBase, class CompactionPriTest : public DBTestBase,
public testing::WithParamInterface<uint32_t> { public testing::WithParamInterface<uint32_t> {
public: public:
CompactionPriTest() : DBTestBase("/compaction_pri_test") { CompactionPriTest()
: DBTestBase("/compaction_pri_test", /*env_do_fsync=*/true) {
compaction_pri_ = GetParam(); compaction_pri_ = GetParam();
} }

View File

@ -19,7 +19,8 @@
namespace ROCKSDB_NAMESPACE { namespace ROCKSDB_NAMESPACE {
class DBTestDynamicLevel : public DBTestBase { class DBTestDynamicLevel : public DBTestBase {
public: public:
DBTestDynamicLevel() : DBTestBase("/db_dynamic_level_test") {} DBTestDynamicLevel()
: DBTestBase("/db_dynamic_level_test", /*env_do_fsync=*/true) {}
}; };
TEST_F(DBTestDynamicLevel, DynamicLevelMaxBytesBase) { TEST_F(DBTestDynamicLevel, DynamicLevelMaxBytesBase) {

View File

@ -16,7 +16,8 @@ namespace ROCKSDB_NAMESPACE {
class DBEncryptionTest : public DBTestBase { class DBEncryptionTest : public DBTestBase {
public: public:
DBEncryptionTest() : DBTestBase("/db_encryption_test") {} DBEncryptionTest()
: DBTestBase("/db_encryption_test", /*env_do_fsync=*/true) {}
}; };
#ifndef ROCKSDB_LITE #ifndef ROCKSDB_LITE

View File

@ -22,7 +22,7 @@ namespace ROCKSDB_NAMESPACE {
class DBFlushTest : public DBTestBase { class DBFlushTest : public DBTestBase {
public: public:
DBFlushTest() : DBTestBase("/db_flush_test") {} DBFlushTest() : DBTestBase("/db_flush_test", /*env_do_fsync=*/true) {}
}; };
class DBFlushDirectIOTest : public DBFlushTest, class DBFlushDirectIOTest : public DBFlushTest,

View File

@ -19,7 +19,7 @@ namespace ROCKSDB_NAMESPACE {
class DBSecondaryTest : public DBTestBase { class DBSecondaryTest : public DBTestBase {
public: public:
DBSecondaryTest() DBSecondaryTest()
: DBTestBase("/db_secondary_test"), : DBTestBase("/db_secondary_test", /*env_do_fsync=*/true),
secondary_path_(), secondary_path_(),
handles_secondary_(), handles_secondary_(),
db_secondary_(nullptr) { db_secondary_(nullptr) {

View File

@ -13,7 +13,8 @@ namespace ROCKSDB_NAMESPACE {
class DBTestInPlaceUpdate : public DBTestBase { class DBTestInPlaceUpdate : public DBTestBase {
public: public:
DBTestInPlaceUpdate() : DBTestBase("/db_inplace_update_test") {} DBTestInPlaceUpdate()
: DBTestBase("/db_inplace_update_test", /*env_do_fsync=*/true) {}
}; };
TEST_F(DBTestInPlaceUpdate, InPlaceUpdate) { TEST_F(DBTestInPlaceUpdate, InPlaceUpdate) {

View File

@ -14,7 +14,8 @@ namespace ROCKSDB_NAMESPACE {
class DBIOFailureTest : public DBTestBase { class DBIOFailureTest : public DBTestBase {
public: public:
DBIOFailureTest() : DBTestBase("/db_io_failure_test") {} DBIOFailureTest()
: DBTestBase("/db_io_failure_test", /*env_do_fsync=*/true) {}
}; };
#ifndef ROCKSDB_LITE #ifndef ROCKSDB_LITE

View File

@ -33,7 +33,7 @@ class DummyReadCallback : public ReadCallback {
class DBIteratorTest : public DBTestBase, class DBIteratorTest : public DBTestBase,
public testing::WithParamInterface<bool> { public testing::WithParamInterface<bool> {
public: public:
DBIteratorTest() : DBTestBase("/db_iterator_test") {} DBIteratorTest() : DBTestBase("/db_iterator_test", /*env_do_fsync=*/true) {}
Iterator* NewIterator(const ReadOptions& read_options, Iterator* NewIterator(const ReadOptions& read_options,
ColumnFamilyHandle* column_family = nullptr) { ColumnFamilyHandle* column_family = nullptr) {

View File

@ -19,7 +19,8 @@ namespace ROCKSDB_NAMESPACE {
class DBTestXactLogIterator : public DBTestBase { class DBTestXactLogIterator : public DBTestBase {
public: public:
DBTestXactLogIterator() : DBTestBase("/db_log_iter_test") {} DBTestXactLogIterator()
: DBTestBase("/db_log_iter_test", /*env_do_fsync=*/true) {}
std::unique_ptr<TransactionLogIterator> OpenTransactionLogIter( std::unique_ptr<TransactionLogIterator> OpenTransactionLogIter(
const SequenceNumber seq) { const SequenceNumber seq) {

View File

@ -17,7 +17,7 @@ namespace ROCKSDB_NAMESPACE {
class DBMemTableTest : public DBTestBase { class DBMemTableTest : public DBTestBase {
public: public:
DBMemTableTest() : DBTestBase("/db_memtable_test") {} DBMemTableTest() : DBTestBase("/db_memtable_test", /*env_do_fsync=*/true) {}
}; };
class MockMemTableRep : public MemTableRep { class MockMemTableRep : public MemTableRep {

View File

@ -21,7 +21,8 @@ namespace ROCKSDB_NAMESPACE {
class DBMergeOperandTest : public DBTestBase { class DBMergeOperandTest : public DBTestBase {
public: public:
DBMergeOperandTest() : DBTestBase("/db_merge_operand_test") {} DBMergeOperandTest()
: DBTestBase("/db_merge_operand_test", /*env_do_fsync=*/true) {}
}; };
TEST_F(DBMergeOperandTest, GetMergeOperandsBasic) { TEST_F(DBMergeOperandTest, GetMergeOperandsBasic) {

View File

@ -35,7 +35,8 @@ class TestReadCallback : public ReadCallback {
// Test merge operator functionality. // Test merge operator functionality.
class DBMergeOperatorTest : public DBTestBase { class DBMergeOperatorTest : public DBTestBase {
public: public:
DBMergeOperatorTest() : DBTestBase("/db_merge_operator_test") {} DBMergeOperatorTest()
: DBTestBase("/db_merge_operator_test", /*env_do_fsync=*/true) {}
std::string GetWithReadCallback(SnapshotChecker* snapshot_checker, std::string GetWithReadCallback(SnapshotChecker* snapshot_checker,
const Slice& key, const Slice& key,

View File

@ -27,7 +27,7 @@ namespace ROCKSDB_NAMESPACE {
class DBOptionsTest : public DBTestBase { class DBOptionsTest : public DBTestBase {
public: public:
DBOptionsTest() : DBTestBase("/db_options_test") {} DBOptionsTest() : DBTestBase("/db_options_test", /*env_do_fsync=*/true) {}
#ifndef ROCKSDB_LITE #ifndef ROCKSDB_LITE
std::unordered_map<std::string, std::string> GetMutableDBOptionsMap( std::unordered_map<std::string, std::string> GetMutableDBOptionsMap(

View File

@ -26,7 +26,8 @@ namespace ROCKSDB_NAMESPACE {
class DBPropertiesTest : public DBTestBase { class DBPropertiesTest : public DBTestBase {
public: public:
DBPropertiesTest() : DBTestBase("/db_properties_test") {} DBPropertiesTest()
: DBTestBase("/db_properties_test", /*env_do_fsync=*/true) {}
}; };
#ifndef ROCKSDB_LITE #ifndef ROCKSDB_LITE

View File

@ -13,7 +13,7 @@ namespace ROCKSDB_NAMESPACE {
class DBRangeDelTest : public DBTestBase { class DBRangeDelTest : public DBTestBase {
public: public:
DBRangeDelTest() : DBTestBase("/db_range_del_test") {} DBRangeDelTest() : DBTestBase("/db_range_del_test", /*env_do_fsync=*/true) {}
std::string GetNumericStr(int key) { std::string GetNumericStr(int key) {
uint64_t uint64_key = static_cast<uint64_t>(key); uint64_t uint64_key = static_cast<uint64_t>(key);

View File

@ -17,7 +17,7 @@ namespace ROCKSDB_NAMESPACE {
class DBSSTTest : public DBTestBase { class DBSSTTest : public DBTestBase {
public: public:
DBSSTTest() : DBTestBase("/db_sst_test") {} DBSSTTest() : DBTestBase("/db_sst_test", /*env_do_fsync=*/true) {}
}; };
#ifndef ROCKSDB_LITE #ifndef ROCKSDB_LITE

View File

@ -14,7 +14,8 @@ namespace ROCKSDB_NAMESPACE {
class DBStatisticsTest : public DBTestBase { class DBStatisticsTest : public DBTestBase {
public: public:
DBStatisticsTest() : DBTestBase("/db_statistics_test") {} DBStatisticsTest()
: DBTestBase("/db_statistics_test", /*env_do_fsync=*/true) {}
}; };
TEST_F(DBStatisticsTest, CompressionStatsTest) { TEST_F(DBStatisticsTest, CompressionStatsTest) {

View File

@ -48,7 +48,8 @@ void VerifyTableProperties(DB* db, uint64_t expected_entries_size) {
class DBTablePropertiesTest : public DBTestBase, class DBTablePropertiesTest : public DBTestBase,
public testing::WithParamInterface<std::string> { public testing::WithParamInterface<std::string> {
public: public:
DBTablePropertiesTest() : DBTestBase("/db_table_properties_test") {} DBTablePropertiesTest()
: DBTestBase("/db_table_properties_test", /*env_do_fsync=*/true) {}
TablePropertiesCollection TestGetPropertiesOfTablesInRange( TablePropertiesCollection TestGetPropertiesOfTablesInRange(
std::vector<Range> ranges, std::size_t* num_properties = nullptr, std::vector<Range> ranges, std::size_t* num_properties = nullptr,
std::size_t* num_files = nullptr); std::size_t* num_files = nullptr);

View File

@ -20,7 +20,8 @@ namespace ROCKSDB_NAMESPACE {
class DBTestTailingIterator : public DBTestBase { class DBTestTailingIterator : public DBTestBase {
public: public:
DBTestTailingIterator() : DBTestBase("/db_tailing_iterator_test") {} DBTestTailingIterator()
: DBTestBase("/db_tailing_iterator_test", /*env_do_fsync=*/true) {}
}; };
TEST_F(DBTestTailingIterator, TailingIteratorSingle) { TEST_F(DBTestTailingIterator, TailingIteratorSingle) {

View File

@ -70,9 +70,12 @@
namespace ROCKSDB_NAMESPACE { namespace ROCKSDB_NAMESPACE {
// Note that whole DBTest and its child classes disable fsync on files
// and directories for speed.
// If fsync needs to be covered in a test, put it in other places.
class DBTest : public DBTestBase { class DBTest : public DBTestBase {
public: public:
DBTest() : DBTestBase("/db_test") {} DBTest() : DBTestBase("/db_test", /*env_do_fsync=*/false) {}
}; };
class DBTestWithParam class DBTestWithParam
@ -1790,7 +1793,6 @@ TEST_F(DBTest, Snapshot) {
TEST_F(DBTest, HiddenValuesAreRemoved) { TEST_F(DBTest, HiddenValuesAreRemoved) {
anon::OptionsOverride options_override; anon::OptionsOverride options_override;
options_override.skip_policy = kSkipNoSnapshot; options_override.skip_policy = kSkipNoSnapshot;
env_->skip_fsync_ = true;
do { do {
Options options = CurrentOptions(options_override); Options options = CurrentOptions(options_override);
CreateAndReopenWithCF({"pikachu"}, options); CreateAndReopenWithCF({"pikachu"}, options);
@ -3995,7 +3997,6 @@ TEST_F(DBTest, DynamicMemtableOptions) {
const uint64_t k128KB = 1 << 17; const uint64_t k128KB = 1 << 17;
const uint64_t k5KB = 5 * 1024; const uint64_t k5KB = 5 * 1024;
Options options; Options options;
env_->skip_fsync_ = true;
options.env = env_; options.env = env_;
options.create_if_missing = true; options.create_if_missing = true;
options.compression = kNoCompression; options.compression = kNoCompression;
@ -5142,7 +5143,6 @@ TEST_F(DBTest, DynamicUniversalCompactionOptions) {
TEST_F(DBTest, FileCreationRandomFailure) { TEST_F(DBTest, FileCreationRandomFailure) {
Options options; Options options;
env_->skip_fsync_ = true;
options.env = env_; options.env = env_;
options.create_if_missing = true; options.create_if_missing = true;
options.write_buffer_size = 100000; // Small write buffer options.write_buffer_size = 100000; // Small write buffer
@ -5502,7 +5502,6 @@ TEST_F(DBTest, MergeTestTime) {
#ifndef ROCKSDB_LITE #ifndef ROCKSDB_LITE
TEST_P(DBTestWithParam, MergeCompactionTimeTest) { TEST_P(DBTestWithParam, MergeCompactionTimeTest) {
SetPerfLevel(kEnableTime); SetPerfLevel(kEnableTime);
env_->skip_fsync_ = true;
Options options = CurrentOptions(); Options options = CurrentOptions();
options.compaction_filter_factory = std::make_shared<KeepFilterFactory>(); options.compaction_filter_factory = std::make_shared<KeepFilterFactory>();
options.statistics = ROCKSDB_NAMESPACE::CreateDBStatistics(); options.statistics = ROCKSDB_NAMESPACE::CreateDBStatistics();

View File

@ -22,7 +22,7 @@ namespace ROCKSDB_NAMESPACE {
class DBTest2 : public DBTestBase { class DBTest2 : public DBTestBase {
public: public:
DBTest2() : DBTestBase("/db_test2") {} DBTest2() : DBTestBase("/db_test2", /*env_do_fsync=*/true) {}
}; };
#ifndef ROCKSDB_LITE #ifndef ROCKSDB_LITE
@ -92,7 +92,8 @@ class TestReadOnlyWithCompressedCache
public testing::WithParamInterface<std::tuple<int, bool>> { public testing::WithParamInterface<std::tuple<int, bool>> {
public: public:
TestReadOnlyWithCompressedCache() TestReadOnlyWithCompressedCache()
: DBTestBase("/test_readonly_with_compressed_cache") { : DBTestBase("/test_readonly_with_compressed_cache",
/*env_do_fsync=*/true) {
max_open_files_ = std::get<0>(GetParam()); max_open_files_ = std::get<0>(GetParam());
use_mmap_ = std::get<1>(GetParam()); use_mmap_ = std::get<1>(GetParam());
} }
@ -183,7 +184,7 @@ class PrefixFullBloomWithReverseComparator
public ::testing::WithParamInterface<bool> { public ::testing::WithParamInterface<bool> {
public: public:
PrefixFullBloomWithReverseComparator() PrefixFullBloomWithReverseComparator()
: DBTestBase("/prefix_bloom_reverse") {} : DBTestBase("/prefix_bloom_reverse", /*env_do_fsync=*/true) {}
void SetUp() override { if_cache_filter_ = GetParam(); } void SetUp() override { if_cache_filter_ = GetParam(); }
bool if_cache_filter_; bool if_cache_filter_;
}; };
@ -323,7 +324,7 @@ class DBTestSharedWriteBufferAcrossCFs
public testing::WithParamInterface<std::tuple<bool, bool>> { public testing::WithParamInterface<std::tuple<bool, bool>> {
public: public:
DBTestSharedWriteBufferAcrossCFs() DBTestSharedWriteBufferAcrossCFs()
: DBTestBase("/db_test_shared_write_buffer") {} : DBTestBase("/db_test_shared_write_buffer", /*env_do_fsync=*/true) {}
void SetUp() override { void SetUp() override {
use_old_interface_ = std::get<0>(GetParam()); use_old_interface_ = std::get<0>(GetParam());
cost_cache_ = std::get<1>(GetParam()); cost_cache_ = std::get<1>(GetParam());
@ -1790,7 +1791,8 @@ class PinL0IndexAndFilterBlocksTest
: public DBTestBase, : public DBTestBase,
public testing::WithParamInterface<std::tuple<bool, bool>> { public testing::WithParamInterface<std::tuple<bool, bool>> {
public: public:
PinL0IndexAndFilterBlocksTest() : DBTestBase("/db_pin_l0_index_bloom_test") {} PinL0IndexAndFilterBlocksTest()
: DBTestBase("/db_pin_l0_index_bloom_test", /*env_do_fsync=*/true) {}
void SetUp() override { void SetUp() override {
infinite_max_files_ = std::get<0>(GetParam()); infinite_max_files_ = std::get<0>(GetParam());
disallow_preload_ = std::get<1>(GetParam()); disallow_preload_ = std::get<1>(GetParam());

View File

@ -56,7 +56,7 @@ SpecialEnv::SpecialEnv(Env* base)
ROT13BlockCipher rot13Cipher_(16); ROT13BlockCipher rot13Cipher_(16);
#endif // ROCKSDB_LITE #endif // ROCKSDB_LITE
DBTestBase::DBTestBase(const std::string path) DBTestBase::DBTestBase(const std::string path, bool env_do_fsync)
: mem_env_(nullptr), encrypted_env_(nullptr), option_config_(kDefault) { : mem_env_(nullptr), encrypted_env_(nullptr), option_config_(kDefault) {
Env* base_env = Env::Default(); Env* base_env = Env::Default();
#ifndef ROCKSDB_LITE #ifndef ROCKSDB_LITE
@ -83,6 +83,7 @@ DBTestBase::DBTestBase(const std::string path)
: (mem_env_ ? mem_env_ : base_env)); : (mem_env_ ? mem_env_ : base_env));
env_->SetBackgroundThreads(1, Env::LOW); env_->SetBackgroundThreads(1, Env::LOW);
env_->SetBackgroundThreads(1, Env::HIGH); env_->SetBackgroundThreads(1, Env::HIGH);
env_->skip_fsync_ = !env_do_fsync;
dbname_ = test::PerThreadDBPath(env_, path); dbname_ = test::PerThreadDBPath(env_, path);
alternative_wal_dir_ = dbname_ + "/wal"; alternative_wal_dir_ = dbname_ + "/wal";
alternative_db_log_dir_ = dbname_ + "/db_log_dir"; alternative_db_log_dir_ = dbname_ + "/db_log_dir";

View File

@ -872,7 +872,10 @@ class DBTestBase : public testing::Test {
// requires. // requires.
kSkipMmapReads; kSkipMmapReads;
explicit DBTestBase(const std::string path); // `env_do_fsync` decides whether the special Env would do real
// fsync for files and directories. Skipping fsync can speed up
// tests, but won't cover the exact fsync logic.
DBTestBase(const std::string path, bool env_do_fsync);
~DBTestBase(); ~DBTestBase();

View File

@ -25,8 +25,8 @@ class DBTestUniversalCompactionBase
: public DBTestBase, : public DBTestBase,
public ::testing::WithParamInterface<std::tuple<int, bool>> { public ::testing::WithParamInterface<std::tuple<int, bool>> {
public: public:
explicit DBTestUniversalCompactionBase( explicit DBTestUniversalCompactionBase(const std::string& path)
const std::string& path) : DBTestBase(path) {} : DBTestBase(path, /*env_do_fsync=*/true) {}
void SetUp() override { void SetUp() override {
num_levels_ = std::get<0>(GetParam()); num_levels_ = std::get<0>(GetParam());
exclusive_manual_compaction_ = std::get<1>(GetParam()); exclusive_manual_compaction_ = std::get<1>(GetParam());
@ -43,7 +43,8 @@ class DBTestUniversalCompaction : public DBTestUniversalCompactionBase {
class DBTestUniversalCompaction2 : public DBTestBase { class DBTestUniversalCompaction2 : public DBTestBase {
public: public:
DBTestUniversalCompaction2() : DBTestBase("/db_universal_compaction_test2") {} DBTestUniversalCompaction2()
: DBTestBase("/db_universal_compaction_test2", /*env_do_fsync=*/true) {}
}; };
namespace { namespace {

View File

@ -18,7 +18,7 @@
namespace ROCKSDB_NAMESPACE { namespace ROCKSDB_NAMESPACE {
class DBWALTest : public DBTestBase { class DBWALTest : public DBTestBase {
public: public:
DBWALTest() : DBTestBase("/db_wal_test") {} DBWALTest() : DBTestBase("/db_wal_test", /*env_do_fsync=*/true) {}
#if defined(ROCKSDB_PLATFORM_POSIX) #if defined(ROCKSDB_PLATFORM_POSIX)
uint64_t GetAllocatedFileSize(std::string file_name) { uint64_t GetAllocatedFileSize(std::string file_name) {
@ -86,7 +86,8 @@ class EnrichedSpecialEnv : public SpecialEnv {
class DBWALTestWithEnrichedEnv : public DBTestBase { class DBWALTestWithEnrichedEnv : public DBTestBase {
public: public:
DBWALTestWithEnrichedEnv() : DBTestBase("/db_wal_test") { DBWALTestWithEnrichedEnv()
: DBTestBase("/db_wal_test", /*env_do_fsync=*/true) {
enriched_env_ = new EnrichedSpecialEnv(env_->target()); enriched_env_ = new EnrichedSpecialEnv(env_->target());
auto options = CurrentOptions(); auto options = CurrentOptions();
options.env = enriched_env_; options.env = enriched_env_;

View File

@ -22,7 +22,7 @@ namespace ROCKSDB_NAMESPACE {
class DBBasicTestWithTimestampBase : public DBTestBase { class DBBasicTestWithTimestampBase : public DBTestBase {
public: public:
explicit DBBasicTestWithTimestampBase(const std::string& dbname) explicit DBBasicTestWithTimestampBase(const std::string& dbname)
: DBTestBase(dbname) {} : DBTestBase(dbname, /*env_do_fsync=*/true) {}
protected: protected:
static std::string Key1(uint64_t k) { static std::string Key1(uint64_t k) {

View File

@ -31,7 +31,7 @@ std::string Timestamp(uint64_t ts) {
class TimestampCompatibleCompactionTest : public DBTestBase { class TimestampCompatibleCompactionTest : public DBTestBase {
public: public:
TimestampCompatibleCompactionTest() TimestampCompatibleCompactionTest()
: DBTestBase("/ts_compatible_compaction_test") {} : DBTestBase("/ts_compatible_compaction_test", /*env_do_fsync=*/true) {}
std::string Get(const std::string& key, uint64_t ts) { std::string Get(const std::string& key, uint64_t ts) {
ReadOptions read_opts; ReadOptions read_opts;

View File

@ -22,7 +22,7 @@ namespace ROCKSDB_NAMESPACE {
// Test variations of WriteImpl. // Test variations of WriteImpl.
class DBWriteTest : public DBTestBase, public testing::WithParamInterface<int> { class DBWriteTest : public DBTestBase, public testing::WithParamInterface<int> {
public: public:
DBWriteTest() : DBTestBase("/db_write_test") {} DBWriteTest() : DBTestBase("/db_write_test", /*env_do_fsync=*/true) {}
Options GetOptions() { return DBTestBase::GetOptions(GetParam()); } Options GetOptions() { return DBTestBase::GetOptions(GetParam()); }

View File

@ -35,7 +35,7 @@ class DeleteFileTest : public DBTestBase {
const std::string wal_dir_; const std::string wal_dir_;
DeleteFileTest() DeleteFileTest()
: DBTestBase("/deletefile_test"), : DBTestBase("/deletefile_test", /*env_do_fsync=*/true),
numlevels_(7), numlevels_(7),
wal_dir_(dbname_ + "/wal_files") {} wal_dir_(dbname_ + "/wal_files") {}

View File

@ -23,7 +23,8 @@ namespace ROCKSDB_NAMESPACE {
class DBErrorHandlingFSTest : public DBTestBase { class DBErrorHandlingFSTest : public DBTestBase {
public: public:
DBErrorHandlingFSTest() : DBTestBase("/db_error_handling_fs_test") {} DBErrorHandlingFSTest()
: DBTestBase("/db_error_handling_fs_test", /*env_do_fsync=*/true) {}
std::string GetManifestNameFromLiveFiles() { std::string GetManifestNameFromLiveFiles() {
std::vector<std::string> live_files; std::vector<std::string> live_files;

View File

@ -20,7 +20,8 @@ class ExternalSSTFileBasicTest
: public DBTestBase, : public DBTestBase,
public ::testing::WithParamInterface<std::tuple<bool, bool>> { public ::testing::WithParamInterface<std::tuple<bool, bool>> {
public: public:
ExternalSSTFileBasicTest() : DBTestBase("/external_sst_file_basic_test") { ExternalSSTFileBasicTest()
: DBTestBase("/external_sst_file_basic_test", /*env_do_fsync=*/true) {
sst_files_dir_ = dbname_ + "/sst_files/"; sst_files_dir_ = dbname_ + "/sst_files/";
fault_injection_test_env_.reset(new FaultInjectionTestEnv(Env::Default())); fault_injection_test_env_.reset(new FaultInjectionTestEnv(Env::Default()));
DestroyAndRecreateExternalSSTFilesDir(); DestroyAndRecreateExternalSSTFilesDir();

View File

@ -43,7 +43,7 @@ class ExternSSTFileLinkFailFallbackTest
public ::testing::WithParamInterface<std::tuple<bool, bool>> { public ::testing::WithParamInterface<std::tuple<bool, bool>> {
public: public:
ExternSSTFileLinkFailFallbackTest() ExternSSTFileLinkFailFallbackTest()
: DBTestBase("/external_sst_file_test"), : DBTestBase("/external_sst_file_test", /*env_do_fsync=*/true),
test_env_(new ExternalSSTTestEnv(env_, true)) { test_env_(new ExternalSSTTestEnv(env_, true)) {
sst_files_dir_ = dbname_ + "/sst_files/"; sst_files_dir_ = dbname_ + "/sst_files/";
test::DestroyDir(env_, sst_files_dir_); test::DestroyDir(env_, sst_files_dir_);
@ -71,7 +71,8 @@ class ExternalSSTFileTest
: public DBTestBase, : public DBTestBase,
public ::testing::WithParamInterface<std::tuple<bool, bool>> { public ::testing::WithParamInterface<std::tuple<bool, bool>> {
public: public:
ExternalSSTFileTest() : DBTestBase("/external_sst_file_test") { ExternalSSTFileTest()
: DBTestBase("/external_sst_file_test", /*env_do_fsync=*/true) {
sst_files_dir_ = dbname_ + "/sst_files/"; sst_files_dir_ = dbname_ + "/sst_files/";
DestroyAndRecreateExternalSSTFilesDir(); DestroyAndRecreateExternalSSTFilesDir();
} }

View File

@ -11,7 +11,8 @@ namespace ROCKSDB_NAMESPACE {
class ImportColumnFamilyTest : public DBTestBase { class ImportColumnFamilyTest : public DBTestBase {
public: public:
ImportColumnFamilyTest() : DBTestBase("/import_column_family_test") { ImportColumnFamilyTest()
: DBTestBase("/import_column_family_test", /*env_do_fsync=*/true) {
sst_files_dir_ = dbname_ + "/sst_files/"; sst_files_dir_ = dbname_ + "/sst_files/";
DestroyAndRecreateExternalSSTFilesDir(); DestroyAndRecreateExternalSSTFilesDir();
export_files_dir_ = test::PerThreadDBPath(env_, "export"); export_files_dir_ = test::PerThreadDBPath(env_, "export");

View File

@ -41,7 +41,7 @@ namespace ROCKSDB_NAMESPACE {
class EventListenerTest : public DBTestBase { class EventListenerTest : public DBTestBase {
public: public:
EventListenerTest() : DBTestBase("/listener_test") {} EventListenerTest() : DBTestBase("/listener_test", /*env_do_fsync=*/true) {}
static std::string BlobStr(uint64_t blob_file_number, uint64_t offset, static std::string BlobStr(uint64_t blob_file_number, uint64_t offset,
uint64_t size) { uint64_t size) {

View File

@ -38,7 +38,8 @@ namespace ROCKSDB_NAMESPACE {
class ObsoleteFilesTest : public DBTestBase { class ObsoleteFilesTest : public DBTestBase {
public: public:
ObsoleteFilesTest() ObsoleteFilesTest()
: DBTestBase("/obsolete_files_test"), wal_dir_(dbname_ + "/wal_files") {} : DBTestBase("/obsolete_files_test", /*env_do_fsync=*/true),
wal_dir_(dbname_ + "/wal_files") {}
void AddKeys(int numkeys, int startkey) { void AddKeys(int numkeys, int startkey) {
WriteOptions options; WriteOptions options;

View File

@ -22,7 +22,7 @@ namespace ROCKSDB_NAMESPACE {
#ifndef ROCKSDB_LITE #ifndef ROCKSDB_LITE
class RepairTest : public DBTestBase { class RepairTest : public DBTestBase {
public: public:
RepairTest() : DBTestBase("/repair_test") {} RepairTest() : DBTestBase("/repair_test", /*env_do_fsync=*/true) {}
std::string GetFirstSstPath() { std::string GetFirstSstPath() {
uint64_t manifest_size; uint64_t manifest_size;

View File

@ -28,7 +28,8 @@ namespace ROCKSDB_NAMESPACE {
class StatsHistoryTest : public DBTestBase { class StatsHistoryTest : public DBTestBase {
public: public:
StatsHistoryTest() : DBTestBase("/stats_history_test") {} StatsHistoryTest()
: DBTestBase("/stats_history_test", /*env_do_fsync=*/true) {}
}; };
#ifndef ROCKSDB_LITE #ifndef ROCKSDB_LITE

View File

@ -19,7 +19,7 @@ class DBOptionChangeMigrationTests
std::tuple<int, int, bool, int, int, bool>> { std::tuple<int, int, bool, int, int, bool>> {
public: public:
DBOptionChangeMigrationTests() DBOptionChangeMigrationTests()
: DBTestBase("/db_option_change_migration_test") { : DBTestBase("/db_option_change_migration_test", /*env_do_fsync=*/true) {
level1_ = std::get<0>(GetParam()); level1_ = std::get<0>(GetParam());
compaction_style1_ = std::get<1>(GetParam()); compaction_style1_ = std::get<1>(GetParam());
is_dynamic1_ = std::get<2>(GetParam()); is_dynamic1_ = std::get<2>(GetParam());
@ -350,7 +350,8 @@ INSTANTIATE_TEST_CASE_P(
class DBOptionChangeMigrationTest : public DBTestBase { class DBOptionChangeMigrationTest : public DBTestBase {
public: public:
DBOptionChangeMigrationTest() DBOptionChangeMigrationTest()
: DBTestBase("/db_option_change_migration_test2") {} : DBTestBase("/db_option_change_migration_test2", /*env_do_fsync=*/true) {
}
}; };
TEST_F(DBOptionChangeMigrationTest, CompactedSrcToUniversal) { TEST_F(DBOptionChangeMigrationTest, CompactedSrcToUniversal) {

View File

@ -295,7 +295,8 @@ TEST_F(PersistentCacheTierTest, FactoryTest) {
} }
} }
PersistentCacheDBTest::PersistentCacheDBTest() : DBTestBase("/cache_test") { PersistentCacheDBTest::PersistentCacheDBTest()
: DBTestBase("/cache_test", /*env_do_fsync=*/true) {
#ifdef OS_LINUX #ifdef OS_LINUX
ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(

View File

@ -21,7 +21,7 @@ class SimCacheTest : public DBTestBase {
const size_t kNumBlocks = 5; const size_t kNumBlocks = 5;
const size_t kValueSize = 1000; const size_t kValueSize = 1000;
SimCacheTest() : DBTestBase("/sim_cache_test") {} SimCacheTest() : DBTestBase("/sim_cache_test", /*env_do_fsync=*/true) {}
BlockBasedTableOptions GetTableOptions() { BlockBasedTableOptions GetTableOptions() {
BlockBasedTableOptions table_options; BlockBasedTableOptions table_options;