summaryrefslogtreecommitdiff
path: root/jstests/sharding/mapReduce_outSharded.js
diff options
context:
space:
mode:
authorKaloian Manassiev <kaloian.manassiev@mongodb.com>2014-10-03 13:28:48 -0400
committerKaloian Manassiev <kaloian.manassiev@mongodb.com>2014-10-03 15:47:53 -0400
commit524c7648150bf03ae37fa65d91684856a4d1e683 (patch)
tree54410b5cb9a0aa8f22592d2f2815000e410dcce7 /jstests/sharding/mapReduce_outSharded.js
parent90768c7a1129bb08d8bfca4840f53d33c96a0183 (diff)
downloadmongo-524c7648150bf03ae37fa65d91684856a4d1e683.tar.gz
SERVER-15525 Split sharding map/reduce tests
Diffstat (limited to 'jstests/sharding/mapReduce_outSharded.js')
-rw-r--r--jstests/sharding/mapReduce_outSharded.js53
1 files changed, 53 insertions, 0 deletions
diff --git a/jstests/sharding/mapReduce_outSharded.js b/jstests/sharding/mapReduce_outSharded.js
new file mode 100644
index 00000000000..0e8f68acf69
--- /dev/null
+++ b/jstests/sharding/mapReduce_outSharded.js
@@ -0,0 +1,53 @@
+var verifyOutput = function(out) {
+ printjson(out);
+ assert.eq(out.counts.input, 51200, "input count is wrong");
+ assert.eq(out.counts.emit, 51200, "emit count is wrong");
+ assert.gt(out.counts.reduce, 99, "reduce count is wrong");
+ assert.eq(out.counts.output, 512, "output count is wrong");
+}
+
+var st = new ShardingTest({ shards : 2, verbose : 1, mongos : 1, other : { chunksize : 1 } });
+st.startBalancer();
+
+st.adminCommand( { enablesharding : "mrShard" } )
+st.adminCommand( { shardcollection : "mrShard.srcSharded", key : { "_id" : 1 } } )
+
+var db = st.getDB( "mrShard" );
+
+var bulk = db.srcNonSharded.initializeUnorderedBulkOp();
+for (j = 0; j < 100; j++) {
+ for (i = 0; i < 512; i++) {
+ bulk.insert({ j: j, i: i });
+ }
+}
+assert.writeOK(bulk.execute());
+
+function map() { emit(this.i, 1); }
+function reduce(key, values) { return Array.sum(values) }
+
+// non sharded src sharded dst
+var suffix = "OutSharded";
+
+out = db.srcNonSharded.mapReduce(map, reduce, { out: { replace: "mrReplace" + suffix, sharded: true } });
+verifyOutput(out);
+
+out = db.srcNonSharded.mapReduce(map, reduce, { out: { merge: "mrMerge" + suffix, sharded: true } });
+verifyOutput(out);
+
+out = db.srcNonSharded.mapReduce(map, reduce, { out: { reduce: "mrReduce" + suffix, sharded: true } });
+verifyOutput(out);
+
+out = db.srcNonSharded.mapReduce(map, reduce, { out: { inline: 1, sharded: true } });
+verifyOutput(out);
+assert(out.results != 'undefined', "no results for inline");
+
+out = db.srcNonSharded.mapReduce(map, reduce, { out: { replace: "mrReplace" + suffix, db: "mrShardOtherDB", sharded: true } });
+verifyOutput(out);
+
+out = db.runCommand({
+ mapReduce: "srcNonSharded", // use new name mapReduce rather than mapreduce
+ map: map,
+ reduce: reduce,
+ out: "mrBasic" + "srcNonSharded",
+ });
+verifyOutput(out);