From e59cb2a19b2971707d75552ae517586ca0785a6a Mon Sep 17 00:00:00 2001 From: Maysam Yabandeh Date: Wed, 22 Nov 2017 13:52:56 -0800 Subject: [PATCH] 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 --- db/write_callback_test.cc | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/db/write_callback_test.cc b/db/write_callback_test.cc index fbe8fcc99..3d40150f9 100644 --- a/db/write_callback_test.cc +++ b/db/write_callback_test.cc @@ -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 column_families; + column_families.push_back( + ColumnFamilyDescriptor(kDefaultColumnFamilyName, cf_options)); + std::vector 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(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;