1
0
mirror of https://github.com/codership/wsrep-lib.git synced 2025-07-31 18:24:25 +03:00

Renamed server_context to server_state.

This commit is contained in:
Teemu Ollakka
2018-06-17 10:07:48 +03:00
parent 790c2bec4e
commit ef4baa9f9d
29 changed files with 212 additions and 297 deletions

View File

@ -5,7 +5,7 @@
#ifndef WSREP_TEST_CLIENT_CONTEXT_FIXTURE_HPP
#define WSREP_TEST_CLIENT_CONTEXT_FIXTURE_HPP
#include "mock_server_context.hpp"
#include "mock_server_state.hpp"
#include "mock_client_state.hpp"
@ -16,7 +16,7 @@ namespace
struct replicating_client_fixture_sync_rm
{
replicating_client_fixture_sync_rm()
: sc("s1", "s1", wsrep::server_context::rm_sync)
: sc("s1", "s1", wsrep::server_state::rm_sync)
, cc(sc, sc.client_service(), wsrep::client_id(1),
wsrep::client_state::m_replicating)
, tc(cc.transaction())
@ -27,7 +27,7 @@ namespace
BOOST_REQUIRE(tc.active() == false);
BOOST_REQUIRE(tc.state() == wsrep::transaction::s_executing);
}
wsrep::mock_server_context sc;
wsrep::mock_server_state sc;
wsrep::mock_client_state cc;
const wsrep::transaction& tc;
};
@ -35,7 +35,7 @@ namespace
struct replicating_client_fixture_async_rm
{
replicating_client_fixture_async_rm()
: sc("s1", "s1", wsrep::server_context::rm_async)
: sc("s1", "s1", wsrep::server_state::rm_async)
, cc(sc, sc.client_service(), wsrep::client_id(1),
wsrep::client_state::m_replicating)
, tc(cc.transaction())
@ -46,7 +46,7 @@ namespace
BOOST_REQUIRE(tc.active() == false);
BOOST_REQUIRE(tc.state() == wsrep::transaction::s_executing);
}
wsrep::mock_server_context sc;
wsrep::mock_server_state sc;
wsrep::mock_client_state cc;
const wsrep::transaction& tc;
};
@ -54,7 +54,7 @@ namespace
struct replicating_client_fixture_2pc
{
replicating_client_fixture_2pc()
: sc("s1", "s1", wsrep::server_context::rm_sync)
: sc("s1", "s1", wsrep::server_state::rm_sync)
, cc(sc, sc.client_service(), wsrep::client_id(1),
wsrep::client_state::m_replicating)
, tc(cc.transaction())
@ -66,7 +66,7 @@ namespace
BOOST_REQUIRE(tc.active() == false);
BOOST_REQUIRE(tc.state() == wsrep::transaction::s_executing);
}
wsrep::mock_server_context sc;
wsrep::mock_server_state sc;
wsrep::mock_client_state cc;
const wsrep::transaction& tc;
};
@ -74,7 +74,7 @@ namespace
struct replicating_client_fixture_autocommit
{
replicating_client_fixture_autocommit()
: sc("s1", "s1", wsrep::server_context::rm_sync)
: sc("s1", "s1", wsrep::server_state::rm_sync)
, cc(sc, sc.client_service(), wsrep::client_id(1),
wsrep::client_state::m_replicating)
, tc(cc.transaction())
@ -86,7 +86,7 @@ namespace
BOOST_REQUIRE(tc.active() == false);
BOOST_REQUIRE(tc.state() == wsrep::transaction::s_executing);
}
wsrep::mock_server_context sc;
wsrep::mock_server_state sc;
wsrep::mock_client_state cc;
const wsrep::transaction& tc;
};
@ -95,7 +95,7 @@ namespace
{
applying_client_fixture()
: sc("s1", "s1",
wsrep::server_context::rm_async)
wsrep::server_state::rm_async)
, cc(sc, sc.client_service(),
wsrep::client_id(1),
wsrep::client_state::m_high_priority)
@ -114,7 +114,7 @@ namespace
BOOST_REQUIRE(tc.certified() == true);
BOOST_REQUIRE(tc.ordered() == true);
}
wsrep::mock_server_context sc;
wsrep::mock_server_state sc;
wsrep::mock_client_state cc;
const wsrep::transaction& tc;
};
@ -123,7 +123,7 @@ namespace
{
applying_client_fixture_2pc()
: sc("s1", "s1",
wsrep::server_context::rm_async)
wsrep::server_state::rm_async)
, cc(sc, sc.client_service(),
wsrep::client_id(1),
wsrep::client_state::m_high_priority)
@ -143,7 +143,7 @@ namespace
BOOST_REQUIRE(tc.certified() == true);
BOOST_REQUIRE(tc.ordered() == true);
}
wsrep::mock_server_context sc;
wsrep::mock_server_state sc;
wsrep::mock_client_state cc;
const wsrep::transaction& tc;
};
@ -151,7 +151,7 @@ namespace
struct streaming_client_fixture_row
{
streaming_client_fixture_row()
: sc("s1", "s1", wsrep::server_context::rm_sync)
: sc("s1", "s1", wsrep::server_state::rm_sync)
, cc(sc, sc.client_service(), wsrep::client_id(1),
wsrep::client_state::m_replicating)
, tc(cc.transaction())
@ -163,7 +163,7 @@ namespace
BOOST_REQUIRE(tc.state() == wsrep::transaction::s_executing);
cc.enable_streaming(wsrep::streaming_context::row, 1);
}
wsrep::mock_server_context sc;
wsrep::mock_server_state sc;
wsrep::mock_client_state cc;
const wsrep::transaction& tc;
};
@ -171,7 +171,7 @@ namespace
struct streaming_client_fixture_byte
{
streaming_client_fixture_byte()
: sc("s1", "s1", wsrep::server_context::rm_sync)
: sc("s1", "s1", wsrep::server_state::rm_sync)
, cc(sc, sc.client_service(), wsrep::client_id(1),
wsrep::client_state::m_replicating)
, tc(cc.transaction())
@ -183,7 +183,7 @@ namespace
BOOST_REQUIRE(tc.state() == wsrep::transaction::s_executing);
cc.enable_streaming(wsrep::streaming_context::bytes, 1);
}
wsrep::mock_server_context sc;
wsrep::mock_server_state sc;
wsrep::mock_client_state cc;
const wsrep::transaction& tc;
};
@ -191,7 +191,7 @@ namespace
struct streaming_client_fixture_statement
{
streaming_client_fixture_statement()
: sc("s1", "s1", wsrep::server_context::rm_sync)
: sc("s1", "s1", wsrep::server_state::rm_sync)
, cc(sc, sc.client_service(), wsrep::client_id(1),
wsrep::client_state::m_replicating)
, tc(cc.transaction())
@ -204,7 +204,7 @@ namespace
cc.enable_streaming(wsrep::streaming_context::row, 1);
}
wsrep::mock_server_context sc;
wsrep::mock_server_state sc;
wsrep::mock_client_state cc;
const wsrep::transaction& tc;
};

