diff options
author | Alya Berciu <alya.berciu@mongodb.com> | 2019-06-03 17:57:51 -0400 |
---|---|---|
committer | Alya Berciu <alya.berciu@mongodb.com> | 2019-06-13 16:50:54 -0400 |
commit | f90df932ab3f8c5f279b6f14343fe0efa80c1b9a (patch) | |
tree | 0e4de78f318c9ee03b7352b113e25fbf31c72cce /src/mongo/executor/connection_pool_test.cpp | |
parent | b0a979f1ac92bc5ef9f916107d3c5bb1af236fb2 (diff) | |
download | mongo-f90df932ab3f8c5f279b6f14343fe0efa80c1b9a.tar.gz |
SERVER-35797 Add timeout value to NetworkInterfaceExceededTimeLimit messages
Diffstat (limited to 'src/mongo/executor/connection_pool_test.cpp')
-rw-r--r-- | src/mongo/executor/connection_pool_test.cpp | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/src/mongo/executor/connection_pool_test.cpp b/src/mongo/executor/connection_pool_test.cpp index e839371dbcd..e5775bcdfd5 100644 --- a/src/mongo/executor/connection_pool_test.cpp +++ b/src/mongo/executor/connection_pool_test.cpp @@ -37,6 +37,9 @@ #include <stack> #include <tuple> +#include <fmt/format.h> +#include <fmt/ostream.h> + #include "mongo/executor/connection_pool.h" #include "mongo/stdx/future.h" #include "mongo/unittest/unittest.h" @@ -397,20 +400,24 @@ TEST_F(ConnectionPoolTest, DifferentConnWithoutReturn) { TEST_F(ConnectionPoolTest, TimeoutOnSetup) { auto pool = makePool(); - bool notOk = false; - auto now = Date_t::now(); + Milliseconds hostTimeout = Milliseconds(5000); + PoolImpl::setNow(now); + boost::optional<StatusWith<ConnectionPool::ConnectionHandle>> conn; pool->get_forTest( - HostAndPort(), - Milliseconds(5000), - [&](StatusWith<ConnectionPool::ConnectionHandle> swConn) { notOk = !swConn.isOK(); }); + HostAndPort(), hostTimeout, [&](StatusWith<ConnectionPool::ConnectionHandle> swConn) { + conn = std::move(swConn); + }); - PoolImpl::setNow(now + Milliseconds(5000)); + PoolImpl::setNow(now + hostTimeout); - ASSERT(notOk); + ASSERT(!conn->isOK()); + ASSERT_EQ(conn->getStatus(), ErrorCodes::NetworkInterfaceExceededTimeLimit); + ASSERT_STRING_CONTAINS(conn->getStatus().reason(), + fmt::format("{}", ConnectionPool::kHostRetryTimeout)); } /** |