mirror of
https://github.com/codership/wsrep-lib.git
synced 2025-07-30 07:23:07 +03:00
Unit tests for identifier class.
This commit is contained in:
@ -39,6 +39,7 @@
|
||||
#define WSREP_CLIENT_CONTEXT_HPP
|
||||
|
||||
#include "server_context.hpp"
|
||||
#include "provider.hpp"
|
||||
#include "transaction_context.hpp"
|
||||
#include "client_id.hpp"
|
||||
#include "mutex.hpp"
|
||||
@ -46,6 +47,7 @@
|
||||
#include "data.hpp"
|
||||
#include "thread.hpp"
|
||||
|
||||
|
||||
namespace wsrep
|
||||
{
|
||||
class server_context;
|
||||
|
@ -16,7 +16,7 @@ namespace wsrep
|
||||
runtime_error(const std::string& msg)
|
||||
: std::runtime_error(msg)
|
||||
{
|
||||
::abort();
|
||||
// ::abort();
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -5,8 +5,7 @@
|
||||
#ifndef WSREP_PROVIDER_HPP
|
||||
#define WSREP_PROVIDER_HPP
|
||||
|
||||
#include "id.hpp"
|
||||
#include "seqno.hpp"
|
||||
#include "gtid.hpp"
|
||||
#include "key.hpp"
|
||||
#include "data.hpp"
|
||||
#include "client_id.hpp"
|
||||
@ -24,25 +23,6 @@ namespace wsrep
|
||||
{
|
||||
class server_context;
|
||||
|
||||
class gtid
|
||||
{
|
||||
public:
|
||||
gtid()
|
||||
: id_()
|
||||
, seqno_()
|
||||
{ }
|
||||
gtid(const wsrep::id& id, wsrep::seqno seqno)
|
||||
: id_(id)
|
||||
, seqno_(seqno)
|
||||
{ }
|
||||
const wsrep::id& id() const { return id_; }
|
||||
wsrep::seqno seqno() const { return seqno_ ; }
|
||||
private:
|
||||
wsrep::id id_;
|
||||
wsrep::seqno seqno_;
|
||||
};
|
||||
|
||||
|
||||
class stid
|
||||
{
|
||||
public:
|
||||
|
@ -61,20 +61,21 @@
|
||||
#ifndef WSREP_SERVER_CONTEXT_HPP
|
||||
#define WSREP_SERVER_CONTEXT_HPP
|
||||
|
||||
#include "exception.hpp"
|
||||
#include "mutex.hpp"
|
||||
#include "condition_variable.hpp"
|
||||
#include "provider.hpp"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
namespace wsrep
|
||||
{
|
||||
// Forward declarations
|
||||
// class provider;
|
||||
class ws_handle;
|
||||
class ws_meta;
|
||||
class provider;
|
||||
class client_context;
|
||||
class transaction_context;
|
||||
class gtid;
|
||||
class view;
|
||||
class data;
|
||||
|
||||
|
@ -17,6 +17,7 @@ target_link_libraries(wsrep-lib wsrep_api_v26 pthread dl)
|
||||
add_executable(wsrep-lib_test
|
||||
mock_client_context.cpp
|
||||
test_utils.cpp
|
||||
id_test.cpp
|
||||
server_context_test.cpp
|
||||
transaction_context_test.cpp
|
||||
wsrep-lib_test.cpp
|
||||
|
38
src/id_test.cpp
Normal file
38
src/id_test.cpp
Normal file
@ -0,0 +1,38 @@
|
||||
//
|
||||
// Copyright (C) 2018 Codership Oy <info@codership.com>
|
||||
//
|
||||
|
||||
#include "wsrep/id.hpp"
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
#include <sstream>
|
||||
|
||||
namespace
|
||||
{
|
||||
bool exception_check(const wsrep::runtime_error&) { return true; }
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(id_test_uuid)
|
||||
{
|
||||
std::string uuid_str("6a20d44a-6e17-11e8-b1e2-9061aec0cdad");
|
||||
wsrep::id id(uuid_str);
|
||||
std::ostringstream os;
|
||||
os << id;
|
||||
BOOST_REQUIRE(uuid_str == os.str());
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(id_test_string)
|
||||
{
|
||||
std::string id_str("1234567890123456");
|
||||
wsrep::id id(id_str);
|
||||
std::ostringstream os;
|
||||
os << id;
|
||||
BOOST_REQUIRE(id_str == os.str());
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(id_test_string_too_long)
|
||||
{
|
||||
std::string id_str("12345678901234567");
|
||||
BOOST_REQUIRE_EXCEPTION(wsrep::id id(id_str), wsrep::runtime_error,
|
||||
exception_check);
|
||||
}
|
@ -127,7 +127,7 @@ namespace wsrep
|
||||
wsrep::transaction_id trx_id,
|
||||
wsrep::seqno& victim_seqno)
|
||||
{
|
||||
std::cerr << "bf_abort: " << trx_id << "\n";
|
||||
// std::cerr << "bf_abort: " << trx_id << "\n";
|
||||
bf_abort_map_.insert(std::make_pair(trx_id, bf_seqno));
|
||||
if (bf_seqno.nil() == false)
|
||||
{
|
||||
|
@ -37,7 +37,6 @@ namespace
|
||||
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, ws_handle, ws_meta,
|
||||
wsrep::data(buf, 1)) == 0);
|
||||
|
@ -512,18 +512,24 @@ bool wsrep::transaction_context::bf_abort(
|
||||
switch (status)
|
||||
{
|
||||
case wsrep::provider::success:
|
||||
wsrep::log() << "Seqno " << bf_seqno
|
||||
<< " succesfully BF aborted " << id_.get()
|
||||
<< " victim_seqno " << victim_seqno;
|
||||
if (client_context_.debug_log_level() >= 1)
|
||||
{
|
||||
wsrep::log_debug() << "Seqno " << bf_seqno
|
||||
<< " succesfully BF aborted " << id_.get()
|
||||
<< " victim_seqno " << victim_seqno;
|
||||
}
|
||||
bf_abort_state_ = state();
|
||||
state(lock, s_must_abort);
|
||||
ret = true;
|
||||
break;
|
||||
default:
|
||||
wsrep::log() << "Seqno " << bf_seqno
|
||||
<< " failed to BF abort " << id_.get()
|
||||
<< " with status " << status
|
||||
<< " victim_seqno " << victim_seqno;
|
||||
if (client_context_.debug_log_level() >= 1)
|
||||
{
|
||||
wsrep::log_debug() << "Seqno " << bf_seqno
|
||||
<< " failed to BF abort " << id_.get()
|
||||
<< " with status " << status
|
||||
<< " victim_seqno " << victim_seqno;
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
Reference in New Issue
Block a user