From 64b33ee522375a8dc15be2875dfb7db4502259b0 Mon Sep 17 00:00:00 2001 From: Antonin Kral Date: Sat, 18 Jun 2011 21:24:41 +0200 Subject: Imported Upstream version 1.8.2 --- jstests/sharding/multi_mongos2a.js | 31 ++++++++++++++++++++++++ jstests/sharding/shard_insert_getlasterror_w2.js | 4 +-- 2 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 jstests/sharding/multi_mongos2a.js (limited to 'jstests/sharding') diff --git a/jstests/sharding/multi_mongos2a.js b/jstests/sharding/multi_mongos2a.js new file mode 100644 index 0000000..9b907cc --- /dev/null +++ b/jstests/sharding/multi_mongos2a.js @@ -0,0 +1,31 @@ +// multi_mongos2.js +// This tests sharding an existing collection that both shards are aware of (SERVER-2828) + + +// setup sharding with two mongos, s1 and s2 +s1 = new ShardingTest( "multi_mongos1" , 2 , 1 , 2 ); +s2 = s1._mongos[1]; + +s1.adminCommand( { enablesharding : "test" } ); +s1.adminCommand( { shardcollection : "test.foo" , key : { num : 1 } } ); + +s1.config.databases.find().forEach( printjson ) + +s1.getDB('test').existing.insert({_id:1}) +assert.eq(1, s1.getDB('test').existing.count({_id:1})); +assert.eq(1, s2.getDB('test').existing.count({_id:1})); + +s2.adminCommand( { shardcollection : "test.existing" , key : { _id : 1 } } ); +assert.eq(true, s2.getDB('test').existing.stats().sharded); + + +res = s2.getDB( "admin" ).runCommand( { moveChunk: "test.existing" , find : { _id : 1 } , to : s1.getOther( s1.getServer( "test" ) ).name } ); + +assert.eq(1 , res.ok, tojson(res)); + +s1.adminCommand( { flushRouterConfig : 1 } ) + +assert.eq(1, s1.getDB('test').existing.count({_id:1})); // SERVER-2828 +assert.eq(1, s2.getDB('test').existing.count({_id:1})); + +s1.stop(); diff --git a/jstests/sharding/shard_insert_getlasterror_w2.js b/jstests/sharding/shard_insert_getlasterror_w2.js index c722f21..5d185a5 100644 --- a/jstests/sharding/shard_insert_getlasterror_w2.js +++ b/jstests/sharding/shard_insert_getlasterror_w2.js @@ -51,7 +51,7 @@ function go() { db.foo.insert({_id:'a', x:1}); db.foo.insert({_id:'a', x:1}); var x = db.getLastErrorObj(2, 30000) - assert.neq(x.err, null, tojson(x)); + assert.neq(x.err, null, "C1 " + tojson(x)); // Add more data for (var i = N; i < 2*N; i++) { @@ -59,7 +59,7 @@ function go() { var x = db.getLastErrorObj(2, 30000) // wait to be copied to at least one secondary if (i % 30 == 0) print(i) if (i % 100 == 0 || x.err != null) printjson(x); - assert.eq(x.err, null, tojson(x)); + assert.eq(x.err, null, "C2 " + tojson(x)); } // take down the slave and make sure it fails over -- cgit v1.2.3