Add additional checks for three existing unit tests (#8973)
Summary: With test sync points, we can assert on the equality of iterator value in three existing unit tests. Pull Request resolved: https://github.com/facebook/rocksdb/pull/8973 Test Plan: ``` gtest-parallel -r 1000 ./db_test2 --gtest_filter=DBTest2.IterRaceFlush2:DBTest2.IterRaceFlush1:DBTest2.IterRefreshRaceFlush ``` make check Reviewed By: akankshamahajan15 Differential Revision: D31256340 Pulled By: riversand963 fbshipit-source-id: a9440767ab383e0ec61bd43ffa8fbec4ba562ea2
This commit is contained in:
parent
84d71f30c4
commit
2cdaf5ca5b
@ -3670,14 +3670,15 @@ TEST_F(DBTest2, IterRaceFlush1) {
|
|||||||
TEST_SYNC_POINT("DBTest2::IterRaceFlush:2");
|
TEST_SYNC_POINT("DBTest2::IterRaceFlush:2");
|
||||||
});
|
});
|
||||||
|
|
||||||
// iterator is created after the first Put(), so it should see either
|
// iterator is created after the first Put(), and its snapshot sequence is
|
||||||
// "v1" or "v2".
|
// assigned after second Put(), so it must see v2.
|
||||||
{
|
{
|
||||||
std::unique_ptr<Iterator> it(db_->NewIterator(ReadOptions()));
|
std::unique_ptr<Iterator> it(db_->NewIterator(ReadOptions()));
|
||||||
it->Seek("foo");
|
it->Seek("foo");
|
||||||
ASSERT_TRUE(it->Valid());
|
ASSERT_TRUE(it->Valid());
|
||||||
ASSERT_OK(it->status());
|
ASSERT_OK(it->status());
|
||||||
ASSERT_EQ("foo", it->key().ToString());
|
ASSERT_EQ("foo", it->key().ToString());
|
||||||
|
ASSERT_EQ("v2", it->value().ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
t1.join();
|
t1.join();
|
||||||
@ -3700,14 +3701,15 @@ TEST_F(DBTest2, IterRaceFlush2) {
|
|||||||
TEST_SYNC_POINT("DBTest2::IterRaceFlush2:2");
|
TEST_SYNC_POINT("DBTest2::IterRaceFlush2:2");
|
||||||
});
|
});
|
||||||
|
|
||||||
// iterator is created after the first Put(), so it should see either
|
// iterator is created after the first Put(), and its snapshot sequence is
|
||||||
// "v1" or "v2".
|
// assigned before second Put(), thus it must see v1.
|
||||||
{
|
{
|
||||||
std::unique_ptr<Iterator> it(db_->NewIterator(ReadOptions()));
|
std::unique_ptr<Iterator> it(db_->NewIterator(ReadOptions()));
|
||||||
it->Seek("foo");
|
it->Seek("foo");
|
||||||
ASSERT_TRUE(it->Valid());
|
ASSERT_TRUE(it->Valid());
|
||||||
ASSERT_OK(it->status());
|
ASSERT_OK(it->status());
|
||||||
ASSERT_EQ("foo", it->key().ToString());
|
ASSERT_EQ("foo", it->key().ToString());
|
||||||
|
ASSERT_EQ("v1", it->value().ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
t1.join();
|
t1.join();
|
||||||
@ -3730,8 +3732,8 @@ TEST_F(DBTest2, IterRefreshRaceFlush) {
|
|||||||
TEST_SYNC_POINT("DBTest2::IterRefreshRaceFlush:2");
|
TEST_SYNC_POINT("DBTest2::IterRefreshRaceFlush:2");
|
||||||
});
|
});
|
||||||
|
|
||||||
// iterator is created after the first Put(), so it should see either
|
// iterator is refreshed after the first Put(), and its sequence number is
|
||||||
// "v1" or "v2".
|
// assigned after second Put(), thus it must see v2.
|
||||||
{
|
{
|
||||||
std::unique_ptr<Iterator> it(db_->NewIterator(ReadOptions()));
|
std::unique_ptr<Iterator> it(db_->NewIterator(ReadOptions()));
|
||||||
ASSERT_OK(it->status());
|
ASSERT_OK(it->status());
|
||||||
@ -3740,6 +3742,7 @@ TEST_F(DBTest2, IterRefreshRaceFlush) {
|
|||||||
ASSERT_TRUE(it->Valid());
|
ASSERT_TRUE(it->Valid());
|
||||||
ASSERT_OK(it->status());
|
ASSERT_OK(it->status());
|
||||||
ASSERT_EQ("foo", it->key().ToString());
|
ASSERT_EQ("foo", it->key().ToString());
|
||||||
|
ASSERT_EQ("v2", it->value().ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
t1.join();
|
t1.join();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user