summaryrefslogtreecommitdiff
path: root/src/mongo/executor
diff options
context:
space:
mode:
authorSara Golemon <sara.golemon@mongodb.com>2020-03-30 21:22:12 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-03-31 16:46:03 +0000
commit34e80b1d9cfcdadd831daadbcb19ed5dfe40b1d4 (patch)
treef69be7d5cf3c2c0cbd5b5e2d2469adf5f75afac1 /src/mongo/executor
parentfa4a240d42c56c60b1af0ec7f69f5fc8dca28902 (diff)
downloadmongo-34e80b1d9cfcdadd831daadbcb19ed5dfe40b1d4.tar.gz
SERVER-46972 Create test-only command for establishing egress to another node
Diffstat (limited to 'src/mongo/executor')
-rw-r--r--src/mongo/executor/network_interface.h10
-rw-r--r--src/mongo/executor/network_interface_mock.h2
-rw-r--r--src/mongo/executor/network_interface_tl.cpp12
-rw-r--r--src/mongo/executor/network_interface_tl.h5
4 files changed, 29 insertions, 0 deletions
diff --git a/src/mongo/executor/network_interface.h b/src/mongo/executor/network_interface.h
index d269fb2443f..1a5c35aa594 100644
--- a/src/mongo/executor/network_interface.h
+++ b/src/mongo/executor/network_interface.h
@@ -233,6 +233,16 @@ public:
*/
virtual void dropConnections(const HostAndPort& hostAndPort) = 0;
+ /**
+ * Acquire a connection and subsequently release it.
+ * If status is not OK, the connection will be dropped,
+ * otherwise the connection will be returned to the pool.
+ */
+ virtual void testEgress(const HostAndPort& hostAndPort,
+ transport::ConnectSSLMode sslMode,
+ Milliseconds timeout,
+ Status status) = 0;
+
protected:
NetworkInterface();
};
diff --git a/src/mongo/executor/network_interface_mock.h b/src/mongo/executor/network_interface_mock.h
index c67ee4c58a1..bb16bd397ec 100644
--- a/src/mongo/executor/network_interface_mock.h
+++ b/src/mongo/executor/network_interface_mock.h
@@ -139,6 +139,8 @@ public:
void dropConnections(const HostAndPort&) override {}
+ void testEgress(const HostAndPort&, transport::ConnectSSLMode, Milliseconds, Status) override {}
+
////////////////////////////////////////////////////////////////////////////////
//
// Methods for simulating network operations and the passage of time.
diff --git a/src/mongo/executor/network_interface_tl.cpp b/src/mongo/executor/network_interface_tl.cpp
index a988ef76420..d710caaa802 100644
--- a/src/mongo/executor/network_interface_tl.cpp
+++ b/src/mongo/executor/network_interface_tl.cpp
@@ -520,6 +520,18 @@ Status NetworkInterfaceTL::startCommand(const TaskExecutor::CallbackHandle& cbHa
return Status::OK();
}
+void NetworkInterfaceTL::testEgress(const HostAndPort& hostAndPort,
+ transport::ConnectSSLMode sslMode,
+ Milliseconds timeout,
+ Status status) {
+ auto handle = _pool->get(hostAndPort, sslMode, timeout).get();
+ if (status.isOK()) {
+ handle->indicateSuccess();
+ } else {
+ handle->indicateFailure(status);
+ }
+}
+
Future<RemoteCommandResponse> NetworkInterfaceTL::CommandState::sendRequest(size_t reqId) {
auto requestState = requestManager->getRequest(reqId);
invariant(requestState);
diff --git a/src/mongo/executor/network_interface_tl.h b/src/mongo/executor/network_interface_tl.h
index 34bec18a411..942814473be 100644
--- a/src/mongo/executor/network_interface_tl.h
+++ b/src/mongo/executor/network_interface_tl.h
@@ -94,6 +94,11 @@ public:
void dropConnections(const HostAndPort& hostAndPort) override;
+ void testEgress(const HostAndPort& hostAndPort,
+ transport::ConnectSSLMode sslMode,
+ Milliseconds timeout,
+ Status status) override;
+
private:
struct RequestState;
struct RequestManager;