diff options
Diffstat (limited to 'src/mongo/dbtests/mock')
| -rw-r--r-- | src/mongo/dbtests/mock/mock_replica_set.cpp | 16 | ||||
| -rw-r--r-- | src/mongo/dbtests/mock/mock_replica_set.h | 16 |
2 files changed, 14 insertions, 18 deletions
diff --git a/src/mongo/dbtests/mock/mock_replica_set.cpp b/src/mongo/dbtests/mock/mock_replica_set.cpp index b03ffd477ed..3871e1ef191 100644 --- a/src/mongo/dbtests/mock/mock_replica_set.cpp +++ b/src/mongo/dbtests/mock/mock_replica_set.cpp @@ -149,7 +149,7 @@ void MockReplicaSet::setPrimary(const string& hostAndPort) { _primaryHost = hostAndPort; - mockIsMasterCmd(); + mockHelloCmd(); mockReplSetGetStatusCmd(); } @@ -183,7 +183,7 @@ repl::ReplSetConfig MockReplicaSet::getReplConfig() const { void MockReplicaSet::setConfig(const repl::ReplSetConfig& newConfig) { _replConfig = newConfig; - mockIsMasterCmd(); + mockHelloCmd(); mockReplSetGetStatusCmd(); } @@ -211,14 +211,14 @@ BSONObj MockReplicaSet::mockHelloResponseFor(const MockRemoteDBServer& server) c const MemberConfig* member = _replConfig.findMemberByHostAndPort(hostAndPort); if (!member) { - builder.append("ismaster", false); + builder.append("isWritablePrimary", false); builder.append("secondary", false); vector<string> hostList; builder.append("hosts", hostList); } else { const bool isPrimary = hostAndPort.toString() == getPrimary(); - builder.append("ismaster", isPrimary); + builder.append("isWritablePrimary", isPrimary); builder.append("secondary", !isPrimary); { @@ -285,14 +285,12 @@ BSONObj MockReplicaSet::mockHelloResponseFor(const MockRemoteDBServer& server) c return builder.obj(); } -void MockReplicaSet::mockIsMasterCmd() { +void MockReplicaSet::mockHelloCmd() { for (ReplNodeMap::iterator nodeIter = _nodeMap.begin(); nodeIter != _nodeMap.end(); ++nodeIter) { - auto isMaster = mockHelloResponseFor(*nodeIter->second); + auto helloReply = mockHelloResponseFor(*nodeIter->second); - // DBClientBase::isMaster() sends "ismaster", but ReplicaSetMonitor sends "isMaster". - nodeIter->second->setCommandReply("ismaster", isMaster); - nodeIter->second->setCommandReply("isMaster", isMaster); + nodeIter->second->setCommandReply("hello", helloReply); } } diff --git a/src/mongo/dbtests/mock/mock_replica_set.h b/src/mongo/dbtests/mock/mock_replica_set.h index 677d0b822a1..d93ba956ee8 100644 --- a/src/mongo/dbtests/mock/mock_replica_set.h +++ b/src/mongo/dbtests/mock/mock_replica_set.h @@ -57,7 +57,7 @@ class ClockSource; class MockReplicaSet { public: /** - * Creates a mock replica set and automatically mocks the isMaster and replSetGetStatus commands + * Creates a mock replica set and automatically mocks the hello and replSetGetStatus commands * based on the default replica set configuration. Either the first node is primary and the * others are secondaries, or all are secondaries. By default, hostnames begin with "$", which * signals to ReplicaSetMonitor and to ConnectionString::connect that these are mocked hosts. @@ -87,12 +87,11 @@ public: std::vector<std::string> getSecondaries() const; /** - * Sets the configuration for this replica sets. This also has a side effect - * of mocking the ismaster and replSetGetStatus command responses based on - * the new config. + * Sets the configuration for this replica sets. This also has a side effect of mocking the + * hello and replSetGetStatus command responses based on the new config. * - * Note: does not automatically select a new primary. Can be done manually by - * calling setPrimary. + * Note: does not automatically select a new primary. Can be done manually by calling + * setPrimary. */ void setConfig(const repl::ReplSetConfig& newConfig); @@ -138,10 +137,9 @@ private: typedef std::map<std::string, MockRemoteDBServer*> ReplNodeMap; /** - * Mocks the ismaster command based on the information on the current - * replica set configuration. + * Mocks the "hello" command based on the information on the current replica set configuration. */ - void mockIsMasterCmd(); + void mockHelloCmd(); /** * Mock the hello response for the given server. |
