mirror of
https://github.com/codership/wsrep-lib.git
synced 2025-07-28 20:02:00 +03:00
Call before_prepare()/after_prepare() for applier in before_commit()
if no 2PC is required.
This commit is contained in:
@ -51,6 +51,25 @@ namespace
|
||||
const wsrep::transaction_context& tc;
|
||||
};
|
||||
|
||||
struct replicating_client_fixture_2pc
|
||||
{
|
||||
replicating_client_fixture_2pc()
|
||||
: sc("s1", "s1", wsrep::server_context::rm_sync)
|
||||
, cc(sc, wsrep::client_id(1),
|
||||
wsrep::client_context::m_replicating, false, true)
|
||||
, tc(cc.transaction())
|
||||
{
|
||||
BOOST_REQUIRE(cc.before_command() == 0);
|
||||
BOOST_REQUIRE(cc.before_statement() == 0);
|
||||
// Verify initial state
|
||||
BOOST_REQUIRE(tc.active() == false);
|
||||
BOOST_REQUIRE(tc.state() == wsrep::transaction_context::s_executing);
|
||||
}
|
||||
wsrep::fake_server_context sc;
|
||||
wsrep::fake_client_context cc;
|
||||
const wsrep::transaction_context& tc;
|
||||
};
|
||||
|
||||
struct replicating_client_fixture_autocommit
|
||||
{
|
||||
replicating_client_fixture_autocommit()
|
||||
@ -100,6 +119,36 @@ namespace
|
||||
const wsrep::transaction_context& tc;
|
||||
};
|
||||
|
||||
struct applying_client_fixture_2pc
|
||||
{
|
||||
applying_client_fixture_2pc()
|
||||
: sc("s1", "s1",
|
||||
wsrep::server_context::rm_async)
|
||||
, cc(sc,
|
||||
wsrep::client_id(1),
|
||||
wsrep::client_context::m_applier, false, true)
|
||||
, tc(cc.transaction())
|
||||
{
|
||||
BOOST_REQUIRE(cc.before_command() == 0);
|
||||
BOOST_REQUIRE(cc.before_statement() == 0);
|
||||
wsrep::ws_handle ws_handle(1, (void*)1);
|
||||
wsrep::ws_meta ws_meta(wsrep::gtid(wsrep::id("1"), wsrep::seqno(1)),
|
||||
wsrep::stid(sc.id(), 1, cc.id()),
|
||||
wsrep::seqno(0),
|
||||
wsrep::provider::flag::start_transaction |
|
||||
wsrep::provider::flag::commit);
|
||||
BOOST_REQUIRE(cc.start_transaction(ws_handle, ws_meta) == 0);
|
||||
BOOST_REQUIRE(tc.active() == false);
|
||||
BOOST_REQUIRE(cc.start_transaction() == 0);
|
||||
BOOST_REQUIRE(tc.active() == true);
|
||||
BOOST_REQUIRE(tc.certified() == true);
|
||||
BOOST_REQUIRE(tc.ordered() == true);
|
||||
}
|
||||
wsrep::fake_server_context sc;
|
||||
wsrep::fake_client_context cc;
|
||||
const wsrep::transaction_context& tc;
|
||||
};
|
||||
|
||||
struct streaming_client_fixture_row
|
||||
{
|
||||
streaming_client_fixture_row()
|
||||
|
@ -8,7 +8,7 @@
|
||||
// Test a succesful 2PC transaction lifecycle
|
||||
//
|
||||
BOOST_FIXTURE_TEST_CASE(transaction_context_2pc,
|
||||
replicating_client_fixture_sync_rm)
|
||||
replicating_client_fixture_2pc)
|
||||
{
|
||||
cc.start_transaction(1);
|
||||
BOOST_REQUIRE(tc.active());
|
||||
@ -36,7 +36,7 @@ BOOST_FIXTURE_TEST_CASE(transaction_context_2pc,
|
||||
//
|
||||
BOOST_FIXTURE_TEST_CASE(
|
||||
transaction_context_2pc_bf_before_before_prepare,
|
||||
replicating_client_fixture_sync_rm)
|
||||
replicating_client_fixture_2pc)
|
||||
{
|
||||
cc.start_transaction(1);
|
||||
BOOST_REQUIRE(tc.active());
|
||||
@ -63,7 +63,7 @@ BOOST_FIXTURE_TEST_CASE(
|
||||
//
|
||||
BOOST_FIXTURE_TEST_CASE(
|
||||
transaction_context_2pc_bf_before_after_prepare,
|
||||
replicating_client_fixture_sync_rm)
|
||||
replicating_client_fixture_2pc)
|
||||
{
|
||||
cc.start_transaction(1);
|
||||
BOOST_REQUIRE(tc.active());
|
||||
@ -93,7 +93,7 @@ BOOST_FIXTURE_TEST_CASE(
|
||||
//
|
||||
BOOST_FIXTURE_TEST_CASE(
|
||||
transaction_context_2pc_bf_after_after_prepare,
|
||||
replicating_client_fixture_sync_rm)
|
||||
replicating_client_fixture_2pc)
|
||||
{
|
||||
cc.start_transaction(1);
|
||||
BOOST_REQUIRE(tc.active());
|
||||
@ -121,7 +121,7 @@ BOOST_FIXTURE_TEST_CASE(
|
||||
//
|
||||
BOOST_FIXTURE_TEST_CASE(
|
||||
transaction_context_2pc_bf_before_before_commit,
|
||||
replicating_client_fixture_sync_rm)
|
||||
replicating_client_fixture_2pc)
|
||||
{
|
||||
cc.start_transaction(1);
|
||||
BOOST_REQUIRE(tc.active());
|
||||
@ -154,7 +154,7 @@ BOOST_FIXTURE_TEST_CASE(
|
||||
//
|
||||
BOOST_FIXTURE_TEST_CASE(
|
||||
transaction_context_2pc_bf_during_commit_order_enter,
|
||||
replicating_client_fixture_sync_rm)
|
||||
replicating_client_fixture_2pc)
|
||||
{
|
||||
cc.start_transaction(1);
|
||||
BOOST_REQUIRE(tc.active());
|
||||
@ -227,7 +227,7 @@ BOOST_FIXTURE_TEST_CASE(transaction_context_streaming_2pc_commit_two_statements,
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
BOOST_FIXTURE_TEST_CASE(transaction_context_2pc_applying,
|
||||
applying_client_fixture)
|
||||
applying_client_fixture_2pc)
|
||||
{
|
||||
BOOST_REQUIRE(cc.before_prepare() == 0);
|
||||
BOOST_REQUIRE(tc.state() == wsrep::transaction_context::s_preparing);
|
||||
|
Reference in New Issue
Block a user