-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SERVER-6878 Clean distinct3.js and make evalb.js more robust.
Conflicts: jstests/evalb.js
- Loading branch information
Showing
2 changed files
with
41 additions
and
11 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
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 |
---|---|---|
@@ -1,17 +1,40 @@ | ||
// Check the return value of a db.eval function running a database query, and ensure the function's | ||
// contents are logged in the profile log. | ||
|
||
t = db.evalb; | ||
t.drop(); | ||
// Use a reserved database name to avoid a conflict in the parallel test suite. | ||
var stddb = db; | ||
var db = db.getSisterDB( 'evalb' ); | ||
|
||
t.save( { x : 3 } ); | ||
function profileCursor() { | ||
return db.system.profile.find( { user:username } ); | ||
} | ||
|
||
assert.eq( 3, db.eval( function(){ return db.evalb.findOne().x; } ) , "A" ); | ||
function lastOp() { | ||
return profileCursor().sort( { $natural:-1 } ).next(); | ||
} | ||
|
||
db.setProfilingLevel( 2 ); | ||
try { | ||
|
||
assert.eq( 3, db.eval( function(){ return db.evalb.findOne().x; } ) , "B" ); | ||
username = 'jstests_evalb_user'; | ||
db.addUser( username, 'password', false, 1 ); | ||
db.auth( username, 'password' ); | ||
|
||
o = db.system.profile.find().sort( { $natural : -1 } ).limit(1).next(); | ||
assert( tojson(o).indexOf( "findOne().x" ) > 0 , "C : " + tojson( o ) ) | ||
t = db.evalb; | ||
t.drop(); | ||
|
||
db.setProfilingLevel( 0 ); | ||
t.save( { x:3 } ); | ||
|
||
assert.eq( 3, db.eval( function() { return db.evalb.findOne().x; } ), 'A' ); | ||
|
||
db.setProfilingLevel( 2 ); | ||
|
||
assert.eq( 3, db.eval( function() { return db.evalb.findOne().x; } ), 'B' ); | ||
|
||
o = lastOp(); | ||
assert( tojson( o ).indexOf( 'findOne().x' ) > 0, 'C : ' + tojson( o ) ); | ||
} | ||
finally { | ||
|
||
db.setProfilingLevel(0); | ||
db = stddb; | ||
} |