summaryrefslogtreecommitdiff
path: root/jstests/gle
diff options
context:
space:
mode:
authorJonathan Abrahams <jonathan@mongodb.com>2016-03-09 12:17:50 -0500
committerJonathan Abrahams <jonathan@mongodb.com>2016-03-09 12:18:14 -0500
commit4ae691e8edc87d0e3cfb633bb91c328426be007b (patch)
tree52079a593f54382ca13a2e741633eab1b6271893 /jstests/gle
parenta025d43f3ce2efc1fb1282a718f5d286fa0a4dc1 (diff)
downloadmongo-4ae691e8edc87d0e3cfb633bb91c328426be007b.tar.gz
SERVER-22468 Format JS code with approved style in jstests/
Diffstat (limited to 'jstests/gle')
-rw-r--r--jstests/gle/block2.js49
-rw-r--r--jstests/gle/core/error1.js43
-rw-r--r--jstests/gle/core/error3.js8
-rw-r--r--jstests/gle/core/gle_example.js13
-rw-r--r--jstests/gle/core/gle_shell_server5441.js14
-rw-r--r--jstests/gle/core/remove5.js30
-rw-r--r--jstests/gle/core/update4.js42
-rw-r--r--jstests/gle/create_index_gle.js74
-rw-r--r--jstests/gle/get_last_error.js17
-rw-r--r--jstests/gle/gle_explicit_optime.js47
-rw-r--r--jstests/gle/gle_sharded_wc.js250
-rw-r--r--jstests/gle/gle_sharded_write.js101
-rw-r--r--jstests/gle/opcounters_legacy.js87
-rw-r--r--jstests/gle/sync1.js72
-rw-r--r--jstests/gle/sync4.js22
-rw-r--r--jstests/gle/sync8.js10
-rw-r--r--jstests/gle/updated_existing.js18
17 files changed, 449 insertions, 448 deletions
diff --git a/jstests/gle/block2.js b/jstests/gle/block2.js
index 142d51519b2..2d185ca0426 100644
--- a/jstests/gle/block2.js
+++ b/jstests/gle/block2.js
@@ -3,56 +3,51 @@
* available at jstests/repl.
*/
-var rt = new ReplTest( "block1" );
+var rt = new ReplTest("block1");
-var m = rt.start( true );
-var s = rt.start( false );
+var m = rt.start(true);
+var s = rt.start(false);
if (m.writeMode() == 'commands') {
jsTest.log('Skipping test since commands mode is already tested in repl/');
-}
-else {
-
- function setup(){
-
- dbm = m.getDB( "foo" );
- dbs = s.getDB( "foo" );
+} else {
+ function setup() {
+ dbm = m.getDB("foo");
+ dbs = s.getDB("foo");
tm = dbm.bar;
ts = dbs.bar;
}
setup();
- function check( msg ){
- assert.eq( tm.count() , ts.count() , "check: " + msg );
+ function check(msg) {
+ assert.eq(tm.count(), ts.count(), "check: " + msg);
}
- function worked( w , wtimeout ){
- var gle = dbm.getLastError( w , wtimeout );
+ function worked(w, wtimeout) {
+ var gle = dbm.getLastError(w, wtimeout);
if (gle != null) {
printjson(gle);
}
return gle == null;
}
- check( "A" );
+ check("A");
- tm.save( { x : 1 } );
- assert( worked( 2 ) , "B" );
+ tm.save({x: 1});
+ assert(worked(2), "B");
- tm.save( { x : 2 } );
- assert( worked( 2 , 3000 ) , "C" );
+ tm.save({x: 2});
+ assert(worked(2, 3000), "C");
- rt.stop( false );
- tm.save( { x : 3 } );
- assert.eq( 3 , tm.count() , "D1" );
- assert( ! worked( 2 , 3000 ) , "D2" );
+ rt.stop(false);
+ tm.save({x: 3});
+ assert.eq(3, tm.count(), "D1");
+ assert(!worked(2, 3000), "D2");
- s = rt.start( false );
+ s = rt.start(false);
setup();
- assert( worked( 2 , 30000 ) , "E" );
-
+ assert(worked(2, 30000), "E");
}
rt.stop();
-
diff --git a/jstests/gle/core/error1.js b/jstests/gle/core/error1.js
index b29986976c4..44667867d4c 100644
--- a/jstests/gle/core/error1.js
+++ b/jstests/gle/core/error1.js
@@ -1,41 +1,40 @@
db.jstests_error1.drop();
// test 1
-db.runCommand({reseterror:1});
-assert( db.runCommand({getlasterror:1}).err == null, "A" );
-assert( db.runCommand({getpreverror:1}).err == null, "B" );
+db.runCommand({reseterror: 1});
+assert(db.runCommand({getlasterror: 1}).err == null, "A");
+assert(db.runCommand({getpreverror: 1}).err == null, "B");
db.resetError();
-assert( db.getLastError() == null, "C" );
-assert( db.getPrevError().err == null , "preverror 1" );
+assert(db.getLastError() == null, "C");
+assert(db.getPrevError().err == null, "preverror 1");
// test 2
-db.runCommand({forceerror:1});
-assert( db.runCommand({getlasterror:1}).err != null, "D" );
-assert( db.runCommand({getpreverror:1}).err != null, "E" );
+db.runCommand({forceerror: 1});
+assert(db.runCommand({getlasterror: 1}).err != null, "D");
+assert(db.runCommand({getpreverror: 1}).err != null, "E");
-
-assert( db.getLastError() != null, "F" );
-assert( db.getPrevError().err != null , "preverror 2" );
-assert( db.getPrevError().nPrev == 1, "G" );
+assert(db.getLastError() != null, "F");
+assert(db.getPrevError().err != null, "preverror 2");
+assert(db.getPrevError().nPrev == 1, "G");
db.jstests_error1.findOne();
-assert( db.runCommand({getlasterror:1}).err == null, "H" );
-assert( db.runCommand({getpreverror:1}).err != null, "I" );
-assert( db.runCommand({getpreverror:1}).nPrev == 2, "J" );
+assert(db.runCommand({getlasterror: 1}).err == null, "H");
+assert(db.runCommand({getpreverror: 1}).err != null, "I");
+assert(db.runCommand({getpreverror: 1}).nPrev == 2, "J");
db.jstests_error1.findOne();
-assert( db.runCommand({getlasterror:1}).err == null, "K" );
-assert( db.runCommand({getpreverror:1}).err != null, "L" );
-assert( db.runCommand({getpreverror:1}).nPrev == 3, "M" );
+assert(db.runCommand({getlasterror: 1}).err == null, "K");
+assert(db.runCommand({getpreverror: 1}).err != null, "L");
+assert(db.runCommand({getpreverror: 1}).nPrev == 3, "M");
db.resetError();
db.forceError();
db.jstests_error1.findOne();
-assert( db.getLastError() == null , "getLastError 5" );
-assert( db.getPrevError().err != null , "preverror 3" );
+assert(db.getLastError() == null, "getLastError 5");
+assert(db.getPrevError().err != null, "preverror 3");
// test 3
-db.runCommand({reseterror:1});
-assert( db.runCommand({getpreverror:1}).err == null, "N" );
+db.runCommand({reseterror: 1});
+assert(db.runCommand({getpreverror: 1}).err == null, "N");
diff --git a/jstests/gle/core/error3.js b/jstests/gle/core/error3.js
index 9f7f298cb5e..7067f68f8a8 100644
--- a/jstests/gle/core/error3.js
+++ b/jstests/gle/core/error3.js
@@ -1,5 +1,5 @@
-db.runCommand( "forceerror" );
-assert.eq( "forced error" , db.getLastError() );
-db.runCommand( "switchtoclienterrors" );
-assert.isnull( db.getLastError() );
+db.runCommand("forceerror");
+assert.eq("forced error", db.getLastError());
+db.runCommand("switchtoclienterrors");
+assert.isnull(db.getLastError());
diff --git a/jstests/gle/core/gle_example.js b/jstests/gle/core/gle_example.js
index 8c6e481b5a7..6096f605217 100644
--- a/jstests/gle/core/gle_example.js
+++ b/jstests/gle/core/gle_example.js
@@ -5,13 +5,13 @@
var coll = db.getCollection("gle_example");
coll.drop();
-coll.insert({ hello : "world" });
-assert.eq( null, coll.getDB().getLastError() );
+coll.insert({hello: "world"});
+assert.eq(null, coll.getDB().getLastError());
// Error on insert.
coll.drop();
-coll.insert({ _id: 1 });
-coll.insert({ _id: 1 });
+coll.insert({_id: 1});
+coll.insert({_id: 1});
var gle = db.getLastErrorObj();
assert.neq(null, gle.err);
@@ -22,8 +22,7 @@ assert.eq(null, gle.err);
// Error on upsert.
coll.drop();
-coll.insert({ _id: 1 });
-coll.update({ y: 1 }, { _id: 1 }, true);
+coll.insert({_id: 1});
+coll.update({y: 1}, {_id: 1}, true);
gle = db.getLastErrorObj();
assert.neq(null, gle.err);
-
diff --git a/jstests/gle/core/gle_shell_server5441.js b/jstests/gle/core/gle_shell_server5441.js
index dedb135f20a..e488c289299 100644
--- a/jstests/gle/core/gle_shell_server5441.js
+++ b/jstests/gle/core/gle_shell_server5441.js
@@ -12,16 +12,16 @@ function checkgle(iteration) {
assert.eq(2, gle.n, "failed on iteration " + iteration + ", getLastErrorObj()=" + tojson(gle));
}
-t.insert( { x : 1 } );
-t.insert( { x : 1 } );
-updateReturn = t.update( {} , { $inc : { x : 2 } } , false , true );
+t.insert({x: 1});
+t.insert({x: 1});
+updateReturn = t.update({}, {$inc: {x: 2}}, false, true);
-for ( i=0; i<100; i++ ) {
- checkgle(""+i);
+for (i = 0; i < 100; i++) {
+ checkgle("" + i);
}
-db.adminCommand( { replSetGetStatus : 1 , forShell : 1 } );
-shellPrintHelper( updateReturn );
+db.adminCommand({replSetGetStatus: 1, forShell: 1});
+shellPrintHelper(updateReturn);
defaultPrompt();
checkgle("'final'");
diff --git a/jstests/gle/core/remove5.js b/jstests/gle/core/remove5.js
index 6558854264f..4a9393ea202 100644
--- a/jstests/gle/core/remove5.js
+++ b/jstests/gle/core/remove5.js
@@ -2,23 +2,23 @@ f = db.jstests_remove5;
f.drop();
getLastError = function() {
- return db.runCommand( { getlasterror : 1 } );
+ return db.runCommand({getlasterror: 1});
};
-f.remove( {} );
-assert.eq( 0, getLastError().n );
-f.save( {a:1} );
-f.remove( {} );
-assert.eq( 1, getLastError().n );
-for( i = 0; i < 10; ++i ) {
- f.save( {i:i} );
+f.remove({});
+assert.eq(0, getLastError().n);
+f.save({a: 1});
+f.remove({});
+assert.eq(1, getLastError().n);
+for (i = 0; i < 10; ++i) {
+ f.save({i: i});
}
-f.remove( {} );
-assert.eq( 10, getLastError().n );
-assert.eq( 10, db.getPrevError().n );
-assert.eq( 1, db.getPrevError().nPrev );
+f.remove({});
+assert.eq(10, getLastError().n);
+assert.eq(10, db.getPrevError().n);
+assert.eq(1, db.getPrevError().nPrev);
f.findOne();
-assert.eq( 0, getLastError().n );
-assert.eq( 10, db.getPrevError().n );
-assert.eq( 2, db.getPrevError().nPrev );
+assert.eq(0, getLastError().n);
+assert.eq(10, db.getPrevError().n);
+assert.eq(2, db.getPrevError().nPrev);
diff --git a/jstests/gle/core/update4.js b/jstests/gle/core/update4.js
index 3d68dc24916..83dbf717019 100644
--- a/jstests/gle/core/update4.js
+++ b/jstests/gle/core/update4.js
@@ -2,32 +2,32 @@ f = db.jstests_update4;
f.drop();
getLastError = function() {
- ret = db.runCommand( { getlasterror : 1 } );
-// printjson( ret );
+ ret = db.runCommand({getlasterror: 1});
+ // printjson( ret );
return ret;
};
-f.save( {a:1} );
-f.update( {a:1}, {a:2} );
-assert.eq( true, getLastError().updatedExisting , "A" );
-assert.eq( 1, getLastError().n , "B" );
-f.update( {a:1}, {a:2} );
-assert.eq( false, getLastError().updatedExisting , "C" );
-assert.eq( 0, getLastError().n , "D" );
+f.save({a: 1});
+f.update({a: 1}, {a: 2});
+assert.eq(true, getLastError().updatedExisting, "A");
+assert.eq(1, getLastError().n, "B");
+f.update({a: 1}, {a: 2});
+assert.eq(false, getLastError().updatedExisting, "C");
+assert.eq(0, getLastError().n, "D");
-f.update( {a:1}, {a:1}, true );
-assert.eq( false, getLastError().updatedExisting , "E" );
-assert.eq( 1, getLastError().n , "F" );
-f.update( {a:1}, {a:1}, true );
-assert.eq( true, getLastError().updatedExisting , "G" );
-assert.eq( 1, getLastError().n , "H" );
-assert.eq( true, db.getPrevError().updatedExisting , "I" );
-assert.eq( 1, db.getPrevError().nPrev , "J" );
+f.update({a: 1}, {a: 1}, true);
+assert.eq(false, getLastError().updatedExisting, "E");
+assert.eq(1, getLastError().n, "F");
+f.update({a: 1}, {a: 1}, true);
+assert.eq(true, getLastError().updatedExisting, "G");
+assert.eq(1, getLastError().n, "H");
+assert.eq(true, db.getPrevError().updatedExisting, "I");
+assert.eq(1, db.getPrevError().nPrev, "J");
f.findOne();
-assert.eq( undefined, getLastError().updatedExisting , "K" );
-assert.eq( true, db.getPrevError().updatedExisting , "L" );
-assert.eq( 2, db.getPrevError().nPrev , "M" );
+assert.eq(undefined, getLastError().updatedExisting, "K");
+assert.eq(true, db.getPrevError().updatedExisting, "L");
+assert.eq(2, db.getPrevError().nPrev, "M");
db.forceError();
-assert.eq( undefined, getLastError().updatedExisting , "N" );
+assert.eq(undefined, getLastError().updatedExisting, "N");
diff --git a/jstests/gle/create_index_gle.js b/jstests/gle/create_index_gle.js
index 18732fb50fa..ce3dcb58c03 100644
--- a/jstests/gle/create_index_gle.js
+++ b/jstests/gle/create_index_gle.js
@@ -1,48 +1,48 @@
load('jstests/replsets/rslib.js');
-(function () {
-"use strict";
-
-var st = new ShardingTest({
- shards: {
- rs0: {
- nodes: { n0: {}, n1: { rsConfig: { priority: 0 } } },
- oplogSize: 10,
- }
- },
-});
-var replTest = st.rs0;
-
-var config = replTest.getReplSetConfig();
-// Add a delay long enough so getLastError would actually 'wait' for write concern.
-config.members[1].slaveDelay = 3;
-config.version = 2;
-
-reconfig(replTest, config, true);
-
-assert.soon(function() {
- var secConn = replTest.getSecondary();
- var config = secConn.getDB('local').system.replset.findOne();
- return config.members[1].slaveDelay == 3;
-});
+(function() {
+ "use strict";
+
+ var st = new ShardingTest({
+ shards: {
+ rs0: {
+ nodes: {n0: {}, n1: {rsConfig: {priority: 0}}},
+ oplogSize: 10,
+ }
+ },
+ });
+ var replTest = st.rs0;
+
+ var config = replTest.getReplSetConfig();
+ // Add a delay long enough so getLastError would actually 'wait' for write concern.
+ config.members[1].slaveDelay = 3;
+ config.version = 2;
-replTest.awaitSecondaryNodes();
+ reconfig(replTest, config, true);
-var testDB = st.s.getDB('test');
-testDB.adminCommand({ connPoolSync: 1 });
+ assert.soon(function() {
+ var secConn = replTest.getSecondary();
+ var config = secConn.getDB('local').system.replset.findOne();
+ return config.members[1].slaveDelay == 3;
+ });
-var secConn = replTest.getSecondary();
-var testDB2 = secConn.getDB('test');
+ replTest.awaitSecondaryNodes();
+
+ var testDB = st.s.getDB('test');
+ testDB.adminCommand({connPoolSync: 1});
+
+ var secConn = replTest.getSecondary();
+ var testDB2 = secConn.getDB('test');
-testDB.user.insert({ x: 1 });
+ testDB.user.insert({x: 1});
-testDB.user.ensureIndex({ x: 1 });
-assert.gleOK(testDB.runCommand({ getLastError: 1, w: 2 }));
+ testDB.user.ensureIndex({x: 1});
+ assert.gleOK(testDB.runCommand({getLastError: 1, w: 2}));
-var priIdx = testDB.user.getIndexes();
-var secIdx = testDB2.user.getIndexes();
+ var priIdx = testDB.user.getIndexes();
+ var secIdx = testDB2.user.getIndexes();
-assert.eq(priIdx.length, secIdx.length, 'pri: ' + tojson(priIdx) + ', sec: ' + tojson(secIdx));
+ assert.eq(priIdx.length, secIdx.length, 'pri: ' + tojson(priIdx) + ', sec: ' + tojson(secIdx));
-st.stop();
+ st.stop();
}());
diff --git a/jstests/gle/get_last_error.js b/jstests/gle/get_last_error.js
index 3b5d6368c61..cc356ebf539 100644
--- a/jstests/gle/get_last_error.js
+++ b/jstests/gle/get_last_error.js
@@ -1,17 +1,17 @@
// Check that the wtime and writtenTo fields are set or unset depending on the writeConcern used.
// First check on a replica set with different combinations of writeConcern
var name = "SERVER-9005";
-var replTest = new ReplSetTest({name: name, oplogSize: 1, nodes: 3,
- settings: {chainingAllowed: false}});
+var replTest =
+ new ReplSetTest({name: name, oplogSize: 1, nodes: 3, settings: {chainingAllowed: false}});
var nodes = replTest.startSet();
replTest.initiate();
var master = replTest.getPrimary();
var mdb = master.getDB("test");
// synchronize replication
-assert.writeOK(mdb.foo.insert({ _id: "1" }, {writeConcern: {w: 3, wtimeout:30000}}));
+assert.writeOK(mdb.foo.insert({_id: "1"}, {writeConcern: {w: 3, wtimeout: 30000}}));
-var gle = master.getDB("test").runCommand({getLastError : 1, j : true});
+var gle = master.getDB("test").runCommand({getLastError: 1, j: true});
print('Trying j=true');
printjson(gle);
if (gle.err === null) {
@@ -20,8 +20,7 @@ if (gle.err === null) {
assert.eq(gle.waited, null);
assert.eq(gle.wtime, null);
assert.eq(gle.wtimeout, null);
-}
-else {
+} else {
// Bad GLE is a permissible error here, if journaling is disabled.
assert(gle.badGLE);
assert.eq(gle.code, 2);
@@ -52,7 +51,7 @@ replTest.stop(2);
master = replTest.getPrimary();
mdb = master.getDB("test");
// do w:2 write so secondary is caught up before calling {gle w:3}.
-assert.writeOK(mdb.foo.insert({_id: "3"}, {writeConcern: {w: 2, wtimeout:30000}}));
+assert.writeOK(mdb.foo.insert({_id: "3"}, {writeConcern: {w: 2, wtimeout: 30000}}));
gle = mdb.getLastErrorObj(3, 1000);
print('Trying w=3 with 2 nodes up, 1000ms timeout.');
printjson(gle);
@@ -83,7 +82,7 @@ var mongod = MongoRunner.runMongod({});
var sdb = mongod.getDB("test");
sdb.foo.drop();
-sdb.foo.insert({ _id: "1" });
+sdb.foo.insert({_id: "1"});
gle = sdb.getLastErrorObj(1);
print('Trying standalone server with w=1.');
@@ -95,7 +94,7 @@ assert.eq(gle.wtime, null);
assert.eq(gle.waited, null);
assert.eq(gle.wtimeout, null);
-gle = sdb.runCommand({getLastError : 1, w : 2, wtimeout : 10 });
+gle = sdb.runCommand({getLastError: 1, w: 2, wtimeout: 10});
print('Trying standalone server with w=2 and 10ms timeout.');
// This is an error in 2.6
printjson(gle);
diff --git a/jstests/gle/gle_explicit_optime.js b/jstests/gle/gle_explicit_optime.js
index 7bc9e35b3a9..476409c57b4 100644
--- a/jstests/gle/gle_explicit_optime.js
+++ b/jstests/gle/gle_explicit_optime.js
@@ -5,53 +5,62 @@
// support the command.
// @tags: [requires_fsync]
-var rst = new ReplSetTest({ nodes : 2 });
+var rst = new ReplSetTest({nodes: 2});
rst.startSet();
rst.initiate();
var primary = rst.getPrimary();
var secondary = rst.getSecondary();
-var coll = primary.getCollection( "foo.bar" );
+var coll = primary.getCollection("foo.bar");
// Insert a doc and replicate it to two servers
-coll.insert({ some : "doc" });
-var gleObj = coll.getDB().getLastErrorObj( 2 ); // w : 2
-assert.eq( null, gleObj.err );
+coll.insert({some: "doc"});
+var gleObj = coll.getDB().getLastErrorObj(2); // w : 2
+assert.eq(null, gleObj.err);
var opTimeBeforeFailure = gleObj.lastOp;
// Lock the secondary
assert.commandWorked(secondary.getDB("admin").fsyncLock());
// Insert a doc and replicate it to the primary only
-coll.insert({ some : "doc" });
-gleObj = coll.getDB().getLastErrorObj( 1 ); // w : 1
-assert.eq( null, gleObj.err );
+coll.insert({some: "doc"});
+gleObj = coll.getDB().getLastErrorObj(1); // w : 1
+assert.eq(null, gleObj.err);
var opTimeAfterFailure = gleObj.lastOp;
printjson(opTimeBeforeFailure);
printjson(opTimeAfterFailure);
-printjson( primary.getDB("admin").runCommand({ replSetGetStatus : true }) );
+printjson(primary.getDB("admin").runCommand({replSetGetStatus: true}));
// Create a new connection with new client and no opTime
-var newClientConn = new Mongo( primary.host );
+var newClientConn = new Mongo(primary.host);
// New client has no set opTime, so w : 2 has no impact
-gleObj = newClientConn.getCollection( coll.toString() ).getDB().getLastErrorObj( 2 ); // w : 2
-assert.eq( null, gleObj.err );
+gleObj = newClientConn.getCollection(coll.toString()).getDB().getLastErrorObj(2); // w : 2
+assert.eq(null, gleObj.err);
// Using an explicit optime on the new client should work if the optime is earlier than the
// secondary was locked
-var gleOpTimeBefore = { getLastError : true, w : 2, wOpTime : opTimeBeforeFailure };
-gleObj = newClientConn.getCollection( coll.toString() ).getDB().runCommand( gleOpTimeBefore );
-assert.eq( null, gleObj.err );
+var gleOpTimeBefore = {
+ getLastError: true,
+ w: 2,
+ wOpTime: opTimeBeforeFailure
+};
+gleObj = newClientConn.getCollection(coll.toString()).getDB().runCommand(gleOpTimeBefore);
+assert.eq(null, gleObj.err);
// Using an explicit optime on the new client should not work if the optime is later than the
// secondary was locked
-var gleOpTimeAfter = { getLastError : true, w : 2, wtimeout : 1000, wOpTime : opTimeAfterFailure };
-gleObj = newClientConn.getCollection( coll.toString() ).getDB().runCommand( gleOpTimeAfter );
-assert.neq( null, gleObj.err );
-assert( gleObj.wtimeout );
+var gleOpTimeAfter = {
+ getLastError: true,
+ w: 2,
+ wtimeout: 1000,
+ wOpTime: opTimeAfterFailure
+};
+gleObj = newClientConn.getCollection(coll.toString()).getDB().runCommand(gleOpTimeAfter);
+assert.neq(null, gleObj.err);
+assert(gleObj.wtimeout);
jsTest.log("DONE!");
diff --git a/jstests/gle/gle_sharded_wc.js b/jstests/gle/gle_sharded_wc.js
index 71883b12c0f..ba7594588e3 100644
--- a/jstests/gle/gle_sharded_wc.js
+++ b/jstests/gle/gle_sharded_wc.js
@@ -6,129 +6,131 @@
// @tags: [SERVER-21420]
(function() {
-'use strict';
-
-// Options for a cluster with two replica set shards, the first with two nodes the second with one
-// This lets us try a number of GLE scenarios
-var options = { rs : true,
- rsOptions : { nojournal : "" },
- // Options for each replica set shard
- rs0 : { nodes : 3 },
- rs1 : { nodes : 3 } };
-
-var st = new ShardingTest({ shards: 2, other : options });
-
-var mongos = st.s0;
-var admin = mongos.getDB( "admin" );
-var config = mongos.getDB( "config" );
-var coll = mongos.getCollection( jsTestName() + ".coll" );
-var shards = config.shards.find().toArray();
-
-assert.commandWorked( admin.runCommand({ enableSharding : coll.getDB().toString() }) );
-printjson( admin.runCommand({ movePrimary : coll.getDB().toString(), to : shards[0]._id }) );
-assert.commandWorked( admin.runCommand({ shardCollection : coll.toString(), key : { _id : 1 } }) );
-assert.commandWorked( admin.runCommand({ split : coll.toString(), middle : { _id : 0 } }) );
-assert.commandWorked( admin.runCommand({ moveChunk : coll.toString(),
- find : { _id : 0 },
- to : shards[1]._id }) );
-
-st.printShardingStatus();
-
-var gle = null;
-
-//
-// No journal insert, GLE fails
-coll.remove({});
-coll.insert({ _id : 1 });
-printjson(gle = coll.getDB().runCommand({ getLastError : 1, j : true }));
-assert(!gle.ok);
-assert(gle.errmsg);
-
-//
-// Successful insert, write concern mode invalid
-coll.remove({});
-coll.insert({ _id : -1 });
-printjson(gle = coll.getDB().runCommand({ getLastError : 1, w : 'invalid' }));
-assert(!gle.ok);
-assert(!gle.err);
-assert(gle.errmsg);
-assert.eq(gle.code, 79); // UnknownReplWriteConcern - needed for backwards compatibility
-assert.eq(coll.count(), 1);
-
-//
-// Error on insert (dup key), write concern error not reported
-coll.remove({});
-coll.insert({ _id : -1 });
-coll.insert({ _id : -1 });
-printjson(gle = coll.getDB().runCommand({ getLastError : 1, w : 'invalid' }));
-assert(gle.ok);
-assert(gle.err);
-assert(gle.code);
-assert(!gle.errmsg);
-assert.eq(coll.count(), 1);
-
-//
-// Successful remove on one shard, write concern timeout on the other
-var s0Id = st.rs0.getNodeId(st.rs0.liveNodes.slaves[0]);
-st.rs0.stop(s0Id);
-coll.remove({});
-st.rs1.awaitReplication(); // To ensure the first shard won't timeout
-printjson(gle = coll.getDB().runCommand({ getLastError : 1, w : 3, wtimeout : 5 * 1000 }));
-assert(gle.ok);
-assert.eq(gle.err, 'timeout');
-assert(gle.wtimeout);
-assert(gle.shards);
-assert.eq(coll.count(), 0);
-
-//
-// Successful remove on two hosts, write concern timeout on both
-// We don't aggregate two timeouts together
-var s1Id = st.rs1.getNodeId(st.rs1.liveNodes.slaves[0]);
-st.rs1.stop(s1Id);
-// new writes to both shards to ensure that remove will do something on both of them
-coll.insert({ _id : -1 });
-coll.insert({ _id : 1 });
-
-coll.remove({});
-printjson(gle = coll.getDB().runCommand({ getLastError : 1, w : 3, wtimeout : 5 * 1000 }));
-
-assert(!gle.ok);
-assert(gle.errmsg);
-assert.eq(gle.code, 64); // WriteConcernFailed - needed for backwards compatibility
-assert(!gle.wtimeout);
-assert(gle.shards);
-assert(gle.errs);
-assert.eq(coll.count(), 0);
-
-//
-// First replica set with no primary
-//
-
-//
-// Successful bulk insert on two hosts, host changes before gle (error contacting host)
-coll.remove({});
-coll.insert([{ _id : 1 }, { _id : -1 }]);
-// Wait for write to be written to shards before shutting it down.
-printjson(gle = coll.getDB().runCommand({ getLastError : 1 }));
-st.rs0.stop(st.rs0.getPrimary(), true); // wait for stop
-printjson(gle = coll.getDB().runCommand({ getLastError : 1 }));
-// Should get an error about contacting dead host.
-assert(!gle.ok);
-assert(gle.errmsg);
-assert.eq(coll.count({ _id : 1 }), 1);
-
-//
-// Failed insert on two hosts, first replica set with no primary
-// NOTE: This is DIFFERENT from 2.4, since we don't need to contact a host we didn't get
-// successful writes from.
-coll.remove({ _id : 1 });
-coll.insert([{ _id : 1 }, { _id : -1 }]);
-
-printjson(gle = coll.getDB().runCommand({ getLastError : 1 }));
-assert(gle.ok);
-assert(gle.err);
-assert.eq(coll.count({ _id : 1 }), 1);
-
-st.stop();
+ 'use strict';
+
+ // Options for a cluster with two replica set shards, the first with two nodes the second with
+ // one
+ // This lets us try a number of GLE scenarios
+ var options = {
+ rs: true,
+ rsOptions: {nojournal: ""},
+ // Options for each replica set shard
+ rs0: {nodes: 3},
+ rs1: {nodes: 3}
+ };
+
+ var st = new ShardingTest({shards: 2, other: options});
+
+ var mongos = st.s0;
+ var admin = mongos.getDB("admin");
+ var config = mongos.getDB("config");
+ var coll = mongos.getCollection(jsTestName() + ".coll");
+ var shards = config.shards.find().toArray();
+
+ assert.commandWorked(admin.runCommand({enableSharding: coll.getDB().toString()}));
+ printjson(admin.runCommand({movePrimary: coll.getDB().toString(), to: shards[0]._id}));
+ assert.commandWorked(admin.runCommand({shardCollection: coll.toString(), key: {_id: 1}}));
+ assert.commandWorked(admin.runCommand({split: coll.toString(), middle: {_id: 0}}));
+ assert.commandWorked(
+ admin.runCommand({moveChunk: coll.toString(), find: {_id: 0}, to: shards[1]._id}));
+
+ st.printShardingStatus();
+
+ var gle = null;
+
+ //
+ // No journal insert, GLE fails
+ coll.remove({});
+ coll.insert({_id: 1});
+ printjson(gle = coll.getDB().runCommand({getLastError: 1, j: true}));
+ assert(!gle.ok);
+ assert(gle.errmsg);
+
+ //
+ // Successful insert, write concern mode invalid
+ coll.remove({});
+ coll.insert({_id: -1});
+ printjson(gle = coll.getDB().runCommand({getLastError: 1, w: 'invalid'}));
+ assert(!gle.ok);
+ assert(!gle.err);
+ assert(gle.errmsg);
+ assert.eq(gle.code, 79); // UnknownReplWriteConcern - needed for backwards compatibility
+ assert.eq(coll.count(), 1);
+
+ //
+ // Error on insert (dup key), write concern error not reported
+ coll.remove({});
+ coll.insert({_id: -1});
+ coll.insert({_id: -1});
+ printjson(gle = coll.getDB().runCommand({getLastError: 1, w: 'invalid'}));
+ assert(gle.ok);
+ assert(gle.err);
+ assert(gle.code);
+ assert(!gle.errmsg);
+ assert.eq(coll.count(), 1);
+
+ //
+ // Successful remove on one shard, write concern timeout on the other
+ var s0Id = st.rs0.getNodeId(st.rs0.liveNodes.slaves[0]);
+ st.rs0.stop(s0Id);
+ coll.remove({});
+ st.rs1.awaitReplication(); // To ensure the first shard won't timeout
+ printjson(gle = coll.getDB().runCommand({getLastError: 1, w: 3, wtimeout: 5 * 1000}));
+ assert(gle.ok);
+ assert.eq(gle.err, 'timeout');
+ assert(gle.wtimeout);
+ assert(gle.shards);
+ assert.eq(coll.count(), 0);
+
+ //
+ // Successful remove on two hosts, write concern timeout on both
+ // We don't aggregate two timeouts together
+ var s1Id = st.rs1.getNodeId(st.rs1.liveNodes.slaves[0]);
+ st.rs1.stop(s1Id);
+ // new writes to both shards to ensure that remove will do something on both of them
+ coll.insert({_id: -1});
+ coll.insert({_id: 1});
+
+ coll.remove({});
+ printjson(gle = coll.getDB().runCommand({getLastError: 1, w: 3, wtimeout: 5 * 1000}));
+
+ assert(!gle.ok);
+ assert(gle.errmsg);
+ assert.eq(gle.code, 64); // WriteConcernFailed - needed for backwards compatibility
+ assert(!gle.wtimeout);
+ assert(gle.shards);
+ assert(gle.errs);
+ assert.eq(coll.count(), 0);
+
+ //
+ // First replica set with no primary
+ //
+
+ //
+ // Successful bulk insert on two hosts, host changes before gle (error contacting host)
+ coll.remove({});
+ coll.insert([{_id: 1}, {_id: -1}]);
+ // Wait for write to be written to shards before shutting it down.
+ printjson(gle = coll.getDB().runCommand({getLastError: 1}));
+ st.rs0.stop(st.rs0.getPrimary(), true); // wait for stop
+ printjson(gle = coll.getDB().runCommand({getLastError: 1}));
+ // Should get an error about contacting dead host.
+ assert(!gle.ok);
+ assert(gle.errmsg);
+ assert.eq(coll.count({_id: 1}), 1);
+
+ //
+ // Failed insert on two hosts, first replica set with no primary
+ // NOTE: This is DIFFERENT from 2.4, since we don't need to contact a host we didn't get
+ // successful writes from.
+ coll.remove({_id: 1});
+ coll.insert([{_id: 1}, {_id: -1}]);
+
+ printjson(gle = coll.getDB().runCommand({getLastError: 1}));
+ assert(gle.ok);
+ assert(gle.err);
+ assert.eq(coll.count({_id: 1}), 1);
+
+ st.stop();
})();
diff --git a/jstests/gle/gle_sharded_write.js b/jstests/gle/gle_sharded_write.js
index cfe3c8f1ad2..f1feffed5b2 100644
--- a/jstests/gle/gle_sharded_write.js
+++ b/jstests/gle/gle_sharded_write.js
@@ -3,22 +3,21 @@
// Note that test should work correctly with and without write commands.
//
-var st = new ShardingTest({ shards : 2, mongos : 1 });
+var st = new ShardingTest({shards: 2, mongos: 1});
st.stopBalancer();
var mongos = st.s0;
-var admin = mongos.getDB( "admin" );
-var config = mongos.getDB( "config" );
-var coll = mongos.getCollection( jsTestName() + ".coll" );
+var admin = mongos.getDB("admin");
+var config = mongos.getDB("config");
+var coll = mongos.getCollection(jsTestName() + ".coll");
var shards = config.shards.find().toArray();
-assert.commandWorked( admin.runCommand({ enableSharding : coll.getDB().toString() }) );
-printjson( admin.runCommand({ movePrimary : coll.getDB().toString(), to : shards[0]._id }) );
-assert.commandWorked( admin.runCommand({ shardCollection : coll.toString(), key : { _id : 1 } }) );
-assert.commandWorked( admin.runCommand({ split : coll.toString(), middle : { _id : 0 } }) );
-assert.commandWorked( admin.runCommand({ moveChunk : coll.toString(),
- find : { _id : 0 },
- to : shards[1]._id }) );
+assert.commandWorked(admin.runCommand({enableSharding: coll.getDB().toString()}));
+printjson(admin.runCommand({movePrimary: coll.getDB().toString(), to: shards[0]._id}));
+assert.commandWorked(admin.runCommand({shardCollection: coll.toString(), key: {_id: 1}}));
+assert.commandWorked(admin.runCommand({split: coll.toString(), middle: {_id: 0}}));
+assert.commandWorked(
+ admin.runCommand({moveChunk: coll.toString(), find: {_id: 0}, to: shards[1]._id}));
st.printShardingStatus();
@@ -27,8 +26,8 @@ var gle = null;
//
// Successful insert
coll.remove({});
-coll.insert({ _id : -1 });
-printjson(gle = coll.getDB().runCommand({ getLastError : 1 }));
+coll.insert({_id: -1});
+printjson(gle = coll.getDB().runCommand({getLastError: 1}));
assert(gle.ok);
assert('err' in gle);
assert(!gle.err);
@@ -37,9 +36,9 @@ assert.eq(coll.count(), 1);
//
// Successful update
coll.remove({});
-coll.insert({ _id : 1 });
-coll.update({ _id : 1 }, { $set : { foo : "bar" } });
-printjson(gle = coll.getDB().runCommand({ getLastError : 1 }));
+coll.insert({_id: 1});
+coll.update({_id: 1}, {$set: {foo: "bar"}});
+printjson(gle = coll.getDB().runCommand({getLastError: 1}));
assert(gle.ok);
assert('err' in gle);
assert(!gle.err);
@@ -50,9 +49,9 @@ assert.eq(coll.count(), 1);
//
// Successful multi-update
coll.remove({});
-coll.insert({ _id : 1 });
-coll.update({ }, { $set : { foo : "bar" } }, false, true);
-printjson(gle = coll.getDB().runCommand({ getLastError : 1 }));
+coll.insert({_id: 1});
+coll.update({}, {$set: {foo: "bar"}}, false, true);
+printjson(gle = coll.getDB().runCommand({getLastError: 1}));
assert(gle.ok);
assert('err' in gle);
assert(!gle.err);
@@ -63,8 +62,8 @@ assert.eq(coll.count(), 1);
//
// Successful upsert
coll.remove({});
-coll.update({ _id : 1 }, { _id : 1 }, true);
-printjson(gle = coll.getDB().runCommand({ getLastError : 1 }));
+coll.update({_id: 1}, {_id: 1}, true);
+printjson(gle = coll.getDB().runCommand({getLastError: 1}));
assert(gle.ok);
assert('err' in gle);
assert(!gle.err);
@@ -76,9 +75,9 @@ assert.eq(coll.count(), 1);
//
// Successful upserts
coll.remove({});
-coll.update({ _id : -1 }, { _id : -1 }, true);
-coll.update({ _id : 1 }, { _id : 1 }, true);
-printjson(gle = coll.getDB().runCommand({ getLastError : 1 }));
+coll.update({_id: -1}, {_id: -1}, true);
+coll.update({_id: 1}, {_id: 1}, true);
+printjson(gle = coll.getDB().runCommand({getLastError: 1}));
assert(gle.ok);
assert('err' in gle);
assert(!gle.err);
@@ -90,9 +89,9 @@ assert.eq(coll.count(), 2);
//
// Successful remove
coll.remove({});
-coll.insert({ _id : 1 });
-coll.remove({ _id : 1 });
-printjson(gle = coll.getDB().runCommand({ getLastError : 1 }));
+coll.insert({_id: 1});
+coll.remove({_id: 1});
+printjson(gle = coll.getDB().runCommand({getLastError: 1}));
assert(gle.ok);
assert('err' in gle);
assert(!gle.err);
@@ -102,8 +101,8 @@ assert.eq(coll.count(), 0);
//
// Error on one host during update
coll.remove({});
-coll.update({ _id : 1 }, { $invalid : "xxx" }, true);
-printjson(gle = coll.getDB().runCommand({ getLastError : 1 }));
+coll.update({_id: 1}, {$invalid: "xxx"}, true);
+printjson(gle = coll.getDB().runCommand({getLastError: 1}));
assert(gle.ok);
assert(gle.err);
assert(gle.code);
@@ -114,8 +113,8 @@ assert.eq(coll.count(), 0);
//
// Error on two hosts during remove
coll.remove({});
-coll.remove({ $invalid : 'remove' });
-printjson(gle = coll.getDB().runCommand({ getLastError : 1 }));
+coll.remove({$invalid: 'remove'});
+printjson(gle = coll.getDB().runCommand({getLastError: 1}));
assert(gle.ok);
assert(gle.err);
assert(gle.code);
@@ -126,14 +125,14 @@ assert.eq(coll.count(), 0);
//
// Repeated calls to GLE should work
coll.remove({});
-coll.update({ _id : 1 }, { $invalid : "xxx" }, true);
-printjson(gle = coll.getDB().runCommand({ getLastError : 1 }));
+coll.update({_id: 1}, {$invalid: "xxx"}, true);
+printjson(gle = coll.getDB().runCommand({getLastError: 1}));
assert(gle.ok);
assert(gle.err);
assert(gle.code);
assert(!gle.errmsg);
assert(gle.singleShard);
-printjson(gle = coll.getDB().runCommand({ getLastError : 1 }));
+printjson(gle = coll.getDB().runCommand({getLastError: 1}));
assert(gle.ok);
assert(gle.err);
assert(gle.code);
@@ -143,21 +142,18 @@ assert.eq(coll.count(), 0);
//
// Geo $near is not supported on mongos
-coll.ensureIndex( { loc: "2dsphere" } );
+coll.ensureIndex({loc: "2dsphere"});
coll.remove({});
var query = {
- loc : {
- $near : {
- $geometry : {
- type : "Point" ,
- coordinates : [ 0 , 0 ]
- },
- $maxDistance : 1000,
+ loc: {
+ $near: {
+ $geometry: {type: "Point", coordinates: [0, 0]},
+ $maxDistance: 1000,
+ }
}
- }
};
printjson(coll.remove(query));
-printjson(gle = coll.getDB().runCommand({ getLastError : 1 }));
+printjson(gle = coll.getDB().runCommand({getLastError: 1}));
assert(gle.ok);
assert(gle.err);
assert(gle.code);
@@ -172,11 +168,11 @@ assert.eq(coll.count(), 0);
//
// Successful bulk insert on two hosts, host dies before gle (error contacting host)
coll.remove({});
-coll.insert([{ _id : 1 }, { _id : -1 }]);
+coll.insert([{_id: 1}, {_id: -1}]);
// Wait for write to be written to shards before shutting it down.
-printjson(gle = coll.getDB().runCommand({ getLastError : 1 }));
-MongoRunner.stopMongod( st.shard0 );
-printjson(gle = coll.getDB().runCommand({ getLastError : 1 }));
+printjson(gle = coll.getDB().runCommand({getLastError: 1}));
+MongoRunner.stopMongod(st.shard0);
+printjson(gle = coll.getDB().runCommand({getLastError: 1}));
// Should get an error about contacting dead host.
assert(!gle.ok);
assert(gle.errmsg);
@@ -185,14 +181,13 @@ assert(gle.errmsg);
// Failed insert on two hosts, first host dead
// NOTE: This is DIFFERENT from 2.4, since we don't need to contact a host we didn't get
// successful writes from.
-coll.remove({ _id : 1 });
-coll.insert([{ _id : 1 }, { _id : -1 }]);
-printjson(gle = coll.getDB().runCommand({ getLastError : 1 }));
+coll.remove({_id: 1});
+coll.insert([{_id: 1}, {_id: -1}]);
+printjson(gle = coll.getDB().runCommand({getLastError: 1}));
assert(gle.ok);
assert(gle.err);
-assert.eq(coll.count({ _id : 1 }), 1);
+assert.eq(coll.count({_id: 1}), 1);
jsTest.log("DONE!");
st.stop();
-
diff --git a/jstests/gle/opcounters_legacy.js b/jstests/gle/opcounters_legacy.js
index 7f267fbe155..c31494b6c01 100644
--- a/jstests/gle/opcounters_legacy.js
+++ b/jstests/gle/opcounters_legacy.js
@@ -4,7 +4,9 @@
// Remember the global 'db' var
var lastDB = db;
var mongo = new Mongo(db.getMongo().host);
-mongo.writeMode = function() { return "legacy"; };
+mongo.writeMode = function() {
+ return "legacy";
+};
db = mongo.getDB(db.toString());
var t = db.opcounters;
@@ -29,33 +31,33 @@ t.drop();
// Single insert, no error.
opCounters = db.serverStatus().opcounters;
-t.insert({_id:0});
+t.insert({_id: 0});
assert(!db.getLastError());
assert.eq(opCounters.insert + 1, db.serverStatus().opcounters.insert);
// Bulk insert, no error.
opCounters = db.serverStatus().opcounters;
-t.insert([{_id:1},{_id:2}]);
+t.insert([{_id: 1}, {_id: 2}]);
assert(!db.getLastError());
assert.eq(opCounters.insert + 2, db.serverStatus().opcounters.insert);
// Single insert, with error.
opCounters = db.serverStatus().opcounters;
-t.insert({_id:0});
-print( db.getLastError() );
+t.insert({_id: 0});
+print(db.getLastError());
assert(db.getLastError());
assert.eq(opCounters.insert + (isMongos ? 1 : 0), db.serverStatus().opcounters.insert);
// Bulk insert, with error, continueOnError=false.
opCounters = db.serverStatus().opcounters;
-t.insert([{_id:3},{_id:3},{_id:4}]);
+t.insert([{_id: 3}, {_id: 3}, {_id: 4}]);
assert(db.getLastError());
assert.eq(opCounters.insert + (isMongos ? 2 : 1), db.serverStatus().opcounters.insert);
// Bulk insert, with error, continueOnError=true.
var continueOnErrorFlag = 1;
opCounters = db.serverStatus().opcounters;
-t.insert([{_id:5},{_id:5},{_id:6}], continueOnErrorFlag);
+t.insert([{_id: 5}, {_id: 5}, {_id: 6}], continueOnErrorFlag);
assert(db.getLastError());
assert.eq(opCounters.insert + 2, db.serverStatus().opcounters.insert);
@@ -66,17 +68,17 @@ assert.eq(opCounters.insert + 2, db.serverStatus().opcounters.insert);
//
t.drop();
-t.insert({_id:0});
+t.insert({_id: 0});
// Update, no error.
opCounters = db.serverStatus().opcounters;
-t.update({_id:0}, {$set:{a:1}});
+t.update({_id: 0}, {$set: {a: 1}});
assert(!db.getLastError());
assert.eq(opCounters.update + 1, db.serverStatus().opcounters.update);
// Update, with error.
opCounters = db.serverStatus().opcounters;
-t.update({_id:0}, {$set:{_id:1}});
+t.update({_id: 0}, {$set: {_id: 1}});
assert(db.getLastError());
assert.eq(opCounters.update + 1, db.serverStatus().opcounters.update);
@@ -87,17 +89,17 @@ assert.eq(opCounters.update + 1, db.serverStatus().opcounters.update);
//
t.drop();
-t.insert([{_id:0},{_id:1}]);
+t.insert([{_id: 0}, {_id: 1}]);
// Delete, no error.
opCounters = db.serverStatus().opcounters;
-t.remove({_id:0});
+t.remove({_id: 0});
assert(!db.getLastError());
assert.eq(opCounters.delete + 1, db.serverStatus().opcounters.delete);
// Delete, with error.
opCounters = db.serverStatus().opcounters;
-t.remove({_id:{$invalidOp:1}});
+t.remove({_id: {$invalidOp: 1}});
assert(db.getLastError());
assert.eq(opCounters.delete + 1, db.serverStatus().opcounters.delete);
@@ -109,7 +111,7 @@ assert.eq(opCounters.delete + 1, db.serverStatus().opcounters.delete);
//
t.drop();
-t.insert({_id:0});
+t.insert({_id: 0});
// Query, no error.
opCounters = db.serverStatus().opcounters;
@@ -118,7 +120,9 @@ assert.eq(opCounters.query + 1, db.serverStatus().opcounters.query);
// Query, with error.
opCounters = db.serverStatus().opcounters;
-assert.throws(function() { t.findOne({_id:{$invalidOp:1}}); });
+assert.throws(function() {
+ t.findOne({_id: {$invalidOp: 1}});
+});
assert.eq(opCounters.query + (isMongos ? 0 : 1), db.serverStatus().opcounters.query);
//
@@ -128,11 +132,11 @@ assert.eq(opCounters.query + (isMongos ? 0 : 1), db.serverStatus().opcounters.qu
//
t.drop();
-t.insert([{_id:0},{_id:1},{_id:2}]);
+t.insert([{_id: 0}, {_id: 1}, {_id: 2}]);
// Getmore, no error.
opCounters = db.serverStatus().opcounters;
-t.find().batchSize(2).toArray(); // 3 documents, batchSize=2 => 1 query + 1 getmore
+t.find().batchSize(2).toArray(); // 3 documents, batchSize=2 => 1 query + 1 getmore
assert.eq(opCounters.query + 1, db.serverStatus().opcounters.query);
assert.eq(opCounters.getmore + 1, db.serverStatus().opcounters.getmore);
@@ -147,47 +151,50 @@ assert.eq(opCounters.getmore + 1, db.serverStatus().opcounters.getmore);
//
t.drop();
-t.insert({_id:0});
+t.insert({_id: 0});
// Command, recognized, no error.
-serverStatus = db.runCommand({serverStatus:1});
+serverStatus = db.runCommand({serverStatus: 1});
opCounters = serverStatus.opcounters;
metricsObj = serverStatus.metrics.commands;
-assert.eq(opCounters.command + 1, db.serverStatus().opcounters.command); // "serverStatus" counted
+assert.eq(opCounters.command + 1, db.serverStatus().opcounters.command); // "serverStatus" counted
// Count this and the last run of "serverStatus"
-assert.eq( metricsObj.serverStatus.total + 2,
- db.serverStatus().metrics.commands.serverStatus.total,
- "total ServerStatus command counter did not increment" );
-assert.eq( metricsObj.serverStatus.failed,
- db.serverStatus().metrics.commands.serverStatus.failed,
- "failed ServerStatus command counter incremented!" );
+assert.eq(metricsObj.serverStatus.total + 2,
+ db.serverStatus().metrics.commands.serverStatus.total,
+ "total ServerStatus command counter did not increment");
+assert.eq(metricsObj.serverStatus.failed,
+ db.serverStatus().metrics.commands.serverStatus.failed,
+ "failed ServerStatus command counter incremented!");
// Command, recognized, with error.
-serverStatus = db.runCommand({serverStatus:1});
+serverStatus = db.runCommand({serverStatus: 1});
opCounters = serverStatus.opcounters;
metricsObj = serverStatus.metrics.commands;
-var countVal = { "total" : 0, "failed" : 0 };
-if (metricsObj.count != null){
+var countVal = {
+ "total": 0,
+ "failed": 0
+};
+if (metricsObj.count != null) {
countVal = metricsObj.count;
}
-res = t.runCommand("count", {query:{$invalidOp:1}});
+res = t.runCommand("count", {query: {$invalidOp: 1}});
assert.eq(0, res.ok);
assert.eq(opCounters.command + 2,
- db.serverStatus().opcounters.command); // "serverStatus", "count" counted
+ db.serverStatus().opcounters.command); // "serverStatus", "count" counted
-assert.eq( countVal.total +1,
- db.serverStatus().metrics.commands.count.total,
- "total count command counter did not incremented" );
-assert.eq( countVal.failed + 1,
- db.serverStatus().metrics.commands.count.failed,
- "failed count command counter did not increment" );
+assert.eq(countVal.total + 1,
+ db.serverStatus().metrics.commands.count.total,
+ "total count command counter did not incremented");
+assert.eq(countVal.failed + 1,
+ db.serverStatus().metrics.commands.count.failed,
+ "failed count command counter did not increment");
// Command, unrecognized.
-serverStatus = db.runCommand({serverStatus:1});
+serverStatus = db.runCommand({serverStatus: 1});
opCounters = serverStatus.opcounters;
metricsObj = serverStatus.metrics.commands;
res = t.runCommand("invalid");
assert.eq(0, res.ok);
-assert.eq(opCounters.command + 1, db.serverStatus().opcounters.command); // "serverStatus" counted
+assert.eq(opCounters.command + 1, db.serverStatus().opcounters.command); // "serverStatus" counted
assert.eq(null, db.serverStatus().metrics.commands.invalid);
-assert.eq(metricsObj['<UNKNOWN>'] +1, db.serverStatus().metrics.commands['<UNKNOWN>']);
+assert.eq(metricsObj['<UNKNOWN>'] + 1, db.serverStatus().metrics.commands['<UNKNOWN>']);
diff --git a/jstests/gle/sync1.js b/jstests/gle/sync1.js
index d370c53f949..1cdd27530a0 100644
--- a/jstests/gle/sync1.js
+++ b/jstests/gle/sync1.js
@@ -4,58 +4,62 @@
// A restarted standalone will lose all data when using an ephemeral storage engine.
// @tags: [requires_persistence]
-var test = new SyncCCTest( "sync1" );
+var test = new SyncCCTest("sync1");
if (test.conn.writeMode() == 'commands') {
jsTest.log('Skipping test not compatible with write commands');
-}
-else {
-
- db = test.conn.getDB( "test" );
+} else {
+ db = test.conn.getDB("test");
t = db.sync1;
- t.save( { x : 1 } );
- assert.eq( 1 , t.find().itcount() , "A1" );
- assert.eq( 1 , t.find().count() , "A2" );
- t.save( { x : 2 } );
- assert.eq( 2 , t.find().itcount() , "A3" );
- assert.eq( 2 , t.find().count() , "A4" );
+ t.save({x: 1});
+ assert.eq(1, t.find().itcount(), "A1");
+ assert.eq(1, t.find().count(), "A2");
+ t.save({x: 2});
+ assert.eq(2, t.find().itcount(), "A3");
+ assert.eq(2, t.find().count(), "A4");
- test.checkHashes( "test" , "A3" );
+ test.checkHashes("test", "A3");
test.tempKill();
- assert.throws( function(){ t.save( { x : 3 } ); } , null , "B1" );
+ assert.throws(function() {
+ t.save({x: 3});
+ }, null, "B1");
// It's ok even for some of the mongod to be unreachable for read-only cmd
- assert.eq( 2, t.find({}).count() );
+ assert.eq(2, t.find({}).count());
// It's NOT ok for some of the mongod to be unreachable for write cmd
- assert.throws( function(){ t.getDB().runCommand({ profile: 1 }); });
- assert.eq( 2 , t.find().itcount() , "B2" );
+ assert.throws(function() {
+ t.getDB().runCommand({profile: 1});
+ });
+ assert.eq(2, t.find().itcount(), "B2");
test.tempStart();
- test.checkHashes( "test" , "B3" );
+ test.checkHashes("test", "B3");
// Trying killing the second mongod
- test.tempKill( 1 );
- assert.throws( function(){ t.save( { x : 3 } ); } );
+ test.tempKill(1);
+ assert.throws(function() {
+ t.save({x: 3});
+ });
// It's ok even for some of the mongod to be unreachable for read-only cmd
- assert.eq( 2, t.find({}).count() );
+ assert.eq(2, t.find({}).count());
// It's NOT ok for some of the mongod to be unreachable for write cmd
- assert.throws( function(){ t.getDB().runCommand({ profile: 1 }); });
- assert.eq( 2 , t.find().itcount() );
- test.tempStart( 1 );
+ assert.throws(function() {
+ t.getDB().runCommand({profile: 1});
+ });
+ assert.eq(2, t.find().itcount());
+ test.tempStart(1);
- assert.eq( 2 , t.find().itcount() , "C1" );
- assert.soon( function(){
- try {
- t.remove( { x : 1 } );
+ assert.eq(2, t.find().itcount(), "C1");
+ assert.soon(function() {
+ try {
+ t.remove({x: 1});
return true;
- }
- catch ( e ){
- print( e );
+ } catch (e) {
+ print(e);
}
return false;
- } );
- t.find().forEach( printjson );
- assert.eq( 1 , t.find().itcount() , "C2" );
+ });
+ t.find().forEach(printjson);
+ assert.eq(1, t.find().itcount(), "C2");
test.stop();
-
}
diff --git a/jstests/gle/sync4.js b/jstests/gle/sync4.js
index a33f9b8a132..01b98eb1221 100644
--- a/jstests/gle/sync4.js
+++ b/jstests/gle/sync4.js
@@ -1,26 +1,22 @@
// TODO: remove test after we deprecate SyncClusterConnection
-test = new SyncCCTest( "sync4" );
+test = new SyncCCTest("sync4");
if (test.conn.writeMode() == 'commands') {
jsTest.log('Skipping test not compatible with write commands');
-}
-else {
-
- db = test.conn.getDB( "test" );
+} else {
+ db = test.conn.getDB("test");
t = db.sync4;
- for ( i=0; i<1000; i++ ){
- t.insert( { _id : i , x : "asdasdsdasdas" } );
+ for (i = 0; i < 1000; i++) {
+ t.insert({_id: i, x: "asdasdsdasdas"});
}
db.getLastError();
- test.checkHashes( "test" , "A0" );
- assert.eq( 1000 , t.find().count() , "A1" );
- assert.eq( 1000 , t.find().itcount() , "A2" );
- assert.eq( 1000 , t.find().snapshot().batchSize(10).itcount() , "A2" );
+ test.checkHashes("test", "A0");
+ assert.eq(1000, t.find().count(), "A1");
+ assert.eq(1000, t.find().itcount(), "A2");
+ assert.eq(1000, t.find().snapshot().batchSize(10).itcount(), "A2");
test.stop();
-
}
-
diff --git a/jstests/gle/sync8.js b/jstests/gle/sync8.js
index 81404785ac3..f2a32ce418c 100644
--- a/jstests/gle/sync8.js
+++ b/jstests/gle/sync8.js
@@ -2,20 +2,18 @@
// Test for SERVER-11492 - make sure that upserting a new document reports n:1 in GLE
-var test = new SyncCCTest( "sync1" );
+var test = new SyncCCTest("sync1");
if (test.conn.writeMode() == 'commands') {
jsTest.log('Skipping test not compatible with write commands');
-}
-else {
- var db = test.conn.getDB( "test" );
+} else {
+ var db = test.conn.getDB("test");
var t = db.sync8;
t.remove({});
- t.update({_id:1}, {$set:{a:1}}, true);
+ t.update({_id: 1}, {$set: {a: 1}}, true);
var le = db.getLastErrorObj();
assert.eq(1, le.n);
test.stop();
-
}
diff --git a/jstests/gle/updated_existing.js b/jstests/gle/updated_existing.js
index 5e9891ccf85..ff485530e35 100644
--- a/jstests/gle/updated_existing.js
+++ b/jstests/gle/updated_existing.js
@@ -3,26 +3,24 @@
* an upsert is not missing when autosplit takes place.
*/
-var st = new ShardingTest({ shards : 1, mongos : 1, verbose : 1, chunkSize: 1 });
+var st = new ShardingTest({shards: 1, mongos: 1, verbose: 1, chunkSize: 1});
var testDB = st.getDB("test");
var coll = "foo";
testDB[coll].drop();
-st.adminCommand({ enablesharding : 'test' });
-st.adminCommand({ shardcollection : 'test.' + coll, key : { "shardkey2" : 1, "shardkey1" : 1 } });
+st.adminCommand({enablesharding: 'test'});
+st.adminCommand({shardcollection: 'test.' + coll, key: {"shardkey2": 1, "shardkey1": 1}});
var bigString = "";
-while ( bigString.length < 1024 * 50 )
+while (bigString.length < 1024 * 50)
bigString += "asocsancdnsjfnsdnfsjdhfasdfasdfasdfnsadofnsadlkfnsaldknfsad";
-
-
for (var i = 0; i < 10000; ++i) {
- testDB[coll].update({ "shardkey1" : "test" + i, "shardkey2" : "test" + i },
- { $set : { "test_upsert": bigString } },
- true, // upsert
- false); // multi
+ testDB[coll].update({"shardkey1": "test" + i, "shardkey2": "test" + i},
+ {$set: {"test_upsert": bigString}},
+ true, // upsert
+ false); // multi
assert.eq(testDB.getLastErrorObj().updatedExisting, false);
}