slbotbm commented on code in PR #3691:
URL: https://github.com/apache/iggy/pull/3691#discussion_r3610161617


##########
foreign/cpp/tests/client/low_level_e2e.cpp:
##########
@@ -32,6 +35,29 @@
 
 class LowLevelE2E_Client : public E2ETestFixture {};
 
+namespace {
+
+constexpr auto session_removal_timeout       = std::chrono::seconds(5);
+constexpr auto session_removal_poll_interval = std::chrono::milliseconds(10);
+
+bool wait_for_client_removal(iggy::ffi::Client *observer, std::uint32_t 
client_id) {
+    const auto deadline = std::chrono::steady_clock::now() + 
session_removal_timeout;
+    do {
+        const auto clients = observer->get_clients();
+        const auto removed = std::none_of(clients.begin(), clients.end(),
+                                          [client_id](const auto &client) { 
return client.client_id == client_id; });
+        if (removed) {
+            return true;
+        }
+
+        std::this_thread::sleep_for(session_removal_poll_interval);
+    } while (std::chrono::steady_clock::now() < deadline);
+
+    return false;

Review Comment:
   Let's inline this code into the two tests. I would like to avoid defining ad 
hoc functions since it will become difficult to maintain after some time if 
these types of functions keep on accumulating



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to