summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Pasette <dan@10gen.com>2015-10-05 13:52:48 -0400
committerDan Pasette <dan@mongodb.com>2015-10-05 14:12:46 -0400
commit2a86489d6f563a44140e1db7d8b5fb63c66f117c (patch)
tree087fc639cd3ccdf8af387166f3a68192e0988e3b
parent16441614656c0ea6b06422427e28634bb8e21823 (diff)
downloadmongo-2a86489d6f563a44140e1db7d8b5fb63c66f117c.tar.gz
SERVER-20759 dumprestore.js chooses primary port for mongorestore
-rw-r--r--jstests/tool/dumprestore3.js66
1 files changed, 25 insertions, 41 deletions
diff --git a/jstests/tool/dumprestore3.js b/jstests/tool/dumprestore3.js
index 39f97d3992f..f6a8735d5f6 100644
--- a/jstests/tool/dumprestore3.js
+++ b/jstests/tool/dumprestore3.js
@@ -1,59 +1,43 @@
-// dumprestore3.js
+// mongodump/mongoexport from primary should succeed. mongorestore and mongoimport to a
+// secondary node should fail.
var name = "dumprestore3";
-function step(msg) {
- msg = msg || "";
- this.x = (this.x || 0) + 1;
- print('\n' + name + ".js step " + this.x + ' ' + msg);
-}
-
-step();
-
var replTest = new ReplSetTest( {name: name, nodes: 2} );
var nodes = replTest.startSet();
replTest.initiate();
-var master = replTest.getMaster();
-
-{
- step("populate master");
- var foo = master.getDB("foo");
- for (i = 0; i < 20; i++) {
- foo.bar.insert({ x: i, y: "abc" });
- }
-}
+var primary = replTest.getPrimary();
+var secondary = replTest.getSecondary();
-{
- step("wait for slaves");
- replTest.awaitReplication();
+jsTestLog("populate primary");
+var foo = primary.getDB("foo");
+for (i = 0; i < 20; i++) {
+ foo.bar.insert({ x: i, y: "abc" });
}
-{
- step("dump & restore a db into a slave");
- var conn = MongoRunner.runMongod({});
- var c = conn.getDB("foo").bar;
- c.save({ a: 22 });
- assert.eq(1, c.count(), "setup2");
-}
-
-step("try mongorestore to slave");
+jsTestLog("wait for secondary");
+replTest.awaitReplication();
+jsTestLog("mongodump from primary");
var data = MongoRunner.dataDir + "/dumprestore3-other1/";
resetDbpath(data);
-runMongoProgram( "mongodump", "--host", "127.0.0.1:"+conn.port, "--out", data );
+var ret = runMongoProgram( "mongodump", "--host", primary.host, "--out", data );
+assert.eq(ret, 0, "mongodump should exit w/ 0 on primary");
-var x = runMongoProgram( "mongorestore", "--host", "127.0.0.1:"+replTest.ports[1], "--dir", data );
-assert.neq(x, 0, "mongorestore should exit w/ 1 on slave");
-
-step("try mongoimport to slave");
+jsTestLog("try mongorestore to secondary");
+ret = runMongoProgram( "mongorestore", "--host", secondary.host, "--dir", data );
+assert.neq(ret, 0, "mongorestore should exit w/ 1 on secondary");
+jsTestLog("mongoexport from primary");
dataFile = MongoRunner.dataDir + "/dumprestore3-other2.json";
-runMongoProgram( "mongoexport", "--host", "127.0.0.1:"+conn.port, "--out", dataFile, "--db", "foo", "--collection", "bar" );
+ret = runMongoProgram( "mongoexport", "--host", primary.host, "--out",
+ dataFile, "--db", "foo", "--collection", "bar" );
+assert.eq(ret, 0, "mongoexport should exit w/ 0 on primary");
-x = runMongoProgram( "mongoimport", "--host", "127.0.0.1:"+replTest.ports[1], "--file", dataFile );
-assert.neq(x, 0, "mongoreimport should exit w/ 1 on slave");
+jsTestLog("mongoimport from secondary");
+ret = runMongoProgram( "mongoimport", "--host", secondary.host, "--file", dataFile );
+assert.neq(ret, 0, "mongoreimport should exit w/ 1 on secondary");
-step("stopSet");
+jsTestLog("stopSet");
replTest.stopSet();
-
-step("SUCCESS");
+jsTestLog("SUCCESS");