Skip to content

Commit

Permalink
Whole DBTest to skip fsync (facebook#7274)
Browse files Browse the repository at this point in the history
Summary:
After facebook#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.

This commit reinstates facebook#7049, whose un-revert was lost in an automatic
infrastructure mis-merge.

Pull Request resolved: facebook#7274

Test Plan: Run all existing files.

Reviewed By: pdillinger

Differential Revision: D23177444

fbshipit-source-id: 1f61690b2ac6333c3b2c87176fef6b2cba086b33
  • Loading branch information
siying authored and facebook-github-bot committed Aug 18, 2020
1 parent 5d5ff82 commit b194c21
Show file tree
Hide file tree
Showing 46 changed files with 98 additions and 64 deletions.
3 changes: 2 additions & 1 deletion db/blob/db_blob_index_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ class DBBlobIndexTest : public DBTestBase {
Tier::kImmutableMemtables,
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(); }

Expand Down
4 changes: 2 additions & 2 deletions db/db_basic_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ namespace ROCKSDB_NAMESPACE {

class DBBasicTest : public DBTestBase {
public:
DBBasicTest() : DBTestBase("/db_basic_test") {}
DBBasicTest() : DBTestBase("/db_basic_test", /*env_do_fsync=*/true) {}
};

TEST_F(DBBasicTest, OpenWhenOpen) {
Expand Down Expand Up @@ -2374,7 +2374,7 @@ class DBBasicTestMultiGet : public DBTestBase {
DBBasicTestMultiGet(std::string test_dir, int num_cfs, bool compressed_cache,
bool uncompressed_cache, bool _compression_enabled,
bool _fill_cache, uint32_t compression_parallel_threads)
: DBTestBase(test_dir) {
: DBTestBase(test_dir, /*env_do_fsync=*/true) {
compression_enabled_ = _compression_enabled;
fill_cache_ = _fill_cache;

Expand Down
3 changes: 2 additions & 1 deletion db/db_block_cache_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ class DBBlockCacheTest : public DBTestBase {
const size_t kNumBlocks = 10;
const size_t kValueSize = 100;

DBBlockCacheTest() : DBTestBase("/db_block_cache_test") {}
DBBlockCacheTest()
: DBTestBase("/db_block_cache_test", /*env_do_fsync=*/true) {}

BlockBasedTableOptions GetTableOptions() {
BlockBasedTableOptions table_options;
Expand Down
8 changes: 5 additions & 3 deletions db/db_bloom_filter_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ using BFP = BloomFilterPolicy;

class DBBloomFilterTest : public DBTestBase {
public:
DBBloomFilterTest() : DBTestBase("/db_bloom_filter_test") {}
DBBloomFilterTest()
: DBTestBase("/db_bloom_filter_test", /*env_do_fsync=*/true) {}
};

class DBBloomFilterTestWithParam : public DBTestBase,
Expand All @@ -36,7 +37,8 @@ class DBBloomFilterTestWithParam : public DBTestBase,
uint32_t format_version_;

public:
DBBloomFilterTestWithParam() : DBTestBase("/db_bloom_filter_tests") {}
DBBloomFilterTestWithParam()
: DBTestBase("/db_bloom_filter_tests", /*env_do_fsync=*/true) {}

~DBBloomFilterTestWithParam() override {}

Expand Down Expand Up @@ -1039,7 +1041,7 @@ class DBBloomFilterTestVaryPrefixAndFormatVer

public:
DBBloomFilterTestVaryPrefixAndFormatVer()
: DBTestBase("/db_bloom_filter_tests") {}
: DBTestBase("/db_bloom_filter_tests", /*env_do_fsync=*/true) {}

~DBBloomFilterTestVaryPrefixAndFormatVer() override {}

Expand Down
3 changes: 2 additions & 1 deletion db/db_compaction_filter_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ static std::string NEW_VALUE = "NewValue";

class DBTestCompactionFilter : public DBTestBase {
public:
DBTestCompactionFilter() : DBTestBase("/db_compaction_filter_test") {}
DBTestCompactionFilter()
: DBTestBase("/db_compaction_filter_test", /*env_do_fsync=*/true) {}
};

// Param variant of DBTestBase::ChangeCompactOptions
Expand Down
9 changes: 6 additions & 3 deletions db/db_compaction_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,16 @@ namespace ROCKSDB_NAMESPACE {

class DBCompactionTest : public DBTestBase {
public:
DBCompactionTest() : DBTestBase("/db_compaction_test") {}
DBCompactionTest()
: DBTestBase("/db_compaction_test", /*env_do_fsync=*/true) {}
};

class DBCompactionTestWithParam
: public DBTestBase,
public testing::WithParamInterface<std::tuple<uint32_t, bool>> {
public:
DBCompactionTestWithParam() : DBTestBase("/db_compaction_test") {
DBCompactionTestWithParam()
: DBTestBase("/db_compaction_test", /*env_do_fsync=*/true) {
max_subcompactions_ = std::get<0>(GetParam());
exclusive_manual_compaction_ = std::get<1>(GetParam());
}
Expand Down Expand Up @@ -4825,7 +4827,8 @@ INSTANTIATE_TEST_CASE_P(DBCompactionDirectIOTest, DBCompactionDirectIOTest,
class CompactionPriTest : public DBTestBase,
public testing::WithParamInterface<uint32_t> {
public:
CompactionPriTest() : DBTestBase("/compaction_pri_test") {
CompactionPriTest()
: DBTestBase("/compaction_pri_test", /*env_do_fsync=*/true) {
compaction_pri_ = GetParam();
}

Expand Down
3 changes: 2 additions & 1 deletion db/db_dynamic_level_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
namespace ROCKSDB_NAMESPACE {
class DBTestDynamicLevel : public DBTestBase {
public:
DBTestDynamicLevel() : DBTestBase("/db_dynamic_level_test") {}
DBTestDynamicLevel()
: DBTestBase("/db_dynamic_level_test", /*env_do_fsync=*/true) {}
};

TEST_F(DBTestDynamicLevel, DynamicLevelMaxBytesBase) {
Expand Down
3 changes: 2 additions & 1 deletion db/db_encryption_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ namespace ROCKSDB_NAMESPACE {

class DBEncryptionTest : public DBTestBase {
public:
DBEncryptionTest() : DBTestBase("/db_encryption_test") {}
DBEncryptionTest()
: DBTestBase("/db_encryption_test", /*env_do_fsync=*/true) {}
};

#ifndef ROCKSDB_LITE
Expand Down
2 changes: 1 addition & 1 deletion db/db_flush_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace ROCKSDB_NAMESPACE {

class DBFlushTest : public DBTestBase {
public:
DBFlushTest() : DBTestBase("/db_flush_test") {}
DBFlushTest() : DBTestBase("/db_flush_test", /*env_do_fsync=*/true) {}
};

class DBFlushDirectIOTest : public DBFlushTest,
Expand Down
2 changes: 1 addition & 1 deletion db/db_impl/db_secondary_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace ROCKSDB_NAMESPACE {
class DBSecondaryTest : public DBTestBase {
public:
DBSecondaryTest()
: DBTestBase("/db_secondary_test"),
: DBTestBase("/db_secondary_test", /*env_do_fsync=*/true),
secondary_path_(),
handles_secondary_(),
db_secondary_(nullptr) {
Expand Down
3 changes: 2 additions & 1 deletion db/db_inplace_update_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ namespace ROCKSDB_NAMESPACE {

class DBTestInPlaceUpdate : public DBTestBase {
public:
DBTestInPlaceUpdate() : DBTestBase("/db_inplace_update_test") {}
DBTestInPlaceUpdate()
: DBTestBase("/db_inplace_update_test", /*env_do_fsync=*/true) {}
};

TEST_F(DBTestInPlaceUpdate, InPlaceUpdate) {
Expand Down
3 changes: 2 additions & 1 deletion db/db_io_failure_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ namespace ROCKSDB_NAMESPACE {

class DBIOFailureTest : public DBTestBase {
public:
DBIOFailureTest() : DBTestBase("/db_io_failure_test") {}
DBIOFailureTest()
: DBTestBase("/db_io_failure_test", /*env_do_fsync=*/true) {}
};

#ifndef ROCKSDB_LITE
Expand Down
2 changes: 1 addition & 1 deletion db/db_iterator_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class DummyReadCallback : public ReadCallback {
class DBIteratorTest : public DBTestBase,
public testing::WithParamInterface<bool> {
public:
DBIteratorTest() : DBTestBase("/db_iterator_test") {}
DBIteratorTest() : DBTestBase("/db_iterator_test", /*env_do_fsync=*/true) {}

Iterator* NewIterator(const ReadOptions& read_options,
ColumnFamilyHandle* column_family = nullptr) {
Expand Down
3 changes: 2 additions & 1 deletion db/db_log_iter_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ namespace ROCKSDB_NAMESPACE {

class DBTestXactLogIterator : public DBTestBase {
public:
DBTestXactLogIterator() : DBTestBase("/db_log_iter_test") {}
DBTestXactLogIterator()
: DBTestBase("/db_log_iter_test", /*env_do_fsync=*/true) {}

std::unique_ptr<TransactionLogIterator> OpenTransactionLogIter(
const SequenceNumber seq) {
Expand Down
2 changes: 1 addition & 1 deletion db/db_memtable_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespace ROCKSDB_NAMESPACE {

class DBMemTableTest : public DBTestBase {
public:
DBMemTableTest() : DBTestBase("/db_memtable_test") {}
DBMemTableTest() : DBTestBase("/db_memtable_test", /*env_do_fsync=*/true) {}
};

class MockMemTableRep : public MemTableRep {
Expand Down
3 changes: 2 additions & 1 deletion db/db_merge_operand_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ namespace ROCKSDB_NAMESPACE {

class DBMergeOperandTest : public DBTestBase {
public:
DBMergeOperandTest() : DBTestBase("/db_merge_operand_test") {}
DBMergeOperandTest()
: DBTestBase("/db_merge_operand_test", /*env_do_fsync=*/true) {}
};

TEST_F(DBMergeOperandTest, GetMergeOperandsBasic) {
Expand Down
3 changes: 2 additions & 1 deletion db/db_merge_operator_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ class TestReadCallback : public ReadCallback {
// Test merge operator functionality.
class DBMergeOperatorTest : public DBTestBase {
public:
DBMergeOperatorTest() : DBTestBase("/db_merge_operator_test") {}
DBMergeOperatorTest()
: DBTestBase("/db_merge_operator_test", /*env_do_fsync=*/true) {}

std::string GetWithReadCallback(SnapshotChecker* snapshot_checker,
const Slice& key,
Expand Down
2 changes: 1 addition & 1 deletion db/db_options_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ namespace ROCKSDB_NAMESPACE {

class DBOptionsTest : public DBTestBase {
public:
DBOptionsTest() : DBTestBase("/db_options_test") {}
DBOptionsTest() : DBTestBase("/db_options_test", /*env_do_fsync=*/true) {}

#ifndef ROCKSDB_LITE
std::unordered_map<std::string, std::string> GetMutableDBOptionsMap(
Expand Down
3 changes: 2 additions & 1 deletion db/db_properties_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ namespace ROCKSDB_NAMESPACE {

class DBPropertiesTest : public DBTestBase {
public:
DBPropertiesTest() : DBTestBase("/db_properties_test") {}
DBPropertiesTest()
: DBTestBase("/db_properties_test", /*env_do_fsync=*/true) {}
};

#ifndef ROCKSDB_LITE
Expand Down
2 changes: 1 addition & 1 deletion db/db_range_del_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace ROCKSDB_NAMESPACE {

class DBRangeDelTest : public DBTestBase {
public:
DBRangeDelTest() : DBTestBase("/db_range_del_test") {}
DBRangeDelTest() : DBTestBase("/db_range_del_test", /*env_do_fsync=*/true) {}

std::string GetNumericStr(int key) {
uint64_t uint64_key = static_cast<uint64_t>(key);
Expand Down
2 changes: 1 addition & 1 deletion db/db_sst_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ namespace ROCKSDB_NAMESPACE {

class DBSSTTest : public DBTestBase {
public:
DBSSTTest() : DBTestBase("/db_sst_test") {}
DBSSTTest() : DBTestBase("/db_sst_test", /*env_do_fsync=*/true) {}
};

#ifndef ROCKSDB_LITE
Expand Down
3 changes: 2 additions & 1 deletion db/db_statistics_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ namespace ROCKSDB_NAMESPACE {

class DBStatisticsTest : public DBTestBase {
public:
DBStatisticsTest() : DBTestBase("/db_statistics_test") {}
DBStatisticsTest()
: DBTestBase("/db_statistics_test", /*env_do_fsync=*/true) {}
};

TEST_F(DBStatisticsTest, CompressionStatsTest) {
Expand Down
3 changes: 2 additions & 1 deletion db/db_table_properties_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ void VerifyTableProperties(DB* db, uint64_t expected_entries_size) {
class DBTablePropertiesTest : public DBTestBase,
public testing::WithParamInterface<std::string> {
public:
DBTablePropertiesTest() : DBTestBase("/db_table_properties_test") {}
DBTablePropertiesTest()
: DBTestBase("/db_table_properties_test", /*env_do_fsync=*/true) {}
TablePropertiesCollection TestGetPropertiesOfTablesInRange(
std::vector<Range> ranges, std::size_t* num_properties = nullptr,
std::size_t* num_files = nullptr);
Expand Down
3 changes: 2 additions & 1 deletion db/db_tailing_iter_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ namespace ROCKSDB_NAMESPACE {

class DBTestTailingIterator : public DBTestBase {
public:
DBTestTailingIterator() : DBTestBase("/db_tailing_iterator_test") {}
DBTestTailingIterator()
: DBTestBase("/db_tailing_iterator_test", /*env_do_fsync=*/true) {}
};

TEST_F(DBTestTailingIterator, TailingIteratorSingle) {
Expand Down
9 changes: 4 additions & 5 deletions db/db_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,12 @@

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 {
public:
DBTest() : DBTestBase("/db_test") {}
DBTest() : DBTestBase("/db_test", /*env_do_fsync=*/false) {}
};

class DBTestWithParam
Expand Down Expand Up @@ -1792,7 +1795,6 @@ TEST_F(DBTest, Snapshot) {
TEST_F(DBTest, HiddenValuesAreRemoved) {
anon::OptionsOverride options_override;
options_override.skip_policy = kSkipNoSnapshot;
env_->skip_fsync_ = true;
do {
Options options = CurrentOptions(options_override);
CreateAndReopenWithCF({"pikachu"}, options);
Expand Down Expand Up @@ -4000,7 +4002,6 @@ TEST_F(DBTest, DynamicMemtableOptions) {
const uint64_t k128KB = 1 << 17;
const uint64_t k5KB = 5 * 1024;
Options options;
env_->skip_fsync_ = true;
options.env = env_;
options.create_if_missing = true;
options.compression = kNoCompression;
Expand Down Expand Up @@ -5147,7 +5148,6 @@ TEST_F(DBTest, DynamicUniversalCompactionOptions) {

TEST_F(DBTest, FileCreationRandomFailure) {
Options options;
env_->skip_fsync_ = true;
options.env = env_;
options.create_if_missing = true;
options.write_buffer_size = 100000; // Small write buffer
Expand Down Expand Up @@ -5504,7 +5504,6 @@ TEST_F(DBTest, MergeTestTime) {
#ifndef ROCKSDB_LITE
TEST_P(DBTestWithParam, MergeCompactionTimeTest) {
SetPerfLevel(kEnableTime);
env_->skip_fsync_ = true;
Options options = CurrentOptions();
options.compaction_filter_factory = std::make_shared<KeepFilterFactory>();
options.statistics = ROCKSDB_NAMESPACE::CreateDBStatistics();
Expand Down
12 changes: 7 additions & 5 deletions db/db_test2.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ namespace ROCKSDB_NAMESPACE {

class DBTest2 : public DBTestBase {
public:
DBTest2() : DBTestBase("/db_test2") {}
DBTest2() : DBTestBase("/db_test2", /*env_do_fsync=*/true) {}
};

#ifndef ROCKSDB_LITE
Expand Down Expand Up @@ -93,7 +93,8 @@ class TestReadOnlyWithCompressedCache
public testing::WithParamInterface<std::tuple<int, bool>> {
public:
TestReadOnlyWithCompressedCache()
: DBTestBase("/test_readonly_with_compressed_cache") {
: DBTestBase("/test_readonly_with_compressed_cache",
/*env_do_fsync=*/true) {
max_open_files_ = std::get<0>(GetParam());
use_mmap_ = std::get<1>(GetParam());
}
Expand Down Expand Up @@ -184,7 +185,7 @@ class PrefixFullBloomWithReverseComparator
public ::testing::WithParamInterface<bool> {
public:
PrefixFullBloomWithReverseComparator()
: DBTestBase("/prefix_bloom_reverse") {}
: DBTestBase("/prefix_bloom_reverse", /*env_do_fsync=*/true) {}
void SetUp() override { if_cache_filter_ = GetParam(); }
bool if_cache_filter_;
};
Expand Down Expand Up @@ -324,7 +325,7 @@ class DBTestSharedWriteBufferAcrossCFs
public testing::WithParamInterface<std::tuple<bool, bool>> {
public:
DBTestSharedWriteBufferAcrossCFs()
: DBTestBase("/db_test_shared_write_buffer") {}
: DBTestBase("/db_test_shared_write_buffer", /*env_do_fsync=*/true) {}
void SetUp() override {
use_old_interface_ = std::get<0>(GetParam());
cost_cache_ = std::get<1>(GetParam());
Expand Down Expand Up @@ -1790,7 +1791,8 @@ class PinL0IndexAndFilterBlocksTest
: public DBTestBase,
public testing::WithParamInterface<std::tuple<bool, bool>> {
public:
PinL0IndexAndFilterBlocksTest() : DBTestBase("/db_pin_l0_index_bloom_test") {}
PinL0IndexAndFilterBlocksTest()
: DBTestBase("/db_pin_l0_index_bloom_test", /*env_do_fsync=*/true) {}
void SetUp() override {
infinite_max_files_ = std::get<0>(GetParam());
disallow_preload_ = std::get<1>(GetParam());
Expand Down
3 changes: 2 additions & 1 deletion db/db_test_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ SpecialEnv::SpecialEnv(Env* base, bool time_elapse_only_sleep)
ROT13BlockCipher rot13Cipher_(16);
#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) {
Env* base_env = Env::Default();
#ifndef ROCKSDB_LITE
Expand All @@ -84,6 +84,7 @@ DBTestBase::DBTestBase(const std::string path)
: (mem_env_ ? mem_env_ : base_env));
env_->SetBackgroundThreads(1, Env::LOW);
env_->SetBackgroundThreads(1, Env::HIGH);
env_->skip_fsync_ = !env_do_fsync;
dbname_ = test::PerThreadDBPath(env_, path);
alternative_wal_dir_ = dbname_ + "/wal";
alternative_db_log_dir_ = dbname_ + "/db_log_dir";
Expand Down
Loading

0 comments on commit b194c21

Please sign in to comment.