summaryrefslogtreecommitdiff
path: root/jstests/tool
diff options
context:
space:
mode:
authorShaun Verch <shaun.verch@mongodb.com>2014-06-19 16:02:15 -0400
committerShaun Verch <shaun.verch@mongodb.com>2014-06-25 16:04:47 -0400
commitcaa0432e6e3f3f5355dcedbc2352625b07453435 (patch)
tree9578112ea3a1780f0b8e5b5247962773749171db /jstests/tool
parentcdfdc8ee6bbe09cc76724a2f559fe0dc98faa220 (diff)
downloadmongo-caa0432e6e3f3f5355dcedbc2352625b07453435.tar.gz
SERVER-14315 Support MinKey and MaxKey extended JSON objects in JSON parser
Diffstat (limited to 'jstests/tool')
-rw-r--r--jstests/tool/exportimport_minkey_maxkey.js37
1 files changed, 37 insertions, 0 deletions
diff --git a/jstests/tool/exportimport_minkey_maxkey.js b/jstests/tool/exportimport_minkey_maxkey.js
new file mode 100644
index 00000000000..3e91b04e0c1
--- /dev/null
+++ b/jstests/tool/exportimport_minkey_maxkey.js
@@ -0,0 +1,37 @@
+var tt = new ToolTest('exportimport_minkey_maxkey_test');
+
+var exportimport_db = tt.startDB();
+
+var src = exportimport_db.src;
+var dst = exportimport_db.dst;
+
+src.drop();
+dst.drop();
+
+src.insert({ "_id" : MaxKey });
+src.insert({ "_id" : MinKey });
+
+print('About to call mongoexport on: ' + exportimport_db.getName() + '.' + src.getName() +
+ ' with file: ' + tt.extFile);
+tt.runTool('export', '--out' , tt.extFile, '-d', exportimport_db.getName(), '-c', src.getName());
+
+print('About to call mongoimport on: ' + exportimport_db.getName() + '.' + dst.getName() +
+ ' with file: ' + tt.extFile);
+tt.runTool('import', '--file', tt.extFile, '-d', exportimport_db.getName(), '-c', dst.getName());
+
+print('About to verify that source and destination collections match');
+
+src_cursor = src.find().sort({ _id : 1 });
+dst_cursor = dst.find().sort({ _id : 1 });
+
+var documentCount = 0;
+while (src_cursor.hasNext()) {
+ assert(dst_cursor.hasNext(), 'Source has more documents than destination. ' +
+ 'Destination has ' + documentCount + ' documents.');
+ assert.eq(src_cursor.next(), dst_cursor.next(), 'Mismatch on document ' + documentCount);
+ ++documentCount;
+}
+assert(!dst_cursor.hasNext(), 'Destination has more documents than source. ' +
+ 'Source has ' + documentCount + ' documents.');
+
+print('Verified that source and destination collections match');