diff options
author | Randolph Tan <randolph@10gen.com> | 2013-02-27 11:23:14 -0500 |
---|---|---|
committer | Randolph Tan <randolph@10gen.com> | 2013-02-28 16:00:28 -0500 |
commit | 9d638fd65a8010d3d357b2cd0bb11e099a222ae8 (patch) | |
tree | 3383c960965115698cc4d624b60004231f662fbe /src/mongo/client/dbclient_rs_test.cpp | |
parent | 7471ba53b04f21157c4d6066e6e2769d856a3d3c (diff) | |
download | mongo-9d638fd65a8010d3d357b2cd0bb11e099a222ae8.tar.gz |
SERVER-8760 DBClientReplicaSet::slaveConn returns connection to primary
Diffstat (limited to 'src/mongo/client/dbclient_rs_test.cpp')
-rw-r--r-- | src/mongo/client/dbclient_rs_test.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/mongo/client/dbclient_rs_test.cpp b/src/mongo/client/dbclient_rs_test.cpp index 97d9f6f080a..19e94a0fc9f 100644 --- a/src/mongo/client/dbclient_rs_test.cpp +++ b/src/mongo/client/dbclient_rs_test.cpp @@ -250,4 +250,20 @@ namespace mongo_test { ASSERT_NOT_EQUALS(dest, newDest); } } + + // Note: slaveConn is dangerous and should be deprecated! Also see SERVER-7801. + TEST_F(TaggedFiveMemberRS, SlaveConnReturnsSecConn) { + MockReplicaSet* replSet = getReplSet(); + vector<HostAndPort> seedList; + seedList.push_back(HostAndPort(replSet->getPrimary())); + + DBClientReplicaSet replConn(replSet->getSetName(), seedList); + + string dest; + mongo::DBClientConnection& secConn = replConn.slaveConn(); + auto_ptr<DBClientCursor> cursor = secConn.query(IdentityNS, Query()); + BSONObj doc = cursor->next(); + dest = doc[HostField.name()].str(); + ASSERT_NOT_EQUALS(dest, replSet->getPrimary()); + } } |