View File

@ -16,11 +16,11 @@ namespace wsrep
class mock_client_state : public wsrep::client_state
{
public:
mock_client_state(wsrep::server_context& server_context,
mock_client_state(wsrep::server_state& server_state,
wsrep::client_service& client_service,
const wsrep::client_id& id,
enum wsrep::client_state::mode mode)
: wsrep::client_state(mutex_, server_context, client_service, id, mode)
: wsrep::client_state(mutex_, server_state, client_service, id, mode)
// Note: Mutex is initialized only after passed
// to client_state constructor.
, mutex_()

View File

@ -22,8 +22,8 @@ namespace wsrep
public:
typedef std::map<wsrep::transaction_id, wsrep::seqno> bf_abort_map;
mock_provider(wsrep::server_context& server_context)
: provider(server_context)
mock_provider(wsrep::server_state& server_state)
: provider(server_state)
, certify_result_()
, commit_order_enter_result_()
, commit_order_leave_result_()
@ -183,7 +183,7 @@ namespace wsrep
return replay_result_;
}
if (server_context_.on_apply(cc, tc.ws_handle(), ws_meta,
if (server_state_.on_apply(cc, tc.ws_handle(), ws_meta,
wsrep::const_buffer()))
{
return wsrep::provider::error_fatal;

View File

@ -5,7 +5,7 @@
#ifndef WSREP_MOCK_SERVER_CONTEXT_HPP
#define WSREP_MOCK_SERVER_CONTEXT_HPP
#include "wsrep/server_context.hpp"
#include "wsrep/server_state.hpp"
#include "mock_client_state.hpp"
#include "mock_provider.hpp"
@ -13,13 +13,13 @@
namespace wsrep
{
class mock_server_context : public wsrep::server_context
class mock_server_state : public wsrep::server_state
{
public:
mock_server_context(const std::string& name,
mock_server_state(const std::string& name,
const std::string& id,
enum wsrep::server_context::rollback_mode rollback_mode)
: wsrep::server_context(mutex_, cond_,
enum wsrep::server_state::rollback_mode rollback_mode)
: wsrep::server_state(mutex_, cond_,
name, id, "", "./", rollback_mode)
, mutex_()
, cond_()

View File

@ -2,7 +2,7 @@
// Copyright (C) 2018 Codership Oy <info@codership.com>
//
#include "mock_server_context.hpp"
#include "mock_server_state.hpp"
#include <boost/test/unit_test.hpp>
@ -12,7 +12,7 @@ namespace
{
applying_server_fixture()
: sc("s1", "s1",
wsrep::server_context::rm_sync)
wsrep::server_state::rm_sync)
, cc(sc, sc.client_service(),
wsrep::client_id(1),
wsrep::client_state::m_high_priority)
@ -24,7 +24,7 @@ namespace
wsrep::provider::flag::commit)
{
}
wsrep::mock_server_context sc;
wsrep::mock_server_state sc;
wsrep::mock_client_state cc;
wsrep::ws_handle ws_handle;
wsrep::ws_meta ws_meta;
@ -32,7 +32,7 @@ namespace
}
// Test on_apply() method for 1pc
BOOST_FIXTURE_TEST_CASE(server_context_applying_1pc,
BOOST_FIXTURE_TEST_CASE(server_state_applying_1pc,
applying_server_fixture)
{
char buf[1] = { 1 };
@ -46,7 +46,7 @@ BOOST_FIXTURE_TEST_CASE(server_context_applying_1pc,
}
// Test on_apply() method for 2pc
BOOST_FIXTURE_TEST_CASE(server_context_applying_2pc,
BOOST_FIXTURE_TEST_CASE(server_state_applying_2pc,
applying_server_fixture)
{
char buf[1] = { 1 };
@ -58,7 +58,7 @@ BOOST_FIXTURE_TEST_CASE(server_context_applying_2pc,
// Test on_apply() method for 1pc transaction which
// fails applying and rolls back
BOOST_FIXTURE_TEST_CASE(server_context_applying_1pc_rollback,
BOOST_FIXTURE_TEST_CASE(server_state_applying_1pc_rollback,
applying_server_fixture)
{
sc.client_service().fail_next_applying_ = true;
@ -71,7 +71,7 @@ BOOST_FIXTURE_TEST_CASE(server_context_applying_1pc_rollback,
// Test on_apply() method for 2pc transaction which
// fails applying and rolls back
BOOST_FIXTURE_TEST_CASE(server_context_applying_2pc_rollback,
BOOST_FIXTURE_TEST_CASE(server_state_applying_2pc_rollback,
applying_server_fixture)
{
sc.client_service().fail_next_applying_ = true;
@ -82,10 +82,10 @@ BOOST_FIXTURE_TEST_CASE(server_context_applying_2pc_rollback,
BOOST_REQUIRE(txc.state() == wsrep::transaction::s_aborted);
}
BOOST_AUTO_TEST_CASE(server_context_streaming)
BOOST_AUTO_TEST_CASE(server_state_streaming)
{
wsrep::mock_server_context sc("s1", "s1",
wsrep::server_context::rm_sync);
wsrep::mock_server_state sc("s1", "s1",
wsrep::server_state::rm_sync);
wsrep::mock_client_state cc(sc,
sc.client_service(),
wsrep::client_id(1),
@ -116,26 +116,26 @@ BOOST_AUTO_TEST_CASE(server_context_streaming)
}
BOOST_AUTO_TEST_CASE(server_context_state_strings)
BOOST_AUTO_TEST_CASE(server_state_state_strings)
{
BOOST_REQUIRE(wsrep::to_string(
wsrep::server_context::s_disconnected) == "disconnected");
wsrep::server_state::s_disconnected) == "disconnected");
BOOST_REQUIRE(wsrep::to_string(
wsrep::server_context::s_initializing) == "initilizing");
wsrep::server_state::s_initializing) == "initilizing");
BOOST_REQUIRE(wsrep::to_string(
wsrep::server_context::s_initialized) == "initilized");
wsrep::server_state::s_initialized) == "initilized");
BOOST_REQUIRE(wsrep::to_string(
wsrep::server_context::s_connected) == "connected");
wsrep::server_state::s_connected) == "connected");
BOOST_REQUIRE(wsrep::to_string(
wsrep::server_context::s_joiner) == "joiner");
wsrep::server_state::s_joiner) == "joiner");
BOOST_REQUIRE(wsrep::to_string(
wsrep::server_context::s_joined) == "joined");
wsrep::server_state::s_joined) == "joined");
BOOST_REQUIRE(wsrep::to_string(
wsrep::server_context::s_donor) == "donor");
wsrep::server_state::s_donor) == "donor");
BOOST_REQUIRE(wsrep::to_string(
wsrep::server_context::s_synced) == "synced");
wsrep::server_state::s_synced) == "synced");
BOOST_REQUIRE(wsrep::to_string(
wsrep::server_context::s_disconnecting) == "disconnecting");
wsrep::server_state::s_disconnecting) == "disconnecting");
BOOST_REQUIRE(wsrep::to_string(
static_cast<enum wsrep::server_context::state>(0xff)) == "unknown");
static_cast<enum wsrep::server_state::state>(0xff)) == "unknown");
}

