summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEliot Horowitz <eliot@10gen.com>2011-11-22 14:02:38 -0500
committerEliot Horowitz <eliot@10gen.com>2011-11-22 14:02:53 -0500
commit2a4486134b96f756e01765d3e9234776051d0ff5 (patch)
treeed75df1756f61aa853bbe3893bdfd7459cb0ccfa
parent48e6b7b16e808d2a05a3749d02913d8b6e8f6d74 (diff)
downloadmongo-2a4486134b96f756e01765d3e9234776051d0ff5.tar.gz
make profile1 test more robust
-rw-r--r--jstests/profile1.js30
1 files changed, 16 insertions, 14 deletions
diff --git a/jstests/profile1.js b/jstests/profile1.js
index 9654357127f..ba01d597c39 100644
--- a/jstests/profile1.js
+++ b/jstests/profile1.js
@@ -55,12 +55,18 @@ try {
db.eval("sleep(1)") // pre-load system.js
- db.setProfilingLevel(2);
- before = db.system.profile.count();
+ function resetProfile( level , slowms ) {
+ db.setProfilingLevel(0);
+ db.system.profile.drop();
+ db.setProfilingLevel(level,slowms);
+ }
+
+ resetProfile(2);
+
db.eval( "sleep(25)" )
db.eval( "sleep(120)" )
- after = db.system.profile.count()
- assert.eq( before + 3 , after , "X1" )
+
+ assert.eq( 2 , db.system.profile.find( { "command.$eval" : /^sleep/ } ).count() );
/* sleep() could be inaccurate on certain platforms. let's check */
print("\nsleep 2 time actual:");
@@ -90,24 +96,20 @@ try {
return actual >= max ? 1 : 0;
}
- db.setProfilingLevel(1,100);
- before = db.system.profile.count();
+ resetProfile(1,100);
var delta = 0;
delta += evalSleepMoreThan( 15 , 100 );
delta += evalSleepMoreThan( 120 , 100 );
- after = db.system.profile.count()
- assert.eq( before + delta , after , "X2 : " + getProfileAString() )
+ assert.eq( delta , db.system.profile.find( { "command.$eval" : /^sleep/ } ).count() , "X2 : " + getProfileAString() )
- db.setProfilingLevel(1,20);
- before = db.system.profile.count();
+ resetProfile(1,20);
delta = 0;
delta += evalSleepMoreThan( 5 , 20 );
delta += evalSleepMoreThan( 120 , 20 );
- after = db.system.profile.count()
- assert.eq( before + delta , after , "X3 : " + getProfileAString() )
+ assert.eq( delta , db.system.profile.find( { "command.$eval" : /^sleep/ } ).count() , "X3 : " + getProfileAString() )
- db.profile.drop();
- db.setProfilingLevel(2)
+ resetProfile(2);
+ db.profile1.drop();
var q = { _id : 5 };
var u = { $inc : { x : 1 } };
db.profile1.update( q , u );