diff options
-rw-r--r-- | jstests/core/apitest_dbcollection.js | 52 | ||||
-rw-r--r-- | jstests/slow2/sharding_jscore_passthrough.js | 2 | ||||
-rw-r--r-- | src/mongo/shell/collection.js | 8 |
3 files changed, 37 insertions, 25 deletions
diff --git a/jstests/core/apitest_dbcollection.js b/jstests/core/apitest_dbcollection.js index 0983b065477..22a837d2821 100644 --- a/jstests/core/apitest_dbcollection.js +++ b/jstests/core/apitest_dbcollection.js @@ -30,12 +30,6 @@ assert(db.getCollection( "test_db" ).count() == 101,6); db.getCollection( "test_db" ).drop(); assert(db.getCollection( "test_db" ).count() == 0,7); -/* - * test clean (not sure... just be sure it doen't blow up, I guess - */ - - db.getCollection( "test_db" ).clean(); - /* * test validate */ @@ -46,16 +40,44 @@ assert(db.getCollection( "test_db" ).count() == 0,8); for (i = 0; i < 100; i++) { db.getCollection( "test_db" ).save({a:1}); } - -var v = db.getCollection( "test_db" ).validate(); -if( v.ns != "test.test_db" ) { - print("Error: wrong ns name"); - print(tojson(v)); -} -assert (v.ns == "test.test_db",9); -assert (v.ok == 1,10); -assert.eq(100,v.nrecords,11) +(function() { + var validateResult = assert.commandWorked(db.getCollection( "test_db" ).validate()); + // Extract validation results from mongos output if running in a sharded context. + if (jsTest.isMongos(db.getMongo())) { + // Sample mongos format: + // { + // raw: { + // "localhost:30000": { + // "ns" : "test.test_db", + // ... + // "valid": true, + // ... + // "ok": 1 + // } + // }, + // "valid": true, + // ... + // "ok": 1 + // } + + var numFields = 0; + var result = null; + for (var field in validateResult.raw) { + result = validateResult.raw[field]; + numFields++; + } + + assert.eq(1, numFields); + assert.neq(null, result); + validateResult = result; + } + + assert.eq('test.test_db', validateResult.ns, + 'incorrect namespace in db.collection.validate() result: ' + tojson(validateResult)); + assert(validateResult.valid, 'collection validation failed'); + assert.eq(100, validateResult.nrecords, 11); +}()); /* * test deleteIndex, deleteIndexes diff --git a/jstests/slow2/sharding_jscore_passthrough.js b/jstests/slow2/sharding_jscore_passthrough.js index 1f7110a5b68..be1580b7a9a 100644 --- a/jstests/slow2/sharding_jscore_passthrough.js +++ b/jstests/slow2/sharding_jscore_passthrough.js @@ -60,7 +60,6 @@ files.forEach(function(x) { * copydbgetnonce * dbhash * medianKey - * clean (apitest_dbcollection) * logout and getnonce */ @@ -74,7 +73,6 @@ files.forEach(function(x) { 'dbhash|' + 'dbhash2|' + 'median|' + - 'apitest_dbcollection|' + 'evalb|' + 'evald|' + 'eval_nolock|' + diff --git a/src/mongo/shell/collection.js b/src/mongo/shell/collection.js index df3d05636b6..4ce212201b7 100644 --- a/src/mongo/shell/collection.js +++ b/src/mongo/shell/collection.js @@ -1041,14 +1041,6 @@ DBCollection.prototype.count = function( x ){ return this.find( x ).count(); } -/** - * Drop free lists. Normally not used. - * Note this only does the collection itself, not the namespaces of its indexes (see cleanAll). - */ -DBCollection.prototype.clean = function() { - return this._dbCommand( { clean: this.getName() } ); -} - DBCollection.prototype.hashAllDocs = function() { var cmd = { dbhash : 1, collections : [ this._shortName ] }; |