Extend existing unit tests to run with WriteUnPrepared as well

This commit is contained in:
Manuel Ung 2018-06-01 10:48:18 -07:00
parent 82089d59c3
commit 020e575ed1
4 changed files with 80 additions and 10 deletions

View File

@ -39,6 +39,7 @@
#include <stdexcept>
#include <type_traits>
#include <vector>
#include <csignal>
#include "db/column_family.h"
#include "db/db_impl.h"
@ -513,6 +514,7 @@ Status WriteBatch::Iterate(Handler* handler) const {
handler->MarkBeginPrepare();
empty_batch = false;
if (handler->WriteAfterCommit()) {
std::raise(SIGINT);
s = Status::NotSupported(
"WritePrepared txn tag when write_after_commit_ is enabled (in "
"default WriteCommitted mode). If it is not due to corruption, "

View File

@ -217,7 +217,7 @@ Status TransactionDB::Open(
DBOptions db_options_2pc = db_options;
PrepareWrap(&db_options_2pc, &column_families_copy,
&compaction_enabled_cf_indices);
const bool use_seq_per_batch = txn_db_options.write_policy == WRITE_PREPARED;
const bool use_seq_per_batch = txn_db_options.write_policy >= WRITE_PREPARED;
s = DBImpl::Open(db_options_2pc, dbname, column_families_copy, handles, &db,
use_seq_per_batch);
if (s.ok()) {

View File

@ -45,11 +45,14 @@ INSTANTIATE_TEST_CASE_P(
::testing::Values(std::make_tuple(false, false, WRITE_COMMITTED),
std::make_tuple(false, true, WRITE_COMMITTED),
std::make_tuple(false, false, WRITE_PREPARED),
std::make_tuple(false, true, WRITE_PREPARED)));
std::make_tuple(false, true, WRITE_PREPARED),
std::make_tuple(false, false, WRITE_UNPREPARED),
std::make_tuple(false, true, WRITE_UNPREPARED)));
INSTANTIATE_TEST_CASE_P(
StackableDBAsBaseDB, TransactionTest,
::testing::Values(std::make_tuple(true, true, WRITE_COMMITTED),
std::make_tuple(true, true, WRITE_PREPARED)));
std::make_tuple(true, true, WRITE_PREPARED),
std::make_tuple(true, true, WRITE_UNPREPARED)));
// MySQLStyleTransactionTest takes far too long for valgrind to run.
#ifndef ROCKSDB_VALGRIND_RUN
@ -62,7 +65,11 @@ INSTANTIATE_TEST_CASE_P(
std::make_tuple(false, false, WRITE_PREPARED),
std::make_tuple(false, true, WRITE_PREPARED),
std::make_tuple(true, false, WRITE_PREPARED),
std::make_tuple(true, true, WRITE_PREPARED)));
std::make_tuple(true, true, WRITE_PREPARED),
std::make_tuple(false, false, WRITE_UNPREPARED),
std::make_tuple(false, true, WRITE_UNPREPARED),
std::make_tuple(true, false, WRITE_UNPREPARED),
std::make_tuple(true, true, WRITE_UNPREPARED)));
#endif // ROCKSDB_VALGRIND_RUN
TEST_P(TransactionTest, DoubleEmptyWrite) {
@ -1779,10 +1786,10 @@ TEST_P(TransactionTest, TwoPhaseLogRollingTest2) {
ASSERT_EQ(cfh_a->cfd()->GetLogNumber(), db_impl->TEST_LogfileNumber());
break;
case WRITE_PREPARED:
case WRITE_UNPREPARED:
// This cf is not flushed yet and should ref the log that has its data
ASSERT_EQ(cfh_a->cfd()->GetLogNumber(), prepare_log_no);
break;
case WRITE_UNPREPARED:
default:
assert(false);
}

View File

@ -564,7 +564,8 @@ class SeqAdvanceConcurrentTest
INSTANTIATE_TEST_CASE_P(
WritePreparedTransactionTest, WritePreparedTransactionTest,
::testing::Values(std::make_tuple(false, false, WRITE_PREPARED),
std::make_tuple(false, true, WRITE_PREPARED)));
std::make_tuple(false, true, WRITE_PREPARED),
std::make_tuple(false, true, WRITE_UNPREPARED)));
#ifndef ROCKSDB_VALGRIND_RUN
INSTANTIATE_TEST_CASE_P(
@ -588,7 +589,27 @@ INSTANTIATE_TEST_CASE_P(
std::make_tuple(false, true, WRITE_PREPARED, 16, 20),
std::make_tuple(false, true, WRITE_PREPARED, 17, 20),
std::make_tuple(false, true, WRITE_PREPARED, 18, 20),
std::make_tuple(false, true, WRITE_PREPARED, 19, 20)));
std::make_tuple(false, true, WRITE_PREPARED, 19, 20),
std::make_tuple(false, true, WRITE_UNPREPARED, 0, 20),
std::make_tuple(false, true, WRITE_UNPREPARED, 1, 20),
std::make_tuple(false, true, WRITE_UNPREPARED, 2, 20),
std::make_tuple(false, true, WRITE_UNPREPARED, 3, 20),
std::make_tuple(false, true, WRITE_UNPREPARED, 4, 20),
std::make_tuple(false, true, WRITE_UNPREPARED, 5, 20),
std::make_tuple(false, true, WRITE_UNPREPARED, 6, 20),
std::make_tuple(false, true, WRITE_UNPREPARED, 7, 20),
std::make_tuple(false, true, WRITE_UNPREPARED, 8, 20),
std::make_tuple(false, true, WRITE_UNPREPARED, 9, 20),
std::make_tuple(false, true, WRITE_UNPREPARED, 10, 20),
std::make_tuple(false, true, WRITE_UNPREPARED, 11, 20),
std::make_tuple(false, true, WRITE_UNPREPARED, 12, 20),
std::make_tuple(false, true, WRITE_UNPREPARED, 13, 20),
std::make_tuple(false, true, WRITE_UNPREPARED, 14, 20),
std::make_tuple(false, true, WRITE_UNPREPARED, 15, 20),
std::make_tuple(false, true, WRITE_UNPREPARED, 16, 20),
std::make_tuple(false, true, WRITE_UNPREPARED, 17, 20),
std::make_tuple(false, true, WRITE_UNPREPARED, 18, 20),
std::make_tuple(false, true, WRITE_UNPREPARED, 19, 20)));
INSTANTIATE_TEST_CASE_P(
OneWriteQueue, SnapshotConcurrentAccessTest,
@ -611,7 +632,27 @@ INSTANTIATE_TEST_CASE_P(
std::make_tuple(false, false, WRITE_PREPARED, 16, 20),
std::make_tuple(false, false, WRITE_PREPARED, 17, 20),
std::make_tuple(false, false, WRITE_PREPARED, 18, 20),
std::make_tuple(false, false, WRITE_PREPARED, 19, 20)));
std::make_tuple(false, false, WRITE_PREPARED, 19, 20),
std::make_tuple(false, false, WRITE_UNPREPARED, 0, 20),
std::make_tuple(false, false, WRITE_UNPREPARED, 1, 20),
std::make_tuple(false, false, WRITE_UNPREPARED, 2, 20),
std::make_tuple(false, false, WRITE_UNPREPARED, 3, 20),
std::make_tuple(false, false, WRITE_UNPREPARED, 4, 20),
std::make_tuple(false, false, WRITE_UNPREPARED, 5, 20),
std::make_tuple(false, false, WRITE_UNPREPARED, 6, 20),
std::make_tuple(false, false, WRITE_UNPREPARED, 7, 20),
std::make_tuple(false, false, WRITE_UNPREPARED, 8, 20),
std::make_tuple(false, false, WRITE_UNPREPARED, 9, 20),
std::make_tuple(false, false, WRITE_UNPREPARED, 10, 20),
std::make_tuple(false, false, WRITE_UNPREPARED, 11, 20),
std::make_tuple(false, false, WRITE_UNPREPARED, 12, 20),
std::make_tuple(false, false, WRITE_UNPREPARED, 13, 20),
std::make_tuple(false, false, WRITE_UNPREPARED, 14, 20),
std::make_tuple(false, false, WRITE_UNPREPARED, 15, 20),
std::make_tuple(false, false, WRITE_UNPREPARED, 16, 20),
std::make_tuple(false, false, WRITE_UNPREPARED, 17, 20),
std::make_tuple(false, false, WRITE_UNPREPARED, 18, 20),
std::make_tuple(false, false, WRITE_UNPREPARED, 19, 20)));
INSTANTIATE_TEST_CASE_P(
TwoWriteQueues, SeqAdvanceConcurrentTest,
@ -624,7 +665,17 @@ INSTANTIATE_TEST_CASE_P(
std::make_tuple(false, true, WRITE_PREPARED, 6, 10),
std::make_tuple(false, true, WRITE_PREPARED, 7, 10),
std::make_tuple(false, true, WRITE_PREPARED, 8, 10),
std::make_tuple(false, true, WRITE_PREPARED, 9, 10)));
std::make_tuple(false, true, WRITE_PREPARED, 9, 10),
std::make_tuple(false, true, WRITE_UNPREPARED, 0, 10),
std::make_tuple(false, true, WRITE_UNPREPARED, 1, 10),
std::make_tuple(false, true, WRITE_UNPREPARED, 2, 10),
std::make_tuple(false, true, WRITE_UNPREPARED, 3, 10),
std::make_tuple(false, true, WRITE_UNPREPARED, 4, 10),
std::make_tuple(false, true, WRITE_UNPREPARED, 5, 10),
std::make_tuple(false, true, WRITE_UNPREPARED, 6, 10),
std::make_tuple(false, true, WRITE_UNPREPARED, 7, 10),
std::make_tuple(false, true, WRITE_UNPREPARED, 8, 10),
std::make_tuple(false, true, WRITE_UNPREPARED, 9, 10)));
INSTANTIATE_TEST_CASE_P(
OneWriteQueue, SeqAdvanceConcurrentTest,
@ -637,7 +688,17 @@ INSTANTIATE_TEST_CASE_P(
std::make_tuple(false, false, WRITE_PREPARED, 6, 10),
std::make_tuple(false, false, WRITE_PREPARED, 7, 10),
std::make_tuple(false, false, WRITE_PREPARED, 8, 10),
std::make_tuple(false, false, WRITE_PREPARED, 9, 10)));
std::make_tuple(false, false, WRITE_PREPARED, 9, 10),
std::make_tuple(false, false, WRITE_UNPREPARED, 0, 10),
std::make_tuple(false, false, WRITE_UNPREPARED, 1, 10),
std::make_tuple(false, false, WRITE_UNPREPARED, 2, 10),
std::make_tuple(false, false, WRITE_UNPREPARED, 3, 10),
std::make_tuple(false, false, WRITE_UNPREPARED, 4, 10),
std::make_tuple(false, false, WRITE_UNPREPARED, 5, 10),
std::make_tuple(false, false, WRITE_UNPREPARED, 6, 10),
std::make_tuple(false, false, WRITE_UNPREPARED, 7, 10),
std::make_tuple(false, false, WRITE_UNPREPARED, 8, 10),
std::make_tuple(false, false, WRITE_UNPREPARED, 9, 10)));
#endif // ROCKSDB_VALGRIND_RUN
TEST_P(WritePreparedTransactionTest, CommitMapTest) {