View File

@ -4,7 +4,7 @@
#include "test_utils.hpp"
#include "wsrep/client_state.hpp"
#include "mock_server_context.hpp"
#include "mock_server_state.hpp"
// Simple BF abort method to BF abort unordered transasctions
@ -20,7 +20,7 @@ void wsrep_test::bf_abort_ordered(wsrep::client_state& cc)
cc.bf_abort(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::mock_server_state& sc,
const wsrep::transaction& tc,
wsrep::seqno bf_seqno)
{

View File

@ -6,7 +6,7 @@
namespace wsrep
{
class client_state;
class mock_server_context;
class mock_server_state;
}
#include "wsrep/transaction.hpp"
@ -25,7 +25,7 @@ namespace wsrep_test
void bf_abort_ordered(wsrep::client_state& cc);
// BF abort method to abort transactions via provider
void bf_abort_provider(wsrep::mock_server_context& sc,
void bf_abort_provider(wsrep::mock_server_state& sc,
const wsrep::transaction& tc,
wsrep::seqno bf_seqno);

View File

@ -158,7 +158,7 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(
transaction_1pc_bf_during_before_commit_uncertified, T,
replicating_fixtures, T)
{
wsrep::mock_server_context& sc(T::sc);
wsrep::mock_server_state& sc(T::sc);
wsrep::client_state& cc(T::cc);
const wsrep::transaction& tc(T::tc);
@ -198,7 +198,7 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(
transaction_1pc_bf_during_commit_wait_for_replayers, T,
replicating_fixtures, T)
{
wsrep::mock_server_context& sc(T::sc);
wsrep::mock_server_state& sc(T::sc);
wsrep::mock_client_state& cc(T::cc);
const wsrep::transaction& tc(T::tc);
@ -237,7 +237,7 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(
transaction_1pc_error_during_prepare_data, T,
replicating_fixtures, T)
{
wsrep::mock_server_context& sc(T::sc);
wsrep::mock_server_state& sc(T::sc);
wsrep::mock_client_state& cc(T::cc);
const wsrep::transaction& tc(T::tc);
@ -277,7 +277,7 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(
transaction_1pc_killed_before_certify, T,
replicating_fixtures, T)
{
wsrep::mock_server_context& sc(T::sc);
wsrep::mock_server_state& sc(T::sc);
wsrep::mock_client_state& cc(T::cc);
const wsrep::transaction& tc(T::tc);
@ -359,7 +359,7 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(
transaction_1pc_bf_during_before_commit_certified, T,
replicating_fixtures, T)
{
wsrep::mock_server_context& sc(T::sc);
wsrep::mock_server_state& sc(T::sc);
wsrep::mock_client_state& cc(T::cc);
const wsrep::transaction& tc(T::tc);
@ -402,7 +402,7 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(
transaction_1pc_bf_before_unordered_cert_failure, T,
replicating_fixtures, T)
{
wsrep::mock_server_context& sc(T::sc);
wsrep::mock_server_state& sc(T::sc);
wsrep::mock_client_state& cc(T::cc);
const wsrep::transaction& tc(T::tc);
@ -435,7 +435,7 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(
transaction_1pc_warning_error_from_certify, T,
replicating_fixtures, T)
{
wsrep::mock_server_context& sc(T::sc);
wsrep::mock_server_state& sc(T::sc);
wsrep::client_state& cc(T::cc);
const wsrep::transaction& tc(T::tc);
@ -476,7 +476,7 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(
transaction_1pc_transaction_missing_from_certify, T,
replicating_fixtures, T)
{
wsrep::mock_server_context& sc(T::sc);
wsrep::mock_server_state& sc(T::sc);
wsrep::client_state& cc(T::cc);
const wsrep::transaction& tc(T::tc);
@ -517,7 +517,7 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(
transaction_1pc_size_exceeded_from_certify, T,
replicating_fixtures, T)
{
wsrep::mock_server_context& sc(T::sc);
wsrep::mock_server_state& sc(T::sc);
wsrep::client_state& cc(T::cc);
const wsrep::transaction& tc(T::tc);
@ -558,7 +558,7 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(
transaction_1pc_connection_failed_from_certify, T,
replicating_fixtures, T)
{
wsrep::mock_server_context& sc(T::sc);
wsrep::mock_server_state& sc(T::sc);
wsrep::client_state& cc(T::cc);
const wsrep::transaction& tc(T::tc);
@ -599,7 +599,7 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(
transaction_1pc_no_allowed_from_certify, T,
replicating_fixtures, T)
{
wsrep::mock_server_context& sc(T::sc);
wsrep::mock_server_state& sc(T::sc);
wsrep::client_state& cc(T::cc);
const wsrep::transaction& tc(T::tc);
@ -640,7 +640,7 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(
transaction_1pc_fatal_from_certify, T,
replicating_fixtures, T)
{
wsrep::mock_server_context& sc(T::sc);
wsrep::mock_server_state& sc(T::sc);
wsrep::mock_client_state& cc(T::cc);
const wsrep::transaction& tc(T::tc);
@ -682,7 +682,7 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(
transaction_1pc_unknown_from_certify, T,
replicating_fixtures, T)
{
wsrep::mock_server_context& sc(T::sc);
wsrep::mock_server_state& sc(T::sc);
wsrep::mock_client_state& cc(T::cc);
const wsrep::transaction& tc(T::tc);
@ -724,7 +724,7 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(
transaction_1pc_bf_abort_before_certify_regain_lock, T,
replicating_fixtures, T)
{
wsrep::mock_server_context& sc(T::sc);
wsrep::mock_server_state& sc(T::sc);
wsrep::mock_client_state& cc(T::cc);
const wsrep::transaction& tc(T::tc);