From a295c1320438d9100562cac1a55421334ab16760 Mon Sep 17 00:00:00 2001 From: Dmitriy Pavlov Date: Fri, 15 May 2026 21:44:09 +0300 Subject: [PATCH] IGNITE-28685 draft codex fix --- .../thin-client-test/include/test_server.h | 12 +++++- .../src/ignite_client_test.cpp | 41 +++++++++++++++---- 2 files changed, 45 insertions(+), 8 deletions(-) diff --git a/modules/platforms/cpp/thin-client-test/include/test_server.h b/modules/platforms/cpp/thin-client-test/include/test_server.h index 5b0752e7f096e..75c733d1fce5f 100644 --- a/modules/platforms/cpp/thin-client-test/include/test_server.h +++ b/modules/platforms/cpp/thin-client-test/include/test_server.h @@ -159,6 +159,16 @@ class TestServer responses.push_back(resp); } + /** + * Get port that server is listening on. + * + * @return TCP port. + */ + uint16_t GetPort() const + { + return acceptor.local_endpoint().port(); + } + /** * Get specified session. * @param idx Index. @@ -210,4 +220,4 @@ class TestServer } // namespace ignite -#endif //_IGNITE_THIN_CLIENT_TEST_TEST_SERVER \ No newline at end of file +#endif //_IGNITE_THIN_CLIENT_TEST_TEST_SERVER diff --git a/modules/platforms/cpp/thin-client-test/src/ignite_client_test.cpp b/modules/platforms/cpp/thin-client-test/src/ignite_client_test.cpp index 05ce4fb0707ad..c1079dd6e7bd6 100644 --- a/modules/platforms/cpp/thin-client-test/src/ignite_client_test.cpp +++ b/modules/platforms/cpp/thin-client-test/src/ignite_client_test.cpp @@ -19,6 +19,8 @@ #include #include +#include + #include #include @@ -81,7 +83,7 @@ class IgniteClientTestSuiteFixture */ static void CheckThreadsNum(IgniteClientConfiguration &cfg, uint32_t num) { - ignite::TestServer server; + ignite::TestServer server(0); server.PushHandshakeResponse(true); server.Start(); @@ -95,22 +97,47 @@ class IgniteClientTestSuiteFixture int32_t threadsExpected = static_cast(num) + netThreads; cfg.SetUserThreadPoolSize(num); + + std::stringstream endpoint; + endpoint << "127.0.0.1:" << server.GetPort(); + cfg.SetEndPoints(endpoint.str()); + { IgniteClient client = IgniteClient::Start(cfg); - int32_t threadsActual = ignite::common::concurrent::GetThreadsCount() - threadsBefore; - - BOOST_CHECK_EQUAL(threadsExpected, threadsActual); + BOOST_CHECK(WaitForThreadsCount(threadsBefore + threadsExpected)); } - int32_t threadsAfter = ignite::common::concurrent::GetThreadsCount(); - - BOOST_CHECK_EQUAL(threadsBefore, threadsAfter); + BOOST_CHECK(WaitForThreadsCount(threadsBefore)); BOOST_CHECK_EQUAL(num, cfg.GetUserThreadPoolSize()); server.Stop(); } + /** + * Wait for threads count. + * + * @param expected Expected threads count. + * @return True if condition was met, false if timeout has been reached. + */ + static bool WaitForThreadsCount(int32_t expected) + { + return ignite_test::WaitForCondition( + boost::bind(&IgniteClientTestSuiteFixture::CheckThreadsCount, expected), + 5000); + } + + /** + * Check threads count. + * + * @param expected Expected threads count. + * @return @c true on success. + */ + static bool CheckThreadsCount(int32_t expected) + { + return ignite::common::concurrent::GetThreadsCount() == expected; + } + /** * Check number of active connections. *