summaryrefslogtreecommitdiff
path: root/src/mongo/executor/network_interface_asio_integration_test.cpp
diff options
context:
space:
mode:
authorAdam Midvidy <amidvidy@gmail.com>2015-11-19 12:06:22 -0500
committerAdam Midvidy <amidvidy@gmail.com>2015-11-19 15:48:35 -0500
commita6221d1dba72923083af809efb5cd61625d7eee2 (patch)
treeb4fcb5e212a989d083141e0c8e87464b773edc69 /src/mongo/executor/network_interface_asio_integration_test.cpp
parentb42f5356a233404a5d77229892ebbd37c24001a6 (diff)
downloadmongo-a6221d1dba72923083af809efb5cd61625d7eee2.tar.gz
SERVER-21458 thread request timeout in to ConnectionPool::get in NetworkInterfaceASIO
Diffstat (limited to 'src/mongo/executor/network_interface_asio_integration_test.cpp')
-rw-r--r--src/mongo/executor/network_interface_asio_integration_test.cpp38
1 files changed, 36 insertions, 2 deletions
diff --git a/src/mongo/executor/network_interface_asio_integration_test.cpp b/src/mongo/executor/network_interface_asio_integration_test.cpp
index 9739615e1f2..cb85f273764 100644
--- a/src/mongo/executor/network_interface_asio_integration_test.cpp
+++ b/src/mongo/executor/network_interface_asio_integration_test.cpp
@@ -57,8 +57,7 @@ namespace {
class NetworkInterfaceASIOIntegrationTest : public mongo::unittest::Test {
public:
- void setUp() override {
- NetworkInterfaceASIO::Options options{};
+ void startNet(NetworkInterfaceASIO::Options options = NetworkInterfaceASIO::Options()) {
options.streamFactory = stdx::make_unique<AsyncStreamFactory>();
options.timerFactory = stdx::make_unique<AsyncTimerFactoryASIO>();
options.connectionPoolOptions.maxConnections = 256u;
@@ -143,10 +142,12 @@ private:
};
TEST_F(NetworkInterfaceASIOIntegrationTest, Ping) {
+ startNet();
assertCommandOK("admin", BSON("ping" << 1));
}
TEST_F(NetworkInterfaceASIOIntegrationTest, Timeouts) {
+ startNet();
// This sleep command will take 10 seconds, so we should time out client side first given
// our timeout of 100 milliseconds.
assertCommandFailsOnClient("admin",
@@ -241,6 +242,7 @@ private:
};
TEST_F(NetworkInterfaceASIOIntegrationTest, StressTest) {
+ startNet();
const std::size_t numOps = 10000;
std::vector<Deferred<Status>> ops;
@@ -299,6 +301,38 @@ TEST_F(NetworkInterfaceASIOIntegrationTest, StressTest) {
ASSERT_OK(res);
}
+// Hook that intentionally never finishes
+class HangingHook : public executor::NetworkConnectionHook {
+ Status validateHost(const HostAndPort&, const RemoteCommandResponse&) final {
+ return Status::OK();
+ }
+
+ StatusWith<boost::optional<RemoteCommandRequest>> makeRequest(
+ const HostAndPort& remoteHost) final {
+ return {boost::make_optional(RemoteCommandRequest(remoteHost,
+ "admin",
+ BSON("sleep" << 1 << "lock"
+ << "none"
+ << "secs" << 100000000),
+ BSONObj()))};
+ }
+
+ Status handleReply(const HostAndPort& remoteHost, RemoteCommandResponse&& response) final {
+ MONGO_UNREACHABLE;
+ }
+};
+
+
+// Test that we time out a command if the connection hook hangs.
+TEST_F(NetworkInterfaceASIOIntegrationTest, HookHangs) {
+ NetworkInterfaceASIO::Options options;
+ options.networkConnectionHook = stdx::make_unique<HangingHook>();
+ startNet(std::move(options));
+
+ assertCommandFailsOnClient(
+ "admin", BSON("ping" << 1), Seconds(1), ErrorCodes::ExceededTimeLimit);
+}
+
} // namespace
} // namespace executor
} // namespace mongo