diff --git a/buildscripts/smoke.py b/buildscripts/smoke.py index 128c01cc287..405d01c651b 100755 --- a/buildscripts/smoke.py +++ b/buildscripts/smoke.py @@ -280,6 +280,11 @@ def runTest(test): t1 = time.time() # FIXME: we don't handle the case where the subprocess # hangs... that's bad. + argv = argv + [ '--eval', 'TestData = new Object();' + + 'TestData.testPath = "' + path + '";' + + 'TestData.testFile = "' + os.path.basename( path ) + '";' + + 'TestData.testName = "' + re.sub( ".js$", "", os.path.basename( path ) ) + '";' ] + print argv r = call(argv, cwd=test_path) t2 = time.time() print " " + str((t2 - t1) * 1000) + "ms" diff --git a/jstests/sharding/drop_sharded_db.js b/jstests/sharding/drop_sharded_db.js new file mode 100644 index 00000000000..f71883516e9 --- /dev/null +++ b/jstests/sharding/drop_sharded_db.js @@ -0,0 +1,68 @@ +// Tests the dropping of a sharded database SERVER-3471 + +var st = new ShardingTest( testName = "dropShardedDb", + numShards = 2, + verboseLevel = 0, + numMongos = 1 ) + +var mongos = st.s0 +var config = mongos.getDB( "config" ) + +var dbName = "buy" +var dbA = mongos.getDB( dbName ) +var dbB = mongos.getDB( dbName + "_201107" ) +var dbC = mongos.getDB( dbName + "_201108" ) + +print( "1: insert some data and colls into all dbs" ) + +var numDocs = 3000; +var numColls = 10; +for( var i = 0; i < numDocs; i++ ){ + dbA.getCollection( "data" + (i % numColls) ).insert({ _id : i }) + dbB.getCollection( "data" + (i % numColls) ).insert({ _id : i }) + dbC.getCollection( "data" + (i % numColls) ).insert({ _id : i }) +} + +print( "2: shard the colls ") + +for( var i = 0; i < numColls; i++ ){ + + var splitAt = { _id : numDocs / 2 } + st.shardGo( dbA.getCollection( "data" + i ), splitAt ) + st.shardGo( dbB.getCollection( "data" + i ), splitAt ) + st.shardGo( dbC.getCollection( "data" + i ), splitAt ) + +} + +print( "3: drop the non-suffixed db ") + +dbA.drop() + +/* +print( "3: ensure only the non-suffixed db was dropped ") + +var dbs = mongos.getDBs() +for( var i = 0; i < dbs.length; i++ ){ + assert.ne( dbs, "" + dbA ) +} + +assert.eq( 0, config.databases.find({ _id : "" + dbA }).toArray().length ) +assert.eq( 1, config.databases.find({ _id : "" + dbB }).toArray().length ) +assert.eq( 1, config.databases.find({ _id : "" + dbC }).toArray().length ) + +assert.eq( 0, config.collections.find({ db : "" + dbA }).toArray().length ) +assert.eq( numColls, config.collections.find({ db : "" + dbB }).toArray().length ) +assert.eq( numColls, config.collections.find({ db : "" + dbC }).toArray().length ) + +for( var i = 0; i < numColls; i++ ){ + + assert.eq( numDocs / numColls, dbB.getCollection( "data" + (i % numColls) ).find().itcount() ) + assert.eq( numDocs / numColls, dbC.getCollection( "data" + (i % numColls) ).find().itcount() ) + +} + + + +// Finish +st.stop() +*/ \ No newline at end of file diff --git a/shell/utils.js b/shell/utils.js index 9ae3640870e..91ae10b5c3c 100644 --- a/shell/utils.js +++ b/shell/utils.js @@ -950,6 +950,10 @@ printjsononeline = function(x){ print( tojsononeline( x ) ); } +testLog = function(x){ + print( TestData.testFile + " - " + x ) +} + shellPrintHelper = function (x) { if (typeof (x) == "undefined") {