Add seq_per_batch to WriteWithCallbackTest

Summary:
Augment WriteWithCallbackTest to also test when seq_per_batch is true.
Closes https://github.com/facebook/rocksdb/pull/3195

Differential Revision: D6398143

Pulled By: maysamyabandeh

fbshipit-source-id: 7bc4218609355ec20fed25df426a8455ec2390d3
This commit is contained in:
Maysam Yabandeh 2017-11-22 13:52:56 -08:00 committed by Facebook Github Bot
parent 5fac4729cc
commit e59cb2a19b

View File

@ -126,6 +126,7 @@ TEST_F(WriteCallbackTest, WriteWithCallbackTest) {
{false, false, true, false, true},
};
for (auto& seq_per_batch : {true, false}) {
for (auto& two_queues : {true, false}) {
for (auto& allow_parallel : {true, false}) {
for (auto& allow_batching : {true, false}) {
@ -137,6 +138,10 @@ TEST_F(WriteCallbackTest, WriteWithCallbackTest) {
options.allow_concurrent_memtable_write = allow_parallel;
options.enable_pipelined_write = enable_pipelined_write;
options.two_write_queues = two_queues;
if (options.enable_pipelined_write && seq_per_batch) {
// This combination is not supported
continue;
}
if (options.enable_pipelined_write && options.two_write_queues) {
// This combination is not supported
continue;
@ -147,7 +152,18 @@ TEST_F(WriteCallbackTest, WriteWithCallbackTest) {
DBImpl* db_impl;
DestroyDB(dbname, options);
ASSERT_OK(DB::Open(options, dbname, &db));
DBOptions db_options(options);
ColumnFamilyOptions cf_options(options);
std::vector<ColumnFamilyDescriptor> column_families;
column_families.push_back(
ColumnFamilyDescriptor(kDefaultColumnFamilyName, cf_options));
std::vector<ColumnFamilyHandle*> handles;
auto open_s = DBImpl::Open(db_options, dbname, column_families,
&handles, &db, seq_per_batch);
ASSERT_OK(open_s);
assert(handles.size() == 1);
delete handles[0];
db_impl = dynamic_cast<DBImpl*>(db);
ASSERT_TRUE(db_impl);
@ -263,10 +279,13 @@ TEST_F(WriteCallbackTest, WriteWithCallbackTest) {
string sval(10, my_key);
write_op.Put(skey, sval);
if (!write_op.callback_.should_fail_) {
if (!write_op.callback_.should_fail_ && !seq_per_batch) {
seq.fetch_add(1);
}
}
if (!write_op.callback_.should_fail_ && seq_per_batch) {
seq.fetch_add(1);
}
WriteOptions woptions;
woptions.disableWAL = !enable_WAL;
@ -309,7 +328,7 @@ TEST_F(WriteCallbackTest, WriteWithCallbackTest) {
}
}
ASSERT_EQ(seq.load(), db_impl->GetLatestSequenceNumber());
ASSERT_EQ(seq.load(), db_impl->TEST_GetLastVisibleSequence());
delete db;
DestroyDB(dbname, options);
@ -320,6 +339,7 @@ TEST_F(WriteCallbackTest, WriteWithCallbackTest) {
}
}
}
}
TEST_F(WriteCallbackTest, WriteCallBackTest) {
Options options;