From 65749ebccbc46844ce16848c2ea34fcf1881e960 Mon Sep 17 00:00:00 2001 From: Eliot Horowitz Date: Tue, 24 Jan 2012 13:04:38 -0500 Subject: [PATCH] easier to debug tests --- jstests/exists6.js | 8 ++++++-- jstests/or5.js | 1 + jstests/queryoptimizer4.js | 3 ++- jstests/queryoptimizer7.js | 3 ++- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/jstests/exists6.js b/jstests/exists6.js index 6aafca06be65a..3b179dba32454 100644 --- a/jstests/exists6.js +++ b/jstests/exists6.js @@ -10,9 +10,13 @@ t.save( {b:null} ); checkExists = function( query ) { // Index range constraint on 'b' is universal, so a BasicCursor is the default cursor type. - assert.eq( 'BasicCursor', t.find( query ).explain().cursor ); + var x = t.find( query ).explain() + assert.eq( 'BasicCursor', x.cursor , tojson(x) ); // Index bounds include all elements. - assert.eq( [ [ { $minElement:1 }, { $maxElement:1 } ] ], t.find( query ).hint( {b:1} ).explain().indexBounds.b ); + + var x = t.find( query ).hint( {b:1} ).explain() + if ( ! x.indexBounds ) x.indexBounds = {} + assert.eq( [ [ { $minElement:1 }, { $maxElement:1 } ] ], x.indexBounds.b , tojson(x) ); // All keys must be scanned. assert.eq( 3, t.find( query ).hint( {b:1} ).explain().nscanned ); // 2 docs will match. diff --git a/jstests/or5.js b/jstests/or5.js index 98ff141f5751a..d897cb443458c 100644 --- a/jstests/or5.js +++ b/jstests/or5.js @@ -6,6 +6,7 @@ t.ensureIndex( {b:1} ); assert.eq.automsg( "'BasicCursor'", "t.find( {$or:[{a:2},{b:3},{}]} ).explain().cursor" ); assert.eq.automsg( "'BasicCursor'", "t.find( {$or:[{a:2},{b:3},{c:4}]} ).explain().cursor" ); +printjson( t.find( {$or:[{a:2},{b:3}]} ).sort( {c:1} ).explain() ); assert.eq.automsg( "'BasicCursor'", "t.find( {$or:[{a:2},{b:3}]} ).sort( {c:1} ).explain().cursor" ); e = t.find( {$or:[{a:2},{b:3}]} ).sort( {a:1} ).explain(); assert.eq.automsg( "'BtreeCursor a_1'", "e.cursor" ); diff --git a/jstests/queryoptimizer4.js b/jstests/queryoptimizer4.js index 23a7ec8444a75..ebcbf7e230c66 100644 --- a/jstests/queryoptimizer4.js +++ b/jstests/queryoptimizer4.js @@ -24,7 +24,8 @@ function reset( matches, filler ) { function checkCursor( query, cursor ) { t.find(query).itcount(); // Check that index on 'cursor' was chosen in the above query. - assert.eq( 'BtreeCursor ' + cursor, t.find(query).explain(true).oldPlan.cursor ); + var x = t.find(query).explain(true); + assert.eq( 'BtreeCursor ' + cursor, x.oldPlan.cursor , tojson(x) ); } // Check {b:1} takes over when {a:1} is much worse for query {a:100,b:100}. diff --git a/jstests/queryoptimizer7.js b/jstests/queryoptimizer7.js index ac0a5206e9b88..712691cd7296d 100644 --- a/jstests/queryoptimizer7.js +++ b/jstests/queryoptimizer7.js @@ -3,7 +3,8 @@ t = db.jstests_queryoptimizer7; function assertPlanWasRecorded( query ) { - assert.eq( 'BtreeCursor a_1', t.find( query ).explain( true ).oldPlan.cursor ); + var x = t.find( query ).explain( true ); + assert.eq( 'BtreeCursor a_1', x.oldPlan.cursor , tojson(x) ); } function assertNoPlanWasRecorded( query ) {