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

Change unit tests to mimic application behavior on replaying

Allocate separate client state in mock_client_service::replay()
for replaying step.

Added two new test cases for streaming replication replay after
BF abort.
This commit is contained in:
Teemu Ollakka
2023-05-26 12:47:47 +03:00
parent e238c0d240
commit 9070f2a891
3 changed files with 80 additions and 4 deletions

View File

@ -35,14 +35,42 @@ int wsrep::mock_client_service::bf_rollback()
return ret;
}
struct replayer_context
{
wsrep::mock_client_state state;
wsrep::mock_client_service service;
replayer_context(wsrep::server_state& server_state,
const wsrep::transaction& transaction,
const wsrep::client_id& id)
: state{server_state, service, id, wsrep::client_state::m_high_priority}
, service{&state}
{
state.open(id);
state.before_command();
state.clone_transaction_for_replay(transaction);
}
~replayer_context() {
state.after_applying();
state.after_command_before_result();
state.after_command_after_result();
state.close();
}
};
enum wsrep::provider::status
wsrep::mock_client_service::replay()
{
wsrep::mock_high_priority_service hps(client_state_->server_state(),
client_state_, true);
/* Mimic application and allocate separate client state for replaying. */
wsrep::client_id replayer_id{ 1001 };
replayer_context replayer(client_state_->server_state(),
client_state_->transaction(), replayer_id);
wsrep::mock_high_priority_service hps{ client_state_->server_state(),
&replayer.state, true };
enum wsrep::provider::status ret(
client_state_->provider().replay(
client_state_->transaction().ws_handle(),
replayer.state.transaction().ws_handle(),
&hps));
++replays_;
return ret;