summaryrefslogtreecommitdiff
path: root/src/mongo/dbtests/replica_set_monitor_test.cpp
diff options
context:
space:
mode:
authorMathias Stearn <mathias@10gen.com>2014-01-27 15:18:23 -0500
committerMathias Stearn <mathias@10gen.com>2014-01-29 18:28:47 -0500
commit98a4ac46bfcc5cbaf7b6d0ab1530d3fd96202a0d (patch)
tree94253ba538817b59bd0c7f27b6a54b7a570b1194 /src/mongo/dbtests/replica_set_monitor_test.cpp
parentd30a0aec7c9f8e45d0b2b95f9e55fafe3bedf170 (diff)
downloadmongo-98a4ac46bfcc5cbaf7b6d0ab1530d3fd96202a0d.tar.gz
SERVER-12284 Simplify TagSet class
It is now little more than a well-typed BSONArray that has a more useful default constructor. Since the new RSM no longer uses the iterator portion of the API, it isn't worth the cost of maintaining it. Additionally, TagSet being it's own iterator was more than a little odd.
Diffstat (limited to 'src/mongo/dbtests/replica_set_monitor_test.cpp')
-rw-r--r--src/mongo/dbtests/replica_set_monitor_test.cpp106
1 files changed, 5 insertions, 101 deletions
diff --git a/src/mongo/dbtests/replica_set_monitor_test.cpp b/src/mongo/dbtests/replica_set_monitor_test.cpp
index b4332299d37..0393ffdd721 100644
--- a/src/mongo/dbtests/replica_set_monitor_test.cpp
+++ b/src/mongo/dbtests/replica_set_monitor_test.cpp
@@ -1358,34 +1358,7 @@ namespace mongo_test {
ASSERT_EQUALS("b", host.host());
}
- TEST(TagSet, CopyConstructor) {
- TagSet* copy;
-
- {
- BSONArrayBuilder builder;
- builder.append(BSON("dc" << "nyc"));
- builder.append(BSON("priority" << "1"));
- TagSet original(builder.arr());
-
- original.next();
-
- copy = new TagSet(original);
- }
-
- ASSERT_FALSE(copy->isExhausted());
- ASSERT(copy->getCurrentTag().equal(BSON("dc" << "nyc")));
- copy->next();
-
- ASSERT_FALSE(copy->isExhausted());
- ASSERT(copy->getCurrentTag().equal(BSON("priority" << "1")));
- copy->next();
-
- ASSERT(copy->isExhausted());
-
- delete copy;
- }
-
- TEST(TagSet, NearestMultiTagsNoMatch) {
+ TEST(MultiTags, NearestMultiTagsNoMatch) {
vector<Node> nodes =
NodeSetFixtures::getThreeMemberWithTags();
TagSet tags(TagSetFixtures::getMultiNoMatchTag());
@@ -1398,77 +1371,9 @@ namespace mongo_test {
ASSERT(host.empty());
}
- TEST(TagSet, SingleTagSet) {
- BSONArrayBuilder builder;
- builder.append(BSON("dc" << "nyc"));
-
- TagSet tags(BSONArray(builder.done()));
-
- ASSERT(!tags.isExhausted());
- ASSERT(tags.getCurrentTag().equal(BSON("dc" << "nyc")));
-
- ASSERT(!tags.isExhausted());
- tags.next();
-
- ASSERT(tags.isExhausted());
-#if !(defined(_DEBUG) || defined(_DURABLEDEFAULTON) || defined(_DURABLEDEFAULTOFF))
- // TODO: remove this guard once SERVER-6317 is fixed
- ASSERT_THROWS(tags.getCurrentTag(), mongo::AssertionException);
-#endif
- }
-
- TEST(TagSet, MultiTagSet) {
- BSONArrayBuilder builder;
- builder.append(BSON("dc" << "nyc"));
- builder.append(BSON("dc" << "sf"));
- builder.append(BSON("dc" << "ma"));
-
- TagSet tags(BSONArray(builder.done()));
-
- ASSERT(!tags.isExhausted());
- ASSERT(tags.getCurrentTag().equal(BSON("dc" << "nyc")));
-
- ASSERT(!tags.isExhausted());
- tags.next();
- ASSERT(tags.getCurrentTag().equal(BSON("dc" << "sf")));
-
- ASSERT(!tags.isExhausted());
- tags.next();
- ASSERT(tags.getCurrentTag().equal(BSON("dc" << "ma")));
-
- ASSERT(!tags.isExhausted());
- tags.next();
-
- ASSERT(tags.isExhausted());
-#if !(defined(_DEBUG) || defined(_DURABLEDEFAULTON) || defined(_DURABLEDEFAULTOFF))
- // TODO: remove this guard once SERVER-6317 is fixed
- ASSERT_THROWS(tags.getCurrentTag(), mongo::AssertionException);
-#endif
- }
-
- TEST(TagSet, EmptyArrayTags) {
- BSONArray emptyArray;
- TagSet tags(emptyArray);
-
- ASSERT(tags.isExhausted());
-#if !(defined(_DEBUG) || defined(_DURABLEDEFAULTON) || defined(_DURABLEDEFAULTOFF))
- // TODO: remove this guard once SERVER-6317 is fixed
- ASSERT_THROWS(tags.getCurrentTag(), mongo::AssertionException);
-#endif
- }
-
- TEST(TagSet, Reset) {
- BSONArrayBuilder builder;
- builder.append(BSON("dc" << "nyc"));
-
- TagSet tags(BSONArray(builder.done()));
- tags.next();
- ASSERT(tags.isExhausted());
-
- tags.reset();
-
- ASSERT(!tags.isExhausted());
- ASSERT(tags.getCurrentTag().equal(BSON("dc" << "nyc")));
+ TEST(TagSet, DefaultConstructorMatchesAll) {
+ TagSet tags;
+ ASSERT_EQUALS(tags.getTagBSON(), BSON_ARRAY(BSONObj()));
}
@@ -1645,9 +1550,8 @@ namespace mongo_test {
replSet->restore(secHost);
- TagSet tags(BSON_ARRAY(BSONObj()));
HostAndPort node = monitor->getHostOrRefresh(
- ReadPreferenceSetting(mongo::ReadPreference_SecondaryOnly, tags));
+ ReadPreferenceSetting(mongo::ReadPreference_SecondaryOnly, TagSet()));
ASSERT_FALSE(monitor->isPrimary(node));
ASSERT_EQUALS(secHost, node.toString(true));