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/slow2/conc_update.js | |
parent | a025d43f3ce2efc1fb1282a718f5d286fa0a4dc1 (diff) | |
download | mongo-4ae691e8edc87d0e3cfb633bb91c328426be007b.tar.gz |
SERVER-22468 Format JS code with approved style in jstests/
Diffstat (limited to 'jstests/slow2/conc_update.js')
-rw-r--r-- | jstests/slow2/conc_update.js | 47 |
1 files changed, 26 insertions, 21 deletions
diff --git a/jstests/slow2/conc_update.js b/jstests/slow2/conc_update.js index 5cde7489090..b7b8b836831 100644 --- a/jstests/slow2/conc_update.js +++ b/jstests/slow2/conc_update.js @@ -1,52 +1,57 @@ -load( "jstests/libs/slow_weekly_util.js" ); -test = new SlowWeeklyMongod( "conc_update" ); +load("jstests/libs/slow_weekly_util.js"); +test = new SlowWeeklyMongod("conc_update"); db = test.getDB("concurrency"); db.dropDatabase(); -NRECORDS=3*1024*1024; +NRECORDS = 3 * 1024 * 1024; -print("loading "+NRECORDS+" documents (progress msg every 1024*1024 documents)"); +print("loading " + NRECORDS + " documents (progress msg every 1024*1024 documents)"); var bulk = db.conc.initializeUnorderedBulkOp(); for (var i = 0; i < NRECORDS; i++) { - bulk.insert({ x: i }); + bulk.insert({x: i}); } assert.writeOK(bulk.execute()); print("making an index (this will take a while)"); -db.conc.ensureIndex({x:1}); +db.conc.ensureIndex({x: 1}); -var c1=db.conc.count({x:{$lt:NRECORDS}}); +var c1 = db.conc.count({x: {$lt: NRECORDS}}); -updater = startParallelShell("db = db.getSisterDB('concurrency');\ +updater = startParallelShell( + "db = db.getSisterDB('concurrency');\ db.concflag.insert({ inprog: true });\ sleep(20);\ assert.writeOK(db.conc.update({}, \ - { $inc: { x: " + NRECORDS + "}}, false, true)); \ + { $inc: { x: " + + NRECORDS + + "}}, false, true)); \ assert.writeOK(db.concflag.update({}, { inprog: false }));"); -assert.soon( function(){ var x = db.concflag.findOne(); return x && x.inprog; } , - "wait for fork" , 30000 , 1 ); +assert.soon(function() { + var x = db.concflag.findOne(); + return x && x.inprog; +}, "wait for fork", 30000, 1); -querycount=0; -decrements=0; -misses=0; +querycount = 0; +decrements = 0; +misses = 0; -assert.soon(function(){ - c2=db.conc.count({x:{$lt:NRECORDS}}); +assert.soon(function() { + c2 = db.conc.count({x: {$lt: NRECORDS}}); print(c2); querycount++; - if (c2<c1) + if (c2 < c1) decrements++; else misses++; c1 = c2; - return ! db.concflag.findOne().inprog; -}, "update never finished" , 2 * 60 * 60 * 1000 , 10 ); + return !db.concflag.findOne().inprog; +}, "update never finished", 2 * 60 * 60 * 1000, 10); print(querycount + " queries, " + decrements + " decrements, " + misses + " misses"); -assert.eq( NRECORDS , db.conc.count() , "AT END 1" ); +assert.eq(NRECORDS, db.conc.count(), "AT END 1"); -updater(); // wait() +updater(); // wait() test.stop(); |