mirror of
https://github.com/codership/wsrep-lib.git
synced 2025-07-30 07:23:07 +03:00
Renamed unit test doubles
This commit is contained in:
@ -51,7 +51,7 @@ if (WITH_TSAN)
|
||||
endif()
|
||||
|
||||
add_custom_target(coverage_report
|
||||
lcov --capture --directory src --directory test --directory include --output lcov.info --no-external
|
||||
lcov --capture --directory src --directory test --directory dbsim --directory include --output lcov.info --no-external
|
||||
COMMAND genhtml --output-directory coverage_report lcov.info)
|
||||
|
||||
|
||||
|
@ -43,10 +43,7 @@ namespace wsrep
|
||||
}
|
||||
~default_mutex()
|
||||
{
|
||||
if (pthread_mutex_destroy(&mutex_))
|
||||
{
|
||||
throw wsrep::runtime_error("mutex destroy failed");
|
||||
}
|
||||
if (pthread_mutex_destroy(&mutex_)) ::abort();
|
||||
}
|
||||
|
||||
void lock()
|
||||
|
@ -124,7 +124,7 @@ namespace wsrep
|
||||
return flags_;
|
||||
}
|
||||
|
||||
wsrep::mutex& mutex();
|
||||
// wsrep::mutex& mutex();
|
||||
wsrep::ws_handle& ws_handle() { return ws_handle_; }
|
||||
const wsrep::ws_handle& ws_handle() const { return ws_handle_; }
|
||||
const wsrep::ws_meta& ws_meta() const { return ws_meta_; }
|
||||
|
@ -305,13 +305,11 @@ int wsrep::transaction_context::before_commit()
|
||||
|
||||
int wsrep::transaction_context::ordered_commit()
|
||||
{
|
||||
int ret(1);
|
||||
|
||||
wsrep::unique_lock<wsrep::mutex> lock(client_context_.mutex());
|
||||
debug_log_state("ordered_commit_enter");
|
||||
assert(state() == s_committing);
|
||||
assert(ordered());
|
||||
ret = provider_.commit_order_leave(ws_handle_, ws_meta_);
|
||||
int ret(provider_.commit_order_leave(ws_handle_, ws_meta_));
|
||||
// Should always succeed
|
||||
assert(ret == 0);
|
||||
state(lock, s_ordered_commit);
|
||||
@ -450,10 +448,7 @@ int wsrep::transaction_context::after_statement()
|
||||
// ?
|
||||
break;
|
||||
case s_committed:
|
||||
if (is_streaming())
|
||||
{
|
||||
state(lock, s_executing);
|
||||
}
|
||||
assert(is_streaming() == false);
|
||||
break;
|
||||
case s_must_abort:
|
||||
case s_cert_failed:
|
||||
@ -512,7 +507,6 @@ bool wsrep::transaction_context::bf_abort(
|
||||
{
|
||||
bool ret(false);
|
||||
assert(lock.owns_lock());
|
||||
assert(&lock.mutex() == &mutex());
|
||||
|
||||
if (active() == false)
|
||||
{
|
||||
@ -584,11 +578,9 @@ bool wsrep::transaction_context::bf_abort(
|
||||
return ret;
|
||||
}
|
||||
|
||||
wsrep::mutex& wsrep::transaction_context::mutex()
|
||||
{
|
||||
return client_context_.mutex();
|
||||
}
|
||||
// Private
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Private //
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void wsrep::transaction_context::state(
|
||||
wsrep::unique_lock<wsrep::mutex>& lock __attribute__((unused)),
|
||||
|
@ -3,7 +3,7 @@
|
||||
#
|
||||
|
||||
add_executable(wsrep-lib_test
|
||||
mock_client_context.cpp
|
||||
fake_client_context.cpp
|
||||
test_utils.cpp
|
||||
id_test.cpp
|
||||
server_context_test.cpp
|
||||
|
@ -3,10 +3,10 @@
|
||||
//
|
||||
|
||||
#include "wsrep/transaction_context.hpp"
|
||||
#include "mock_client_context.hpp"
|
||||
#include "fake_client_context.hpp"
|
||||
|
||||
|
||||
int wsrep::mock_client_context::apply(
|
||||
int wsrep::fake_client_context::apply(
|
||||
const wsrep::const_buffer& data __attribute__((unused)))
|
||||
|
||||
{
|
||||
@ -14,7 +14,7 @@ int wsrep::mock_client_context::apply(
|
||||
return (fail_next_applying_ ? 1 : 0);
|
||||
}
|
||||
|
||||
int wsrep::mock_client_context::commit()
|
||||
int wsrep::fake_client_context::commit()
|
||||
{
|
||||
int ret(0);
|
||||
if (do_2pc())
|
||||
@ -38,7 +38,7 @@ int wsrep::mock_client_context::commit()
|
||||
return ret;
|
||||
}
|
||||
|
||||
int wsrep::mock_client_context::rollback()
|
||||
int wsrep::fake_client_context::rollback()
|
||||
{
|
||||
int ret(0);
|
||||
if (transaction_.before_rollback())
|
@ -2,8 +2,8 @@
|
||||
// Copyright (C) 2018 Codership Oy <info@codership.com>
|
||||
//
|
||||
|
||||
#ifndef WSREP_MOCK_CLIENT_CONTEXT_HPP
|
||||
#define WSREP_MOCK_CLIENT_CONTEXT_HPP
|
||||
#ifndef WSREP_FAKE_CLIENT_CONTEXT_HPP
|
||||
#define WSREP_FAKE_CLIENT_CONTEXT_HPP
|
||||
|
||||
#include "wsrep/client_context.hpp"
|
||||
#include "wsrep/mutex.hpp"
|
||||
@ -13,10 +13,10 @@
|
||||
|
||||
namespace wsrep
|
||||
{
|
||||
class mock_client_context : public wsrep::client_context
|
||||
class fake_client_context : public wsrep::client_context
|
||||
{
|
||||
public:
|
||||
mock_client_context(wsrep::server_context& server_context,
|
||||
fake_client_context(wsrep::server_context& server_context,
|
||||
const wsrep::client_id& id,
|
||||
enum wsrep::client_context::mode mode,
|
||||
bool is_autocommit = false,
|
||||
@ -35,7 +35,7 @@ namespace wsrep
|
||||
, replays_()
|
||||
, aborts_()
|
||||
{ }
|
||||
~mock_client_context()
|
||||
~fake_client_context()
|
||||
{
|
||||
if (transaction().active())
|
||||
{
|
||||
@ -136,4 +136,4 @@ namespace wsrep
|
||||
};
|
||||
}
|
||||
|
||||
#endif // WSREP_MOCK_CLIENT_CONTEXT_HPP
|
||||
#endif // WSREP_FAKE_CLIENT_CONTEXT_HPP
|
@ -2,8 +2,8 @@
|
||||
// Copyright (C) 2018 Codership Oy <info@codership.com>
|
||||
//
|
||||
|
||||
#ifndef WSREP_MOCK_PROVIDER_HPP
|
||||
#define WSREP_MOCK_PROVIDER_HPP
|
||||
#ifndef WSREP_FAKE_PROVIDER_HPP
|
||||
#define WSREP_FAKE_PROVIDER_HPP
|
||||
|
||||
#include "wsrep/provider.hpp"
|
||||
#include "wsrep/logger.hpp"
|
||||
@ -15,18 +15,21 @@
|
||||
|
||||
namespace wsrep
|
||||
{
|
||||
class mock_provider : public wsrep::provider
|
||||
class fake_provider : public wsrep::provider
|
||||
{
|
||||
public:
|
||||
typedef std::map<wsrep::transaction_id, wsrep::seqno> bf_abort_map;
|
||||
|
||||
mock_provider(wsrep::server_context& server_context)
|
||||
fake_provider(wsrep::server_context& server_context)
|
||||
: provider(server_context)
|
||||
, certify_status_()
|
||||
, commit_order_enter_status_()
|
||||
, commit_order_leave_status_()
|
||||
, release_status_()
|
||||
, group_id_("1")
|
||||
, server_id_("1")
|
||||
, group_seqno_(0)
|
||||
, bf_abort_map_()
|
||||
, next_error_(wsrep::provider::success)
|
||||
, start_fragments_()
|
||||
, fragments_()
|
||||
, commit_fragments_()
|
||||
@ -53,11 +56,11 @@ namespace wsrep
|
||||
<< "client: " << client_id.get()
|
||||
<< " flags: " << std::hex << flags
|
||||
<< std::dec
|
||||
<< " next_error: " << next_error_;
|
||||
<< " certify_status: " << certify_status_;
|
||||
|
||||
if (next_error_)
|
||||
if (certify_status_)
|
||||
{
|
||||
return next_error_;
|
||||
return certify_status_;
|
||||
}
|
||||
|
||||
++fragments_;
|
||||
@ -125,12 +128,14 @@ namespace wsrep
|
||||
enum wsrep::provider::status
|
||||
commit_order_enter(const wsrep::ws_handle&,
|
||||
const wsrep::ws_meta&)
|
||||
{ return next_error_; }
|
||||
{ return commit_order_enter_status_; }
|
||||
|
||||
int commit_order_leave(const wsrep::ws_handle&,
|
||||
const wsrep::ws_meta&)
|
||||
{ return next_error_;}
|
||||
{ return commit_order_leave_status_;}
|
||||
|
||||
int release(wsrep::ws_handle&)
|
||||
{ return next_error_; }
|
||||
{ return release_status_; }
|
||||
|
||||
int replay(wsrep::ws_handle&, void*) { ::abort(); /* not impl */}
|
||||
|
||||
@ -142,7 +147,7 @@ namespace wsrep
|
||||
return std::vector<status_variable>();
|
||||
}
|
||||
|
||||
// Methods to modify mock state
|
||||
// Methods to modify fake state
|
||||
/*! Inject BF abort event into the provider.
|
||||
*
|
||||
* \param bf_seqno Aborter sequence number
|
||||
@ -164,14 +169,12 @@ namespace wsrep
|
||||
return wsrep::provider::success;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \todo Inject an error so that the next call to any
|
||||
* provider call will return the given error.
|
||||
*/
|
||||
void inject_error(enum wsrep::provider::status error)
|
||||
{
|
||||
next_error_ = error;
|
||||
}
|
||||
// Parameters to control return value from the call
|
||||
enum wsrep::provider::status certify_status_;
|
||||
enum wsrep::provider::status commit_order_enter_status_;
|
||||
enum wsrep::provider::status commit_order_leave_status_;
|
||||
enum wsrep::provider::status release_status_;
|
||||
|
||||
size_t start_fragments() const { return start_fragments_; }
|
||||
size_t fragments() const { return fragments_; }
|
||||
size_t commit_fragments() const { return commit_fragments_; }
|
||||
@ -182,7 +185,6 @@ namespace wsrep
|
||||
wsrep::id server_id_;
|
||||
long long group_seqno_;
|
||||
bf_abort_map bf_abort_map_;
|
||||
enum wsrep::provider::status next_error_;
|
||||
size_t start_fragments_;
|
||||
size_t fragments_;
|
||||
size_t commit_fragments_;
|
||||
@ -191,4 +193,4 @@ namespace wsrep
|
||||
}
|
||||
|
||||
|
||||
#endif // WSREP_MOCK_PROVIDER_HPP
|
||||
#endif // WSREP_FAKE_PROVIDER_HPP
|
@ -2,21 +2,21 @@
|
||||
// Copyright (C) 2018 Codership Oy <info@codership.com>
|
||||
//
|
||||
|
||||
#ifndef WSREP_MOCK_SERVER_CONTEXT_HPP
|
||||
#define WSREP_MOCK_SERVER_CONTEXT_HPP
|
||||
#ifndef WSREP_FAKE_SERVER_CONTEXT_HPP
|
||||
#define WSREP_FAKE_SERVER_CONTEXT_HPP
|
||||
|
||||
#include "wsrep/server_context.hpp"
|
||||
#include "mock_client_context.hpp"
|
||||
#include "mock_provider.hpp"
|
||||
#include "fake_client_context.hpp"
|
||||
#include "fake_provider.hpp"
|
||||
|
||||
#include "wsrep/compiler.hpp"
|
||||
|
||||
namespace wsrep
|
||||
{
|
||||
class mock_server_context : public wsrep::server_context
|
||||
class fake_server_context : public wsrep::server_context
|
||||
{
|
||||
public:
|
||||
mock_server_context(const std::string& name,
|
||||
fake_server_context(const std::string& name,
|
||||
const std::string& id,
|
||||
enum wsrep::server_context::rollback_mode rollback_mode)
|
||||
: wsrep::server_context(mutex_, cond_,
|
||||
@ -26,18 +26,18 @@ namespace wsrep
|
||||
, provider_(*this)
|
||||
, last_client_id_(0)
|
||||
{ }
|
||||
wsrep::mock_provider& provider() const
|
||||
wsrep::fake_provider& provider() const
|
||||
{ return provider_; }
|
||||
wsrep::client_context* local_client_context()
|
||||
{
|
||||
return new wsrep::mock_client_context(*this, ++last_client_id_,
|
||||
return new wsrep::fake_client_context(*this, ++last_client_id_,
|
||||
wsrep::client_context::m_local);
|
||||
}
|
||||
wsrep::client_context& streaming_applier_client_context(
|
||||
const wsrep::id& server_id,
|
||||
const wsrep::transaction_id& transaction_id)
|
||||
{
|
||||
wsrep::client_context* sac(new wsrep::mock_client_context(*this, ++last_client_id_, wsrep::client_context::m_applier));
|
||||
wsrep::client_context* sac(new wsrep::fake_client_context(*this, ++last_client_id_, wsrep::client_context::m_applier));
|
||||
insert_streaming_applier(server_id, transaction_id, sac);
|
||||
return *sac;
|
||||
}
|
||||
@ -63,9 +63,9 @@ namespace wsrep
|
||||
private:
|
||||
wsrep::default_mutex mutex_;
|
||||
wsrep::default_condition_variable cond_;
|
||||
mutable wsrep::mock_provider provider_;
|
||||
mutable wsrep::fake_provider provider_;
|
||||
unsigned long long last_client_id_;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // WSREP_MOCK_SERVER_CONTEXT_HPP
|
||||
#endif // WSREP_FAKE_SERVER_CONTEXT_HPP
|
@ -2,7 +2,7 @@
|
||||
// Copyright (C) 2018 Codership Oy <info@codership.com>
|
||||
//
|
||||
|
||||
#include "mock_server_context.hpp"
|
||||
#include "fake_server_context.hpp"
|
||||
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
@ -26,8 +26,8 @@ namespace
|
||||
{
|
||||
cc.start_transaction(ws_handle, ws_meta);
|
||||
}
|
||||
wsrep::mock_server_context sc;
|
||||
wsrep::mock_client_context cc;
|
||||
wsrep::fake_server_context sc;
|
||||
wsrep::fake_client_context cc;
|
||||
wsrep::ws_handle ws_handle;
|
||||
wsrep::ws_meta ws_meta;
|
||||
};
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
#include "test_utils.hpp"
|
||||
#include "wsrep/client_context.hpp"
|
||||
#include "mock_server_context.hpp"
|
||||
#include "fake_server_context.hpp"
|
||||
|
||||
|
||||
// Simple BF abort method to BF abort unordered transasctions
|
||||
@ -22,7 +22,7 @@ void wsrep_test::bf_abort_ordered(wsrep::client_context& cc)
|
||||
cc.bf_abort(lock, wsrep::seqno(0));
|
||||
}
|
||||
// BF abort method to abort transactions via provider
|
||||
void wsrep_test::bf_abort_provider(wsrep::mock_server_context& sc,
|
||||
void wsrep_test::bf_abort_provider(wsrep::fake_server_context& sc,
|
||||
const wsrep::transaction_context& tc,
|
||||
wsrep::seqno bf_seqno)
|
||||
{
|
||||
|
@ -6,7 +6,7 @@
|
||||
namespace wsrep
|
||||
{
|
||||
class client_context;
|
||||
class mock_server_context;
|
||||
class fake_server_context;
|
||||
}
|
||||
|
||||
#include "wsrep/transaction_context.hpp"
|
||||
@ -25,7 +25,7 @@ namespace wsrep_test
|
||||
void bf_abort_ordered(wsrep::client_context& cc);
|
||||
|
||||
// BF abort method to abort transactions via provider
|
||||
void bf_abort_provider(wsrep::mock_server_context& sc,
|
||||
void bf_abort_provider(wsrep::fake_server_context& sc,
|
||||
const wsrep::transaction_context& tc,
|
||||
wsrep::seqno bf_seqno);
|
||||
|
||||
|
@ -5,8 +5,8 @@
|
||||
#include "wsrep/transaction_context.hpp"
|
||||
#include "wsrep/provider.hpp"
|
||||
|
||||
#include "mock_client_context.hpp"
|
||||
#include "mock_server_context.hpp"
|
||||
#include "fake_client_context.hpp"
|
||||
#include "fake_server_context.hpp"
|
||||
|
||||
#include "test_utils.hpp"
|
||||
|
||||
@ -29,8 +29,8 @@ namespace
|
||||
BOOST_REQUIRE(tc.active() == false);
|
||||
BOOST_REQUIRE(tc.state() == wsrep::transaction_context::s_executing);
|
||||
}
|
||||
wsrep::mock_server_context sc;
|
||||
wsrep::mock_client_context cc;
|
||||
wsrep::fake_server_context sc;
|
||||
wsrep::fake_client_context cc;
|
||||
const wsrep::transaction_context& tc;
|
||||
};
|
||||
|
||||
@ -48,8 +48,8 @@ namespace
|
||||
BOOST_REQUIRE(tc.active() == false);
|
||||
BOOST_REQUIRE(tc.state() == wsrep::transaction_context::s_executing);
|
||||
}
|
||||
wsrep::mock_server_context sc;
|
||||
wsrep::mock_client_context cc;
|
||||
wsrep::fake_server_context sc;
|
||||
wsrep::fake_client_context cc;
|
||||
const wsrep::transaction_context& tc;
|
||||
};
|
||||
|
||||
@ -67,8 +67,8 @@ namespace
|
||||
BOOST_REQUIRE(tc.active() == false);
|
||||
BOOST_REQUIRE(tc.state() == wsrep::transaction_context::s_executing);
|
||||
}
|
||||
wsrep::mock_server_context sc;
|
||||
wsrep::mock_client_context cc;
|
||||
wsrep::fake_server_context sc;
|
||||
wsrep::fake_client_context cc;
|
||||
const wsrep::transaction_context& tc;
|
||||
};
|
||||
|
||||
@ -97,8 +97,8 @@ namespace
|
||||
BOOST_REQUIRE(tc.certified() == true);
|
||||
BOOST_REQUIRE(tc.ordered() == true);
|
||||
}
|
||||
wsrep::mock_server_context sc;
|
||||
wsrep::mock_client_context cc;
|
||||
wsrep::fake_server_context sc;
|
||||
wsrep::fake_client_context cc;
|
||||
const wsrep::transaction_context& tc;
|
||||
};
|
||||
|
||||
@ -117,8 +117,8 @@ namespace
|
||||
BOOST_REQUIRE(tc.state() == wsrep::transaction_context::s_executing);
|
||||
cc.enable_streaming(wsrep::transaction_context::streaming_context::row, 1);
|
||||
}
|
||||
wsrep::mock_server_context sc;
|
||||
wsrep::mock_client_context cc;
|
||||
wsrep::fake_server_context sc;
|
||||
wsrep::fake_client_context cc;
|
||||
const wsrep::transaction_context& tc;
|
||||
};
|
||||
|
||||
@ -387,7 +387,7 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(
|
||||
transaction_context_1pc_bf_during_before_commit_uncertified, T,
|
||||
replicating_fixtures, T)
|
||||
{
|
||||
wsrep::mock_server_context& sc(T::sc);
|
||||
wsrep::fake_server_context& sc(T::sc);
|
||||
wsrep::client_context& cc(T::cc);
|
||||
const wsrep::transaction_context& tc(T::tc);
|
||||
|
||||
@ -427,7 +427,7 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(
|
||||
transaction_context_1pc_bf_during_commit_wait_for_replayers, T,
|
||||
replicating_fixtures, T)
|
||||
{
|
||||
wsrep::mock_client_context& cc(T::cc);
|
||||
wsrep::fake_client_context& cc(T::cc);
|
||||
const wsrep::transaction_context& tc(T::tc);
|
||||
|
||||
// Start a new transaction with ID 1
|
||||
@ -465,7 +465,7 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(
|
||||
transaction_context_1pc_error_during_prepare_data, T,
|
||||
replicating_fixtures, T)
|
||||
{
|
||||
wsrep::mock_client_context& cc(T::cc);
|
||||
wsrep::fake_client_context& cc(T::cc);
|
||||
const wsrep::transaction_context& tc(T::tc);
|
||||
|
||||
// Start a new transaction with ID 1
|
||||
@ -504,7 +504,7 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(
|
||||
transaction_context_1pc_killed_before_certify, T,
|
||||
replicating_fixtures, T)
|
||||
{
|
||||
wsrep::mock_client_context& cc(T::cc);
|
||||
wsrep::fake_client_context& cc(T::cc);
|
||||
const wsrep::transaction_context& tc(T::tc);
|
||||
|
||||
// Start a new transaction with ID 1
|
||||
@ -546,8 +546,8 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(
|
||||
transaction_context_1pc_bf_during_before_commit_certified, T,
|
||||
replicating_fixtures, T)
|
||||
{
|
||||
wsrep::mock_server_context& sc(T::sc);
|
||||
wsrep::mock_client_context& cc(T::cc);
|
||||
wsrep::fake_server_context& sc(T::sc);
|
||||
wsrep::fake_client_context& cc(T::cc);
|
||||
const wsrep::transaction_context& tc(T::tc);
|
||||
|
||||
// Start a new transaction with ID 1
|
||||
@ -586,7 +586,7 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(
|
||||
transaction_context_1pc_warning_error_from_certify, T,
|
||||
replicating_fixtures, T)
|
||||
{
|
||||
wsrep::mock_server_context& sc(T::sc);
|
||||
wsrep::fake_server_context& sc(T::sc);
|
||||
wsrep::client_context& cc(T::cc);
|
||||
const wsrep::transaction_context& tc(T::tc);
|
||||
|
||||
@ -596,7 +596,7 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(
|
||||
BOOST_REQUIRE(tc.id() == wsrep::transaction_id(1));
|
||||
BOOST_REQUIRE(tc.state() == wsrep::transaction_context::s_executing);
|
||||
|
||||
sc.provider().inject_error(wsrep::provider::error_warning);
|
||||
sc.provider().certify_status_ = wsrep::provider::error_warning;
|
||||
|
||||
// Run before commit
|
||||
BOOST_REQUIRE(cc.before_commit());
|
||||
@ -604,7 +604,7 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(
|
||||
BOOST_REQUIRE(tc.certified() == false);
|
||||
BOOST_REQUIRE(tc.ordered() == false);
|
||||
|
||||
sc.provider().inject_error(wsrep::provider::success);
|
||||
sc.provider().certify_status_ = wsrep::provider::success;
|
||||
|
||||
// Rollback sequence
|
||||
BOOST_REQUIRE(cc.before_rollback() == 0);
|
||||
@ -627,7 +627,7 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(
|
||||
transaction_context_1pc_transaction_missing_from_certify, T,
|
||||
replicating_fixtures, T)
|
||||
{
|
||||
wsrep::mock_server_context& sc(T::sc);
|
||||
wsrep::fake_server_context& sc(T::sc);
|
||||
wsrep::client_context& cc(T::cc);
|
||||
const wsrep::transaction_context& tc(T::tc);
|
||||
|
||||
@ -637,7 +637,7 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(
|
||||
BOOST_REQUIRE(tc.id() == wsrep::transaction_id(1));
|
||||
BOOST_REQUIRE(tc.state() == wsrep::transaction_context::s_executing);
|
||||
|
||||
sc.provider().inject_error(wsrep::provider::error_transaction_missing);
|
||||
sc.provider().certify_status_ = wsrep::provider::error_transaction_missing;
|
||||
|
||||
// Run before commit
|
||||
BOOST_REQUIRE(cc.before_commit());
|
||||
@ -645,7 +645,7 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(
|
||||
BOOST_REQUIRE(tc.certified() == false);
|
||||
BOOST_REQUIRE(tc.ordered() == false);
|
||||
|
||||
sc.provider().inject_error(wsrep::provider::success);
|
||||
sc.provider().certify_status_ = wsrep::provider::success;
|
||||
|
||||
// Rollback sequence
|
||||
BOOST_REQUIRE(cc.before_rollback() == 0);
|
||||
@ -668,7 +668,7 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(
|
||||
transaction_context_1pc_size_exceeded_from_certify, T,
|
||||
replicating_fixtures, T)
|
||||
{
|
||||
wsrep::mock_server_context& sc(T::sc);
|
||||
wsrep::fake_server_context& sc(T::sc);
|
||||
wsrep::client_context& cc(T::cc);
|
||||
const wsrep::transaction_context& tc(T::tc);
|
||||
|
||||
@ -678,7 +678,7 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(
|
||||
BOOST_REQUIRE(tc.id() == wsrep::transaction_id(1));
|
||||
BOOST_REQUIRE(tc.state() == wsrep::transaction_context::s_executing);
|
||||
|
||||
sc.provider().inject_error(wsrep::provider::error_size_exceeded);
|
||||
sc.provider().certify_status_ = wsrep::provider::error_size_exceeded;
|
||||
|
||||
// Run before commit
|
||||
BOOST_REQUIRE(cc.before_commit());
|
||||
@ -686,7 +686,7 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(
|
||||
BOOST_REQUIRE(tc.certified() == false);
|
||||
BOOST_REQUIRE(tc.ordered() == false);
|
||||
|
||||
sc.provider().inject_error(wsrep::provider::success);
|
||||
sc.provider().certify_status_ = wsrep::provider::success;
|
||||
|
||||
// Rollback sequence
|
||||
BOOST_REQUIRE(cc.before_rollback() == 0);
|
||||
@ -709,7 +709,7 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(
|
||||
transaction_context_1pc_connection_failed_from_certify, T,
|
||||
replicating_fixtures, T)
|
||||
{
|
||||
wsrep::mock_server_context& sc(T::sc);
|
||||
wsrep::fake_server_context& sc(T::sc);
|
||||
wsrep::client_context& cc(T::cc);
|
||||
const wsrep::transaction_context& tc(T::tc);
|
||||
|
||||
@ -719,7 +719,7 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(
|
||||
BOOST_REQUIRE(tc.id() == wsrep::transaction_id(1));
|
||||
BOOST_REQUIRE(tc.state() == wsrep::transaction_context::s_executing);
|
||||
|
||||
sc.provider().inject_error(wsrep::provider::error_connection_failed);
|
||||
sc.provider().certify_status_ = wsrep::provider::error_connection_failed;
|
||||
|
||||
// Run before commit
|
||||
BOOST_REQUIRE(cc.before_commit());
|
||||
@ -727,7 +727,7 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(
|
||||
BOOST_REQUIRE(tc.certified() == false);
|
||||
BOOST_REQUIRE(tc.ordered() == false);
|
||||
|
||||
sc.provider().inject_error(wsrep::provider::success);
|
||||
sc.provider().certify_status_ = wsrep::provider::success;
|
||||
|
||||
// Rollback sequence
|
||||
BOOST_REQUIRE(cc.before_rollback() == 0);
|
||||
@ -750,7 +750,7 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(
|
||||
transaction_context_1pc_no_allowed_from_certify, T,
|
||||
replicating_fixtures, T)
|
||||
{
|
||||
wsrep::mock_server_context& sc(T::sc);
|
||||
wsrep::fake_server_context& sc(T::sc);
|
||||
wsrep::client_context& cc(T::cc);
|
||||
const wsrep::transaction_context& tc(T::tc);
|
||||
|
||||
@ -760,7 +760,7 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(
|
||||
BOOST_REQUIRE(tc.id() == wsrep::transaction_id(1));
|
||||
BOOST_REQUIRE(tc.state() == wsrep::transaction_context::s_executing);
|
||||
|
||||
sc.provider().inject_error(wsrep::provider::error_not_allowed);
|
||||
sc.provider().certify_status_ = wsrep::provider::error_not_allowed;
|
||||
|
||||
// Run before commit
|
||||
BOOST_REQUIRE(cc.before_commit());
|
||||
@ -768,7 +768,7 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(
|
||||
BOOST_REQUIRE(tc.certified() == false);
|
||||
BOOST_REQUIRE(tc.ordered() == false);
|
||||
|
||||
sc.provider().inject_error(wsrep::provider::success);
|
||||
sc.provider().certify_status_ = wsrep::provider::success;
|
||||
|
||||
// Rollback sequence
|
||||
BOOST_REQUIRE(cc.before_rollback() == 0);
|
||||
@ -791,8 +791,8 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(
|
||||
transaction_context_1pc_fatal_from_certify, T,
|
||||
replicating_fixtures, T)
|
||||
{
|
||||
wsrep::mock_server_context& sc(T::sc);
|
||||
wsrep::mock_client_context& cc(T::cc);
|
||||
wsrep::fake_server_context& sc(T::sc);
|
||||
wsrep::fake_client_context& cc(T::cc);
|
||||
const wsrep::transaction_context& tc(T::tc);
|
||||
|
||||
// Start a new transaction with ID 1
|
||||
@ -801,7 +801,7 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(
|
||||
BOOST_REQUIRE(tc.id() == wsrep::transaction_id(1));
|
||||
BOOST_REQUIRE(tc.state() == wsrep::transaction_context::s_executing);
|
||||
|
||||
sc.provider().inject_error(wsrep::provider::error_fatal);
|
||||
sc.provider().certify_status_ = wsrep::provider::error_fatal;
|
||||
|
||||
// Run before commit
|
||||
BOOST_REQUIRE(cc.before_commit());
|
||||
@ -809,7 +809,7 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(
|
||||
BOOST_REQUIRE(tc.certified() == false);
|
||||
BOOST_REQUIRE(tc.ordered() == false);
|
||||
|
||||
sc.provider().inject_error(wsrep::provider::success);
|
||||
sc.provider().certify_status_ = wsrep::provider::success;
|
||||
|
||||
// Rollback sequence
|
||||
BOOST_REQUIRE(cc.before_rollback() == 0);
|
||||
@ -833,8 +833,8 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(
|
||||
transaction_context_1pc_unknown_from_certify, T,
|
||||
replicating_fixtures, T)
|
||||
{
|
||||
wsrep::mock_server_context& sc(T::sc);
|
||||
wsrep::mock_client_context& cc(T::cc);
|
||||
wsrep::fake_server_context& sc(T::sc);
|
||||
wsrep::fake_client_context& cc(T::cc);
|
||||
const wsrep::transaction_context& tc(T::tc);
|
||||
|
||||
// Start a new transaction with ID 1
|
||||
@ -843,7 +843,7 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(
|
||||
BOOST_REQUIRE(tc.id() == wsrep::transaction_id(1));
|
||||
BOOST_REQUIRE(tc.state() == wsrep::transaction_context::s_executing);
|
||||
|
||||
sc.provider().inject_error(wsrep::provider::error_unknown);
|
||||
sc.provider().certify_status_ = wsrep::provider::error_unknown;
|
||||
|
||||
// Run before commit
|
||||
BOOST_REQUIRE(cc.before_commit());
|
||||
@ -851,7 +851,7 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(
|
||||
BOOST_REQUIRE(tc.certified() == false);
|
||||
BOOST_REQUIRE(tc.ordered() == false);
|
||||
|
||||
sc.provider().inject_error(wsrep::provider::success);
|
||||
sc.provider().certify_status_ = wsrep::provider::success;
|
||||
|
||||
// Rollback sequence
|
||||
BOOST_REQUIRE(cc.before_rollback() == 0);
|
||||
@ -875,8 +875,8 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(
|
||||
transaction_context_1pc_bf_abort_after_certify_regain_lock, T,
|
||||
replicating_fixtures, T)
|
||||
{
|
||||
// wsrep::mock_server_context& sc(T::sc);
|
||||
wsrep::mock_client_context& cc(T::cc);
|
||||
// wsrep::fake_server_context& sc(T::sc);
|
||||
wsrep::fake_client_context& cc(T::cc);
|
||||
const wsrep::transaction_context& tc(T::tc);
|
||||
|
||||
// Start a new transaction with ID 1
|
||||
@ -915,7 +915,7 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(
|
||||
transaction_context_2pc_bf_during_commit_order_enter, T,
|
||||
replicating_fixtures, T)
|
||||
{
|
||||
wsrep::mock_server_context& sc(T::sc);
|
||||
wsrep::fake_server_context& sc(T::sc);
|
||||
wsrep::client_context& cc(T::cc);
|
||||
const wsrep::transaction_context& tc(T::tc);
|
||||
|
||||
@ -928,7 +928,7 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(
|
||||
BOOST_REQUIRE(cc.before_prepare() == 0);
|
||||
BOOST_REQUIRE(cc.after_prepare() == 0);
|
||||
|
||||
sc.provider().inject_error(wsrep::provider::error_bf_abort);
|
||||
sc.provider().commit_order_enter_status_ = wsrep::provider::error_bf_abort;
|
||||
|
||||
// Run before commit
|
||||
BOOST_REQUIRE(cc.before_commit());
|
||||
@ -936,7 +936,7 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(
|
||||
BOOST_REQUIRE(tc.certified() == true);
|
||||
BOOST_REQUIRE(tc.ordered() == true);
|
||||
|
||||
sc.provider().inject_error(wsrep::provider::success);
|
||||
sc.provider().commit_order_enter_status_ = wsrep::provider::success;
|
||||
// Rollback sequence
|
||||
BOOST_REQUIRE(cc.before_rollback() == 0);
|
||||
BOOST_REQUIRE(tc.state() == wsrep::transaction_context::s_must_replay);
|
||||
@ -1277,3 +1277,23 @@ BOOST_FIXTURE_TEST_CASE(transaction_context_streaming_rollback,
|
||||
BOOST_REQUIRE(sc.provider().start_fragments() == 1);
|
||||
BOOST_REQUIRE(sc.provider().rollback_fragments() == 1);
|
||||
}
|
||||
|
||||
#if 0
|
||||
BOOST_FIXTURE_TEST_CASE(transaction_context_streaming_cert_fail_non_commit,
|
||||
streaming_client_fixture_row)
|
||||
{
|
||||
BOOST_REQUIRE(cc.start_transaction(1) == 0);
|
||||
BOOST_REQUIRE(cc.after_row() == 0);
|
||||
BOOST_REQUIRE(tc.streaming_context_.fragments_certified() == 1);
|
||||
sc.provider().certify_status_ = wsrep::provider::error_certification_failed;
|
||||
BOOST_REQUIRE(cc.after_row() == 1);
|
||||
sc.provider().certify_status_ = wsrep::provider::success;
|
||||
BOOST_REQUIRE(cc.before_rollback() == 0);
|
||||
BOOST_REQUIRE(cc.after_rollback() == 0);
|
||||
BOOST_REQUIRE(cc.after_statement() == wsrep::client_context::asr_success);
|
||||
BOOST_REQUIRE(sc.provider().fragments() == 2);
|
||||
BOOST_REQUIRE(sc.provider().start_fragments() == 1);
|
||||
BOOST_REQUIRE(sc.provider().rollback_fragments() == 1);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user