12
12
13
13
#include < memory>
14
14
#include < optional>
15
+ #include < ostream>
15
16
#include < string_view>
16
17
#include < thread>
17
18
#include < chrono>
18
19
19
20
using namespace clickhouse ;
20
21
22
+ namespace clickhouse {
23
+ std::ostream & operator << (std::ostream & ostr, const Endpoint & endpoint) {
24
+ return ostr << endpoint.host << " :" << endpoint.port ;
25
+ }
26
+ }
21
27
22
28
template <typename T>
23
29
std::shared_ptr<T> createTableWithOneColumn (Client & client, const std::string & table_name, const std::string & column_name)
@@ -1431,7 +1437,7 @@ TEST(SimpleClientTest, issue_335_reconnects_count) {
1431
1437
std::unique_ptr<SocketFactory> wrapped_socket_factory = std::make_unique<NonSecureSocketFactory>();
1432
1438
std::unique_ptr<SocketFactory> socket_factory = std::make_unique<CountingSocketFactoryAdapter>(*wrapped_socket_factory, connect_requests);
1433
1439
1434
- const auto endpoints = {
1440
+ const std::vector<Endpoint> endpoints = {
1435
1441
Endpoint{" foo-invalid-hostname" , 1234 },
1436
1442
Endpoint{" bar-invalid-hostname" , 4567 },
1437
1443
};
@@ -1444,4 +1450,14 @@ TEST(SimpleClientTest, issue_335_reconnects_count) {
1444
1450
);
1445
1451
1446
1452
EXPECT_EQ (endpoints.size (), connect_requests.size ());
1453
+ // make sure there was an attempt to connect to each endpoint at least once.
1454
+ for (const auto & endpoint : endpoints)
1455
+ {
1456
+ auto p = std::find_if (connect_requests.begin (), connect_requests.end (), [&endpoint](const auto & connect_request) {
1457
+ return connect_request.second == endpoint;
1458
+ });
1459
+
1460
+ EXPECT_TRUE (connect_requests.end () != p)
1461
+ << " \t There was no attempt to connect to endpoint " << endpoint;
1462
+ }
1447
1463
}
0 commit comments