Skip to content

Commit

Permalink
test: Add test for wait_for_done cancellation
Browse files Browse the repository at this point in the history
  • Loading branch information
Tradias committed Dec 7, 2023
1 parent f0f2110 commit 5027b18
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
23 changes: 23 additions & 0 deletions test/src/test_server_rpc_17.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,29 @@ TEST_CASE_TEMPLATE("ServerRPC resumable read can be cancelled", RPC, test::Clien
CHECK_EQ(grpc::StatusCode::OK, rpc.finish(yield).error_code());
});
}

TEST_CASE_FIXTURE(ServerRPCTest<test::NotifyWhenDoneClientStreamingServerRPC>, "ServerRPC cancel wait_for_done")
{
register_and_perform_three_requests(
[&](ServerRPC& rpc, const asio::yield_context& yield)
{
asio::experimental::make_parallel_group(rpc.wait_for_done(test::ASIO_DEFERRED),
asio::post(asio::bind_executor(grpc_context, test::ASIO_DEFERRED)))
.async_wait(asio::experimental::wait_for_one(), yield);
CHECK_FALSE(rpc.is_done());
CHECK(rpc.send_initial_metadata(yield));
rpc.wait_for_done(yield);
CHECK(rpc.is_done());
CHECK(rpc.context().IsCancelled());
rpc.wait_for_done(yield);
},
[&](Request& request, Response& response, const asio::yield_context& yield)
{
auto rpc = create_rpc();
CHECK(start_rpc(rpc, request, response, yield));
CHECK(rpc.read_initial_metadata(yield));
});
}
#endif

// Callback
Expand Down
1 change: 1 addition & 0 deletions test/utils/utils/protobuf.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#define AGRPC_UTILS_PROTOBUF_HPP

#include <doctest/doctest.h>
#include <grpcpp/impl/codegen/proto_utils.h>
#include <grpcpp/support/proto_buffer_reader.h>
#include <grpcpp/support/proto_buffer_writer.h>

Expand Down

0 comments on commit 5027b18

Please sign in to comment.