summaryrefslogtreecommitdiff
path: root/src/mongo/db/commands/mr_test.cpp
diff options
context:
space:
mode:
authorJames Wahlin <james@mongodb.com>2019-06-27 16:56:40 -0400
committerJames Wahlin <james@mongodb.com>2019-07-03 08:41:52 -0400
commit52487cca347e4a549bba84d188f2e978c6908aa3 (patch)
tree898a03507229fa62f2318051b686f05c15c37f1c /src/mongo/db/commands/mr_test.cpp
parentea6c7f08de9e406c8dc05408f1ed688220e03954 (diff)
downloadmongo-52487cca347e4a549bba84d188f2e978c6908aa3.tar.gz
SERVER-41938 Refactor mapReduce command in support of alternate execution path
Diffstat (limited to 'src/mongo/db/commands/mr_test.cpp')
-rw-r--r--src/mongo/db/commands/mr_test.cpp64
1 files changed, 31 insertions, 33 deletions
diff --git a/src/mongo/db/commands/mr_test.cpp b/src/mongo/db/commands/mr_test.cpp
index f2a580730fb..53735cdc5ea 100644
--- a/src/mongo/db/commands/mr_test.cpp
+++ b/src/mongo/db/commands/mr_test.cpp
@@ -84,15 +84,15 @@ void _compareOutputOptionField(const std::string& dbname,
/**
* Returns string representation of mr::Config::OutputType
*/
-std::string _getOutTypeString(mr::Config::OutputType outType) {
+std::string _getOutTypeString(mr::OutputType outType) {
switch (outType) {
- case mr::Config::REPLACE:
+ case mr::OutputType::kReplace:
return "REPLACE";
- case mr::Config::MERGE:
+ case mr::OutputType::kMerge:
return "MERGE";
- case mr::Config::REDUCE:
+ case mr::OutputType::kReduce:
return "REDUCE";
- case mr::Config::INMEMORY:
+ case mr::OutputType::kInMemory:
return "INMEMORY";
}
MONGO_UNREACHABLE;
@@ -107,9 +107,9 @@ void _testConfigParseOutputOptions(const std::string& dbname,
const std::string& expectedCollectionName,
const std::string& expectedFinalNamespace,
bool expectedOutNonAtomic,
- mr::Config::OutputType expectedOutType) {
+ mr::OutputType expectedOutType) {
const BSONObj cmdObj = fromjson(cmdObjStr);
- mr::Config::OutputOptions outputOptions = mr::Config::parseOutputOptions(dbname, cmdObj);
+ mr::OutputOptions outputOptions = mr::parseOutputOptions(dbname, cmdObj);
_compareOutputOptionField(dbname, cmdObjStr, "outDb", outputOptions.outDB, expectedOutDb);
_compareOutputOptionField(
dbname, cmdObjStr, "collectionName", outputOptions.collectionName, expectedCollectionName);
@@ -128,33 +128,31 @@ void _testConfigParseOutputOptions(const std::string& dbname,
}
/**
- * Tests for mr::Config::parseOutputOptions.
+ * Tests for mr::parseOutputOptions.
*/
TEST(ConfigOutputOptionsTest, parseOutputOptions) {
// Missing 'out' field.
- ASSERT_THROWS(mr::Config::parseOutputOptions("mydb", fromjson("{}")), AssertionException);
+ ASSERT_THROWS(mr::parseOutputOptions("mydb", fromjson("{}")), AssertionException);
// 'out' must be either string or object.
- ASSERT_THROWS(mr::Config::parseOutputOptions("mydb", fromjson("{out: 99}")),
- AssertionException);
+ ASSERT_THROWS(mr::parseOutputOptions("mydb", fromjson("{out: 99}")), AssertionException);
// 'out.nonAtomic' is not supported with normal, replace or inline.
- ASSERT_THROWS(mr::Config::parseOutputOptions(
- "mydb", fromjson("{out: {normal: 'mycoll', nonAtomic: true}}")),
- AssertionException);
- ASSERT_THROWS(mr::Config::parseOutputOptions(
- "mydb", fromjson("{out: {replace: 'mycoll', nonAtomic: true}}")),
- AssertionException);
- ASSERT_THROWS(mr::Config::parseOutputOptions(
- "mydb", fromjson("{out: {inline: 'mycoll', nonAtomic: true}}")),
- AssertionException);
- // Unknown output specifer.
ASSERT_THROWS(
- mr::Config::parseOutputOptions("mydb", fromjson("{out: {no_such_out_type: 'mycoll'}}")),
+ mr::parseOutputOptions("mydb", fromjson("{out: {normal: 'mycoll', nonAtomic: true}}")),
AssertionException);
+ ASSERT_THROWS(
+ mr::parseOutputOptions("mydb", fromjson("{out: {replace: 'mycoll', nonAtomic: true}}")),
+ AssertionException);
+ ASSERT_THROWS(
+ mr::parseOutputOptions("mydb", fromjson("{out: {inline: 'mycoll', nonAtomic: true}}")),
+ AssertionException);
+ // Unknown output specifer.
+ ASSERT_THROWS(mr::parseOutputOptions("mydb", fromjson("{out: {no_such_out_type: 'mycoll'}}")),
+ AssertionException);
// 'out' is string.
_testConfigParseOutputOptions(
- "mydb", "{out: 'mycoll'}", "", "mycoll", "mydb.mycoll", false, mr::Config::REPLACE);
+ "mydb", "{out: 'mycoll'}", "", "mycoll", "mydb.mycoll", false, mr::OutputType::kReplace);
// 'out' is object.
_testConfigParseOutputOptions("mydb",
"{out: {normal: 'mycoll'}}",
@@ -162,7 +160,7 @@ TEST(ConfigOutputOptionsTest, parseOutputOptions) {
"mycoll",
"mydb.mycoll",
false,
- mr::Config::REPLACE);
+ mr::OutputType::kReplace);
// 'out.db' overrides dbname parameter
_testConfigParseOutputOptions("mydb1",
"{out: {replace: 'mycoll', db: 'mydb2'}}",
@@ -170,7 +168,7 @@ TEST(ConfigOutputOptionsTest, parseOutputOptions) {
"mycoll",
"mydb2.mycoll",
false,
- mr::Config::REPLACE);
+ mr::OutputType::kReplace);
// 'out.nonAtomic' is supported with merge and reduce.
_testConfigParseOutputOptions("mydb",
"{out: {merge: 'mycoll', nonAtomic: true}}",
@@ -178,14 +176,14 @@ TEST(ConfigOutputOptionsTest, parseOutputOptions) {
"mycoll",
"mydb.mycoll",
true,
- mr::Config::MERGE);
+ mr::OutputType::kMerge);
_testConfigParseOutputOptions("mydb",
"{out: {reduce: 'mycoll', nonAtomic: true}}",
"",
"mycoll",
"mydb.mycoll",
true,
- mr::Config::REDUCE);
+ mr::OutputType::kReduce);
// inline
_testConfigParseOutputOptions("mydb1",
"{out: {inline: 'mycoll', db: 'mydb2'}}",
@@ -193,7 +191,7 @@ TEST(ConfigOutputOptionsTest, parseOutputOptions) {
"",
"",
false,
- mr::Config::INMEMORY);
+ mr::OutputType::kInMemory);
// Order should not matter in fields of 'out' object.
_testConfigParseOutputOptions("mydb1",
@@ -202,35 +200,35 @@ TEST(ConfigOutputOptionsTest, parseOutputOptions) {
"mycoll",
"mydb2.mycoll",
false,
- mr::Config::REPLACE);
+ mr::OutputType::kReplace);
_testConfigParseOutputOptions("mydb1",
"{out: {db: 'mydb2', replace: 'mycoll'}}",
"mydb2",
"mycoll",
"mydb2.mycoll",
false,
- mr::Config::REPLACE);
+ mr::OutputType::kReplace);
_testConfigParseOutputOptions("mydb1",
"{out: {nonAtomic: true, merge: 'mycoll'}}",
"",
"mycoll",
"mydb1.mycoll",
true,
- mr::Config::MERGE);
+ mr::OutputType::kMerge);
_testConfigParseOutputOptions("mydb1",
"{out: {nonAtomic: true, reduce: 'mycoll'}}",
"",
"mycoll",
"mydb1.mycoll",
true,
- mr::Config::REDUCE);
+ mr::OutputType::kReduce);
_testConfigParseOutputOptions("mydb1",
"{out: {db: 'mydb2', inline: 'mycoll'}}",
"mydb2",
"",
"",
false,
- mr::Config::INMEMORY);
+ mr::OutputType::kInMemory);
}
TEST(ConfigTest, ParseCollation) {