From b202965c2aa985232699b059c7135dd64f09700e Mon Sep 17 00:00:00 2001 From: Kevin Matulef Date: Thu, 2 Aug 2012 08:14:22 -0400 Subject: SERVER-5516 SERVER-5304 SERVER-6577 new capped collections now get _id index by default (except in local db) --- jstests/capped5.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'jstests/capped5.js') diff --git a/jstests/capped5.js b/jstests/capped5.js index be6c27d7256..9af06f84063 100644 --- a/jstests/capped5.js +++ b/jstests/capped5.js @@ -7,7 +7,7 @@ t.drop(); db.createCollection( tn , {capped: true, size: 1024 * 1024 * 1 } ); t.insert( { _id : 5 , x : 11 , z : 52 } ); -assert.eq( 0 , t.getIndexKeys().length , "A0" ) +assert.eq( 1 , t.getIndexKeys().length , "A0" ) //now we assume _id index even on capped coll assert.eq( 52 , t.findOne( { x : 11 } ).z , "A1" ); t.ensureIndex( { _id : 1 } ) @@ -21,23 +21,22 @@ db.createCollection( tn , {capped: true, size: 1024 * 1024 * 1 } ); t.insert( { _id : 5 , x : 11 } ); t.insert( { _id : 6 , x : 11 } ); t.ensureIndex( { x:1 }, {unique:true, dropDups:true } ); -assert.eq( 0, db.system.indexes.count( {ns:"test."+tn} ) ); +assert.eq( 1, db.system.indexes.count( {ns:"test."+tn} ) ); //now we assume _id index assert.eq( 2, t.find().toArray().length ); t.drop(); db.createCollection( tn , {capped: true, size: 1024 * 1024 * 1 } ); t.insert( { _id : 5 , x : 11 } ); t.insert( { _id : 5 , x : 12 } ); -t.ensureIndex( { _id:1 } ); -assert.eq( 0, db.system.indexes.count( {ns:"test."+tn} ) ); -assert.eq( 2, t.find().toArray().length ); +assert.eq( 1, db.system.indexes.count( {ns:"test."+tn} ) ); //now we assume _id index +assert.eq( 1, t.find().toArray().length ); //_id index unique, so second insert fails t.drop(); db.createCollection( tn , {capped: true, size: 1024 * 1024 * 1 } ); t.insert( { _id : 5 , x : 11 } ); t.insert( { _id : 6 , x : 12 } ); t.ensureIndex( { x:1 }, {unique:true, dropDups:true } ); -assert.eq( 1, db.system.indexes.count( {ns:"test."+tn} ) ); +assert.eq( 2, db.system.indexes.count( {ns:"test."+tn} ) ); //now we assume _id index assert.eq( 2, t.find().hint( {x:1} ).toArray().length ); // SERVER-525 (closed) unique indexes in capped collection -- cgit v1.2.1