diff options
author | Jonathan Abrahams <jonathan@mongodb.com> | 2016-03-09 12:17:50 -0500 |
---|---|---|
committer | Jonathan Abrahams <jonathan@mongodb.com> | 2016-03-09 12:18:14 -0500 |
commit | 4ae691e8edc87d0e3cfb633bb91c328426be007b (patch) | |
tree | 52079a593f54382ca13a2e741633eab1b6271893 /jstests/dur/manyRestart.js | |
parent | a025d43f3ce2efc1fb1282a718f5d286fa0a4dc1 (diff) | |
download | mongo-4ae691e8edc87d0e3cfb633bb91c328426be007b.tar.gz |
SERVER-22468 Format JS code with approved style in jstests/
Diffstat (limited to 'jstests/dur/manyRestart.js')
-rw-r--r--[-rwxr-xr-x] | jstests/dur/manyRestart.js | 111 |
1 files changed, 59 insertions, 52 deletions
diff --git a/jstests/dur/manyRestart.js b/jstests/dur/manyRestart.js index 7bcae61f082..f4d03f60edc 100755..100644 --- a/jstests/dur/manyRestart.js +++ b/jstests/dur/manyRestart.js @@ -1,4 +1,4 @@ -/* +/* test durability */ @@ -9,7 +9,9 @@ var conn = null; function checkNoJournalFiles(path, pass) { var files = listFiles(path); - if (files.some(function (f) { return f.name.indexOf("prealloc") < 0; })) { + if (files.some(function(f) { + return f.name.indexOf("prealloc") < 0; + })) { if (pass == null) { // wait a bit longer for mongod to potentially finish if it is still running. sleep(10000); @@ -44,25 +46,26 @@ function runDiff(a, b) { function log(str) { print(); - if(str) - print(testname+" step " + step++ + " " + str); + if (str) + print(testname + " step " + step++ + " " + str); else - print(testname+" step " + step++); + print(testname + " step " + step++); } -// if you do inserts here, you will want to set _id. otherwise they won't match on different +// if you do inserts here, you will want to set _id. otherwise they won't match on different // runs so we can't do a binary diff of the resulting files to check they are consistent. function work() { log("work"); var d = conn.getDB("test"); - d.foo.insert({ _id: 3, x: 22 }); - d.foo.insert({ _id: 4, x: 22 }); - d.a.insert({ _id: 3, x: 22, y: [1, 2, 3] }); - d.a.insert({ _id: 4, x: 22, y: [1, 2, 3] }); - d.a.update({ _id: 4 }, { $inc: { x: 1} }); - - // try building an index. however, be careful as object id's in system.indexes would vary, so we do it manually: - d.system.indexes.insert({ _id: 99, ns: "test.a", key: { x: 1 }, name: "x_1" }); + d.foo.insert({_id: 3, x: 22}); + d.foo.insert({_id: 4, x: 22}); + d.a.insert({_id: 3, x: 22, y: [1, 2, 3]}); + d.a.insert({_id: 4, x: 22, y: [1, 2, 3]}); + d.a.update({_id: 4}, {$inc: {x: 1}}); + + // try building an index. however, be careful as object id's in system.indexes would vary, so + // we do it manually: + d.system.indexes.insert({_id: 99, ns: "test.a", key: {x: 1}, name: "x_1"}); log("endwork"); return d; } @@ -72,12 +75,12 @@ function addRows() { log("add rows " + rand); var d = conn.getDB("test"); for (var j = 0; j < rand; ++j) { - d.rows.insert({a:1, b: "blah"}); + d.rows.insert({a: 1, b: "blah"}); } return rand; } -function verify() { +function verify() { log("verify"); var d = conn.getDB("test"); assert.eq(d.foo.count(), 2, "collection count is wrong"); @@ -90,7 +93,7 @@ function verifyRows(nrows) { assert.eq(d.rows.count(), nrows, "collection count is wrong"); } -if( debugging ) { +if (debugging) { // mongod already running in debugger conn = db.getMongo(); work(); @@ -101,8 +104,8 @@ if( debugging ) { log(); // directories -var path1 = MongoRunner.dataPath + testname+"nodur"; -var path2 = MongoRunner.dataPath + testname+"dur"; +var path1 = MongoRunner.dataPath + testname + "nodur"; +var path2 = MongoRunner.dataPath + testname + "dur"; // non-durable version log("starting first mongod"); @@ -111,38 +114,40 @@ work(); MongoRunner.stopMongod(conn); // hail mary for windows -// Sat Jun 11 14:07:57 Error: boost::filesystem::create_directory: Access is denied: "\data\db\manyRestartsdur" (anon):1 +// Sat Jun 11 14:07:57 Error: boost::filesystem::create_directory: Access is denied: +// "\data\db\manyRestartsdur" (anon):1 sleep(1000); log("starting second mongod"); conn = MongoRunner.runMongod({dbpath: path2, journal: "", smallfiles: "", journalOptions: 8}); work(); // wait for group commit. -printjson(conn.getDB('admin').runCommand({getlasterror:1, fsync:1})); +printjson(conn.getDB('admin').runCommand({getlasterror: 1, fsync: 1})); MongoRunner.stopMongod(conn); sleep(5000); for (var i = 0; i < 3; ++i) { - // durable version log("restarting second mongod"); - conn = MongoRunner.runMongod({restart: true, - cleanData: false, - dbpath: path2, - journal: "", - smallfiles: "", - journalOptions: 8}); + conn = MongoRunner.runMongod({ + restart: true, + cleanData: false, + dbpath: path2, + journal: "", + smallfiles: "", + journalOptions: 8 + }); // wait for group commit. - printjson(conn.getDB('admin').runCommand({getlasterror:1, fsync:1})); - + printjson(conn.getDB('admin').runCommand({getlasterror: 1, fsync: 1})); + verify(); - + // kill the process hard log("hard kill"); - MongoRunner.stopMongod(conn, /*signal*/9); - + MongoRunner.stopMongod(conn, /*signal*/ 9); + sleep(5000); } @@ -150,12 +155,14 @@ for (var i = 0; i < 3; ++i) { // restart and recover log("restart"); -conn = MongoRunner.runMongod({restart: true, - cleanData: false, - dbpath: path2, - journal: "", - smallfiles: "", - journalOptions: 8}); +conn = MongoRunner.runMongod({ + restart: true, + cleanData: false, + dbpath: path2, + journal: "", + smallfiles: "", + journalOptions: 8 +}); log("verify"); verify(); log("stop"); @@ -179,27 +186,27 @@ log("check data matches done"); Random.setRandomSeed(); var nrows = 0; for (var i = 0; i < 5; ++i) { - // durable version log("restarting second mongod"); - conn = MongoRunner.runMongod({restart: true, - cleanData: false, - dbpath: path2, - journal: "", - smallfiles: "", - journalOptions: 8}); + conn = MongoRunner.runMongod({ + restart: true, + cleanData: false, + dbpath: path2, + journal: "", + smallfiles: "", + journalOptions: 8 + }); nrows += addRows(); // wait for group commit. - printjson(conn.getDB('admin').runCommand({getlasterror:1, fsync:1})); - + printjson(conn.getDB('admin').runCommand({getlasterror: 1, fsync: 1})); + verifyRows(nrows); - + // kill the process hard log("hard kill"); - MongoRunner.stopMongod(conn, /*signal*/9); - + MongoRunner.stopMongod(conn, /*signal*/ 9); + sleep(5000); } print(testname + " SUCCESS"); - |