diff options
author | Kevin Matulef <matulef@gmail.com> | 2012-08-02 08:14:22 -0400 |
---|---|---|
committer | Kevin Matulef <matulef@gmail.com> | 2012-08-02 08:14:22 -0400 |
commit | b202965c2aa985232699b059c7135dd64f09700e (patch) | |
tree | 46990d7966f7631c09d4c7dc8e87b99db999b51d /jstests | |
parent | af67eafd77bb5d77218dae510c5241d410f0337f (diff) | |
download | mongo-b202965c2aa985232699b059c7135dd64f09700e.tar.gz |
SERVER-5516 SERVER-5304 SERVER-6577 new capped collections now get _id index by default (except in local db)
Diffstat (limited to 'jstests')
-rw-r--r-- | jstests/capped.js | 2 | ||||
-rw-r--r-- | jstests/capped5.js | 11 | ||||
-rw-r--r-- | jstests/queryoptimizera.js | 8 | ||||
-rw-r--r-- | jstests/replsets/capped_id.js | 4 | ||||
-rw-r--r-- | jstests/tool/dumprestore8.js | 8 |
5 files changed, 16 insertions, 17 deletions
diff --git a/jstests/capped.js b/jstests/capped.js index 6fdc4df9e60..421132b6f75 100644 --- a/jstests/capped.js +++ b/jstests/capped.js @@ -1,7 +1,7 @@ db.jstests_capped.drop(); db.createCollection("jstests_capped", {capped:true, size:30000}); -assert.eq( 0, db.system.indexes.find( {ns:"test.jstests_capped"} ).count(), "expected a count of zero indexes for new capped collection" ); +assert.eq( 1, db.system.indexes.find( {ns:"test.jstests_capped"} ).count(), "expected a count of one index for new capped collection" ); t = db.jstests_capped; t.save({x:1}); 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 diff --git a/jstests/queryoptimizera.js b/jstests/queryoptimizera.js index a7d520c15d8..f26c2b0978c 100644 --- a/jstests/queryoptimizera.js +++ b/jstests/queryoptimizera.js @@ -52,9 +52,9 @@ function assertNewWarning() { oldNumWarnings = newNumWarnings; } -// Simple _id query without an _id index. +// Simple _id query t.find( { _id:0 } ).itcount(); -assertNewWarning(); +assertNoNewWarnings(); // Simple _id query without an _id index, on a non capped collection. notCapped.find( { _id:0 } ).itcount(); @@ -62,7 +62,7 @@ assertNoNewWarnings(); // A multi field query, including _id. t.find( { _id:0, a:0 } ).itcount(); -assertNewWarning(); +assertNoNewWarnings(); // An unsatisfiable query. t.find( { _id:0, a:{$in:[]} } ).itcount(); @@ -74,7 +74,7 @@ assertNoNewWarnings(); // Retry a multi field query. t.find( { _id:0, a:0 } ).itcount(); -assertNewWarning(); +assertNoNewWarnings(); // Warnings should not be printed when an index is added on _id. t.ensureIndex( { _id:1 } ); diff --git a/jstests/replsets/capped_id.js b/jstests/replsets/capped_id.js index 3cd51a617b4..ef700e48959 100644 --- a/jstests/replsets/capped_id.js +++ b/jstests/replsets/capped_id.js @@ -101,8 +101,8 @@ for( testnum=0; testnum < numtests; testnum++ ){ slave2db.system.indexes.find().forEach(printjson); print(""); - // insure each slave has _id index, but not master - assert.eq( 0 , + // insure all nodes have _id index + assert.eq( 1 , masterdb.system.indexes.find( { key:{"_id" : 1}, ns: dbname + "." + coll } ).count() , "master has an _id index on capped collection"); assert.eq( 1 , diff --git a/jstests/tool/dumprestore8.js b/jstests/tool/dumprestore8.js index d3d2ef590c7..4e6591738d6 100644 --- a/jstests/tool/dumprestore8.js +++ b/jstests/tool/dumprestore8.js @@ -31,7 +31,7 @@ db.bar.ensureIndex({x:1}); barDocCount = db.bar.count(); assert.gt( barDocCount, 0 , "No documents inserted" ); assert.lt( db.bar.count(), 1000 , "Capped collection didn't evict documents" ); -assert.eq( 4 , db.system.indexes.count() , "Indexes weren't created right" ); +assert.eq( 5 , db.system.indexes.count() , "Indexes weren't created right" ); // Full dump/restore @@ -52,7 +52,7 @@ for (var i = 0; i < 10; i++) { db.bar.save({x:i}); } assert.eq( barDocCount, db.bar.count(), "Capped collection didn't evict documents after restore." ); -assert.eq( 4 , db.system.indexes.count() , "Indexes weren't created correctly by restore" ); +assert.eq( 5 , db.system.indexes.count() , "Indexes weren't created correctly by restore" ); // Dump/restore single DB @@ -77,7 +77,7 @@ for (var i = 0; i < 10; i++) { db.bar.save({x:i}); } assert.eq( barDocCount, db.bar.count(), "Capped collection didn't evict documents after restore 2." ); -assert.eq( 4 , db.system.indexes.count() , "Indexes weren't created correctly by restore 2" ); +assert.eq( 5 , db.system.indexes.count() , "Indexes weren't created correctly by restore 2" ); // Dump/restore single collection @@ -100,6 +100,6 @@ for (var i = 0; i < 10; i++) { db.baz.save({x:i}); } assert.eq( barDocCount, db.baz.count(), "Capped collection didn't evict documents after restore 3." ); -assert.eq( 1 , db.system.indexes.count() , "Indexes weren't created correctly by restore 3" ); +assert.eq( 2 , db.system.indexes.count() , "Indexes weren't created correctly by restore 3" ); t.stop(); |