1
0
mirror of https://github.com/codership/wsrep-lib.git synced 2025-07-27 09:01:50 +03:00

Allow read-only access to transaction context through

client context to enforce use of client context interface
for manipulating transaction context state.
This commit is contained in:
Teemu Ollakka
2018-05-31 16:55:57 +03:00
parent 2f46758064
commit ae93785a57
14 changed files with 267 additions and 300 deletions

View File

@ -16,13 +16,13 @@ BOOST_AUTO_TEST_CASE(server_context_applying_1pc)
trrep::client_id(1),
trrep::client_context::m_applier,
false);
trrep::transaction_context& tc(
trrep_mock::start_applying_transaction(
cc, 1, 1,
WSREP_FLAG_TRX_START | WSREP_FLAG_TRX_END));
trrep_mock::start_applying_transaction(
cc, 1, 1,
WSREP_FLAG_TRX_START | WSREP_FLAG_TRX_END);
char buf[1] = { 1 };
BOOST_REQUIRE(sc.on_apply(cc, tc, trrep::data(buf, 1)) == 0);
BOOST_REQUIRE(tc.state() == trrep::transaction_context::s_committed);
BOOST_REQUIRE(sc.on_apply(cc, trrep::data(buf, 1)) == 0);
const trrep::transaction_context& txc(cc.transaction());
BOOST_REQUIRE(txc.state() == trrep::transaction_context::s_committed);
}
// Test on_apply() method for 2pc
@ -34,13 +34,13 @@ BOOST_AUTO_TEST_CASE(server_context_applying_2pc)
trrep::client_id(1),
trrep::client_context::m_applier,
true);
trrep::transaction_context& tc(
trrep_mock::start_applying_transaction(
cc, 1, 1,
WSREP_FLAG_TRX_START | WSREP_FLAG_TRX_END));
trrep_mock::start_applying_transaction(
cc, 1, 1,
WSREP_FLAG_TRX_START | WSREP_FLAG_TRX_END);
char buf[1] = { 1 };
BOOST_REQUIRE(sc.on_apply(cc, tc, trrep::data(buf, 1)) == 0);
BOOST_REQUIRE(tc.state() == trrep::transaction_context::s_committed);
BOOST_REQUIRE(sc.on_apply(cc, trrep::data(buf, 1)) == 0);
const trrep::transaction_context& txc(cc.transaction());
BOOST_REQUIRE(txc.state() == trrep::transaction_context::s_committed);
}
// Test on_apply() method for 1pc transaction which
@ -54,14 +54,14 @@ BOOST_AUTO_TEST_CASE(server_context_applying_1pc_rollback)
trrep::client_context::m_applier,
false);
cc.fail_next_applying(true);
trrep::transaction_context& tc(
trrep_mock::start_applying_transaction(
cc, 1, 1,
WSREP_FLAG_TRX_START | WSREP_FLAG_TRX_END));
trrep_mock::start_applying_transaction(
cc, 1, 1,
WSREP_FLAG_TRX_START | WSREP_FLAG_TRX_END);
char buf[1] = { 1 };
BOOST_REQUIRE(sc.on_apply(cc, tc, trrep::data(buf, 1)) == 1);
BOOST_REQUIRE(tc.state() == trrep::transaction_context::s_aborted);
BOOST_REQUIRE(sc.on_apply(cc, trrep::data(buf, 1)) == 1);
const trrep::transaction_context& txc(cc.transaction());
BOOST_REQUIRE(txc.state() == trrep::transaction_context::s_aborted);
}
// Test on_apply() method for 2pc transaction which
@ -75,11 +75,11 @@ BOOST_AUTO_TEST_CASE(server_context_applying_2pc_rollback)
trrep::client_context::m_applier,
true);
cc.fail_next_applying(true);
trrep::transaction_context& tc(
trrep_mock::start_applying_transaction(
cc, 1, 1,
WSREP_FLAG_TRX_START | WSREP_FLAG_TRX_END));
trrep_mock::start_applying_transaction(
cc, 1, 1,
WSREP_FLAG_TRX_START | WSREP_FLAG_TRX_END);
char buf[1] = { 1 };
BOOST_REQUIRE(sc.on_apply(cc, tc, trrep::data(buf, 1)) == 1);
BOOST_REQUIRE(tc.state() == trrep::transaction_context::s_aborted);
BOOST_REQUIRE(sc.on_apply(cc, trrep::data(buf, 1)) == 1);
const trrep::transaction_context& txc(cc.transaction());
BOOST_REQUIRE(txc.state() == trrep::transaction_context::s_aborted);
}