Skip to content

Commit

Permalink
[coro_io] add more output to test (#467)
Browse files Browse the repository at this point in the history
  • Loading branch information
poor-circle authored Sep 25, 2023
1 parent ea977aa commit 8620086
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
4 changes: 4 additions & 0 deletions include/ylt/coro_io/client_pool.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,10 @@ class client_pools {
ELOG_DEBUG << "add new client pool of {" << host_name
<< "} to hash table";
}
else {
ELOG_DEBUG << "add new client pool of {" << host_name
<< "} failed, element existed.";
}
}
return iter->second;
}
Expand Down
11 changes: 10 additions & 1 deletion src/coro_io/tests/test_client_pool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ TEST_CASE("test client pool") {
CHECK(pool->free_client_count() == 0);
server.stop();
}());
ELOG_DEBUG << "test client pool over.";
}
TEST_CASE("test idle timeout yield") {
async_simple::coro::syncAwait([]() -> async_simple::coro::Lazy<void> {
Expand All @@ -127,6 +128,7 @@ TEST_CASE("test idle timeout yield") {
CHECK(pool->free_client_count() == 0);
server.stop();
}());
ELOG_DEBUG << "test idle timeout yield over.";
}

TEST_CASE("test reconnect") {
Expand All @@ -149,6 +151,7 @@ TEST_CASE("test reconnect") {
server.stop();
co_return;
}());
ELOG_DEBUG << "test reconnect over.";
}

struct mock_client : public coro_rpc::coro_rpc_client {
Expand All @@ -161,7 +164,7 @@ struct mock_client : public coro_rpc::coro_rpc_client {
co_return ec;
}
};
TEST_CASE("test reconnect retry wait time exinclude reconnect cost time") {
TEST_CASE("test reconnect retry wait time exclude reconnect cost time") {
async_simple::coro::syncAwait([]() -> async_simple::coro::Lazy<void> {
auto tp = std::chrono::steady_clock::now();
auto pool = coro_io::client_pool<mock_client>::create(
Expand All @@ -184,6 +187,8 @@ TEST_CASE("test reconnect retry wait time exinclude reconnect cost time") {
server.stop();
co_return;
}());
ELOG_DEBUG
<< "test reconnect retry wait time exclude reconnect cost time over.";
}

TEST_CASE("test collect_free_client") {
Expand All @@ -204,6 +209,7 @@ TEST_CASE("test collect_free_client") {
server.stop();
co_return;
}());
ELOG_DEBUG << "test collect_free_client over.";
}

TEST_CASE("test client pools parallel r/w") {
Expand All @@ -214,8 +220,10 @@ TEST_CASE("test client pools parallel r/w") {
CHECK(cli->get_host_name() == std::to_string(i));
}
auto rw = [&pool](int i) -> Lazy<void> {
ELOG_DEBUG << "start to insert {" << i << "} to hash table.";
auto cli = pool[std::to_string(i)];
CHECK(cli->get_host_name() == std::to_string(i));
ELOG_DEBUG << "end to insert {" << i << "} to hash table.";
co_return;
};

Expand All @@ -228,4 +236,5 @@ TEST_CASE("test client pools parallel r/w") {
}
co_await collectAll(std::move(works));
}());
ELOG_DEBUG << "test client pools parallel r/w over.";
}

0 comments on commit 8620086

Please sign in to comment.