summaryrefslogtreecommitdiff
path: root/jstests/core/currentop.js
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/core/currentop.js
parenta025d43f3ce2efc1fb1282a718f5d286fa0a4dc1 (diff)
downloadmongo-4ae691e8edc87d0e3cfb633bb91c328426be007b.tar.gz
SERVER-22468 Format JS code with approved style in jstests/
Diffstat (limited to 'jstests/core/currentop.js')
-rw-r--r--jstests/core/currentop.js34
1 files changed, 18 insertions, 16 deletions
diff --git a/jstests/core/currentop.js b/jstests/core/currentop.js
index 34e96696481..ef948d415be 100644
--- a/jstests/core/currentop.js
+++ b/jstests/core/currentop.js
@@ -4,20 +4,21 @@ print("BEGIN currentop.js");
t = db.jstests_currentop;
t.drop();
-for(i=0;i<100;i++) {
- t.save({ "num": i });
+for (i = 0; i < 100; i++) {
+ t.save({"num": i});
}
print("count:" + t.count());
function ops(q) {
- printjson( db.currentOp().inprog );
+ printjson(db.currentOp().inprog);
return db.currentOp(q).inprog;
}
print("start shell");
-// sleep for a second for each (of 100) documents; can be killed in between documents & test should complete before 100 seconds
+// sleep for a second for each (of 100) documents; can be killed in between documents & test should
+// complete before 100 seconds
s1 = startParallelShell("db.jstests_currentop.count( { '$where': function() { sleep(1000); } } )");
print("sleep");
@@ -33,25 +34,26 @@ print();
// need to wait for read to start
print("wait have some ops");
-assert.soon( function(){
- return ops( { "locks.Collection": "r", "ns": "test.jstests_currentop" } ).length +
- ops({ "locks.Collection": "R", "ns": "test.jstests_currentop" }).length >= 1;
+assert.soon(function() {
+ return ops({"locks.Collection": "r", "ns": "test.jstests_currentop"}).length +
+ ops({"locks.Collection": "R", "ns": "test.jstests_currentop"}).length >=
+ 1;
}, "have_some_ops");
print("ok");
-
-s2 = startParallelShell( "db.jstests_currentop.update({ '$where': function() { sleep(150); } }," +
- " { '$inc': {num: 1} }, false, true );" );
+
+s2 = startParallelShell("db.jstests_currentop.update({ '$where': function() { sleep(150); } }," +
+ " { '$inc': {num: 1} }, false, true );");
o = [];
function f() {
- o = ops({ "ns": "test.jstests_currentop" });
+ o = ops({"ns": "test.jstests_currentop"});
printjson(o);
- var writes = ops({ "locks.Collection": "w", "ns": "test.jstests_currentop" }).length;
+ var writes = ops({"locks.Collection": "w", "ns": "test.jstests_currentop"}).length;
- var readops = ops({ "locks.Collection": "r", "ns": "test.jstests_currentop" });
+ var readops = ops({"locks.Collection": "r", "ns": "test.jstests_currentop"});
print("readops:");
printjson(readops);
var reads = readops.length;
@@ -63,10 +65,10 @@ function f() {
print("go");
-assert.soon( f, "f" );
+assert.soon(f, "f");
// avoid waiting for the operations to complete (if soon succeeded)
-for(var i in o) {
+for (var i in o) {
db.killOp(o[i].opid);
}
@@ -77,4 +79,4 @@ s1({checkExitSuccess: false});
s2({checkExitSuccess: false});
// don't want to pass if timeout killed the js function
-assert( ( new Date() ) - start < 30000 );
+assert((new Date()) - start < 30000);