1
0
mirror of https://github.com/codership/wsrep-lib.git synced 2025-04-21 08:25:53 +03:00

Rollback and release streaming appliers in unit tests

Unit tests which cause streaming rollback leaked memory because
the streaming applier handle which was created for rollback
fragment handling was not released. Roll back a streaming transaction
and release applier handle appropriately in corresponding tests.
This commit is contained in:
Teemu Ollakka 2018-10-17 12:51:01 +03:00
parent a9abb3a80a
commit cb1ca4e66e
3 changed files with 40 additions and 2 deletions

View File

@ -203,6 +203,7 @@ namespace
BOOST_REQUIRE(tc.state() == wsrep::transaction::s_executing);
cc.enable_streaming(wsrep::streaming_context::row, 1);
}
wsrep::mock_server_service server_service;
wsrep::mock_server_state sc;
wsrep::mock_client cc;

View File

@ -115,8 +115,9 @@ namespace wsrep
WSREP_OVERRIDE
{
mock_high_priority_service* mhps(
reinterpret_cast<mock_high_priority_service*>(high_priority_service));
wsrep::client_state* cs(mhps->client_state());
static_cast<mock_high_priority_service*>(high_priority_service));
wsrep::mock_client* cs(static_cast<wsrep::mock_client*>(
mhps->client_state()));
cs->after_command_before_result();
cs->after_command_after_result();
cs->close();

View File

@ -1067,6 +1067,15 @@ BOOST_FIXTURE_TEST_CASE(transaction_row_streaming_rollback,
BOOST_REQUIRE(sc.provider().fragments() == 2);
BOOST_REQUIRE(sc.provider().start_fragments() == 1);
BOOST_REQUIRE(sc.provider().rollback_fragments() == 1);
wsrep::high_priority_service* hps(
sc.find_streaming_applier(
sc.id(), wsrep::transaction_id(1)));
BOOST_REQUIRE(hps);
hps->rollback(wsrep::ws_handle(), wsrep::ws_meta());
hps->after_apply();
sc.stop_streaming_applier(sc.id(), wsrep::transaction_id(1));
server_service.release_high_priority_service(hps);
}
//
@ -1087,6 +1096,15 @@ BOOST_FIXTURE_TEST_CASE(transaction_row_streaming_cert_fail_non_commit,
BOOST_REQUIRE(sc.provider().fragments() == 2);
BOOST_REQUIRE(sc.provider().start_fragments() == 1);
BOOST_REQUIRE(sc.provider().rollback_fragments() == 1);
wsrep::high_priority_service* hps(
sc.find_streaming_applier(
sc.id(), wsrep::transaction_id(1)));
BOOST_REQUIRE(hps);
hps->rollback(wsrep::ws_handle(), wsrep::ws_meta());
hps->after_apply();
sc.stop_streaming_applier(sc.id(), wsrep::transaction_id(1));
server_service.release_high_priority_service(hps);
}
//
@ -1109,6 +1127,15 @@ BOOST_FIXTURE_TEST_CASE(transaction_row_streaming_cert_fail_commit,
BOOST_REQUIRE(sc.provider().fragments() == 2);
BOOST_REQUIRE(sc.provider().start_fragments() == 1);
BOOST_REQUIRE(sc.provider().rollback_fragments() == 1);
wsrep::high_priority_service* hps(
sc.find_streaming_applier(
sc.id(), wsrep::transaction_id(1)));
BOOST_REQUIRE(hps);
hps->rollback(wsrep::ws_handle(), wsrep::ws_meta());
hps->after_apply();
sc.stop_streaming_applier(sc.id(), wsrep::transaction_id(1));
server_service.release_high_priority_service(hps);
}
//
@ -1243,6 +1270,15 @@ BOOST_FIXTURE_TEST_CASE(transaction_statement_streaming_cert_fail,
BOOST_REQUIRE(sc.provider().fragments() == 1);
BOOST_REQUIRE(sc.provider().start_fragments() == 0);
BOOST_REQUIRE(sc.provider().rollback_fragments() == 1);
wsrep::high_priority_service* hps(
sc.find_streaming_applier(
sc.id(), wsrep::transaction_id(1)));
BOOST_REQUIRE(hps);
hps->rollback(wsrep::ws_handle(), wsrep::ws_meta());
hps->after_apply();
sc.stop_streaming_applier(sc.id(), wsrep::transaction_id(1));
server_service.release_high_priority_service(hps);
}
///////////////////////////////////////////////////////////////////////////////