From d324cff2fccfd7f2f1397093e01a1eb4af9a3e52 Mon Sep 17 00:00:00 2001 From: Andy Schwerin Date: Tue, 4 Nov 2014 16:17:48 -0500 Subject: SERVER-15882 Get rid of ensureIndex in dbtests. --- src/mongo/dbtests/clienttests.cpp | 53 +++++---------------------------------- 1 file changed, 6 insertions(+), 47 deletions(-) (limited to 'src/mongo/dbtests/clienttests.cpp') diff --git a/src/mongo/dbtests/clienttests.cpp b/src/mongo/dbtests/clienttests.cpp index f3cd6792b1a..29e5b95d47f 100644 --- a/src/mongo/dbtests/clienttests.cpp +++ b/src/mongo/dbtests/clienttests.cpp @@ -71,13 +71,13 @@ namespace ClientTests { db.insert( ns() , BSON( "x" << 2 ) ); ASSERT_EQUALS( 1u , db.getIndexSpecs(ns()).size() ); - db.ensureIndex( ns() , BSON( "x" << 1 ) ); + ASSERT_OK(dbtests::createIndex( &txn, ns(), BSON( "x" << 1 ) )); ASSERT_EQUALS( 2u , db.getIndexSpecs(ns()).size() ); db.dropIndex( ns() , BSON( "x" << 1 ) ); ASSERT_EQUALS( 1u , db.getIndexSpecs(ns()).size() ); - db.ensureIndex( ns() , BSON( "x" << 1 ) ); + ASSERT_OK(dbtests::createIndex( &txn, ns(), BSON( "x" << 1 ) )); ASSERT_EQUALS( 2u , db.getIndexSpecs(ns()).size() ); db.dropIndexes( ns() ); @@ -85,46 +85,6 @@ namespace ClientTests { } }; - class ReIndex : public Base { - public: - ReIndex() : Base( "reindex" ) {} - void run() { - OperationContextImpl txn; - DBDirectClient db(&txn); - - db.insert( ns() , BSON( "x" << 2 ) ); - ASSERT_EQUALS( 1u , db.getIndexSpecs(ns()).size() ); - - db.ensureIndex( ns() , BSON( "x" << 1 ) ); - ASSERT_EQUALS( 2u , db.getIndexSpecs(ns()).size() ); - - db.reIndex( ns() ); - ASSERT_EQUALS( 2u , db.getIndexSpecs(ns()).size() ); - } - - }; - - class ReIndex2 : public Base { - public: - ReIndex2() : Base( "reindex2" ) {} - void run() { - OperationContextImpl txn; - DBDirectClient db(&txn); - - db.insert( ns() , BSON( "x" << 2 ) ); - ASSERT_EQUALS( 1u , db.getIndexSpecs(ns()).size() ); - - db.ensureIndex( ns() , BSON( "x" << 1 ) ); - ASSERT_EQUALS( 2u , db.getIndexSpecs(ns()).size() ); - - BSONObj out; - ASSERT( db.runCommand( "test" , BSON( "reIndex" << "reindex2" ) , out ) ); - ASSERT_EQUALS( 2 , out["nIndexes"].number() ); - ASSERT_EQUALS( 2u , db.getIndexSpecs(ns()).size() ); - } - - }; - /** * Check that nIndexes is incremented correctly when an index builds (and that it is not * incremented when an index fails to build), system.indexes has an entry added (or not), and @@ -150,12 +110,13 @@ namespace ClientTests { // _id index ASSERT_EQUALS(1U, db.getIndexSpecs(ns()).size()); - db.ensureIndex(ns(), BSON("y" << 1), true); + ASSERT_EQUALS(ErrorCodes::DuplicateKey, + dbtests::createIndex(&txn, ns(), BSON("y" << 1), true)); ASSERT_EQUALS(1, indexCatalog->numIndexesReady(&txn)); ASSERT_EQUALS(1U, db.getIndexSpecs(ns()).size()); - db.ensureIndex(ns(), BSON("x" << 1), true); + ASSERT_OK(dbtests::createIndex(&txn, ns(), BSON("x" << 1), true)); ASSERT_EQUALS(2, indexCatalog->numIndexesReady(&txn)); ASSERT_EQUALS(2U, db.getIndexSpecs(ns()).size()); @@ -174,7 +135,7 @@ namespace ClientTests { db.insert(ns(), BSON("a" << i << "b" << longs)); } - db.ensureIndex( ns(), BSON( "a" << 1 << "b" << 1 ) ); + ASSERT_OK(dbtests::createIndex(&txn, ns(), BSON( "a" << 1 << "b" << 1 ) )); auto_ptr< DBClientCursor > c = db.query( ns(), Query().sort( BSON( "a" << 1 << "b" << 1 ) ) ); ASSERT_EQUALS( 1111, c->itcount() ); @@ -263,8 +224,6 @@ namespace ClientTests { void setupTests() { add(); - add(); - add(); add(); add(); add(); -- cgit v1.2.1