1
0
mirror of https://github.com/codership/wsrep-lib.git synced 2025-07-28 20:02:00 +03:00

Unit tests for identifier class.

This commit is contained in:
Teemu Ollakka
2018-06-12 11:22:02 +03:00
parent 65b4ce9123
commit 3456a8b953
9 changed files with 62 additions and 35 deletions

View File

@ -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
View 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);
}

View File

@ -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)
{

View File

@ -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);

View File

@ -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;