summaryrefslogtreecommitdiff
path: root/jstests/tool/dumprestore3.js
diff options
context:
space:
mode:
authorKristina Chodorow <kristina@10gen.com>2010-10-08 11:23:08 -0400
committerKristina Chodorow <kristina@10gen.com>2010-10-08 11:23:23 -0400
commit0bb165f589ce8b813df149f309e080e200497911 (patch)
treed01ecbd3ab904aa2f606d1c5ba45a8f15727396b /jstests/tool/dumprestore3.js
parent7a21313631aa998bf6456310882b9ba75be8679d (diff)
downloadmongo-0bb165f589ce8b813df149f309e080e200497911.tar.gz
check imports are going to a master SERVER-1878
Diffstat (limited to 'jstests/tool/dumprestore3.js')
-rw-r--r--jstests/tool/dumprestore3.js45
1 files changed, 45 insertions, 0 deletions
diff --git a/jstests/tool/dumprestore3.js b/jstests/tool/dumprestore3.js
new file mode 100644
index 00000000000..75708f9b7b3
--- /dev/null
+++ b/jstests/tool/dumprestore3.js
@@ -0,0 +1,45 @@
+// dumprestore3.js
+
+var name = "dumprestore3";
+
+var replTest = new ReplSetTest( {name: name, nodes: 2} );
+var nodes = replTest.startSet();
+replTest.initiate();
+var master = replTest.getMaster();
+
+// populate master
+var foo = master.getDB("foo");
+for (i=0; i<20; i++) {
+ foo.bar.insert({x:i,y:"abc"});
+}
+
+// wait for slaves
+replTest.awaitReplication();
+
+// dump & restore a db into a slave
+var port = 30020;
+var conn = startMongodTest( port , name + "-other" );
+var c = conn.getDB("foo").bar;
+c.save( { a : 22 } );
+assert.eq( 1 , c.count() , "setup2" );
+
+
+// try mongorestore to slave
+
+var data = "/data/db/dumprestore3-other1/";
+resetDbpath(data);
+runMongoProgram( "mongodump", "--host", "127.0.0.1:"+port, "--out", data );
+
+var x = runMongoProgram( "mongorestore", "--host", "127.0.0.1:"+replTest.ports[1], "--dir", data );
+assert.eq(x, 255, "mongorestore should exit w/ -1 on slave");
+
+
+// try mongoimport to slave
+
+dataFile = "/data/db/dumprestore3-other2.json";
+runMongoProgram( "mongoexport", "--host", "127.0.0.1:"+port, "--out", dataFile, "--db", "foo", "--collection", "bar" );
+
+x = runMongoProgram( "mongoimport", "--host", "127.0.0.1:"+replTest.ports[1], "--file", dataFile );
+assert.eq(x, 255, "mongoreimport should exit w/ -1 on slave");
+
+replTest.stopSet();