summaryrefslogtreecommitdiff
path: root/jstests/tool
diff options
context:
space:
mode:
Diffstat (limited to 'jstests/tool')
-rw-r--r--jstests/tool/csv1.js3
-rw-r--r--jstests/tool/dumprestore10.js129
-rw-r--r--jstests/tool/dumprestore3.js104
-rw-r--r--jstests/tool/dumprestore7.js190
-rw-r--r--jstests/tool/dumprestore9.js2
-rw-r--r--jstests/tool/dumprestore_auth2.js9
-rw-r--r--jstests/tool/dumprestore_auth3.js1
-rw-r--r--jstests/tool/dumprestore_excludecollections.js16
-rw-r--r--jstests/tool/dumpsecondary.js118
-rw-r--r--jstests/tool/gridfs.js4
-rw-r--r--jstests/tool/shell_mkdir.js64
-rw-r--r--jstests/tool/tool_replset.js176
12 files changed, 403 insertions, 413 deletions
diff --git a/jstests/tool/csv1.js b/jstests/tool/csv1.js
index 7a5690062f8..7c0321757ca 100644
--- a/jstests/tool/csv1.js
+++ b/jstests/tool/csv1.js
@@ -7,7 +7,8 @@ c = t.startDB("foo");
base = {
a: 1,
b: "foo,bar\"baz,qux",
- c: 5, 'd d': -6,
+ c: 5,
+ 'd d': -6,
e: '-',
f: "."
};
diff --git a/jstests/tool/dumprestore10.js b/jstests/tool/dumprestore10.js
index 632fac68482..ff63773850f 100644
--- a/jstests/tool/dumprestore10.js
+++ b/jstests/tool/dumprestore10.js
@@ -1,82 +1,81 @@
// simple test to ensure write concern functions as expected
(function() {
- // Skip this test if running with --nojournal and WiredTiger.
- if (jsTest.options().noJournal &&
- (!jsTest.options().storageEngine || jsTest.options().storageEngine === "wiredTiger")) {
- print("Skipping test because running WiredTiger without journaling isn't a valid" +
- " replica set configuration");
- return;
+// Skip this test if running with --nojournal and WiredTiger.
+if (jsTest.options().noJournal &&
+ (!jsTest.options().storageEngine || jsTest.options().storageEngine === "wiredTiger")) {
+ print("Skipping test because running WiredTiger without journaling isn't a valid" +
+ " replica set configuration");
+ return;
+}
+
+var name = "dumprestore10";
+
+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.getPrimary();
+var total = 1000;
+
+{
+ step("store data");
+ var foo = master.getDB("foo");
+ for (i = 0; i < total; i++) {
+ foo.bar.insert({x: i, y: "abc"});
}
+}
- var name = "dumprestore10";
+{
+ step("wait");
+ replTest.awaitReplication();
+}
- 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.getPrimary();
- var total = 1000;
-
- {
- step("store data");
- var foo = master.getDB("foo");
- for (i = 0; i < total; i++) {
- foo.bar.insert({x: i, y: "abc"});
- }
- }
+step("mongodump from replset");
- {
- step("wait");
- replTest.awaitReplication();
- }
-
- step("mongodump from replset");
+var data = MongoRunner.dataDir + "/dumprestore10-dump1/";
- var data = MongoRunner.dataDir + "/dumprestore10-dump1/";
+var exitCode = MongoRunner.runMongoTool("mongodump", {
+ host: "127.0.0.1:" + master.port,
+ out: data,
+});
+assert.eq(0, exitCode, "mongodump failed to dump data from the replica set");
- var exitCode = MongoRunner.runMongoTool("mongodump", {
- host: "127.0.0.1:" + master.port,
- out: data,
- });
- assert.eq(0, exitCode, "mongodump failed to dump data from the replica set");
+{
+ step("remove data after dumping");
+ master.getDB("foo").getCollection("bar").drop();
+}
- {
- step("remove data after dumping");
- master.getDB("foo").getCollection("bar").drop();
- }
-
- {
- step("wait");
- replTest.awaitReplication();
- }
+{
+ step("wait");
+ replTest.awaitReplication();
+}
- step("try mongorestore with write concern");
+step("try mongorestore with write concern");
- exitCode = MongoRunner.runMongoTool("mongorestore", {
- writeConcern: "2",
- host: "127.0.0.1:" + master.port,
- dir: data,
- });
- assert.eq(0,
- exitCode,
- "mongorestore failed to restore the data to a replica set while using w=2 writes");
+exitCode = MongoRunner.runMongoTool("mongorestore", {
+ writeConcern: "2",
+ host: "127.0.0.1:" + master.port,
+ dir: data,
+});
+assert.eq(
+ 0, exitCode, "mongorestore failed to restore the data to a replica set while using w=2 writes");
- var x = 0;
+var x = 0;
- // no waiting for replication
- x = master.getDB("foo").getCollection("bar").count();
+// no waiting for replication
+x = master.getDB("foo").getCollection("bar").count();
- assert.eq(x, total, "mongorestore should have successfully restored the collection");
+assert.eq(x, total, "mongorestore should have successfully restored the collection");
- step("stopSet");
- replTest.stopSet();
+step("stopSet");
+replTest.stopSet();
- step("SUCCESS");
+step("SUCCESS");
}());
diff --git a/jstests/tool/dumprestore3.js b/jstests/tool/dumprestore3.js
index 18817bb20ea..13efe2696c0 100644
--- a/jstests/tool/dumprestore3.js
+++ b/jstests/tool/dumprestore3.js
@@ -2,65 +2,65 @@
// secondary node should fail.
(function() {
- // Skip this test if running with --nojournal and WiredTiger.
- if (jsTest.options().noJournal &&
- (!jsTest.options().storageEngine || jsTest.options().storageEngine === "wiredTiger")) {
- print("Skipping test because running WiredTiger without journaling isn't a valid" +
- " replica set configuration");
- return;
- }
+// Skip this test if running with --nojournal and WiredTiger.
+if (jsTest.options().noJournal &&
+ (!jsTest.options().storageEngine || jsTest.options().storageEngine === "wiredTiger")) {
+ print("Skipping test because running WiredTiger without journaling isn't a valid" +
+ " replica set configuration");
+ return;
+}
- var name = "dumprestore3";
+var name = "dumprestore3";
- var replTest = new ReplSetTest({name: name, nodes: 2});
- var nodes = replTest.startSet();
- replTest.initiate();
- var primary = replTest.getPrimary();
- var secondary = replTest.getSecondary();
+var replTest = new ReplSetTest({name: name, nodes: 2});
+var nodes = replTest.startSet();
+replTest.initiate();
+var primary = replTest.getPrimary();
+var secondary = replTest.getSecondary();
- jsTestLog("populate primary");
- var foo = primary.getDB("foo");
- for (i = 0; i < 20; i++) {
- foo.bar.insert({x: i, y: "abc"});
- }
+jsTestLog("populate primary");
+var foo = primary.getDB("foo");
+for (i = 0; i < 20; i++) {
+ foo.bar.insert({x: i, y: "abc"});
+}
- jsTestLog("wait for secondary");
- replTest.awaitReplication();
+jsTestLog("wait for secondary");
+replTest.awaitReplication();
- jsTestLog("mongodump from primary");
- var data = MongoRunner.dataDir + "/dumprestore3-other1/";
- resetDbpath(data);
- var ret = MongoRunner.runMongoTool("mongodump", {
- host: primary.host,
- out: data,
- });
- assert.eq(ret, 0, "mongodump should exit w/ 0 on primary");
+jsTestLog("mongodump from primary");
+var data = MongoRunner.dataDir + "/dumprestore3-other1/";
+resetDbpath(data);
+var ret = MongoRunner.runMongoTool("mongodump", {
+ host: primary.host,
+ out: data,
+});
+assert.eq(ret, 0, "mongodump should exit w/ 0 on primary");
- jsTestLog("try mongorestore to secondary");
- ret = MongoRunner.runMongoTool("mongorestore", {
- host: secondary.host,
- dir: data,
- });
- assert.neq(ret, 0, "mongorestore should exit w/ 1 on secondary");
+jsTestLog("try mongorestore to secondary");
+ret = MongoRunner.runMongoTool("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";
- ret = MongoRunner.runMongoTool("mongoexport", {
- host: primary.host,
- out: dataFile,
- db: "foo",
- collection: "bar",
- });
- assert.eq(ret, 0, "mongoexport should exit w/ 0 on primary");
+jsTestLog("mongoexport from primary");
+dataFile = MongoRunner.dataDir + "/dumprestore3-other2.json";
+ret = MongoRunner.runMongoTool("mongoexport", {
+ host: primary.host,
+ out: dataFile,
+ db: "foo",
+ collection: "bar",
+});
+assert.eq(ret, 0, "mongoexport should exit w/ 0 on primary");
- jsTestLog("mongoimport from secondary");
- ret = MongoRunner.runMongoTool("mongoimport", {
- host: secondary.host,
- file: dataFile,
- });
- assert.neq(ret, 0, "mongoimport should exit w/ 1 on secondary");
+jsTestLog("mongoimport from secondary");
+ret = MongoRunner.runMongoTool("mongoimport", {
+ host: secondary.host,
+ file: dataFile,
+});
+assert.neq(ret, 0, "mongoimport should exit w/ 1 on secondary");
- jsTestLog("stopSet");
- replTest.stopSet();
- jsTestLog("SUCCESS");
+jsTestLog("stopSet");
+replTest.stopSet();
+jsTestLog("SUCCESS");
}());
diff --git a/jstests/tool/dumprestore7.js b/jstests/tool/dumprestore7.js
index 8078a7ab595..782529f0383 100644
--- a/jstests/tool/dumprestore7.js
+++ b/jstests/tool/dumprestore7.js
@@ -1,97 +1,97 @@
(function() {
- "use strict";
-
- // Skip this test if running with --nojournal and WiredTiger.
- if (jsTest.options().noJournal &&
- (!jsTest.options().storageEngine || jsTest.options().storageEngine === "wiredTiger")) {
- print("Skipping test because running WiredTiger without journaling isn't a valid" +
- " replica set configuration");
- return;
- }
-
- var name = "dumprestore7";
-
- var step = (function() {
- var n = 0;
- return function(msg) {
- msg = msg || "";
- print('\n' + name + ".js step " + (++n) + ' ' + msg);
- };
- })();
-
- step("starting the replset test");
-
- var replTest = new ReplSetTest({name: name, nodes: 1});
- var nodes = replTest.startSet();
- replTest.initiate();
-
- step("inserting first chunk of data");
- var foo = replTest.getPrimary().getDB("foo");
- for (var i = 0; i < 20; i++) {
- foo.bar.insert({x: i, y: "abc"});
- }
-
- step("waiting for replication");
- replTest.awaitReplication();
- assert.eq(foo.bar.count(), 20, "should have inserted 20 documents");
-
- // The time of the last oplog entry.
- var time = replTest.getPrimary()
- .getDB("local")
- .getCollection("oplog.rs")
- .find()
- .limit(1)
- .sort({$natural: -1})
- .next()
- .ts;
- step("got time of last oplog entry: " + time);
-
- step("inserting second chunk of data");
- for (var i = 30; i < 50; i++) {
- foo.bar.insert({x: i, y: "abc"});
- }
- assert.eq(foo.bar.count(), 40, "should have inserted 40 total documents");
-
- step("try mongodump with $timestamp");
-
- var data = MongoRunner.dataDir + "/dumprestore7-dump1/";
- var query = {ts: {$gt: time}};
- var queryJSON = '{"ts":{"$gt":{"$timestamp":{"t":' + time.t + ',"i":' + time.i + '}}}}';
- print("mongodump query: " + queryJSON);
- if (_isWindows()) {
- queryJSON = '"' + queryJSON.replace(/"/g, '\\"') + '"';
- }
- var testQueryCount =
- replTest.getPrimary().getDB("local").getCollection("oplog.rs").find(query).itcount();
- assert.eq(testQueryCount, 20, "the query should match 20 documents");
-
- var exitCode = MongoRunner.runMongoTool("mongodump", {
- host: "127.0.0.1:" + replTest.ports[0],
- db: "local",
- collection: "oplog.rs",
- query: queryJSON,
- out: data,
- });
- assert.eq(0, exitCode, "monogdump failed to dump the oplog");
-
- step("try mongorestore from $timestamp");
-
- var restoreMongod = MongoRunner.runMongod({});
- exitCode = MongoRunner.runMongoTool("mongorestore", {
- host: "127.0.0.1:" + restoreMongod.port,
- dir: data,
- writeConcern: 1,
- });
- assert.eq(0, exitCode, "mongorestore failed to restore the oplog");
-
- var count = restoreMongod.getDB("local").getCollection("oplog.rs").count();
- if (count != 20) {
- print("mongorestore restored too many documents");
- restoreMongod.getDB("local").getCollection("oplog.rs").find().pretty().shellPrint();
- assert.eq(count, 20, "mongorestore should only have inserted the latter 20 entries");
- }
-
- MongoRunner.stopMongod(restoreMongod);
- step("stopping replset test");
- replTest.stopSet();
+"use strict";
+
+// Skip this test if running with --nojournal and WiredTiger.
+if (jsTest.options().noJournal &&
+ (!jsTest.options().storageEngine || jsTest.options().storageEngine === "wiredTiger")) {
+ print("Skipping test because running WiredTiger without journaling isn't a valid" +
+ " replica set configuration");
+ return;
+}
+
+var name = "dumprestore7";
+
+var step = (function() {
+ var n = 0;
+ return function(msg) {
+ msg = msg || "";
+ print('\n' + name + ".js step " + (++n) + ' ' + msg);
+ };
+})();
+
+step("starting the replset test");
+
+var replTest = new ReplSetTest({name: name, nodes: 1});
+var nodes = replTest.startSet();
+replTest.initiate();
+
+step("inserting first chunk of data");
+var foo = replTest.getPrimary().getDB("foo");
+for (var i = 0; i < 20; i++) {
+ foo.bar.insert({x: i, y: "abc"});
+}
+
+step("waiting for replication");
+replTest.awaitReplication();
+assert.eq(foo.bar.count(), 20, "should have inserted 20 documents");
+
+// The time of the last oplog entry.
+var time = replTest.getPrimary()
+ .getDB("local")
+ .getCollection("oplog.rs")
+ .find()
+ .limit(1)
+ .sort({$natural: -1})
+ .next()
+ .ts;
+step("got time of last oplog entry: " + time);
+
+step("inserting second chunk of data");
+for (var i = 30; i < 50; i++) {
+ foo.bar.insert({x: i, y: "abc"});
+}
+assert.eq(foo.bar.count(), 40, "should have inserted 40 total documents");
+
+step("try mongodump with $timestamp");
+
+var data = MongoRunner.dataDir + "/dumprestore7-dump1/";
+var query = {ts: {$gt: time}};
+var queryJSON = '{"ts":{"$gt":{"$timestamp":{"t":' + time.t + ',"i":' + time.i + '}}}}';
+print("mongodump query: " + queryJSON);
+if (_isWindows()) {
+ queryJSON = '"' + queryJSON.replace(/"/g, '\\"') + '"';
+}
+var testQueryCount =
+ replTest.getPrimary().getDB("local").getCollection("oplog.rs").find(query).itcount();
+assert.eq(testQueryCount, 20, "the query should match 20 documents");
+
+var exitCode = MongoRunner.runMongoTool("mongodump", {
+ host: "127.0.0.1:" + replTest.ports[0],
+ db: "local",
+ collection: "oplog.rs",
+ query: queryJSON,
+ out: data,
+});
+assert.eq(0, exitCode, "monogdump failed to dump the oplog");
+
+step("try mongorestore from $timestamp");
+
+var restoreMongod = MongoRunner.runMongod({});
+exitCode = MongoRunner.runMongoTool("mongorestore", {
+ host: "127.0.0.1:" + restoreMongod.port,
+ dir: data,
+ writeConcern: 1,
+});
+assert.eq(0, exitCode, "mongorestore failed to restore the oplog");
+
+var count = restoreMongod.getDB("local").getCollection("oplog.rs").count();
+if (count != 20) {
+ print("mongorestore restored too many documents");
+ restoreMongod.getDB("local").getCollection("oplog.rs").find().pretty().shellPrint();
+ assert.eq(count, 20, "mongorestore should only have inserted the latter 20 entries");
+}
+
+MongoRunner.stopMongod(restoreMongod);
+step("stopping replset test");
+replTest.stopSet();
})();
diff --git a/jstests/tool/dumprestore9.js b/jstests/tool/dumprestore9.js
index 2fb63f70889..9235ac45bd5 100644
--- a/jstests/tool/dumprestore9.js
+++ b/jstests/tool/dumprestore9.js
@@ -1,7 +1,6 @@
// Test disabled until SERVER-3853 is finished
if (0) {
(function() {
-
var name = "dumprestore9";
function step(msg) {
msg = msg || "";
@@ -104,6 +103,5 @@ if (0) {
step("Stop cluster");
s.stop();
step("SUCCESS");
-
})();
}
diff --git a/jstests/tool/dumprestore_auth2.js b/jstests/tool/dumprestore_auth2.js
index 39dcaa19b6e..7e3c8c10238 100644
--- a/jstests/tool/dumprestore_auth2.js
+++ b/jstests/tool/dumprestore_auth2.js
@@ -3,7 +3,6 @@
// Tests that the default auth roles of backup and restore work properly.
var dumpRestoreAuth2 = function(backup_role, restore_role) {
-
t = new ToolTest("dumprestore_auth2", {auth: ""});
coll = t.startDB("foo");
@@ -18,10 +17,9 @@ var dumpRestoreAuth2 = function(backup_role, restore_role) {
admindb.createRole({
role: "customRole",
- privileges: [{
- resource: {db: "jstests_tool_dumprestore_auth2", collection: "foo"},
- actions: ["find"]
- }],
+ privileges: [
+ {resource: {db: "jstests_tool_dumprestore_auth2", collection: "foo"}, actions: ["find"]}
+ ],
roles: []
});
admindb.createUser({user: "test", pwd: "pass", roles: ["customRole"]});
@@ -118,7 +116,6 @@ var dumpRestoreAuth2 = function(backup_role, restore_role) {
admindb.logout();
t.stop();
-
};
// Tests that the default auth roles of backup and restore work properly.
diff --git a/jstests/tool/dumprestore_auth3.js b/jstests/tool/dumprestore_auth3.js
index 8fb70d2a91b..b90eebb30bf 100644
--- a/jstests/tool/dumprestore_auth3.js
+++ b/jstests/tool/dumprestore_auth3.js
@@ -10,7 +10,6 @@ function runTool(toolName, mongod, options) {
}
var dumpRestoreAuth3 = function(backup_role, restore_role) {
-
var mongod = MongoRunner.runMongod();
var admindb = mongod.getDB("admin");
var db = mongod.getDB("foo");
diff --git a/jstests/tool/dumprestore_excludecollections.js b/jstests/tool/dumprestore_excludecollections.js
index cfda283b46a..4bf8dd50c60 100644
--- a/jstests/tool/dumprestore_excludecollections.js
+++ b/jstests/tool/dumprestore_excludecollections.js
@@ -35,10 +35,10 @@ assert.neq(ret, 0, "mongodump started successfully with --excludeCollection and
resetDbpath(dumpDir);
ret = MongoRunner.runMongoTool(
"mongodump", {out: dumpDir, excludeCollectionsWithPrefix: "test", host: mongodSource.host});
-assert.neq(
- ret,
- 0,
- "mongodump started successfully with --excludeCollectionsWithPrefix but " + "no --db option");
+assert.neq(ret,
+ 0,
+ "mongodump started successfully with --excludeCollectionsWithPrefix but " +
+ "no --db option");
resetDbpath(dumpDir);
ret = MongoRunner.runMongoTool("mongodump", {
@@ -48,10 +48,10 @@ ret = MongoRunner.runMongoTool("mongodump", {
excludeCollectionsWithPrefix: "test",
host: mongodSource.host
});
-assert.neq(
- ret,
- 0,
- "mongodump started successfully with --excludeCollectionsWithPrefix and " + "--collection");
+assert.neq(ret,
+ 0,
+ "mongodump started successfully with --excludeCollectionsWithPrefix and " +
+ "--collection");
jsTest.log("Testing proper behavior of collection exclusion");
resetDbpath(dumpDir);
diff --git a/jstests/tool/dumpsecondary.js b/jstests/tool/dumpsecondary.js
index 32f075e10fc..059a3eeb4db 100644
--- a/jstests/tool/dumpsecondary.js
+++ b/jstests/tool/dumpsecondary.js
@@ -1,61 +1,61 @@
(function() {
- // Skip this test if running with --nojournal and WiredTiger.
- if (jsTest.options().noJournal &&
- (!jsTest.options().storageEngine || jsTest.options().storageEngine === "wiredTiger")) {
- print("Skipping test because running WiredTiger without journaling isn't a valid" +
- " replica set configuration");
- return;
- }
-
- var replTest = new ReplSetTest({name: 'testSet', nodes: 2});
-
- var nodes = replTest.startSet();
- replTest.initiate();
-
- var master = replTest.getPrimary();
- db = master.getDB("foo");
- db.foo.save({a: 1000});
- replTest.awaitReplication();
- replTest.awaitSecondaryNodes();
-
- assert.eq(1, db.foo.count(), "setup");
-
- var slaves = replTest._slaves;
- assert(slaves.length == 1, "Expected 1 slave but length was " + slaves.length);
- slave = slaves[0];
-
- var commonOptions = {};
- if (jsTest.options().keyFile) {
- commonOptions.username = jsTest.options().authUser;
- commonOptions.password = jsTest.options().authPassword;
- }
-
- var exitCode = MongoRunner.runMongoTool(
- "mongodump",
- Object.extend({
- host: slave.host,
- out: MongoRunner.dataDir + "/jstests_tool_dumpsecondary_external/",
- },
- commonOptions));
- assert.eq(0, exitCode, "mongodump failed to dump data from the secondary");
-
- db.foo.drop();
- assert.eq(0, db.foo.count(), "after drop");
-
- exitCode = MongoRunner.runMongoTool(
- "mongorestore",
- Object.extend({
- host: master.host,
- dir: MongoRunner.dataDir + "/jstests_tool_dumpsecondary_external/",
- },
- commonOptions));
- assert.eq(0, exitCode, "mongorestore failed to restore data to the primary");
-
- assert.soon("db.foo.findOne()", "no data after sleep");
- assert.eq(1, db.foo.count(), "after restore");
- assert.eq(1000, db.foo.findOne().a, "after restore 2");
-
- resetDbpath(MongoRunner.dataDir + '/jstests_tool_dumpsecondary_external');
-
- replTest.stopSet(15);
+// Skip this test if running with --nojournal and WiredTiger.
+if (jsTest.options().noJournal &&
+ (!jsTest.options().storageEngine || jsTest.options().storageEngine === "wiredTiger")) {
+ print("Skipping test because running WiredTiger without journaling isn't a valid" +
+ " replica set configuration");
+ return;
+}
+
+var replTest = new ReplSetTest({name: 'testSet', nodes: 2});
+
+var nodes = replTest.startSet();
+replTest.initiate();
+
+var master = replTest.getPrimary();
+db = master.getDB("foo");
+db.foo.save({a: 1000});
+replTest.awaitReplication();
+replTest.awaitSecondaryNodes();
+
+assert.eq(1, db.foo.count(), "setup");
+
+var slaves = replTest._slaves;
+assert(slaves.length == 1, "Expected 1 slave but length was " + slaves.length);
+slave = slaves[0];
+
+var commonOptions = {};
+if (jsTest.options().keyFile) {
+ commonOptions.username = jsTest.options().authUser;
+ commonOptions.password = jsTest.options().authPassword;
+}
+
+var exitCode =
+ MongoRunner.runMongoTool("mongodump",
+ Object.extend({
+ host: slave.host,
+ out: MongoRunner.dataDir + "/jstests_tool_dumpsecondary_external/",
+ },
+ commonOptions));
+assert.eq(0, exitCode, "mongodump failed to dump data from the secondary");
+
+db.foo.drop();
+assert.eq(0, db.foo.count(), "after drop");
+
+exitCode =
+ MongoRunner.runMongoTool("mongorestore",
+ Object.extend({
+ host: master.host,
+ dir: MongoRunner.dataDir + "/jstests_tool_dumpsecondary_external/",
+ },
+ commonOptions));
+assert.eq(0, exitCode, "mongorestore failed to restore data to the primary");
+
+assert.soon("db.foo.findOne()", "no data after sleep");
+assert.eq(1, db.foo.count(), "after restore");
+assert.eq(1000, db.foo.findOne().a, "after restore 2");
+
+resetDbpath(MongoRunner.dataDir + '/jstests_tool_dumpsecondary_external');
+
+replTest.stopSet(15);
}());
diff --git a/jstests/tool/gridfs.js b/jstests/tool/gridfs.js
index d4d84aeb4c4..d559b580ab9 100644
--- a/jstests/tool/gridfs.js
+++ b/jstests/tool/gridfs.js
@@ -21,8 +21,8 @@ function testGridFS(name) {
// upload file (currently calls filemd5 internally)
var exitCode = MongoRunner.runMongoTool("mongofiles",
{
- port: mongos.port,
- db: name,
+ port: mongos.port,
+ db: name,
},
"put",
filename);
diff --git a/jstests/tool/shell_mkdir.js b/jstests/tool/shell_mkdir.js
index b2ac1eae135..ea3b86384ed 100644
--- a/jstests/tool/shell_mkdir.js
+++ b/jstests/tool/shell_mkdir.js
@@ -1,37 +1,35 @@
// Test the shell's mkdir utility.
(function() {
- "use strict";
-
- var dir = MongoRunner.dataPath + "ShellMkdirTestDirectory";
- removeFile(dir);
-
- // Make a new directory
- var res = mkdir(dir);
- printjson(res);
- assert(res);
- assert(res["exists"]);
- assert(res["created"]);
-
- // Make the same directory again
- res = mkdir(dir);
- printjson(res);
- assert(res);
- assert(res["exists"]);
- assert(!res["created"]);
-
- // Check that we throw, rather than crash, on ""
- // (see https://svn.boost.org/trac/boost/ticket/12495)
- assert.throws(function() {
- mkdir("");
- }, [], "");
-
- removeFile(dir);
-
- // check that other internal path functions do not crash on ""
- assert(pathExists("") === false, "expected pathExists to return false on empty path");
- assert(copyDbpath("", "") === undefined,
- "expected copyDbpath to return undefined on empty path");
- assert(resetDbpath("") === undefined, "expected resetDbpath to return undefined on empty path");
-
+"use strict";
+
+var dir = MongoRunner.dataPath + "ShellMkdirTestDirectory";
+removeFile(dir);
+
+// Make a new directory
+var res = mkdir(dir);
+printjson(res);
+assert(res);
+assert(res["exists"]);
+assert(res["created"]);
+
+// Make the same directory again
+res = mkdir(dir);
+printjson(res);
+assert(res);
+assert(res["exists"]);
+assert(!res["created"]);
+
+// Check that we throw, rather than crash, on ""
+// (see https://svn.boost.org/trac/boost/ticket/12495)
+assert.throws(function() {
+ mkdir("");
+}, [], "");
+
+removeFile(dir);
+
+// check that other internal path functions do not crash on ""
+assert(pathExists("") === false, "expected pathExists to return false on empty path");
+assert(copyDbpath("", "") === undefined, "expected copyDbpath to return undefined on empty path");
+assert(resetDbpath("") === undefined, "expected resetDbpath to return undefined on empty path");
}());
diff --git a/jstests/tool/tool_replset.js b/jstests/tool/tool_replset.js
index 162e0e778c6..be65c11118c 100644
--- a/jstests/tool/tool_replset.js
+++ b/jstests/tool/tool_replset.js
@@ -8,95 +8,93 @@
* 6. Export a collection.
* 7. Drop the collection.
* 8. Import the collection.
-*/
+ */
(function() {
- "use strict";
-
- // Skip this test if running with --nojournal and WiredTiger.
- if (jsTest.options().noJournal &&
- (!jsTest.options().storageEngine || jsTest.options().storageEngine === "wiredTiger")) {
- print("Skipping test because running WiredTiger without journaling isn't a valid" +
- " replica set configuration");
- return;
- }
-
- var replTest =
- new ReplSetTest({name: 'tool_replset', nodes: 2, oplogSize: 5, nodeOptions: {"vvvvv": ""}});
- var nodes = replTest.startSet();
- var config = replTest.getReplSetConfig();
- config.members[0].priority = 3;
- config.members[1].priority = 0;
- replTest.initiate(config);
- var master = replTest.getPrimary();
- assert.eq(nodes[0], master, "incorrect master elected");
- for (var i = 0; i < 100; i++) {
- assert.writeOK(master.getDB("foo").bar.insert({a: i}));
- }
- replTest.awaitReplication();
-
- var replSetConnString =
- "tool_replset/127.0.0.1:" + replTest.ports[0] + ",127.0.0.1:" + replTest.ports[1];
-
- // Test with mongodump/mongorestore
- var data = MongoRunner.dataDir + "/tool_replset-dump1/";
- print("using mongodump to dump the db to " + data);
- var exitCode = MongoRunner.runMongoTool("mongodump", {
- host: replSetConnString,
- out: data,
- });
- assert.eq(0, exitCode, "mongodump failed to dump from the replica set");
-
- print("db successfully dumped to " + data +
- ". dropping collection before testing the restore process");
- assert(master.getDB("foo").bar.drop());
- replTest.awaitReplication();
-
- print("using mongorestore to restore the db from " + data);
- exitCode = MongoRunner.runMongoTool("mongorestore", {
- host: replSetConnString,
- dir: data,
- });
- assert.eq(0, exitCode, "mongorestore failed to restore data to the replica set");
-
- print("db successfully restored, checking count");
- var x = master.getDB("foo").getCollection("bar").count();
- assert.eq(x, 100, "mongorestore should have successfully restored the collection");
-
- replTest.awaitReplication();
-
- // Test with mongoexport/mongoimport
- print("export the collection");
- var extFile = MongoRunner.dataDir + "/tool_replset/export";
- exitCode = MongoRunner.runMongoTool("mongoexport", {
- host: replSetConnString,
- out: extFile,
- db: "foo",
- collection: "bar",
- });
- assert.eq(
- 0, exitCode, "mongoexport failed to export collection 'foo.bar' from the replica set");
-
- print("collection successfully exported, dropping now");
- master.getDB("foo").getCollection("bar").drop();
- replTest.awaitReplication();
-
- print("import the collection");
- exitCode = MongoRunner.runMongoTool("mongoimport", {
- host: replSetConnString,
- file: extFile,
- db: "foo",
- collection: "bar",
- });
- assert.eq(
- 0, exitCode, "mongoimport failed to import collection 'foo.bar' into the replica set");
-
- var x = master.getDB("foo").getCollection("bar").count();
- assert.eq(x, 100, "mongoimport should have successfully imported the collection");
-
- print("all tests successful, stopping replica set");
-
- replTest.stopSet();
-
- print("replica set stopped, test complete");
+"use strict";
+
+// Skip this test if running with --nojournal and WiredTiger.
+if (jsTest.options().noJournal &&
+ (!jsTest.options().storageEngine || jsTest.options().storageEngine === "wiredTiger")) {
+ print("Skipping test because running WiredTiger without journaling isn't a valid" +
+ " replica set configuration");
+ return;
+}
+
+var replTest =
+ new ReplSetTest({name: 'tool_replset', nodes: 2, oplogSize: 5, nodeOptions: {"vvvvv": ""}});
+var nodes = replTest.startSet();
+var config = replTest.getReplSetConfig();
+config.members[0].priority = 3;
+config.members[1].priority = 0;
+replTest.initiate(config);
+var master = replTest.getPrimary();
+assert.eq(nodes[0], master, "incorrect master elected");
+for (var i = 0; i < 100; i++) {
+ assert.writeOK(master.getDB("foo").bar.insert({a: i}));
+}
+replTest.awaitReplication();
+
+var replSetConnString =
+ "tool_replset/127.0.0.1:" + replTest.ports[0] + ",127.0.0.1:" + replTest.ports[1];
+
+// Test with mongodump/mongorestore
+var data = MongoRunner.dataDir + "/tool_replset-dump1/";
+print("using mongodump to dump the db to " + data);
+var exitCode = MongoRunner.runMongoTool("mongodump", {
+ host: replSetConnString,
+ out: data,
+});
+assert.eq(0, exitCode, "mongodump failed to dump from the replica set");
+
+print("db successfully dumped to " + data +
+ ". dropping collection before testing the restore process");
+assert(master.getDB("foo").bar.drop());
+replTest.awaitReplication();
+
+print("using mongorestore to restore the db from " + data);
+exitCode = MongoRunner.runMongoTool("mongorestore", {
+ host: replSetConnString,
+ dir: data,
+});
+assert.eq(0, exitCode, "mongorestore failed to restore data to the replica set");
+
+print("db successfully restored, checking count");
+var x = master.getDB("foo").getCollection("bar").count();
+assert.eq(x, 100, "mongorestore should have successfully restored the collection");
+
+replTest.awaitReplication();
+
+// Test with mongoexport/mongoimport
+print("export the collection");
+var extFile = MongoRunner.dataDir + "/tool_replset/export";
+exitCode = MongoRunner.runMongoTool("mongoexport", {
+ host: replSetConnString,
+ out: extFile,
+ db: "foo",
+ collection: "bar",
+});
+assert.eq(0, exitCode, "mongoexport failed to export collection 'foo.bar' from the replica set");
+
+print("collection successfully exported, dropping now");
+master.getDB("foo").getCollection("bar").drop();
+replTest.awaitReplication();
+
+print("import the collection");
+exitCode = MongoRunner.runMongoTool("mongoimport", {
+ host: replSetConnString,
+ file: extFile,
+ db: "foo",
+ collection: "bar",
+});
+assert.eq(0, exitCode, "mongoimport failed to import collection 'foo.bar' into the replica set");
+
+var x = master.getDB("foo").getCollection("bar").count();
+assert.eq(x, 100, "mongoimport should have successfully imported the collection");
+
+print("all tests successful, stopping replica set");
+
+replTest.stopSet();
+
+print("replica set stopped, test complete");
}());