summaryrefslogtreecommitdiff
path: root/src/mongo/s
diff options
context:
space:
mode:
authorGreg Studer <greg@10gen.com>2012-12-03 15:50:15 -0500
committerGreg Studer <greg@10gen.com>2012-12-03 17:01:20 -0500
commitd2df0645428251b2d107b8ebe2f6f37b203ec057 (patch)
tree48a459d07356f06a78f6f2890b13d979afea1ea1 /src/mongo/s
parente857f6608ceafa5dbb4b863ca78193de47694402 (diff)
downloadmongo-d2df0645428251b2d107b8ebe2f6f37b203ec057.tar.gz
SERVER-939 minor fixes to test cases for new type_ parsing
Diffstat (limited to 'src/mongo/s')
-rw-r--r--src/mongo/s/collection_manager_test.cpp2
-rw-r--r--src/mongo/s/metadata_loader.cpp3
-rw-r--r--src/mongo/s/metadata_loader_test.cpp2
-rw-r--r--src/mongo/s/type_chunk_test.cpp41
-rw-r--r--src/mongo/s/type_collection_test.cpp55
-rw-r--r--src/mongo/s/type_shard_test.cpp13
6 files changed, 80 insertions, 36 deletions
diff --git a/src/mongo/s/collection_manager_test.cpp b/src/mongo/s/collection_manager_test.cpp
index 997ca008556..ab005baade3 100644
--- a/src/mongo/s/collection_manager_test.cpp
+++ b/src/mongo/s/collection_manager_test.cpp
@@ -64,7 +64,7 @@ namespace {
BSONObj collFoo = BSON(CollectionType::ns("test.foo") <<
CollectionType::keyPattern(BSON("a" << 1)) <<
CollectionType::unique(false) <<
- CollectionType::createdAt(1ULL) <<
+ CollectionType::updatedAt(1ULL) <<
CollectionType::epoch(OID::gen()));
// XXX Awaiting mock review
//dummyConfig.setQueryReply("config.collections", BSONArray(collFoo));
diff --git a/src/mongo/s/metadata_loader.cpp b/src/mongo/s/metadata_loader.cpp
index cd5c08807f9..ffa7c83bfff 100644
--- a/src/mongo/s/metadata_loader.cpp
+++ b/src/mongo/s/metadata_loader.cpp
@@ -129,8 +129,7 @@ namespace mongo {
}
CollectionType collDoc;
- collDoc.parseBSON(collObj);
- if (!collDoc.isValid(errMsg)) {
+ if (!collDoc.parseBSON(collObj, errMsg) || !collDoc.isValid(errMsg)) {
return false;
}
diff --git a/src/mongo/s/metadata_loader_test.cpp b/src/mongo/s/metadata_loader_test.cpp
index ab3f7551b71..6485e1de3e1 100644
--- a/src/mongo/s/metadata_loader_test.cpp
+++ b/src/mongo/s/metadata_loader_test.cpp
@@ -58,7 +58,7 @@ namespace {
BSONObj collFoo = BSON(CollectionType::ns("test.foo") <<
CollectionType::keyPattern(BSON("a" << 1)) <<
CollectionType::unique(false) <<
- CollectionType::createdAt(1ULL) <<
+ CollectionType::updatedAt(1ULL) <<
CollectionType::epoch(OID::gen()));
// XXX Awaiting mock review
//_dummyConfig.setQueryReply("config.collections", BSONArray(collFoo));
diff --git a/src/mongo/s/type_chunk_test.cpp b/src/mongo/s/type_chunk_test.cpp
index b2e5928befb..1da72160991 100644
--- a/src/mongo/s/type_chunk_test.cpp
+++ b/src/mongo/s/type_chunk_test.cpp
@@ -24,6 +24,7 @@
namespace {
+ using std::string;
using mongo::BSONArray;
using mongo::BSONObj;
using mongo::ChunkType;
@@ -40,7 +41,9 @@ namespace {
ChunkType::max(BSON("a" << 20)) <<
ChunkType::version(version) <<
ChunkType::shard("shard0001"));
- chunk.parseBSON(objModNS);
+ string errMsg;
+ ASSERT(chunk.parseBSON(objModNS, &errMsg));
+ ASSERT(errMsg == "");
ASSERT_FALSE(chunk.isValid(NULL));
BSONObj objModName = BSON(ChunkType::ns("test.mycol") <<
@@ -48,14 +51,18 @@ namespace {
ChunkType::max(BSON("a" << 20)) <<
ChunkType::version(version) <<
ChunkType::shard("shard0001"));
- chunk.parseBSON(objModName);
+
+ ASSERT(chunk.parseBSON(objModName, &errMsg));
+ ASSERT(errMsg == "");
ASSERT_FALSE(chunk.isValid(NULL));
BSONObj objModKeys = BSON(ChunkType::name("test.mycol-a_MinKey") <<
ChunkType::ns("test.mycol") <<
ChunkType::version(version) <<
ChunkType::shard("shard0001"));
- chunk.parseBSON(objModKeys);
+
+ ASSERT(chunk.parseBSON(objModKeys, &errMsg));
+ ASSERT(errMsg == "");
ASSERT_FALSE(chunk.isValid(NULL));
BSONObj objModVersion = BSON(ChunkType::name("test.mycol-a_MinKey") <<
@@ -63,7 +70,9 @@ namespace {
ChunkType::min(BSON("a" << 10 << "b" << 10)) <<
ChunkType::max(BSON("a" << 20)) <<
ChunkType::shard("shard0001"));
- chunk.parseBSON(objModVersion);
+
+ ASSERT(chunk.parseBSON(objModVersion, &errMsg));
+ ASSERT(errMsg == "");
ASSERT_FALSE(chunk.isValid(NULL));
BSONObj objModShard = BSON(ChunkType::name("test.mycol-a_MinKey") <<
@@ -72,7 +81,9 @@ namespace {
ChunkType::max(BSON("a" << 20)) <<
ChunkType::version(version) <<
ChunkType::shard("shard0001"));
- chunk.parseBSON(objModShard);
+
+ ASSERT(chunk.parseBSON(objModShard, &errMsg));
+ ASSERT(errMsg == "");
ASSERT_FALSE(chunk.isValid(NULL));
}
@@ -85,7 +96,9 @@ namespace {
ChunkType::max(BSON("a" << 20)) <<
ChunkType::version(version) <<
ChunkType::shard("shard0001"));
- chunk.parseBSON(obj);
+ string errMsg;
+ ASSERT(chunk.parseBSON(obj, &errMsg));
+ ASSERT(errMsg == "");
ASSERT_FALSE(chunk.isValid(NULL));
}
@@ -98,7 +111,9 @@ namespace {
ChunkType::max(BSON("b" << 20)) <<
ChunkType::version(version) <<
ChunkType::shard("shard0001"));
- chunk.parseBSON(obj);
+ string errMsg;
+ ASSERT(chunk.parseBSON(obj, &errMsg));
+ ASSERT(errMsg == "");
ASSERT_FALSE(chunk.isValid(NULL));
}
@@ -111,7 +126,9 @@ namespace {
ChunkType::max(BSON("a" << 10)) <<
ChunkType::version(version) <<
ChunkType::shard("shard0001"));
- chunk.parseBSON(obj);
+ string errMsg;
+ ASSERT(chunk.parseBSON(obj, &errMsg));
+ ASSERT(errMsg == "");
ASSERT_FALSE(chunk.isValid(NULL));
}
@@ -125,7 +142,9 @@ namespace {
ChunkType::max(BSON("a" << 20)) <<
ChunkType::version(version) <<
ChunkType::shard("shard0001"));
- chunk.parseBSON(obj);
+ string errMsg;
+ ASSERT(chunk.parseBSON(obj, &errMsg));
+ ASSERT(errMsg == "");
ASSERT_TRUE(chunk.isValid(NULL));
ASSERT_EQUALS(chunk.getName(), "test.mycol-a_MinKey");
ASSERT_EQUALS(chunk.getNS(), "test.mycol");
@@ -147,7 +166,9 @@ namespace {
ChunkType::DEPRECATED_lastmod(Date_t(1)) <<
ChunkType::DEPRECATED_epoch(epoch) <<
ChunkType::shard("shard0001"));
- chunk.parseBSON(obj);
+ string errMsg;
+ ASSERT(chunk.parseBSON(obj, &errMsg));
+ ASSERT(errMsg == "");
ASSERT_TRUE(chunk.isValid(NULL));
ASSERT_EQUALS(chunk.getName(), "test.mycol-a_MinKey");
ASSERT_EQUALS(chunk.getNS(), "test.mycol");
diff --git a/src/mongo/s/type_collection_test.cpp b/src/mongo/s/type_collection_test.cpp
index 64d4176ff28..db9be226bce 100644
--- a/src/mongo/s/type_collection_test.cpp
+++ b/src/mongo/s/type_collection_test.cpp
@@ -23,6 +23,7 @@
namespace {
+ using std::string;
using mongo::CollectionType;
using mongo::BSONObj;
using mongo::OID;
@@ -31,7 +32,9 @@ namespace {
TEST(Validity, Empty) {
CollectionType coll;
BSONObj emptyObj = BSONObj();
- coll.parseBSON(emptyObj);
+ string errMsg;
+ ASSERT(coll.parseBSON(emptyObj, &errMsg));
+ ASSERT(errMsg == "");
ASSERT_FALSE(coll.isValid(NULL));
}
@@ -39,9 +42,11 @@ namespace {
CollectionType coll;
BSONObj obj = BSON(CollectionType::ns("db.coll") <<
CollectionType::keyPattern(BSON("a" << 1)) <<
- CollectionType::createdAt(1ULL) <<
+ CollectionType::updatedAt(1ULL) <<
CollectionType::epoch(OID::gen()));
- coll.parseBSON(obj);
+ string errMsg;
+ ASSERT(coll.parseBSON(obj, &errMsg));
+ ASSERT(errMsg == "");
ASSERT_TRUE(coll.isValid(NULL));
}
@@ -49,18 +54,22 @@ namespace {
CollectionType coll;
BSONObj obj = BSON(CollectionType::ns("db.coll") <<
CollectionType::primary("my_primary_shard") <<
- CollectionType::createdAt(1ULL) <<
+ CollectionType::updatedAt(1ULL) <<
CollectionType::epoch(OID::gen()));
- coll.parseBSON(obj);
+ string errMsg;
+ ASSERT(coll.parseBSON(obj, &errMsg));
+ ASSERT(errMsg == "");
ASSERT_TRUE(coll.isValid(NULL));
}
TEST(Validity, MixingOptionals) {
CollectionType coll;
BSONObj obj = BSON(CollectionType::ns("db.coll") <<
- CollectionType::createdAt(time(0)) <<
+ CollectionType::updatedAt(time(0)) <<
CollectionType::unique(true));
- coll.parseBSON(obj);
+ string errMsg;
+ ASSERT(coll.parseBSON(obj, &errMsg));
+ ASSERT(errMsg == "");
ASSERT_FALSE(coll.isValid(NULL));
}
@@ -71,9 +80,11 @@ namespace {
CollectionType::primary("my_primary_shard") <<
CollectionType::DEPRECATED_lastmod(creation) <<
CollectionType::epoch(OID::gen()));
- coll.parseBSON(obj);
+ string errMsg;
+ ASSERT(coll.parseBSON(obj, &errMsg));
+ ASSERT(errMsg == "");
ASSERT_TRUE(coll.isValid(NULL));
- ASSERT_EQUALS(coll.getCreatedAt(), creation);
+ ASSERT_EQUALS(coll.getUpdatedAt(), creation);
}
TEST(Compatibility, OldEpoch) {
@@ -81,9 +92,11 @@ namespace {
OID epoch = OID::gen();
BSONObj obj = BSON(CollectionType::ns("db.coll") <<
CollectionType::primary("my_primary_shard") <<
- CollectionType::createdAt(1ULL) <<
+ CollectionType::updatedAt(1ULL) <<
CollectionType::DEPRECATED_lastmodEpoch(epoch));
- coll.parseBSON(obj);
+ string errMsg;
+ ASSERT(coll.parseBSON(obj, &errMsg));
+ ASSERT(errMsg == "");
ASSERT_TRUE(coll.isValid(NULL));
ASSERT_EQUALS(coll.getEpoch(), epoch);
}
@@ -97,12 +110,14 @@ namespace {
CollectionType::unique(false) <<
CollectionType::DEPRECATED_lastmod(1ULL) <<
CollectionType::DEPRECATED_lastmodEpoch(OID::gen()) <<
- CollectionType::DEPRECATED_dropped(true));
- coll.parseBSON(obj);
+ CollectionType::dropped(true));
+ string errMsg;
+ ASSERT(coll.parseBSON(obj, &errMsg));
+ ASSERT(errMsg == "");
ASSERT_EQUALS(coll.getNS(), "");
ASSERT_EQUALS(coll.getKeyPattern(), BSONObj());
- ASSERT_EQUALS(coll.getUnique(), false);
- ASSERT_EQUALS(coll.getCreatedAt(), 0ULL);
+ ASSERT_EQUALS(coll.isUnique(), false);
+ ASSERT_EQUALS(coll.getUpdatedAt(), 0ULL);
ASSERT_EQUALS(coll.getEpoch(), OID());
ASSERT_FALSE(coll.isValid(NULL));
}
@@ -115,12 +130,14 @@ namespace {
CollectionType::unique(true) <<
CollectionType::DEPRECATED_lastmod(1ULL) <<
CollectionType::DEPRECATED_lastmodEpoch(epoch) <<
- CollectionType::DEPRECATED_dropped(false));
- coll.parseBSON(obj);
+ CollectionType::dropped(false));
+ string errMsg;
+ ASSERT(coll.parseBSON(obj, &errMsg));
+ ASSERT(errMsg == "");
ASSERT_EQUALS(coll.getNS(), "db.coll");
ASSERT_EQUALS(coll.getKeyPattern(), BSON("a" << 1));
- ASSERT_EQUALS(coll.getUnique(), true);
- ASSERT_EQUALS(coll.getCreatedAt(), 1ULL);
+ ASSERT_EQUALS(coll.isUnique(), true);
+ ASSERT_EQUALS(coll.getUpdatedAt(), 1ULL);
ASSERT_EQUALS(coll.getEpoch(), epoch);
ASSERT_TRUE(coll.isValid(NULL));
}
diff --git a/src/mongo/s/type_shard_test.cpp b/src/mongo/s/type_shard_test.cpp
index a316158175a..128e89b6fd9 100644
--- a/src/mongo/s/type_shard_test.cpp
+++ b/src/mongo/s/type_shard_test.cpp
@@ -21,13 +21,16 @@
namespace {
+ using std::string;
using mongo::ShardType;
using mongo::BSONObj;
TEST(Validity, Empty) {
ShardType shard;
BSONObj emptyObj = BSONObj();
- shard.parseBSON(emptyObj);
+ string errMsg;
+ ASSERT(shard.parseBSON(emptyObj, &errMsg));
+ ASSERT(errMsg == "");
ASSERT_FALSE(shard.isValid(NULL));
}
@@ -35,7 +38,9 @@ namespace {
ShardType shard;
BSONObj obj = BSON(ShardType::name("shard0000") <<
ShardType::host("localhost:27017"));
- shard.parseBSON(obj);
+ string errMsg;
+ ASSERT(shard.parseBSON(obj, &errMsg));
+ ASSERT(errMsg == "");
ASSERT_TRUE(shard.isValid(NULL));
}
@@ -45,7 +50,9 @@ namespace {
ShardType::host("localhost:27017") <<
ShardType::draining(true) <<
ShardType::maxSize(100));
- shard.parseBSON(obj);
+ string errMsg;
+ ASSERT(shard.parseBSON(obj, &errMsg));
+ ASSERT(errMsg == "");
ASSERT_TRUE(shard.isValid(NULL));
}