summaryrefslogtreecommitdiff
path: root/jstests/sharding
diff options
context:
space:
mode:
authorAntonin Kral <a.kral@bobek.cz>2011-06-18 21:24:41 +0200
committerAntonin Kral <a.kral@bobek.cz>2011-06-18 21:24:41 +0200
commit64b33ee522375a8dc15be2875dfb7db4502259b0 (patch)
tree44979e0aaf6bb576f4a737a93e071e28809b6779 /jstests/sharding
parent4d87ff4aa74d7ae975268ac43eee152dc3f5b7e9 (diff)
downloadmongodb-64b33ee522375a8dc15be2875dfb7db4502259b0.tar.gz
Imported Upstream version 1.8.2
Diffstat (limited to 'jstests/sharding')
-rw-r--r--jstests/sharding/multi_mongos2a.js31
-rw-r--r--jstests/sharding/shard_insert_getlasterror_w2.js4
2 files changed, 33 insertions, 2 deletions
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