diff options
author | Antonin Kral <a.kral@bobek.cz> | 2011-06-18 21:24:41 +0200 |
---|---|---|
committer | Antonin Kral <a.kral@bobek.cz> | 2011-06-18 21:24:41 +0200 |
commit | 64b33ee522375a8dc15be2875dfb7db4502259b0 (patch) | |
tree | 44979e0aaf6bb576f4a737a93e071e28809b6779 /jstests | |
parent | 4d87ff4aa74d7ae975268ac43eee152dc3f5b7e9 (diff) | |
download | mongodb-64b33ee522375a8dc15be2875dfb7db4502259b0.tar.gz |
Imported Upstream version 1.8.2
Diffstat (limited to 'jstests')
-rw-r--r-- | jstests/check_shard_index.js | 5 | ||||
-rw-r--r-- | jstests/mr_undef.js | 22 | ||||
-rw-r--r-- | jstests/or5.js | 4 | ||||
-rw-r--r-- | jstests/replsets/auth1.js | 12 | ||||
-rw-r--r-- | jstests/replsets/initial_sync1.js | 5 | ||||
-rw-r--r-- | jstests/sharding/multi_mongos2a.js | 31 | ||||
-rw-r--r-- | jstests/sharding/shard_insert_getlasterror_w2.js | 4 |
7 files changed, 77 insertions, 6 deletions
diff --git a/jstests/check_shard_index.js b/jstests/check_shard_index.js index a5a1fc1..e63b79d 100644 --- a/jstests/check_shard_index.js +++ b/jstests/check_shard_index.js @@ -42,4 +42,9 @@ assert.eq( 3 , f.count() , "2. count after initial insert should be 3" ); res = db.runCommand( { checkShardingIndex: "test.jstests_shardingindex" , keyPattern: {x:1, y:1} , force: true }); assert.eq( false , res.ok , "2b " + tojson(res) ); +// +res = db.runCommand( { checkShardingIndex: "test.jstests_shardingindex" , keyPattern: {_id:1} , force: true }); +assert.eq( true , res.ok , "3a " + tojson(res) ); +assert( res.idskip , "3b " + tojson(res) ) + print("PASSED"); diff --git a/jstests/mr_undef.js b/jstests/mr_undef.js new file mode 100644 index 0000000..e162f99 --- /dev/null +++ b/jstests/mr_undef.js @@ -0,0 +1,22 @@ + +t = db.mr_undef +t.drop() + +outname = "mr_undef_out" +out = db[outname] +out.drop() + +t.insert({x : 0}) + +var m = function() { emit(this.mod, this.x); } +var r = function(k,v) { total = 0; for(i in v) { total+= v[i]; } return total; } + +res = t.mapReduce(m, r, {out : outname } ) + +assert.eq( 0 , out.find( { _id : { $type : 6 } } ).itcount() , "A1" ) +assert.eq( 1 , out.find( { _id : { $type : 10 } } ).itcount() , "A2" ) + +x = out.findOne() +assert.eq( x , out.findOne( { _id : x["_id"] } ) , "A3" ) + + diff --git a/jstests/or5.js b/jstests/or5.js index baa6bd6..98ff141 100644 --- a/jstests/or5.js +++ b/jstests/or5.js @@ -70,6 +70,7 @@ assert.eq.automsg( "6", "t.find( {$or:[{a:2},{b:3},{c:4}]} ).batchSize( 2 ).itco c = t.find( {$or:[{a:2},{b:3},{c:4}]} ).batchSize( 2 ); c.next(); t.remove( {b:3} ); +db.getLastError(); assert.eq.automsg( "3", c.itcount() ); reset(); @@ -78,6 +79,7 @@ c = t.find( {$or:[{a:2},{b:3},{c:4}]} ).batchSize( 2 ); c.next(); c.next(); t.remove( {b:3} ); +db.getLastError(); assert.eq.automsg( "2", c.itcount() ); reset(); @@ -87,6 +89,7 @@ c.next(); c.next(); c.next(); t.remove( {b:3} ); +db.getLastError(); assert.eq.automsg( "3", c.itcount() ); reset(); @@ -97,6 +100,7 @@ c.next(); c.next(); c.next(); t.remove( {b:3} ); +db.getLastError(); assert.eq.automsg( "2", c.itcount() ); t.drop(); diff --git a/jstests/replsets/auth1.js b/jstests/replsets/auth1.js index 4945869..60e4b95 100644 --- a/jstests/replsets/auth1.js +++ b/jstests/replsets/auth1.js @@ -182,3 +182,15 @@ wait(function() { return results.members[3].state == 2; }); +print("make sure it has the config, too"); +assert.soon(function() { + for (var i in rs.nodes) { + rs.nodes[i].setSlaveOk(); + rs.nodes[i].getDB("admin").auth("foo","bar"); + config = rs.nodes[i].getDB("local").system.replset.findOne(); + if (config.version != 2) { + return false; + } + } + return true; + }); diff --git a/jstests/replsets/initial_sync1.js b/jstests/replsets/initial_sync1.js index ee30b4e..df978c4 100644 --- a/jstests/replsets/initial_sync1.js +++ b/jstests/replsets/initial_sync1.js @@ -114,9 +114,6 @@ wait(function() { }); -/** - * TODO: this fails on buildbot - * see SERVER-2550 print("10. Insert some stuff"); master = replTest.getMaster(); for (var i=0; i<10000; i++) { @@ -126,4 +123,4 @@ for (var i=0; i<10000; i++) { print("11. Everyone happy eventually"); replTest.awaitReplication(); -*/ + 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 |