diff options
author | Andy Schwerin <schwerin@mongodb.com> | 2014-11-04 16:17:48 -0500 |
---|---|---|
committer | Andy Schwerin <schwerin@mongodb.com> | 2014-11-05 15:38:53 -0500 |
commit | d324cff2fccfd7f2f1397093e01a1eb4af9a3e52 (patch) | |
tree | 6b789f95a95ba33d6889c9ba898b77c03508ea8c /src/mongo/dbtests/clienttests.cpp | |
parent | ca0d6d5d907ebe39437b4032ccb4795946573183 (diff) | |
download | mongo-d324cff2fccfd7f2f1397093e01a1eb4af9a3e52.tar.gz |
SERVER-15882 Get rid of ensureIndex in dbtests.
Diffstat (limited to 'src/mongo/dbtests/clienttests.cpp')
-rw-r--r-- | src/mongo/dbtests/clienttests.cpp | 53 |
1 files changed, 6 insertions, 47 deletions
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<DropIndex>(); - add<ReIndex>(); - add<ReIndex2>(); add<BuildIndex>(); add<CS_10>(); add<PushBack>(); |