Split FaultInjectionTest.FaultTest to avoid timeout

Summary:
tsan flavor of this test occasionally times out in our test infra. The patch split the test to two, each working on half of the option range.
Before:
[       OK ] FaultTest/FaultInjectionTest.FaultTest/0 (5918 ms)
[       OK ] FaultTest/FaultInjectionTest.FaultTest/1 (5336 ms)
After:
[       OK ] FaultTest/FaultInjectionTestSplitted.FaultTest/0 (2930 ms)
[       OK ] FaultTest/FaultInjectionTestSplitted.FaultTest/1 (2676 ms)
[       OK ] FaultTest/FaultInjectionTestSplitted.FaultTest/2 (2759 ms)
[       OK ] FaultTest/FaultInjectionTestSplitted.FaultTest/3 (2546 ms)
Closes https://github.com/facebook/rocksdb/pull/3819

Differential Revision: D7894975

Pulled By: maysamyabandeh

fbshipit-source-id: 809f1411cbcc27f8aa71a6b29a16b039f51b67c9
main
Maysam Yabandeh 7 years ago committed by Facebook Github Bot
parent 72942ad7a4
commit d72a51e9e1
  1. 39
      db/fault_injection_test.cc

@ -34,10 +34,7 @@ static const int kValueSize = 1000;
static const int kMaxNumValues = 2000;
static const size_t kNumIterations = 3;
class FaultInjectionTest : public testing::Test,
public testing::WithParamInterface<bool> {
protected:
enum OptionConfig {
enum FaultInjectionOptionConfig {
kDefault,
kDifferentDataDir,
kWalDir,
@ -45,8 +42,14 @@ class FaultInjectionTest : public testing::Test,
kWalDirSyncWal,
kMultiLevels,
kEnd,
};
};
class FaultInjectionTest
: public testing::Test,
public testing::WithParamInterface<std::tuple<
bool, FaultInjectionOptionConfig, FaultInjectionOptionConfig>> {
protected:
int option_config_;
int non_inclusive_end_range_; // kEnd or equivalent to that
// When need to make sure data is persistent, sync WAL
bool sync_use_wal_;
// When need to make sure data is persistent, call DB::CompactRange()
@ -72,13 +75,13 @@ class FaultInjectionTest : public testing::Test,
DB* db_;
FaultInjectionTest()
: option_config_(kDefault),
: option_config_(std::get<1>(GetParam())),
non_inclusive_end_range_(std::get<2>(GetParam())),
sync_use_wal_(false),
sync_use_compact_(true),
base_env_(nullptr),
env_(nullptr),
db_(nullptr) {
}
db_(nullptr) {}
~FaultInjectionTest() {
rocksdb::SyncPoint::GetInstance()->DisableProcessing();
@ -87,7 +90,7 @@ class FaultInjectionTest : public testing::Test,
bool ChangeOptions() {
option_config_++;
if (option_config_ >= kEnd) {
if (option_config_ >= non_inclusive_end_range_) {
return false;
} else {
if (option_config_ == kMultiLevels) {
@ -166,7 +169,7 @@ class FaultInjectionTest : public testing::Test,
}
void SetUp() override {
sequential_order_ = GetParam();
sequential_order_ = std::get<0>(GetParam());
ASSERT_OK(NewDB());
}
@ -343,7 +346,9 @@ class FaultInjectionTest : public testing::Test,
}
};
TEST_P(FaultInjectionTest, FaultTest) {
class FaultInjectionTestSplitted : public FaultInjectionTest {};
TEST_P(FaultInjectionTestSplitted, FaultTest) {
do {
Random rnd(301);
@ -530,7 +535,17 @@ TEST_P(FaultInjectionTest, WriteBatchWalTerminationTest) {
ASSERT_EQ(db_->Get(ro, "boys", &val), Status::NotFound());
}
INSTANTIATE_TEST_CASE_P(FaultTest, FaultInjectionTest, ::testing::Bool());
INSTANTIATE_TEST_CASE_P(
FaultTest, FaultInjectionTest,
::testing::Values(std::make_tuple(false, kDefault, kEnd),
std::make_tuple(true, kDefault, kEnd)));
INSTANTIATE_TEST_CASE_P(
FaultTest, FaultInjectionTestSplitted,
::testing::Values(std::make_tuple(false, kDefault, kSyncWal),
std::make_tuple(true, kDefault, kSyncWal),
std::make_tuple(false, kSyncWal, kEnd),
std::make_tuple(true, kSyncWal, kEnd)));
} // namespace rocksdb

Loading…
Cancel
Save