Extend existing unit tests to run with WriteUnprepared as well

Summary:
As titled.

I have not extended the Compatibility tests because the new WAL markers are still unimplemented.
Closes https://github.com/facebook/rocksdb/pull/3941

Differential Revision: D8238394

Pulled By: lth

fbshipit-source-id: 980e3d44837bbf2cfa64047f9738f559dfac4b1d
This commit is contained in:
Manuel Ung 2018-06-01 14:57:55 -07:00 committed by Facebook Github Bot
parent 89b37081a1
commit 01e3c30def
8 changed files with 60 additions and 7 deletions

View File

@ -959,6 +959,7 @@ if(WITH_TESTS)
utilities/transactions/optimistic_transaction_test.cc utilities/transactions/optimistic_transaction_test.cc
utilities/transactions/transaction_test.cc utilities/transactions/transaction_test.cc
utilities/transactions/write_prepared_transaction_test.cc utilities/transactions/write_prepared_transaction_test.cc
utilities/transactions/write_unprepared_transaction_test.cc
utilities/ttl/ttl_test.cc utilities/ttl/ttl_test.cc
utilities/write_batch_with_index/write_batch_with_index_test.cc utilities/write_batch_with_index/write_batch_with_index_test.cc
) )

View File

@ -518,6 +518,7 @@ TESTS = \
repair_test \ repair_test \
env_timed_test \ env_timed_test \
write_prepared_transaction_test \ write_prepared_transaction_test \
write_unprepared_transaction_test \
db_universal_compaction_test \ db_universal_compaction_test \
PARALLEL_TEST = \ PARALLEL_TEST = \
@ -537,6 +538,7 @@ PARALLEL_TEST = \
table_test \ table_test \
transaction_test \ transaction_test \
write_prepared_transaction_test \ write_prepared_transaction_test \
write_unprepared_transaction_test \
# options_settable_test doesn't pass with UBSAN as we use hack in the test # options_settable_test doesn't pass with UBSAN as we use hack in the test
ifdef COMPILE_WITH_UBSAN ifdef COMPILE_WITH_UBSAN
@ -1474,6 +1476,9 @@ transaction_test: utilities/transactions/transaction_test.o $(LIBOBJECTS) $(TEST
write_prepared_transaction_test: utilities/transactions/write_prepared_transaction_test.o $(LIBOBJECTS) $(TESTHARNESS) write_prepared_transaction_test: utilities/transactions/write_prepared_transaction_test.o $(LIBOBJECTS) $(TESTHARNESS)
$(AM_LINK) $(AM_LINK)
write_unprepared_transaction_test: utilities/transactions/write_unprepared_transaction_test.o $(LIBOBJECTS) $(TESTHARNESS)
$(AM_LINK)
sst_dump: tools/sst_dump.o $(LIBOBJECTS) sst_dump: tools/sst_dump.o $(LIBOBJECTS)
$(AM_LINK) $(AM_LINK)

View File

@ -1042,6 +1042,11 @@ ROCKS_TESTS = [
"utilities/transactions/write_prepared_transaction_test.cc", "utilities/transactions/write_prepared_transaction_test.cc",
"parallel", "parallel",
], ],
[
"write_unprepared_transaction_test",
"utilities/transactions/write_unprepared_transaction_test.cc",
"parallel",
],
] ]
# Generate a test rule for each entry in ROCKS_TESTS # Generate a test rule for each entry in ROCKS_TESTS

1
src.mk
View File

@ -397,6 +397,7 @@ MAIN_SOURCES = \
utilities/transactions/optimistic_transaction_test.cc \ utilities/transactions/optimistic_transaction_test.cc \
utilities/transactions/transaction_test.cc \ utilities/transactions/transaction_test.cc \
utilities/transactions/write_prepared_transaction_test.cc \ utilities/transactions/write_prepared_transaction_test.cc \
utilities/transactions/write_unprepared_transaction_test.cc \
utilities/ttl/ttl_test.cc \ utilities/ttl/ttl_test.cc \
utilities/write_batch_with_index/write_batch_with_index_test.cc \ utilities/write_batch_with_index/write_batch_with_index_test.cc \

View File

@ -217,7 +217,9 @@ Status TransactionDB::Open(
DBOptions db_options_2pc = db_options; DBOptions db_options_2pc = db_options;
PrepareWrap(&db_options_2pc, &column_families_copy, PrepareWrap(&db_options_2pc, &column_families_copy,
&compaction_enabled_cf_indices); &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 ||
txn_db_options.write_policy == WRITE_UNPREPARED;
s = DBImpl::Open(db_options_2pc, dbname, column_families_copy, handles, &db, s = DBImpl::Open(db_options_2pc, dbname, column_families_copy, handles, &db,
use_seq_per_batch); use_seq_per_batch);
if (s.ok()) { if (s.ok()) {

View File

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

View File

@ -144,7 +144,8 @@ class TransactionTestBase : public ::testing::Test {
DB* root_db = nullptr; DB* root_db = nullptr;
Options options_copy(options); Options options_copy(options);
const bool use_seq_per_batch = const bool use_seq_per_batch =
txn_db_options.write_policy == WRITE_PREPARED; txn_db_options.write_policy == WRITE_PREPARED ||
txn_db_options.write_policy == WRITE_UNPREPARED;
Status s = DBImpl::Open(options_copy, dbname, cfs, handles, &root_db, Status s = DBImpl::Open(options_copy, dbname, cfs, handles, &root_db,
use_seq_per_batch); use_seq_per_batch);
StackableDB* stackable_db = new StackableDB(root_db); StackableDB* stackable_db = new StackableDB(root_db);
@ -173,7 +174,8 @@ class TransactionTestBase : public ::testing::Test {
DB* root_db = nullptr; DB* root_db = nullptr;
Options options_copy(options); Options options_copy(options);
const bool use_seq_per_batch = const bool use_seq_per_batch =
txn_db_options.write_policy == WRITE_PREPARED; txn_db_options.write_policy == WRITE_PREPARED ||
txn_db_options.write_policy == WRITE_UNPREPARED;
Status s = DBImpl::Open(options_copy, dbname, column_families, &handles, Status s = DBImpl::Open(options_copy, dbname, column_families, &handles,
&root_db, use_seq_per_batch); &root_db, use_seq_per_batch);
StackableDB* stackable_db = new StackableDB(root_db); StackableDB* stackable_db = new StackableDB(root_db);

View File

@ -0,0 +1,30 @@
// Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
// This source code is licensed under both the GPLv2 (found in the
// COPYING file in the root directory) and Apache 2.0 License
// (found in the LICENSE.Apache file in the root directory).
#ifndef ROCKSDB_LITE
#ifndef __STDC_FORMAT_MACROS
#define __STDC_FORMAT_MACROS
#endif
#include "utilities/transactions/transaction_test.h"
namespace rocksdb {} // namespace rocksdb
int main(int argc, char** argv) {
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
#else
#include <stdio.h>
int main(int /*argc*/, char** /*argv*/) {
fprintf(stderr,
"SKIPPED as Transactions are not supported in ROCKSDB_LITE\n");
return 0;
}
#endif // ROCKSDB_LITE