[COMMIT seastar master] tests: rpc_test: simple test for connection aborting

0 views
Skip to first unread message

Commit Bot

<bot@cloudius-systems.com>
unread,
May 25, 2023, 6:29:37 AM5/25/23
to seastar-dev@googlegroups.com, Kamil Braun
From: Kamil Braun <kbr...@scylladb.com>
Committer: Kamil Braun <kbr...@scylladb.com>
Branch: master

tests: rpc_test: simple test for connection aborting

The handler aborts the connection after receiving the second message.
The response to that message won't be received, and the third message
won't arrive at this connection.

---
diff --git a/tests/unit/rpc_test.cc b/tests/unit/rpc_test.cc
--- a/tests/unit/rpc_test.cc
+++ b/tests/unit/rpc_test.cc
@@ -1500,3 +1500,25 @@ SEASTAR_TEST_CASE(test_rpc_send_timeout_on_connect) {
send_messages_and_check_timeouts(env, cln);
});
}
+
+SEASTAR_TEST_CASE(test_rpc_abort_connection) {
+ return rpc_test_env<>::do_with_thread(rpc_test_config(), [] (rpc_test_env<>& env) {
+ test_rpc_proto::client c1(env.proto(), {}, env.make_socket(), ipv4_addr());
+ int arrived = 0;
+ env.register_handler(1, [&arrived] (rpc::client_info& cinfo, int x) {
+ BOOST_REQUIRE_EQUAL(x, arrived++);
+ if (arrived == 2) {
+ cinfo.server.abort_connection(cinfo.conn_id);
+ }
+ // The third message won't arrive because we abort the connection.
+
+ return 0;
+ }).get();
+ auto f = env.proto().make_client<int (int)>(1);
+ BOOST_REQUIRE_EQUAL(f(c1, 0).get0(), 0);
+ BOOST_REQUIRE_THROW(f(c1, 1).get0(), rpc::closed_error);
+ BOOST_REQUIRE_THROW(f(c1, 2).get0(), rpc::closed_error);
+ BOOST_REQUIRE_EQUAL(arrived, 2);
+ c1.stop().get0();
+ });
+}
Reply all
Reply to author
Forward
0 new messages