add prefix_seek_mode to db_iter_test

Summary: add prefix_seek_mode to db_iter_test to enable data race test for iterator when prefix_extractor != nullptr

Test Plan: make all check -j64

Reviewers: andrewkr, IslamAbdelRahman, sdong

Reviewed By: sdong

Subscribers: andrewkr, dhruba, leveldb

Differential Revision: https://reviews.facebook.net/D63027
main
Aaron Gao 8 years ago
parent de47e2bd4d
commit 6a14d55bd9
  1. 34
      db/db_iter_test.cc

@ -1842,7 +1842,7 @@ TEST_F(DBIteratorTest, DBIterator12) {
ASSERT_FALSE(db_iter->Valid()); ASSERT_FALSE(db_iter->Valid());
} }
class DBIterWithMergeIterTest : public testing::Test { class DBIterWithMergeIterTest : public ::testing::TestWithParam<bool> {
public: public:
DBIterWithMergeIterTest() DBIterWithMergeIterTest()
: env_(Env::Default()), icomp_(BytewiseComparator()) { : env_(Env::Default()), icomp_(BytewiseComparator()) {
@ -1865,9 +1865,11 @@ class DBIterWithMergeIterTest : public testing::Test {
child_iters.push_back(internal_iter1_); child_iters.push_back(internal_iter1_);
child_iters.push_back(internal_iter2_); child_iters.push_back(internal_iter2_);
InternalKeyComparator icomp(BytewiseComparator()); InternalKeyComparator icomp(BytewiseComparator());
InternalIterator* merge_iter = if (GetParam() == false) {
NewMergingIterator(&icomp_, &child_iters[0], 2u); options_.prefix_extractor.reset(NewFixedPrefixTransform(0));
}
InternalIterator* merge_iter = NewMergingIterator(
&icomp_, &child_iters[0], 2u, nullptr, options_.prefix_extractor.get());
db_iter_.reset(NewDBIterator(env_, ImmutableCFOptions(options_), db_iter_.reset(NewDBIterator(env_, ImmutableCFOptions(options_),
BytewiseComparator(), merge_iter, BytewiseComparator(), merge_iter,
8 /* read data earlier than seqId 8 */, 8 /* read data earlier than seqId 8 */,
@ -1883,7 +1885,7 @@ class DBIterWithMergeIterTest : public testing::Test {
std::unique_ptr<Iterator> db_iter_; std::unique_ptr<Iterator> db_iter_;
}; };
TEST_F(DBIterWithMergeIterTest, InnerMergeIterator1) { TEST_P(DBIterWithMergeIterTest, InnerMergeIterator1) {
db_iter_->SeekToFirst(); db_iter_->SeekToFirst();
ASSERT_TRUE(db_iter_->Valid()); ASSERT_TRUE(db_iter_->Valid());
ASSERT_EQ(db_iter_->key().ToString(), "a"); ASSERT_EQ(db_iter_->key().ToString(), "a");
@ -1912,7 +1914,7 @@ TEST_F(DBIterWithMergeIterTest, InnerMergeIterator1) {
ASSERT_FALSE(db_iter_->Valid()); ASSERT_FALSE(db_iter_->Valid());
} }
TEST_F(DBIterWithMergeIterTest, InnerMergeIterator2) { TEST_P(DBIterWithMergeIterTest, InnerMergeIterator2) {
// Test Prev() when one child iterator is at its end. // Test Prev() when one child iterator is at its end.
db_iter_->Seek("g"); db_iter_->Seek("g");
ASSERT_TRUE(db_iter_->Valid()); ASSERT_TRUE(db_iter_->Valid());
@ -1940,7 +1942,7 @@ TEST_F(DBIterWithMergeIterTest, InnerMergeIterator2) {
ASSERT_EQ(db_iter_->value().ToString(), "4"); ASSERT_EQ(db_iter_->value().ToString(), "4");
} }
TEST_F(DBIterWithMergeIterTest, InnerMergeIteratorDataRace1) { TEST_P(DBIterWithMergeIterTest, InnerMergeIteratorDataRace1) {
// Test Prev() when one child iterator is at its end but more rows // Test Prev() when one child iterator is at its end but more rows
// are added. // are added.
db_iter_->Seek("f"); db_iter_->Seek("f");
@ -1976,7 +1978,7 @@ TEST_F(DBIterWithMergeIterTest, InnerMergeIteratorDataRace1) {
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); rocksdb::SyncPoint::GetInstance()->DisableProcessing();
} }
TEST_F(DBIterWithMergeIterTest, InnerMergeIteratorDataRace2) { TEST_P(DBIterWithMergeIterTest, InnerMergeIteratorDataRace2) {
// Test Prev() when one child iterator is at its end but more rows // Test Prev() when one child iterator is at its end but more rows
// are added. // are added.
db_iter_->Seek("f"); db_iter_->Seek("f");
@ -2014,7 +2016,7 @@ TEST_F(DBIterWithMergeIterTest, InnerMergeIteratorDataRace2) {
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); rocksdb::SyncPoint::GetInstance()->DisableProcessing();
} }
TEST_F(DBIterWithMergeIterTest, InnerMergeIteratorDataRace3) { TEST_P(DBIterWithMergeIterTest, InnerMergeIteratorDataRace3) {
// Test Prev() when one child iterator is at its end but more rows // Test Prev() when one child iterator is at its end but more rows
// are added and max_skipped is triggered. // are added and max_skipped is triggered.
db_iter_->Seek("f"); db_iter_->Seek("f");
@ -2056,7 +2058,7 @@ TEST_F(DBIterWithMergeIterTest, InnerMergeIteratorDataRace3) {
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); rocksdb::SyncPoint::GetInstance()->DisableProcessing();
} }
TEST_F(DBIterWithMergeIterTest, InnerMergeIteratorDataRace4) { TEST_P(DBIterWithMergeIterTest, InnerMergeIteratorDataRace4) {
// Test Prev() when one child iterator has more rows inserted // Test Prev() when one child iterator has more rows inserted
// between Seek() and Prev() when changing directions. // between Seek() and Prev() when changing directions.
internal_iter2_->Add("z", kTypeValue, "9", 4u); internal_iter2_->Add("z", kTypeValue, "9", 4u);
@ -2107,7 +2109,7 @@ TEST_F(DBIterWithMergeIterTest, InnerMergeIteratorDataRace4) {
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); rocksdb::SyncPoint::GetInstance()->DisableProcessing();
} }
TEST_F(DBIterWithMergeIterTest, InnerMergeIteratorDataRace5) { TEST_P(DBIterWithMergeIterTest, InnerMergeIteratorDataRace5) {
internal_iter2_->Add("z", kTypeValue, "9", 4u); internal_iter2_->Add("z", kTypeValue, "9", 4u);
// Test Prev() when one child iterator has more rows inserted // Test Prev() when one child iterator has more rows inserted
@ -2154,7 +2156,7 @@ TEST_F(DBIterWithMergeIterTest, InnerMergeIteratorDataRace5) {
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); rocksdb::SyncPoint::GetInstance()->DisableProcessing();
} }
TEST_F(DBIterWithMergeIterTest, InnerMergeIteratorDataRace6) { TEST_P(DBIterWithMergeIterTest, InnerMergeIteratorDataRace6) {
internal_iter2_->Add("z", kTypeValue, "9", 4u); internal_iter2_->Add("z", kTypeValue, "9", 4u);
// Test Prev() when one child iterator has more rows inserted // Test Prev() when one child iterator has more rows inserted
@ -2200,7 +2202,7 @@ TEST_F(DBIterWithMergeIterTest, InnerMergeIteratorDataRace6) {
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); rocksdb::SyncPoint::GetInstance()->DisableProcessing();
} }
TEST_F(DBIterWithMergeIterTest, InnerMergeIteratorDataRace7) { TEST_P(DBIterWithMergeIterTest, InnerMergeIteratorDataRace7) {
internal_iter1_->Add("u", kTypeValue, "10", 4u); internal_iter1_->Add("u", kTypeValue, "10", 4u);
internal_iter1_->Add("v", kTypeValue, "11", 4u); internal_iter1_->Add("v", kTypeValue, "11", 4u);
internal_iter1_->Add("w", kTypeValue, "12", 4u); internal_iter1_->Add("w", kTypeValue, "12", 4u);
@ -2254,7 +2256,7 @@ TEST_F(DBIterWithMergeIterTest, InnerMergeIteratorDataRace7) {
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); rocksdb::SyncPoint::GetInstance()->DisableProcessing();
} }
TEST_F(DBIterWithMergeIterTest, InnerMergeIteratorDataRace8) { TEST_P(DBIterWithMergeIterTest, InnerMergeIteratorDataRace8) {
// internal_iter1_: a, f, g // internal_iter1_: a, f, g
// internal_iter2_: a, b, c, d, adding (z) // internal_iter2_: a, b, c, d, adding (z)
internal_iter2_->Add("z", kTypeValue, "9", 4u); internal_iter2_->Add("z", kTypeValue, "9", 4u);
@ -2290,6 +2292,10 @@ TEST_F(DBIterWithMergeIterTest, InnerMergeIteratorDataRace8) {
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); rocksdb::SyncPoint::GetInstance()->DisableProcessing();
} }
INSTANTIATE_TEST_CASE_P(InnerMergeIteratorDataRaceInstance,
DBIterWithMergeIterTest, ::testing::Bool());
} // namespace rocksdb } // namespace rocksdb
int main(int argc, char** argv) { int main(int argc, char** argv) {

Loading…
Cancel
Save