545 static const size_t MAX_OPENED_CONN_COUNT = 100;
548 std::atomic<int> test_state(0);
552 ASSERT_TRUE(epee::net_utils::async_invoke_remote_command2<CMD_START_OPEN_CLOSE_TEST::response>(m_cmd_conn_id, CMD_START_OPEN_CLOSE_TEST::ID, req_start,
554 test_state.store(0 < code ? 1 : -1, std::memory_order_seq_cst);
558 EXPECT_TRUE(busy_wait_for(DEFAULT_OPERATION_TIMEOUT, [&]{
return 1 == test_state.load(std::memory_order_seq_cst); }));
559 ASSERT_EQ(1, test_state.load(std::memory_order_seq_cst));
562 t_connection_opener_1 connection_opener(m_tcp_server, CONNECTION_COUNT);
564 while (connection_opener.open());
568 EXPECT_TRUE(busy_wait_for(DEFAULT_OPERATION_TIMEOUT, [&](){
return CONNECTION_COUNT + RESERVED_CONN_CNT <= m_commands_handler.new_connection_counter() + connection_opener.error_count(); }));
569 LOG_PRINT_L0(
"number of opened connections / fails (total): " << m_commands_handler.new_connection_counter() <<
570 " / " << connection_opener.error_count() <<
" (" << (m_commands_handler.new_connection_counter() + connection_opener.error_count()) <<
")");
571 LOG_PRINT_L0(
"actual number of opened connections: " << m_tcp_server.get_config_object().get_connections_count());
573 ASSERT_GT(m_commands_handler.new_connection_counter(), RESERVED_CONN_CNT);
574 ASSERT_EQ(m_commands_handler.new_connection_counter() + connection_opener.error_count(), CONNECTION_COUNT + RESERVED_CONN_CNT);
578 int last_new_connection_counter = -1;
581 else { last_new_connection_counter = static_cast<int>(stat.new_connection_counter); return false; }
589 busy_wait_for(DEFAULT_OPERATION_TIMEOUT, [&](){
return m_commands_handler.new_connection_counter() <= m_commands_handler.close_connection_counter() + RESERVED_CONN_CNT; });
592 ASSERT_LE(m_commands_handler.close_connection_counter() + RESERVED_CONN_CNT, m_commands_handler.new_connection_counter());
593 ASSERT_LE(RESERVED_CONN_CNT, m_tcp_server.get_config_object().get_connections_count());
597 LOG_PRINT_L0(
"server statistics: " << srv_stat.to_string());
600 ASSERT_EQ(srv_stat.close_connection_counter, srv_stat.new_connection_counter - RESERVED_CONN_CNT);
601 ASSERT_EQ(RESERVED_CONN_CNT, srv_stat.opened_connections_count);
607 CMD_DATA_REQUEST::request req;
608 bool r = epee::net_utils::async_invoke_remote_command2<CMD_DATA_REQUEST::response>(ctx.m_connection_id, CMD_DATA_REQUEST::ID, req,
609 m_tcp_server.get_config_object(), [=](int code, const CMD_DATA_REQUEST::response& rsp, const test_connection_context&) {
612 LOG_PRINT_L0(
"Failed to invoke CMD_DATA_REQUEST. code = " << code);
622 EXPECT_TRUE(busy_wait_for(DEFAULT_OPERATION_TIMEOUT, [&](){
return m_commands_handler.new_connection_counter() - RESERVED_CONN_CNT <= m_commands_handler.close_connection_counter(); }));
623 LOG_PRINT_L0(
"number of opened / closed connections: " << m_tcp_server.get_config_object().get_connections_count() <<
624 " / " << m_commands_handler.close_connection_counter());
627 ASSERT_EQ(m_commands_handler.close_connection_counter(), m_commands_handler.new_connection_counter() - RESERVED_CONN_CNT);
628 ASSERT_EQ(RESERVED_CONN_CNT, m_tcp_server.get_config_object().get_connections_count());
#define EXPECT_TRUE(condition)
bool notify_remote_command2(int command, const t_arg &out_struct, t_transport &transport)
uint64_t max_opened_conn_count
uint64_t close_connection_counter
#define ASSERT_EQ(val1, val2)
#define ASSERT_GT(val1, val2)
uint64_t open_request_target
uint64_t new_connection_counter
#define ASSERT_TRUE(condition)
#define ASSERT_LE(val1, val2)
const boost::uuids::uuid m_connection_id