mirror of
https://github.com/codership/wsrep-lib.git
synced 2025-07-27 09:01:50 +03:00
Fixed problems with server_context unit tests.
Added WITH_ASAN and WITH_TSAN options, enabled unit tests by default.
This commit is contained in:
@ -7,36 +7,46 @@
|
||||
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
// Test on_apply() method for 1pc
|
||||
BOOST_AUTO_TEST_CASE(server_context_applying_1pc)
|
||||
namespace
|
||||
{
|
||||
wsrep::mock_server_context sc("s1", "s1",
|
||||
wsrep::server_context::rm_sync);
|
||||
wsrep::mock_client_context cc(sc,
|
||||
wsrep::client_id(1),
|
||||
wsrep::client_context::m_applier,
|
||||
false);
|
||||
wsrep_mock::start_applying_transaction(
|
||||
cc, 1, 1,
|
||||
wsrep::provider::flag::start_transaction | wsrep::provider::flag::commit);
|
||||
struct applying_server_fixture
|
||||
{
|
||||
applying_server_fixture()
|
||||
: sc("s1", "s1",
|
||||
wsrep::server_context::rm_sync)
|
||||
, cc(sc,
|
||||
wsrep::client_id(1),
|
||||
wsrep::client_context::m_applier,
|
||||
false)
|
||||
{
|
||||
wsrep_mock::start_applying_transaction(
|
||||
cc, 1, 1,
|
||||
wsrep::provider::flag::start_transaction |
|
||||
wsrep::provider::flag::commit);
|
||||
}
|
||||
wsrep::mock_server_context sc;
|
||||
wsrep::mock_client_context cc;
|
||||
};
|
||||
}
|
||||
|
||||
// Test on_apply() method for 1pc
|
||||
BOOST_FIXTURE_TEST_CASE(server_context_applying_1pc,
|
||||
applying_server_fixture)
|
||||
{
|
||||
cc.debug_log_level(1);
|
||||
char buf[1] = { 1 };
|
||||
BOOST_REQUIRE(sc.on_apply(cc, wsrep::data(buf, 1)) == 0);
|
||||
const wsrep::transaction_context& txc(cc.transaction());
|
||||
BOOST_REQUIRE(txc.state() == wsrep::transaction_context::s_committed);
|
||||
// ::abort();
|
||||
BOOST_REQUIRE_MESSAGE(
|
||||
txc.state() == wsrep::transaction_context::s_committed,
|
||||
"Transaction state " << txc.state() << " not committed");
|
||||
}
|
||||
|
||||
// Test on_apply() method for 2pc
|
||||
BOOST_AUTO_TEST_CASE(server_context_applying_2pc)
|
||||
BOOST_FIXTURE_TEST_CASE(server_context_applying_2pc,
|
||||
applying_server_fixture)
|
||||
{
|
||||
wsrep::mock_server_context sc("s1", "s1",
|
||||
wsrep::server_context::rm_sync);
|
||||
wsrep::mock_client_context cc(sc,
|
||||
wsrep::client_id(1),
|
||||
wsrep::client_context::m_applier,
|
||||
true);
|
||||
wsrep_mock::start_applying_transaction(
|
||||
cc, 1, 1,
|
||||
wsrep::provider::flag::start_transaction | wsrep::provider::flag::commit);
|
||||
char buf[1] = { 1 };
|
||||
BOOST_REQUIRE(sc.on_apply(cc, wsrep::data(buf, 1)) == 0);
|
||||
const wsrep::transaction_context& txc(cc.transaction());
|
||||
@ -45,20 +55,11 @@ BOOST_AUTO_TEST_CASE(server_context_applying_2pc)
|
||||
|
||||
// Test on_apply() method for 1pc transaction which
|
||||
// fails applying and rolls back
|
||||
BOOST_AUTO_TEST_CASE(server_context_applying_1pc_rollback)
|
||||
BOOST_FIXTURE_TEST_CASE(server_context_applying_1pc_rollback,
|
||||
applying_server_fixture)
|
||||
{
|
||||
wsrep::mock_server_context sc("s1", "s1",
|
||||
wsrep::server_context::rm_sync);
|
||||
wsrep::mock_client_context cc(sc,
|
||||
wsrep::client_id(1),
|
||||
wsrep::client_context::m_applier,
|
||||
false);
|
||||
cc.fail_next_applying(true);
|
||||
wsrep_mock::start_applying_transaction(
|
||||
cc, 1, 1,
|
||||
wsrep::provider::flag::start_transaction | wsrep::provider::flag::commit);
|
||||
char buf[1] = { 1 };
|
||||
|
||||
BOOST_REQUIRE(sc.on_apply(cc, wsrep::data(buf, 1)) == 1);
|
||||
const wsrep::transaction_context& txc(cc.transaction());
|
||||
BOOST_REQUIRE(txc.state() == wsrep::transaction_context::s_aborted);
|
||||
@ -66,18 +67,10 @@ BOOST_AUTO_TEST_CASE(server_context_applying_1pc_rollback)
|
||||
|
||||
// Test on_apply() method for 2pc transaction which
|
||||
// fails applying and rolls back
|
||||
BOOST_AUTO_TEST_CASE(server_context_applying_2pc_rollback)
|
||||
BOOST_FIXTURE_TEST_CASE(server_context_applying_2pc_rollback,
|
||||
applying_server_fixture)
|
||||
{
|
||||
wsrep::mock_server_context sc("s1", "s1",
|
||||
wsrep::server_context::rm_sync);
|
||||
wsrep::mock_client_context cc(sc,
|
||||
wsrep::client_id(1),
|
||||
wsrep::client_context::m_applier,
|
||||
true);
|
||||
cc.fail_next_applying(true);
|
||||
wsrep_mock::start_applying_transaction(
|
||||
cc, 1, 1,
|
||||
wsrep::provider::flag::start_transaction | wsrep::provider::flag::commit);
|
||||
char buf[1] = { 1 };
|
||||
BOOST_REQUIRE(sc.on_apply(cc, wsrep::data(buf, 1)) == 1);
|
||||
const wsrep::transaction_context& txc(cc.transaction());
|
||||
|
Reference in New Issue
Block a user