summaryrefslogtreecommitdiff
path: root/src/mongo/rpc/protocol_test.cpp
diff options
context:
space:
mode:
authorAdam Midvidy <amidvidy@gmail.com>2015-06-24 13:54:45 -0400
committerAdam Midvidy <amidvidy@gmail.com>2015-06-24 15:50:30 -0400
commit1fc9cba6988ab1b600be1a0549caf6146619e4df (patch)
treea5fcf53a04666b1bfc2ca43332cd824894154985 /src/mongo/rpc/protocol_test.cpp
parent313c3bdc2547f2746639e84f8668a756ad95d8f3 (diff)
downloadmongo-1fc9cba6988ab1b600be1a0549caf6146619e4df.tar.gz
SERVER-19035 autodetect support for OP_COMMAND in remote servers
Diffstat (limited to 'src/mongo/rpc/protocol_test.cpp')
-rw-r--r--src/mongo/rpc/protocol_test.cpp36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/mongo/rpc/protocol_test.cpp b/src/mongo/rpc/protocol_test.cpp
index 71ff1559fda..0f26cc586b2 100644
--- a/src/mongo/rpc/protocol_test.cpp
+++ b/src/mongo/rpc/protocol_test.cpp
@@ -29,12 +29,17 @@
#include "mongo/platform/basic.h"
#include "mongo/base/status.h"
+#include "mongo/db/jsobj.h"
+#include "mongo/db/wire_version.h"
#include "mongo/rpc/protocol.h"
#include "mongo/unittest/unittest.h"
namespace {
+using mongo::WireVersion;
using namespace mongo::rpc;
+using mongo::unittest::assertGet;
+using mongo::BSONObj;
// Checks if negotiation of the first to protocol sets results in the 'proto'
const auto assert_negotiated = [](ProtocolSet fst, ProtocolSet snd, Protocol proto) {
@@ -63,4 +68,35 @@ TEST(Protocol, FailedNegotiation) {
assert_not_negotiated(supports::kOpCommandOnly, supports::kNone);
}
+TEST(Protocol, parseProtocolSetFromIsMasterReply) {
+ {
+ // MongoDB 3.2 (mongod)
+ auto mongod32 = BSON("maxWireVersion"
+ << static_cast<int>(WireVersion::RELEASE_3_1_5) << "minWireVersion"
+ << static_cast<int>(WireVersion::RELEASE_2_4_AND_BEFORE));
+
+ ASSERT_EQ(assertGet(parseProtocolSetFromIsMasterReply(mongod32)), supports::kAll);
+ }
+ {
+ // MongoDB 3.2 (mongos)
+ auto mongos32 = BSON("maxWireVersion"
+ << static_cast<int>(WireVersion::RELEASE_3_1_5) << "minWireVersion"
+ << static_cast<int>(WireVersion::RELEASE_2_4_AND_BEFORE) << "msg"
+ << "isdbgrid");
+
+ ASSERT_EQ(assertGet(parseProtocolSetFromIsMasterReply(mongos32)), supports::kOpQueryOnly);
+ }
+ {
+ // MongoDB 3.0 (mongod)
+ auto mongod30 = BSON("maxWireVersion"
+ << static_cast<int>(WireVersion::RELEASE_2_7_7) << "minWireVersion"
+ << static_cast<int>(WireVersion::RELEASE_2_4_AND_BEFORE));
+ ASSERT_EQ(assertGet(parseProtocolSetFromIsMasterReply(mongod30)), supports::kOpQueryOnly);
+ }
+ {
+ auto mongod24 = BSONObj();
+ ASSERT_EQ(assertGet(parseProtocolSetFromIsMasterReply(mongod24)), supports::kOpQueryOnly);
+ }
+}
+
} // namespace