diff options
author | Spencer T Brody <spencer@mongodb.com> | 2014-11-18 19:10:13 -0500 |
---|---|---|
committer | Spencer T Brody <spencer@mongodb.com> | 2014-11-20 11:38:11 -0500 |
commit | 13577a48b51202aabd2e55ef95404439aaa4a0c3 (patch) | |
tree | fc39effb51783448ce01d782ca1e767e97b583e6 /src/mongo/client | |
parent | 42d802af32f99663bc1c66456b2d57749010bed5 (diff) | |
download | mongo-13577a48b51202aabd2e55ef95404439aaa4a0c3.tar.gz |
SERVER-15496 Update old unit tests to use new ReplicaSetConfig
Diffstat (limited to 'src/mongo/client')
-rw-r--r-- | src/mongo/client/dbclient_rs_test.cpp | 67 | ||||
-rw-r--r-- | src/mongo/client/replica_set_monitor_test.cpp | 1 |
2 files changed, 43 insertions, 25 deletions
diff --git a/src/mongo/client/dbclient_rs_test.cpp b/src/mongo/client/dbclient_rs_test.cpp index cd9ccc55948..6082d899a31 100644 --- a/src/mongo/client/dbclient_rs_test.cpp +++ b/src/mongo/client/dbclient_rs_test.cpp @@ -433,14 +433,21 @@ namespace { mongo::MockConnRegistry::get()->getConnStrHook()); { - mongo::MockReplicaSet::ReplConfigMap config = _replSet->getReplConfig(); + mongo::repl::ReplicaSetConfig oldConfig = _replSet->getReplConfig(); + mongo::BSONObjBuilder newConfigBuilder; + newConfigBuilder.append("_id", oldConfig.getReplSetName()); + newConfigBuilder.append("version", oldConfig.getConfigVersion()); + + mongo::BSONArrayBuilder membersBuilder(newConfigBuilder.subarrayStart("members")); { const string host(_replSet->getPrimary()); - map<string, string>& tag = config[host].tags; - tag.clear(); - tag["dc"] = "ny"; - tag["p"] = "1"; + const mongo::repl::MemberConfig* member = + oldConfig.findMemberByHostAndPort(HostAndPort(host)); + membersBuilder.append(BSON("_id" << member->getId() << + "host" << host << + "tags" << BSON("dc" << "ny" << + "p" << "1"))); _replSet->getNode(host)->insert(IdentityNS, BSON(HostField(host))); } @@ -449,46 +456,58 @@ namespace { { const string host(*secIter); - map<string, string>& tag = config[host].tags; - tag.clear(); - tag["dc"] = "sf"; - tag["s"] = "1"; - tag["group"] = "1"; + const mongo::repl::MemberConfig* member = + oldConfig.findMemberByHostAndPort(HostAndPort(host)); + membersBuilder.append(BSON("_id" << member->getId() << + "host" << host << + "tags" << BSON("dc" << "sf" << + "s" << "1" << + "group" << "1"))); _replSet->getNode(host)->insert(IdentityNS, BSON(HostField(host))); } { ++secIter; const string host(*secIter); - map<string, string>& tag = config[host].tags; - tag.clear(); - tag["dc"] = "ma"; - tag["s"] = "2"; - tag["group"] = "1"; + const mongo::repl::MemberConfig* member = + oldConfig.findMemberByHostAndPort(HostAndPort(host)); + membersBuilder.append(BSON("_id" << member->getId() << + "host" << host << + "tags" << BSON("dc" << "ma" << + "s" << "2" << + "group" << "1"))); _replSet->getNode(host)->insert(IdentityNS, BSON(HostField(host))); } { ++secIter; const string host(*secIter); - map<string, string>& tag = config[host].tags; - tag.clear(); - tag["dc"] = "eu"; - tag["s"] = "3"; + const mongo::repl::MemberConfig* member = + oldConfig.findMemberByHostAndPort(HostAndPort(host)); + membersBuilder.append(BSON("_id" << member->getId() << + "host" << host << + "tags" << BSON("dc" << "eu" << + "s" << "3"))); _replSet->getNode(host)->insert(IdentityNS, BSON(HostField(host))); } { ++secIter; const string host(*secIter); - map<string, string>& tag = config[host].tags; - tag.clear(); - tag["dc"] = "jp"; - tag["s"] = "4"; + const mongo::repl::MemberConfig* member = + oldConfig.findMemberByHostAndPort(HostAndPort(host)); + membersBuilder.append(BSON("_id" << member->getId() << + "host" << host << + "tags" << BSON("dc" << "jp" << + "s" << "4"))); _replSet->getNode(host)->insert(IdentityNS, BSON(HostField(host))); } - _replSet->setConfig(config); + membersBuilder.done(); + mongo::repl::ReplicaSetConfig newConfig; + fassert(28569, newConfig.initialize(newConfigBuilder.done())); + fassert(28568, newConfig.validate()); + _replSet->setConfig(newConfig); } } diff --git a/src/mongo/client/replica_set_monitor_test.cpp b/src/mongo/client/replica_set_monitor_test.cpp index 559b4f3d443..9316baefad9 100644 --- a/src/mongo/client/replica_set_monitor_test.cpp +++ b/src/mongo/client/replica_set_monitor_test.cpp @@ -32,7 +32,6 @@ #include "mongo/client/replica_set_monitor.h" #include "mongo/client/replica_set_monitor_internal.h" #include "mongo/dbtests/mock/mock_conn_registry.h" -#include "mongo/dbtests/mock/mock_replica_set.h" #include "mongo/unittest/unittest.h" using namespace mongo; |