mirror of
https://github.com/codership/wsrep-lib.git
synced 2025-07-28 20:02:00 +03:00
Bytes and statement streaming unit.
This commit is contained in:
@ -182,7 +182,7 @@ namespace
|
||||
// Verify initial state
|
||||
BOOST_REQUIRE(tc.active() == false);
|
||||
BOOST_REQUIRE(tc.state() == wsrep::transaction_context::s_executing);
|
||||
cc.enable_streaming(wsrep::transaction_context::streaming_context::row, 1);
|
||||
cc.enable_streaming(wsrep::transaction_context::streaming_context::bytes, 1);
|
||||
}
|
||||
wsrep::fake_server_context sc;
|
||||
wsrep::fake_client_context cc;
|
||||
|
@ -33,6 +33,7 @@ namespace wsrep
|
||||
, killed_before_certify_()
|
||||
, sync_point_enabled_()
|
||||
, sync_point_action_()
|
||||
, bytes_generated_()
|
||||
, replays_()
|
||||
, aborts_()
|
||||
{ }
|
||||
@ -87,6 +88,11 @@ namespace wsrep
|
||||
return transaction_.append_data(data);
|
||||
}
|
||||
|
||||
size_t bytes_generated() const
|
||||
{
|
||||
return bytes_generated_;
|
||||
}
|
||||
|
||||
int prepare_fragment_for_replication(const wsrep::transaction_context&,
|
||||
wsrep::mutable_buffer& buffer)
|
||||
WSREP_OVERRIDE
|
||||
@ -142,6 +148,7 @@ namespace wsrep
|
||||
{
|
||||
spa_bf_abort
|
||||
} sync_point_action_;
|
||||
size_t bytes_generated_;
|
||||
private:
|
||||
size_t replays_;
|
||||
size_t aborts_;
|
||||
|
@ -917,6 +917,28 @@ BOOST_FIXTURE_TEST_CASE(transaction_context_row_streaming_1pc_commit,
|
||||
BOOST_REQUIRE(sc.provider().commit_fragments() == 1);
|
||||
}
|
||||
|
||||
//
|
||||
// Test 1PC with row streaming with one row
|
||||
//
|
||||
BOOST_FIXTURE_TEST_CASE(transaction_context_row_batch_streaming_1pc_commit,
|
||||
streaming_client_fixture_row)
|
||||
{
|
||||
BOOST_REQUIRE(cc.enable_streaming(
|
||||
wsrep::transaction_context::streaming_context::row, 2) == 0);
|
||||
BOOST_REQUIRE(cc.start_transaction(1) == 0);
|
||||
BOOST_REQUIRE(cc.after_row() == 0);
|
||||
BOOST_REQUIRE(tc.streaming_context_.fragments_certified() == 0);
|
||||
BOOST_REQUIRE(cc.after_row() == 0);
|
||||
BOOST_REQUIRE(tc.streaming_context_.fragments_certified() == 1);
|
||||
BOOST_REQUIRE(cc.before_commit() == 0);
|
||||
BOOST_REQUIRE(cc.ordered_commit() == 0);
|
||||
BOOST_REQUIRE(cc.after_commit() == 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().commit_fragments() == 1);
|
||||
}
|
||||
|
||||
//
|
||||
// Test 1PC row streaming with two separate statements
|
||||
//
|
||||
@ -1005,7 +1027,6 @@ BOOST_FIXTURE_TEST_CASE(transaction_context_row_streaming_cert_fail_commit,
|
||||
BOOST_FIXTURE_TEST_CASE(transaction_context_row_streaming_bf_abort_committing,
|
||||
streaming_client_fixture_row)
|
||||
{
|
||||
cc.debug_log_level(1);
|
||||
BOOST_REQUIRE(cc.start_transaction(1) == 0);
|
||||
BOOST_REQUIRE(cc.after_row() == 0);
|
||||
BOOST_REQUIRE(tc.streaming_context_.fragments_certified() == 1);
|
||||
@ -1025,21 +1046,105 @@ BOOST_FIXTURE_TEST_CASE(transaction_context_row_streaming_bf_abort_committing,
|
||||
|
||||
|
||||
|
||||
BOOST_FIXTURE_TEST_CASE(transaction_context_byte_batch_streaming_1pc_commit,
|
||||
streaming_client_fixture_byte)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
BOOST_FIXTURE_TEST_CASE(transaction_context_byte_streaming_1pc_commit,
|
||||
streaming_client_fixture_byte)
|
||||
{
|
||||
BOOST_REQUIRE(cc.start_transaction(1) == 0);
|
||||
cc.bytes_generated_ = 1;
|
||||
BOOST_REQUIRE(cc.after_row() == 0);
|
||||
BOOST_REQUIRE(tc.streaming_context_.fragments_certified() == 1);
|
||||
BOOST_REQUIRE(cc.before_commit() == 0);
|
||||
BOOST_REQUIRE(cc.ordered_commit() == 0);
|
||||
BOOST_REQUIRE(cc.after_commit() == 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().commit_fragments() == 1);
|
||||
}
|
||||
|
||||
BOOST_FIXTURE_TEST_CASE(transaction_context_byte_batch_streaming_1pc_commit,
|
||||
streaming_client_fixture_byte)
|
||||
{
|
||||
BOOST_REQUIRE(
|
||||
cc.enable_streaming(
|
||||
wsrep::transaction_context::streaming_context::bytes, 2) == 0);
|
||||
BOOST_REQUIRE(cc.start_transaction(1) == 0);
|
||||
cc.bytes_generated_ = 1;
|
||||
BOOST_REQUIRE(cc.after_row() == 0);
|
||||
BOOST_REQUIRE(tc.streaming_context_.fragments_certified() == 0);
|
||||
cc.bytes_generated_ = 2;
|
||||
BOOST_REQUIRE(cc.after_row() == 0);
|
||||
BOOST_REQUIRE(tc.streaming_context_.fragments_certified() == 1);
|
||||
BOOST_REQUIRE(cc.before_commit() == 0);
|
||||
BOOST_REQUIRE(cc.ordered_commit() == 0);
|
||||
BOOST_REQUIRE(cc.after_commit() == 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().commit_fragments() == 1);
|
||||
}
|
||||
|
||||
|
||||
BOOST_FIXTURE_TEST_CASE(transaction_context_statement_streaming_1pc_commit,
|
||||
streaming_client_fixture_statement)
|
||||
{
|
||||
|
||||
BOOST_REQUIRE(
|
||||
cc.enable_streaming(
|
||||
wsrep::transaction_context::streaming_context::statement, 1) == 0);
|
||||
BOOST_REQUIRE(cc.start_transaction(1) == 0);
|
||||
BOOST_REQUIRE(cc.after_row() == 0);
|
||||
BOOST_REQUIRE(tc.streaming_context_.fragments_certified() == 0);
|
||||
BOOST_REQUIRE(cc.after_statement() == wsrep::client_context::asr_success);
|
||||
BOOST_REQUIRE(tc.streaming_context_.fragments_certified() == 1);
|
||||
BOOST_REQUIRE(cc.before_statement() == 0);
|
||||
BOOST_REQUIRE(cc.before_commit() == 0);
|
||||
BOOST_REQUIRE(cc.ordered_commit() == 0);
|
||||
BOOST_REQUIRE(cc.after_commit() == 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().commit_fragments() == 1);
|
||||
}
|
||||
|
||||
BOOST_FIXTURE_TEST_CASE(transaction_context_statement_batch_streaming_1pc_commit,
|
||||
streaming_client_fixture_statement)
|
||||
{
|
||||
BOOST_REQUIRE(
|
||||
cc.enable_streaming(
|
||||
wsrep::transaction_context::streaming_context::statement, 2) == 0);
|
||||
BOOST_REQUIRE(cc.start_transaction(1) == 0);
|
||||
BOOST_REQUIRE(cc.after_row() == 0);
|
||||
BOOST_REQUIRE(tc.streaming_context_.fragments_certified() == 0);
|
||||
BOOST_REQUIRE(cc.after_statement() == wsrep::client_context::asr_success);
|
||||
BOOST_REQUIRE(tc.streaming_context_.fragments_certified() == 0);
|
||||
BOOST_REQUIRE(cc.before_statement() == 0);
|
||||
BOOST_REQUIRE(cc.after_row() == 0);
|
||||
BOOST_REQUIRE(tc.streaming_context_.fragments_certified() == 0);
|
||||
BOOST_REQUIRE(cc.after_statement() == wsrep::client_context::asr_success);
|
||||
BOOST_REQUIRE(tc.streaming_context_.fragments_certified() == 1);
|
||||
BOOST_REQUIRE(cc.before_statement() == 0);
|
||||
BOOST_REQUIRE(cc.before_commit() == 0);
|
||||
BOOST_REQUIRE(cc.ordered_commit() == 0);
|
||||
BOOST_REQUIRE(cc.after_commit() == 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().commit_fragments() == 1);
|
||||
}
|
||||
|
||||
BOOST_FIXTURE_TEST_CASE(transaction_context_statement_streaming_cert_fail,
|
||||
streaming_client_fixture_row)
|
||||
{
|
||||
BOOST_REQUIRE(
|
||||
cc.enable_streaming(
|
||||
wsrep::transaction_context::streaming_context::statement, 1) == 0);
|
||||
BOOST_REQUIRE(cc.start_transaction(1) == 0);
|
||||
BOOST_REQUIRE(cc.after_row() == 0);
|
||||
BOOST_REQUIRE(tc.streaming_context_.fragments_certified() == 0);
|
||||
sc.provider().certify_status_ = wsrep::provider::error_certification_failed;
|
||||
BOOST_REQUIRE(cc.after_statement() == wsrep::client_context::asr_error);
|
||||
BOOST_REQUIRE(cc.current_error() == wsrep::e_deadlock_error);
|
||||
BOOST_REQUIRE(sc.provider().fragments() == 0);
|
||||
BOOST_REQUIRE(sc.provider().start_fragments() == 0);
|
||||
BOOST_REQUIRE(sc.provider().rollback_fragments() == 0);
|
||||
}
|
||||
|
Reference in New Issue
Block a user