Skip to content

Commit

Permalink
Test append_entry
Browse files Browse the repository at this point in the history
  • Loading branch information
szmyd committed Oct 4, 2023
1 parent 4fb1fe5 commit 64061ef
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/include/nuraft_mesg/grpc_factory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class grpc_factory : public nuraft::rpc_client_factory, public std::enable_share
NullAsyncResult add_server(uint32_t const srv_id, peer_id_t const& srv_addr, nuraft::srv_config const& dest_cfg);

// Send a client request to the cluster
NullAsyncResult client_request(std::shared_ptr< nuraft::buffer > buf, nuraft::srv_config const& dest_cfg);
NullAsyncResult append_entry(std::shared_ptr< nuraft::buffer > buf, nuraft::srv_config const& dest_cfg);

// Construct and send a RemoveServer message to the cluster
NullAsyncResult rem_server(uint32_t const srv_id, nuraft::srv_config const& dest_cfg);
Expand Down
3 changes: 1 addition & 2 deletions src/lib/grpc_factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,7 @@ NullAsyncResult grpc_factory::rem_server(uint32_t const srv_id, nuraft::srv_conf
return ctx->future();
}

NullAsyncResult grpc_factory::client_request(std::shared_ptr< nuraft::buffer > buf,
nuraft::srv_config const& dest_cfg) {
NullAsyncResult grpc_factory::append_entry(std::shared_ptr< nuraft::buffer > buf, nuraft::srv_config const& dest_cfg) {
auto client = create_client(dest_cfg.get_endpoint());
if (!client) { return folly::makeUnexpected(nuraft::CANCELLED); }

Expand Down
4 changes: 3 additions & 1 deletion src/tests/MessagingTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,9 @@ TEST_F(MessagingFixture, MemberCrash) {
auto buf = nuraft_mesg::create_message(nlohmann::json{
{"op_type", 2},
});
EXPECT_TRUE(!!app_1_->instance_->append_entries(group_id_, {buf}).get());
auto factory = std::make_shared< mesg_factory >(custom_factory_, group_id_, "test_type");
auto const dest_cfg = nuraft::srv_config(to_server_id(app_1_->id_), to_string(app_1_->id_));
EXPECT_TRUE(!!factory->append_entry(buf, dest_cfg).get());

app_3_ = std::make_shared< TestApplication >("sm3", ports[2]);
app_3_->set_id(our_id);
Expand Down
2 changes: 1 addition & 1 deletion test_package/example_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ int send_message(uint32_t leader_id, nuraft_mesg::group_id_t const& group_id, st

auto result = nuraft_mesg::NullResult(folly::makeUnexpected(nuraft::SERVER_IS_JOINING));
while (!result && (nuraft::SERVER_IS_JOINING == result.error() || nuraft::CONFIG_CHANGING == result.error())) {
auto sf = factory->client_request(buf, dest_cfg);
auto sf = factory->append_entry(buf, dest_cfg);
std::this_thread::sleep_for(std::chrono::milliseconds(200));
result = std::move(sf).get();
}
Expand Down

0 comments on commit 64061ef

Please sign in to comment.