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:
parent
89b37081a1
commit
01e3c30def
@ -959,6 +959,7 @@ if(WITH_TESTS)
|
||||
utilities/transactions/optimistic_transaction_test.cc
|
||||
utilities/transactions/transaction_test.cc
|
||||
utilities/transactions/write_prepared_transaction_test.cc
|
||||
utilities/transactions/write_unprepared_transaction_test.cc
|
||||
utilities/ttl/ttl_test.cc
|
||||
utilities/write_batch_with_index/write_batch_with_index_test.cc
|
||||
)
|
||||
|
5
Makefile
5
Makefile
@ -518,6 +518,7 @@ TESTS = \
|
||||
repair_test \
|
||||
env_timed_test \
|
||||
write_prepared_transaction_test \
|
||||
write_unprepared_transaction_test \
|
||||
db_universal_compaction_test \
|
||||
|
||||
PARALLEL_TEST = \
|
||||
@ -537,6 +538,7 @@ PARALLEL_TEST = \
|
||||
table_test \
|
||||
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
|
||||
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)
|
||||
$(AM_LINK)
|
||||
|
||||
write_unprepared_transaction_test: utilities/transactions/write_unprepared_transaction_test.o $(LIBOBJECTS) $(TESTHARNESS)
|
||||
$(AM_LINK)
|
||||
|
||||
sst_dump: tools/sst_dump.o $(LIBOBJECTS)
|
||||
$(AM_LINK)
|
||||
|
||||
|
5
TARGETS
5
TARGETS
@ -1042,6 +1042,11 @@ ROCKS_TESTS = [
|
||||
"utilities/transactions/write_prepared_transaction_test.cc",
|
||||
"parallel",
|
||||
],
|
||||
[
|
||||
"write_unprepared_transaction_test",
|
||||
"utilities/transactions/write_unprepared_transaction_test.cc",
|
||||
"parallel",
|
||||
],
|
||||
]
|
||||
|
||||
# Generate a test rule for each entry in ROCKS_TESTS
|
||||
|
1
src.mk
1
src.mk
@ -397,6 +397,7 @@ MAIN_SOURCES = \
|
||||
utilities/transactions/optimistic_transaction_test.cc \
|
||||
utilities/transactions/transaction_test.cc \
|
||||
utilities/transactions/write_prepared_transaction_test.cc \
|
||||
utilities/transactions/write_unprepared_transaction_test.cc \
|
||||
utilities/ttl/ttl_test.cc \
|
||||
utilities/write_batch_with_index/write_batch_with_index_test.cc \
|
||||
|
||||
|
@ -217,7 +217,9 @@ 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 ||
|
||||
txn_db_options.write_policy == WRITE_UNPREPARED;
|
||||
s = DBImpl::Open(db_options_2pc, dbname, column_families_copy, handles, &db,
|
||||
use_seq_per_batch);
|
||||
if (s.ok()) {
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -144,7 +144,8 @@ class TransactionTestBase : public ::testing::Test {
|
||||
DB* root_db = nullptr;
|
||||
Options options_copy(options);
|
||||
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,
|
||||
use_seq_per_batch);
|
||||
StackableDB* stackable_db = new StackableDB(root_db);
|
||||
@ -173,7 +174,8 @@ class TransactionTestBase : public ::testing::Test {
|
||||
DB* root_db = nullptr;
|
||||
Options options_copy(options);
|
||||
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,
|
||||
&root_db, use_seq_per_batch);
|
||||
StackableDB* stackable_db = new StackableDB(root_db);
|
||||
|
30
utilities/transactions/write_unprepared_transaction_test.cc
Normal file
30
utilities/transactions/write_unprepared_transaction_test.cc
Normal 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
|
Loading…
Reference in New Issue
Block a user