summaryrefslogtreecommitdiff
path: root/jstests
diff options
context:
space:
mode:
authorKaloian Manassiev <kaloian.manassiev@mongodb.com>2015-04-13 15:47:20 -0400
committerKaloian Manassiev <kaloian.manassiev@mongodb.com>2015-04-21 14:31:46 -0400
commit4777fb87f36dc4c1f808570490eab01a1c12095f (patch)
tree34e6d877daf775d3d1a4d6006b82a2b6eabe61e2 /jstests
parent1e0624eb98e4c5609ddf86c8f14bdea68bce9f3b (diff)
downloadmongo-4777fb87f36dc4c1f808570490eab01a1c12095f.tar.gz
SERVER-18024 Move collection metadata loading under the catalog manager
Cleans up the CollectionType parsing code and moves all the collection metadata retrieval logic under the catalog manager. Also moves type_collection.* under the catalog manager library.
Diffstat (limited to 'jstests')
-rw-r--r--jstests/noPassthroughWithMongod/no_balance_collection.js10
-rw-r--r--jstests/sharding/drop_sharded_db.js28
-rw-r--r--jstests/sharding/mrShardedOutputAuth.js8
-rw-r--r--jstests/sharding/shard1.js10
-rw-r--r--jstests/sharding/top_chunk_autosplit.js4
5 files changed, 34 insertions, 26 deletions
diff --git a/jstests/noPassthroughWithMongod/no_balance_collection.js b/jstests/noPassthroughWithMongod/no_balance_collection.js
index 8cc580a29e0..bdb4a9b4b66 100644
--- a/jstests/noPassthroughWithMongod/no_balance_collection.js
+++ b/jstests/noPassthroughWithMongod/no_balance_collection.js
@@ -82,7 +82,11 @@ assert.writeOK(bulk.execute());
printjson( lastMigration )
printjson( sh._lastMigration( collB ) )
-if( lastMigration == null ) assert.eq( null, sh._lastMigration( collB ) )
-else assert.eq( lastMigration.time, sh._lastMigration( collB ).time )
+if(lastMigration == null) {
+ assert.eq(null, sh._lastMigration(collB));
+}
+else {
+ assert.eq(lastMigration.time, sh._lastMigration(collB).time);
+}
-st.stop()
+st.stop();
diff --git a/jstests/sharding/drop_sharded_db.js b/jstests/sharding/drop_sharded_db.js
index 44669cd17c2..d453e4fcdfe 100644
--- a/jstests/sharding/drop_sharded_db.js
+++ b/jstests/sharding/drop_sharded_db.js
@@ -1,15 +1,14 @@
// Tests the dropping of a sharded database SERVER-3471 SERVER-1726
-
var st = new ShardingTest({ name : jsTestName() })
st.stopBalancer()
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" )
+var dbA = mongos.getDB( "DropSharded_A" );
+var dbB = mongos.getDB( "DropSharded_B" );
+var dbC = mongos.getDB( "DropSharded_C" );
+
print( "1: insert some data and colls into all dbs" )
@@ -21,10 +20,10 @@ for( var i = 0; i < numDocs; i++ ){
dbC.getCollection( "data" + (i % numColls) ).insert({ _id : i })
}
+
print( "2: shard the colls ")
for( var i = 0; i < numColls; i++ ){
-
var key = { _id : 1 }
st.shardColl( dbA.getCollection( "data" + i ), key )
st.shardColl( dbB.getCollection( "data" + i ), key )
@@ -48,16 +47,17 @@ 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 )
+// 10 dropped collections
assert.eq( numColls, config.collections.find({ _id : RegExp( "^" + dbA + "\\..*" ), dropped : true }).toArray().length )
-assert.eq( numColls, config.collections.find({ _id : RegExp( "^" + dbB + "\\..*" ), dropped : false }).toArray().length )
-assert.eq( numColls, config.collections.find({ _id : RegExp( "^" + dbC + "\\..*" ), dropped : false }).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() )
-
+// 20 active (dropped is missing)
+assert.eq( numColls, config.collections.find({ _id : RegExp( "^" + dbB + "\\..*" ) }).toArray().length )
+assert.eq( numColls, config.collections.find({ _id : RegExp( "^" + 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()
+st.stop();
diff --git a/jstests/sharding/mrShardedOutputAuth.js b/jstests/sharding/mrShardedOutputAuth.js
index 4bafa04fa95..36c1ace4966 100644
--- a/jstests/sharding/mrShardedOutputAuth.js
+++ b/jstests/sharding/mrShardedOutputAuth.js
@@ -34,7 +34,7 @@ function doMapReduce(connection, outputDb) {
function assertSuccess(configDb, outputDb) {
adminDb.printShardingStatus();
assert.eq(outputDb.numbers_out.count(), 50, "map/reduce failed");
- assert.eq(configDb.collections.findOne().dropped, false, "no sharded collections");
+ assert.eq(configDb.collections.findOne().dropped, undefined, "no sharded collections");
}
function assertFailure(configDb, outputDb) {
@@ -50,7 +50,7 @@ var st = new ShardingTest( testName = "mrShardedOutputAuth",
{ extraOptions : {"keyFile" : "jstests/libs/key1"} }
);
-// setup the users to the input, output and admin databases
+// Setup the users to the input, output and admin databases
var mongos = st.s;
var adminDb = mongos.getDB("admin");
adminDb.createUser({user: "user", pwd: "pass", roles: jsTest.adminUserRoles});
@@ -67,14 +67,14 @@ inputDb.createUser({user: "user", pwd: "pass", roles: jsTest.basicUserRoles});
var outputDb = authenticatedConn.getDB("output");
outputDb.createUser({user: "user", pwd: "pass", roles: jsTest.basicUserRoles});
-// setup the input db
+// Setup the input db
inputDb.numbers.drop();
for (var i = 0; i < 50; i++) {
inputDb.numbers.insert({ num : i });
}
assert.eq(inputDb.numbers.count(), 50);
-// setup a connection authenticated to both input and output db
+// Setup a connection authenticated to both input and output db
var inputOutputAuthConn = new Mongo(mongos.host);
inputOutputAuthConn.getDB('input').auth("user", "pass");
inputOutputAuthConn.getDB('output').auth("user", "pass");
diff --git a/jstests/sharding/shard1.js b/jstests/sharding/shard1.js
index 10dcafd6ec6..b14ec95f66f 100644
--- a/jstests/sharding/shard1.js
+++ b/jstests/sharding/shard1.js
@@ -23,14 +23,18 @@ s.adminCommand( shardCommand );
assert.throws( function(){ s.adminCommand({ shardCollection: 'test', key: { x: 1 }}); });
assert.throws( function(){ s.adminCommand({ shardCollection: '.foo', key: { x: 1 }}); });
-cconfig = s.config.collections.findOne( { _id : "test.foo" } );
+var cconfig = s.config.collections.findOne( { _id : "test.foo" } );
assert( cconfig , "why no collection entry for test.foo" )
+
delete cconfig.lastmod
delete cconfig.dropped
delete cconfig.lastmodEpoch
-assert.eq( cconfig , { _id : "test.foo" , key : { num : 1 } , unique : false } , "Sharded content" );
-s.config.collections.find().forEach( printjson )
+assert.eq(cconfig,
+ { _id : "test.foo" , key : { num : 1 } , unique : false },
+ "Sharded content mismatch");
+
+s.config.collections.find().forEach( printjson );
assert.eq( 1 , s.config.chunks.count() , "num chunks A");
si = s.config.chunks.findOne();
diff --git a/jstests/sharding/top_chunk_autosplit.js b/jstests/sharding/top_chunk_autosplit.js
index cab28bb7d4a..0ebd8bf1a60 100644
--- a/jstests/sharding/top_chunk_autosplit.js
+++ b/jstests/sharding/top_chunk_autosplit.js
@@ -25,9 +25,9 @@ function runTest(test) {
// Setup
// Enable sharding, set primary shard and shard collection
- db.adminCommand({enableSharding: dbName});
+ assert.commandWorked(db.adminCommand({enableSharding: dbName}));
db.adminCommand({movePrimary: dbName, to: 'shard0000'});
- db.adminCommand({shardCollection: coll + "", key: {x: 1}});
+ assert.commandWorked(db.adminCommand({shardCollection: coll + "", key: {x: 1}}));
// Pre-split, move chunks & create tags
for (var i = 0; i < test.shards.length; i++) {