From 900bcc333981add129f422a3126b29b855b3bd32 Mon Sep 17 00:00:00 2001 From: t-horikawa Date: Wed, 1 May 2024 17:50:20 +0900 Subject: [PATCH] introduce the chain of responsibility pattern to the processing of the routing service --- src/tateyama/endpoint/common/worker_common.h | 61 +++++++++++++++---- .../endpoint/ipc/bootstrap/ipc_worker.cpp | 39 +++++++++--- .../stream/bootstrap/stream_worker.cpp | 31 +++++++--- src/tateyama/framework/routing_service.cpp | 33 +++++----- src/tateyama/proto/core/request.proto | 26 +++++++- src/tateyama/proto/core/response.proto | 5 ++ src/tateyama/proto/endpoint/request.proto | 27 +------- src/tateyama/proto/endpoint/response.proto | 5 -- test/tateyama/endpoint/ipc/ipc_info_test.cpp | 5 +- .../endpoint/ipc/ipc_session_test.cpp | 8 +-- test/tateyama/endpoint/ipc/ipc_store_test.cpp | 4 +- .../endpoint/stream/stream_info_test.cpp | 7 ++- .../endpoint/stream/stream_session_test.cpp | 26 ++++---- .../endpoint/stream/stream_store_test.cpp | 6 +- test/tateyama/framework/router_test.cpp | 8 +-- 15 files changed, 181 insertions(+), 110 deletions(-) diff --git a/src/tateyama/endpoint/common/worker_common.h b/src/tateyama/endpoint/common/worker_common.h index 7e96b792..4dcc84c8 100644 --- a/src/tateyama/endpoint/common/worker_common.h +++ b/src/tateyama/endpoint/common/worker_common.h @@ -35,6 +35,8 @@ #include #include +#include +#include #include #include "request.h" @@ -249,19 +251,43 @@ class worker_common { return true; } - case tateyama::proto::endpoint::request::Request::kShutdown: + default: // error { - VLOG_LP(log_trace) << "received shutdown request, slot = " << slot; //NOLINT + std::stringstream ss; + ss << "bad request for endpoint: " << rq.command_case(); + LOG(INFO) << ss.str(); + notify_client(res.get(), tateyama::proto::diagnostics::Code::INVALID_REQUEST, ss.str()); + } + return false; + } + } + + bool routing_service_chain(const std::shared_ptr& req, + const std::shared_ptr& res) { + auto data = req->payload(); + tateyama::proto::core::request::Request rq{}; + if(! rq.ParseFromArray(data.data(), static_cast(data.size()))) { + std::string error_message{"request parse error"}; + LOG(INFO) << error_message; + notify_client(res.get(), tateyama::proto::diagnostics::Code::INVALID_REQUEST, error_message); + return false; + } + + switch (rq.command_case()) { + + case tateyama::proto::core::request::Request::kShutdown: + { + VLOG_LP(log_trace) << "received shutdown request"; //NOLINT { tateyama::session::shutdown_request_type shutdown_type{}; switch (rq.shutdown().type()) { - case tateyama::proto::endpoint::request::ShutdownType::SHUTDOWN_TYPE_NOT_SET: + case tateyama::proto::core::request::ShutdownType::SHUTDOWN_TYPE_NOT_SET: shutdown_type = tateyama::session::shutdown_request_type::forceful; break; - case tateyama::proto::endpoint::request::ShutdownType::GRACEFUL: + case tateyama::proto::core::request::ShutdownType::GRACEFUL: shutdown_type = tateyama::session::shutdown_request_type::graceful; break; - case tateyama::proto::endpoint::request::ShutdownType::FORCEFUL: + case tateyama::proto::core::request::ShutdownType::FORCEFUL: shutdown_type = tateyama::session::shutdown_request_type::forceful; break; default: // error @@ -270,7 +296,7 @@ class worker_common { request_shutdown(shutdown_type); // FIXME confirm when response should be sent - tateyama::proto::endpoint::response::Shutdown rp{}; + tateyama::proto::core::response::Shutdown rp{}; auto body = rp.SerializeAsString(); res->body(body); return true; @@ -278,14 +304,25 @@ class worker_common { return true; } - default: // error + case tateyama::proto::core::request::Request::kUpdateExpirationTime: { - std::stringstream ss; - ss << "bad request (cancel in endpoint): " << rq.command_case(); - LOG(INFO) << ss.str(); - notify_client(res.get(), tateyama::proto::diagnostics::Code::INVALID_REQUEST, ss.str()); + // mock impl. for UpdateExpirationTime // TODO + auto et = rq.update_expiration_time().expiration_time(); + VLOG_LP(log_debug) << + "UpdateExpirationTime received session_id:" << req->session_id() << + " expiration_time:" << et; + tateyama::proto::core::response::UpdateExpirationTime rp{}; + rp.mutable_success(); + res->session_id(req->session_id()); + auto body = rp.SerializeAsString(); + res->body(body); + rp.clear_success(); + return true; } - return false; + + default: + // this request can not be handled here; + return false; } } diff --git a/src/tateyama/endpoint/ipc/bootstrap/ipc_worker.cpp b/src/tateyama/endpoint/ipc/bootstrap/ipc_worker.cpp index ec7c0c22..dc6b7038 100644 --- a/src/tateyama/endpoint/ipc/bootstrap/ipc_worker.cpp +++ b/src/tateyama/endpoint/ipc/bootstrap/ipc_worker.cpp @@ -81,23 +81,44 @@ void Worker::do_work() { register_reqres(index, std::dynamic_pointer_cast(request), std::dynamic_pointer_cast(response)); - if (request->service_id() != tateyama::framework::service_id_endpoint_broker) { + bool exit_frag = false; + switch (request->service_id()) { + case tateyama::framework::service_id_endpoint_broker: + if (!endpoint_service(std::dynamic_pointer_cast(request), + std::dynamic_pointer_cast(response), + index)) { + VLOG_LP(log_info) << "terminate worker because endpoint service returns an error"; + exit_frag = true; + } + break; + + case tateyama::framework::service_id_routing: + if (routing_service_chain(std::dynamic_pointer_cast(request), + std::dynamic_pointer_cast(response))) { + break; + } + if (!service_(std::dynamic_pointer_cast(request), + std::dynamic_pointer_cast(response))) { + VLOG_LP(log_info) << "terminate worker because service returns an error"; + exit_frag = true; + } + break; + + default: if (!is_shuttingdown()) { if (!service_(std::dynamic_pointer_cast(request), std::dynamic_pointer_cast(response))) { VLOG_LP(log_info) << "terminate worker because service returns an error"; - break; + exit_frag = true; } } else { notify_client(response.get(), tateyama::proto::diagnostics::SESSION_CLOSED, ""); } - } else { - if (!endpoint_service(std::dynamic_pointer_cast(request), - std::dynamic_pointer_cast(response), - index)) { - VLOG_LP(log_info) << "terminate worker because endpoint service returns an error"; - break; - } + break; + + } + if (exit_frag) { + break; } request->dispose(); request = nullptr; diff --git a/src/tateyama/endpoint/stream/bootstrap/stream_worker.cpp b/src/tateyama/endpoint/stream/bootstrap/stream_worker.cpp index e7e5976d..d9bca068 100644 --- a/src/tateyama/endpoint/stream/bootstrap/stream_worker.cpp +++ b/src/tateyama/endpoint/stream/bootstrap/stream_worker.cpp @@ -85,7 +85,29 @@ void stream_worker::do_work() register_reqres(slot, std::dynamic_pointer_cast(request), std::dynamic_pointer_cast(response)); - if (request->service_id() != tateyama::framework::service_id_endpoint_broker) { + switch (request->service_id()) { + case tateyama::framework::service_id_endpoint_broker: + if (endpoint_service(std::dynamic_pointer_cast(request), + std::dynamic_pointer_cast(response), + slot)) { + continue; + } + VLOG_LP(log_info) << "terminate worker because endpoint service returns an error"; + break; + + case tateyama::framework::service_id_routing: + if (routing_service_chain(std::dynamic_pointer_cast(request), + std::dynamic_pointer_cast(response))) { + continue; + } + if (service_(std::dynamic_pointer_cast(request), + std::dynamic_pointer_cast(response))) { + continue; + } + VLOG_LP(log_info) << "terminate worker because service returns an error"; + break; + + default: if (!is_shuttingdown()) { if(service_(std::dynamic_pointer_cast(request), std::dynamic_pointer_cast(response))) { @@ -96,13 +118,6 @@ void stream_worker::do_work() notify_client(response.get(), tateyama::proto::diagnostics::SESSION_CLOSED, ""); continue; } - } else { - if (endpoint_service(std::dynamic_pointer_cast(request), - std::dynamic_pointer_cast(response), - slot)) { - continue; - } - VLOG_LP(log_info) << "terminate worker because endpoint service returns an error"; } request = nullptr; response = nullptr; diff --git a/src/tateyama/framework/routing_service.cpp b/src/tateyama/framework/routing_service.cpp index 981fdf7b..ec857201 100644 --- a/src/tateyama/framework/routing_service.cpp +++ b/src/tateyama/framework/routing_service.cpp @@ -31,6 +31,7 @@ #include #include +#include namespace tateyama::framework { @@ -59,7 +60,7 @@ bool routing_service::shutdown(environment&) { return true; } -bool handle_update_expiration_time( +static bool service_( std::shared_ptr const& req, std::shared_ptr const& res ) { @@ -70,26 +71,20 @@ bool handle_update_expiration_time( VLOG_LP(log_error) << "request parse error"; return false; } - if(rq.command_case() != ns::Request::kUpdateExpirationTime) { + tateyama::proto::diagnostics::Record record{}; + switch (rq.command_case()) { + case ns::Request::kUpdateExpirationTime: + LOG_LP(INFO) << "does not support UpdateExpirationTime for this endpoint"; + record.set_code(tateyama::proto::diagnostics::Code::UNSUPPORTED_OPERATION); + res->error(record); + return true; + + default: + record.set_code(tateyama::proto::diagnostics::Code::UNKNOWN); + res->error(record); LOG_LP(ERROR) << "bad request destination (routing service): " << rq.command_case(); return false; } - if(! rq.has_update_expiration_time()) { - LOG_LP(ERROR) << "bad request content"; - return false; - } - // mock impl. for UpdateExpirationTime // TODO - auto et = rq.update_expiration_time().expiration_time(); - VLOG_LP(log_debug) << - "UpdateExpirationTime received session_id:" << req->session_id() << - " expiration_time:" << et; - tateyama::proto::core::response::UpdateExpirationTime rp{}; - rp.mutable_success(); - res->session_id(req->session_id()); - auto body = rp.SerializeAsString(); - res->body(body); - rp.clear_success(); - return true; } bool routing_service::operator()(std::shared_ptr req, std::shared_ptr res) { @@ -99,7 +94,7 @@ bool routing_service::operator()(std::shared_ptr req, std::shared_ptrservice_id() == tag) { // must be UpdateExpirationTime - return handle_update_expiration_time(req, res); + return service_(req, res); } if (auto destination = services_->find_by_id(req->service_id()); destination != nullptr) { destination->operator()(std::move(req), std::move(res)); diff --git a/src/tateyama/proto/core/request.proto b/src/tateyama/proto/core/request.proto index 810617ba..4a446574 100644 --- a/src/tateyama/proto/core/request.proto +++ b/src/tateyama/proto/core/request.proto @@ -19,9 +19,13 @@ message Request { // the request command. oneof command { + // update session expiration time operation. UpdateExpirationTime update_expiration_time = 11; + + // shutdown operation. + Shutdown shutdown = 12; } - reserved 12 to 99; + reserved 13 to 99; } // update session expiration time @@ -30,3 +34,23 @@ message UpdateExpirationTime { // the expiration time (milliseconds from now) to be set uint64 expiration_time = 1; } + +// kind of shutdown type. +enum ShutdownType { + + // The default shutdown type. + SHUTDOWN_TYPE_NOT_SET = 0; + + // Waits for the ongoing requests and safely shutdown the session. + GRACEFUL = 1; + + // Cancelling the ongoing requests and safely shutdown the session. + FORCEFUL = 2; +} + +// request shutdown to the session. +message Shutdown { + + // the shutdown type. + ShutdownType type = 1; +} \ No newline at end of file diff --git a/src/tateyama/proto/core/response.proto b/src/tateyama/proto/core/response.proto index 9a8842a3..c90a7285 100644 --- a/src/tateyama/proto/core/response.proto +++ b/src/tateyama/proto/core/response.proto @@ -28,3 +28,8 @@ message UpdateExpirationTime { UnknownError unknown_error = 12; } } + +// shutdown operation. +message Shutdown { + // no special message +} \ No newline at end of file diff --git a/src/tateyama/proto/endpoint/request.proto b/src/tateyama/proto/endpoint/request.proto index b42fb919..72939166 100644 --- a/src/tateyama/proto/endpoint/request.proto +++ b/src/tateyama/proto/endpoint/request.proto @@ -24,11 +24,8 @@ message Request { // cancel operation. Cancel cancel = 12; - - // shutdown operation. - Shutdown shutdown = 13; } - reserved 14 to 99; + reserved 13 to 99; } // handshake operation. @@ -83,24 +80,4 @@ message WireInformation { // cancel operation. message Cancel { // no special properties. -} - -// kind of shutdown type. -enum ShutdownType { - - // The default shutdown type. - SHUTDOWN_TYPE_NOT_SET = 0; - - // Waits for the ongoing requests and safely shutdown the session. - GRACEFUL = 1; - - // Cancelling the ongoing requests and safely shutdown the session. - FORCEFUL = 2; -} - -// request shutdown to the session. -message Shutdown { - - // the shutdown type. - ShutdownType type = 1; -} +} \ No newline at end of file diff --git a/src/tateyama/proto/endpoint/response.proto b/src/tateyama/proto/endpoint/response.proto index 8a99ade2..a6ea3d02 100644 --- a/src/tateyama/proto/endpoint/response.proto +++ b/src/tateyama/proto/endpoint/response.proto @@ -38,9 +38,4 @@ message Handshake { // the session id. uint64 session_id = 11; } -} - -// shutdown operation. -message Shutdown { - // no special message } \ No newline at end of file diff --git a/test/tateyama/endpoint/ipc/ipc_info_test.cpp b/test/tateyama/endpoint/ipc/ipc_info_test.cpp index 357f0a29..2da15862 100644 --- a/test/tateyama/endpoint/ipc/ipc_info_test.cpp +++ b/test/tateyama/endpoint/ipc/ipc_info_test.cpp @@ -45,6 +45,7 @@ static constexpr std::size_t datachannel_buffer_size = 64 * 1024; static constexpr tateyama::common::wire::message_header::index_type index_ = 1; static constexpr std::string_view response_test_message = "opqrstuvwxyz"; static constexpr std::string_view request_test_message = "abcdefgh"; +static constexpr std::size_t service_id_of_info_service = 101; class info_service : public tateyama::framework::routing_service { public: @@ -53,7 +54,7 @@ class info_service : public tateyama::framework::routing_service { bool shutdown(tateyama::framework::environment&) { return true; } std::string_view label() const noexcept { return __func__; } - id_type id() const noexcept { return 100; } // dummy + id_type id() const noexcept { return service_id_of_info_service; } bool operator ()(std::shared_ptr req, std::shared_ptr res) override { req_ = req; @@ -109,7 +110,7 @@ TEST_F(ipc_info_test, basic) { cci.release_credential(); hs.release_client_information(); - client->send(0, std::string(request_test_message)); // we do not care service_id nor request message here + client->send(service_id_of_info_service, std::string(request_test_message)); // we do not care service_id nor request message here std::string res{}; client->receive(res); diff --git a/test/tateyama/endpoint/ipc/ipc_session_test.cpp b/test/tateyama/endpoint/ipc/ipc_session_test.cpp index fc189b5f..ed8a75e1 100644 --- a/test/tateyama/endpoint/ipc/ipc_session_test.cpp +++ b/test/tateyama/endpoint/ipc/ipc_session_test.cpp @@ -47,15 +47,15 @@ static constexpr std::string_view database_name = "ipc_session_test"; static constexpr std::size_t datachannel_buffer_size = 64 * 1024; static constexpr std::string_view request_test_message = "abcdefgh"; static constexpr std::string_view response_test_message = "opqrstuvwxyz"; -static constexpr std::size_t service_id_of_session_service = 0; +static constexpr std::size_t service_id_of_session_service = 100; -class session_service : public tateyama::framework::routing_service { +class service_for_ipc_session_test : public tateyama::framework::routing_service { public: bool setup(tateyama::framework::environment&) { return true; } bool start(tateyama::framework::environment&) { return true; } bool shutdown(tateyama::framework::environment&) { return true; } - id_type id() const noexcept { return 100; } // dummy + id_type id() const noexcept { return service_id_of_session_service; } bool operator ()(std::shared_ptr req, std::shared_ptr res) override { req_ = req; @@ -129,7 +129,7 @@ class ipc_session_test : public ::testing::Test { protected: tateyama::status_info::resource::database_info_impl database_info_{database_name}; - session_service service_{}; + service_for_ipc_session_test service_{}; std::unique_ptr worker_{}; std::shared_ptr session_bridge_{}; std::unique_ptr client_{}; diff --git a/test/tateyama/endpoint/ipc/ipc_store_test.cpp b/test/tateyama/endpoint/ipc/ipc_store_test.cpp index f351bddc..37c3818a 100644 --- a/test/tateyama/endpoint/ipc/ipc_store_test.cpp +++ b/test/tateyama/endpoint/ipc/ipc_store_test.cpp @@ -51,7 +51,7 @@ static constexpr std::size_t datachannel_buffer_size = 64 * 1024; static constexpr tateyama::common::wire::message_header::index_type index_ = 1; static constexpr std::string_view response_test_message = "opqrstuvwxyz"; static constexpr std::string_view request_test_message = "abcdefgh"; -static constexpr std::size_t service_id_of_store_service = 0; +static constexpr std::size_t service_id_of_store_service = 102; class store_service : public tateyama::framework::routing_service { public: @@ -60,7 +60,7 @@ class store_service : public tateyama::framework::routing_service { bool shutdown(tateyama::framework::environment&) { return true; } std::string_view label() const noexcept { return __func__; } - id_type id() const noexcept { return 100; } // dummy + id_type id() const noexcept { return service_id_of_store_service; } bool operator ()(std::shared_ptr req, std::shared_ptr res) override { req_ = req; diff --git a/test/tateyama/endpoint/stream/stream_info_test.cpp b/test/tateyama/endpoint/stream/stream_info_test.cpp index da944a67..83ca17a4 100644 --- a/test/tateyama/endpoint/stream/stream_info_test.cpp +++ b/test/tateyama/endpoint/stream/stream_info_test.cpp @@ -25,9 +25,10 @@ static constexpr std::string_view label = "label_fot_test"; static constexpr std::string_view application_name = "application_name_fot_test"; -static constexpr std::size_t my_session_id_ = 123; +static constexpr std::size_t my_session_id_ = 1234; static constexpr std::string_view request_test_message = "abcdefgh"; static constexpr std::string_view response_test_message = "opqrstuvwxyz"; +static constexpr std::size_t service_id_of_info_service = 122; namespace tateyama::endpoint::stream { @@ -38,7 +39,7 @@ class info_service_for_test : public tateyama::framework::routing_service { bool shutdown(tateyama::framework::environment&) { return true; } std::string_view label() const noexcept { return __func__; } - id_type id() const noexcept { return 100; } // dummy + id_type id() const noexcept { return service_id_of_info_service; } bool operator ()(std::shared_ptr req, std::shared_ptr res) override { req_ = req; @@ -119,7 +120,7 @@ TEST_F(stream_info_test, basic) { tateyama::proto::endpoint::request::Handshake hs{}; hs.set_allocated_client_information(&cci); auto client = std::make_unique(hs); - client->send(0, request_test_message); // we do not care service_id nor request message here + client->send(service_id_of_info_service, request_test_message); // we do not care service_id nor request message here cci.release_credential(); hs.release_client_information(); client->receive(); diff --git a/test/tateyama/endpoint/stream/stream_session_test.cpp b/test/tateyama/endpoint/stream/stream_session_test.cpp index 279618d5..ddc68430 100644 --- a/test/tateyama/endpoint/stream/stream_session_test.cpp +++ b/test/tateyama/endpoint/stream/stream_session_test.cpp @@ -25,20 +25,20 @@ #include -static constexpr std::size_t my_session_id = 123; +static constexpr std::size_t my_session_id = 1234; static constexpr std::string_view request_test_message = "abcdefgh"; static constexpr std::string_view response_test_message = "opqrstuvwxyz"; -static constexpr std::size_t service_id_of_session_service = 0; +static constexpr std::size_t service_id_of_session_service = 121; namespace tateyama::endpoint::stream { -class service_for_session_test : public tateyama::framework::routing_service { +class service_for_stream_session_test : public tateyama::framework::routing_service { public: bool setup(tateyama::framework::environment&) { return true; } bool start(tateyama::framework::environment&) { return true; } bool shutdown(tateyama::framework::environment&) { return true; } - id_type id() const noexcept { return 100; } // dummy + id_type id() const noexcept { return service_id_of_session_service; } bool operator ()(std::shared_ptr req, std::shared_ptr res) override { req_ = req; @@ -88,7 +88,7 @@ class service_for_session_test : public tateyama::framework::routing_service { class stream_listener_for_session_test { public: - stream_listener_for_session_test(service_for_session_test& service, std::shared_ptr session_bridge) : + stream_listener_for_session_test(service_for_stream_session_test& service, std::shared_ptr session_bridge) : service_(service), session_bridge_(session_bridge) { } @@ -121,7 +121,7 @@ class stream_listener_for_session_test { } private: - service_for_session_test& service_; + service_for_stream_session_test& service_; std::shared_ptr session_bridge_; connection_socket connection_socket_{tateyama::api::endpoint::stream::stream_client::PORT_FOR_TEST}; std::unique_ptr worker_{}; @@ -156,7 +156,7 @@ class stream_session_test : public ::testing::Test { public: std::shared_ptr session_bridge_{}; std::unique_ptr listener_{}; - tateyama::endpoint::stream::service_for_session_test service_{}; + tateyama::endpoint::stream::service_for_stream_session_test service_{}; std::thread thread_{}; std::unique_ptr client_{}; }; @@ -164,7 +164,7 @@ class stream_session_test : public ::testing::Test { TEST_F(stream_session_test, cancel_request_reply) { try { // client part (send request) - EXPECT_TRUE(client_->send(0, request_test_message)); // we do not care service_id nor request message here + EXPECT_TRUE(client_->send(service_id_of_session_service, request_test_message)); // we do not care service_id nor request message here // client part (send cancel) tateyama::proto::endpoint::request::Cancel cancel{}; @@ -196,7 +196,7 @@ TEST_F(stream_session_test, cancel_request_reply) { TEST_F(stream_session_test, cancel_request_noreply) { try { // client part (send request) - EXPECT_TRUE(client_->send(0, request_test_message)); // we do not care service_id nor request message here + EXPECT_TRUE(client_->send(service_id_of_session_service, request_test_message)); // we do not care service_id nor request message here // client part (send cancel) tateyama::proto::endpoint::request::Cancel cancel{}; @@ -228,7 +228,7 @@ TEST_F(stream_session_test, cancel_request_noreply) { TEST_F(stream_session_test, forceful_shutdown_after_request) { try { // client part (send request) - EXPECT_TRUE(client_->send(0, std::string(request_test_message))); // we do not care service_id nor request message here + EXPECT_TRUE(client_->send(service_id_of_session_service, std::string(request_test_message))); // we do not care service_id nor request message here service_.wait_request_arrival(); // shutdown request @@ -288,7 +288,7 @@ TEST_F(stream_session_test, forceful_shutdown_before_request) { EXPECT_EQ(listener_->worker()->wait_for(), std::future_status::ready); // client part (send request) - EXPECT_FALSE(client_->send(0, std::string(request_test_message))); + EXPECT_FALSE(client_->send(service_id_of_session_service, std::string(request_test_message))); } catch (std::runtime_error &ex) { std::cout << ex.what() << std::endl; FAIL(); @@ -298,7 +298,7 @@ TEST_F(stream_session_test, forceful_shutdown_before_request) { TEST_F(stream_session_test, graceful_shutdown_after_request) { try { // client part (send request) - EXPECT_TRUE(client_->send(0, std::string(request_test_message))); // we do not care service_id nor request message here + EXPECT_TRUE(client_->send(service_id_of_session_service, std::string(request_test_message))); // we do not care service_id nor request message here service_.wait_request_arrival(); // shutdown request @@ -358,7 +358,7 @@ TEST_F(stream_session_test, graceful_shutdown_before_request) { EXPECT_EQ(listener_->worker()->wait_for(), std::future_status::ready); // client part (send request) - EXPECT_FALSE(client_->send(0, std::string(request_test_message))); + EXPECT_FALSE(client_->send(service_id_of_session_service, std::string(request_test_message))); } catch (std::runtime_error &ex) { std::cout << ex.what() << std::endl; FAIL(); diff --git a/test/tateyama/endpoint/stream/stream_store_test.cpp b/test/tateyama/endpoint/stream/stream_store_test.cpp index 58d6c7de..1cc7d2ef 100644 --- a/test/tateyama/endpoint/stream/stream_store_test.cpp +++ b/test/tateyama/endpoint/stream/stream_store_test.cpp @@ -26,10 +26,10 @@ #include -static constexpr std::size_t my_session_id_ = 123; +static constexpr std::size_t my_session_id_ = 1234; static constexpr std::string_view request_test_message = "abcdefgh"; static constexpr std::string_view response_test_message = "opqrstuvwxyz"; -static constexpr std::size_t service_id_of_store_service = 0; +static constexpr std::size_t service_id_of_store_service = 123; namespace tateyama::endpoint::stream { @@ -40,7 +40,7 @@ class store_service_for_test : public tateyama::framework::routing_service { bool shutdown(tateyama::framework::environment&) { return true; } std::string_view label() const noexcept { return __func__; } - id_type id() const noexcept { return 100; } // dummy + id_type id() const noexcept { return service_id_of_store_service; } bool operator ()(std::shared_ptr req, std::shared_ptr res) override { req_ = req; diff --git a/test/tateyama/framework/router_test.cpp b/test/tateyama/framework/router_test.cpp index 5838fc3d..2cbc83a1 100644 --- a/test/tateyama/framework/router_test.cpp +++ b/test/tateyama/framework/router_test.cpp @@ -194,10 +194,10 @@ TEST_F(router_test, update_expiration_time) { (*router)(svrreq, svrres); ASSERT_FALSE(svc0->called_); - auto pl = svrreq->payload(); - ::tateyama::proto::core::response::UpdateExpirationTime out{}; - ASSERT_TRUE(out.ParseFromArray(pl.data(), pl.size())); - EXPECT_TRUE(out.has_success()); + // update_expiration_time is now handled at the endpoint + ASSERT_TRUE(svrres->error_invoked_); + ASSERT_EQ(svrres->error_record_.code(), ::tateyama::proto::diagnostics::Code::UNSUPPORTED_OPERATION); + sv.shutdown(); }