forked from mongodb/mongo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SERVER-4729: Ensure query logged when slow
- Loading branch information
Brandon Diamond
committed
Feb 6, 2012
1 parent
baf02d5
commit a950ba5
Showing
2 changed files
with
39 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// tests getlog as well as slow querying logging | ||
|
||
glcol = db.getLogTest2; | ||
glcol.drop() | ||
|
||
contains = function(arr, func) { | ||
var i = arr.length; | ||
while (i--) { | ||
if (func(arr[i])) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
} | ||
|
||
// run a slow query | ||
glcol.save({ "SENTINEL": 1 }); | ||
glcol.findOne({ "SENTINEL": 1, "$where": function() { sleep(1000); return true; } }); | ||
|
||
// run a slow update | ||
glcol.update({ "SENTINEL": 1, "$where": function() { sleep(1000); return true; } }, { "x": "x" }); | ||
|
||
var resp = db.adminCommand({getLog:"global"}); | ||
assert( resp.ok == 1, "error executing getLog command" ); | ||
assert( resp.log, "no log field" ); | ||
assert( resp.log.length > 0 , "no log lines" ); | ||
|
||
// ensure that slow query is logged in detail | ||
assert( contains(resp.log, function(v) { | ||
print(v); | ||
return v.indexOf(" query ") != -1 && v.indexOf("query:") != -1 && v.indexOf("SENTINEL") != -1; | ||
}) ); | ||
|
||
// same, but for update | ||
assert( contains(resp.log, function(v) { | ||
print(v); | ||
return v.indexOf(" update ") != -1 && v.indexOf("query:") != -1 && v.indexOf("SENTINEL") != -1; | ||
}) ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters