diff options
Diffstat (limited to 'jstests/replsets/rollback5.js')
-rw-r--r-- | jstests/replsets/rollback5.js | 69 |
1 files changed, 39 insertions, 30 deletions
diff --git a/jstests/replsets/rollback5.js b/jstests/replsets/rollback5.js index 07f02419a59..e63b7ab34ea 100644 --- a/jstests/replsets/rollback5.js +++ b/jstests/replsets/rollback5.js @@ -9,16 +9,18 @@ // run on ephemeral storage engines. // @tags: [requires_persistence] -var replTest = new ReplSetTest({ name: 'rollback5', nodes: 3 }); +var replTest = new ReplSetTest({name: 'rollback5', nodes: 3}); var nodes = replTest.nodeList(); var conns = replTest.startSet(); -var r = replTest.initiate({ "_id": "rollback5", - "members": [ - { "_id": 0, "host": nodes[0], priority: 3 }, - { "_id": 1, "host": nodes[1] }, - { "_id": 2, "host": nodes[2], arbiterOnly: true}] - }); +var r = replTest.initiate({ + "_id": "rollback5", + "members": [ + {"_id": 0, "host": nodes[0], priority: 3}, + {"_id": 1, "host": nodes[1]}, + {"_id": 2, "host": nodes[2], arbiterOnly: true} + ] +}); // Make sure we have a master replTest.waitForState(replTest.nodes[0], ReplSetTest.State.PRIMARY, 60 * 1000); @@ -37,26 +39,35 @@ assert(master == conns[0], "conns[0] assumed to be master"); assert(a_conn.host == master.host); // Make sure we have an arbiter -assert.soon(function () { - res = conns[2].getDB("admin").runCommand({ replSetGetStatus: 1 }); +assert.soon(function() { + res = conns[2].getDB("admin").runCommand({replSetGetStatus: 1}); return res.myState == 7; }, "Arbiter failed to initialize."); -var options = { writeConcern: { w: 2, wtimeout: 60000 }, upsert: true }; -assert.writeOK(A.foo.update({ key: 'value1' }, { $set: { req: 'req' }}, options)); +var options = { + writeConcern: {w: 2, wtimeout: 60000}, + upsert: true +}; +assert.writeOK(A.foo.update({key: 'value1'}, {$set: {req: 'req'}}, options)); replTest.stop(AID); master = replTest.getPrimary(); assert(b_conn.host == master.host); -options = { writeConcern: { w: 1, wtimeout: 60000 }, upsert: true }; -assert.writeOK(B.foo.update({key:'value1'}, {$set: {res: 'res'}}, options)); +options = { + writeConcern: {w: 1, wtimeout: 60000}, + upsert: true +}; +assert.writeOK(B.foo.update({key: 'value1'}, {$set: {res: 'res'}}, options)); replTest.stop(BID); replTest.restart(AID); master = replTest.getPrimary(); assert(a_conn.host == master.host); -options = { writeConcern: { w: 1, wtimeout: 60000 }, upsert: true }; -assert.writeOK(A.foo.update({ key: 'value2' }, { $set: { req: 'req' }}, options)); -replTest.restart(BID); // should rollback +options = { + writeConcern: {w: 1, wtimeout: 60000}, + upsert: true +}; +assert.writeOK(A.foo.update({key: 'value2'}, {$set: {req: 'req'}}, options)); +replTest.restart(BID); // should rollback reconnect(B); print("BEFORE------------------"); @@ -69,12 +80,12 @@ print("AFTER------------------"); printjson(A.foo.find().toArray()); assert.eq(2, A.foo.count()); -assert.eq('req', A.foo.findOne({key:'value1'}).req); -assert.eq(null, A.foo.findOne({key:'value1'}).res); +assert.eq('req', A.foo.findOne({key: 'value1'}).req); +assert.eq(null, A.foo.findOne({key: 'value1'}).res); reconnect(B); assert.eq(2, B.foo.count()); -assert.eq('req', B.foo.findOne({key:'value1'}).req); -assert.eq(null, B.foo.findOne({key:'value1'}).res); +assert.eq('req', B.foo.findOne({key: 'value1'}).req); +assert.eq(null, B.foo.findOne({key: 'value1'}).res); // check here for rollback files var rollbackDir = Bpath + "rollback/"; @@ -83,7 +94,6 @@ assert(pathExists(rollbackDir), "rollback directory was not created!"); print("rollback5.js SUCCESS"); replTest.stopSet(15); - function wait(f) { var n = 0; while (!f()) { @@ -98,14 +108,13 @@ function wait(f) { } function reconnect(a) { - wait(function() { - try { - a.bar.stats(); - return true; - } catch(e) { - print(e); - return false; - } + wait(function() { + try { + a.bar.stats(); + return true; + } catch (e) { + print(e); + return false; + } }); } - |