diff options
author | Dianna Hohensee <dianna.hohensee@10gen.com> | 2016-02-26 10:26:54 -0500 |
---|---|---|
committer | Dianna Hohensee <dianna.hohensee@10gen.com> | 2016-02-26 17:10:54 -0500 |
commit | 66746f4654189fa633066f2a353c66279d3cadab (patch) | |
tree | 3e48a760d220b46d6c40d143f85c920feeb630c6 /jstests | |
parent | 7f7a64a1d6ef791d3b111245301d73902e9e4875 (diff) | |
download | mongo-66746f4654189fa633066f2a353c66279d3cadab.tar.gz |
SERVER-22870 rename getServerName and getServer
Diffstat (limited to 'jstests')
33 files changed, 107 insertions, 58 deletions
diff --git a/jstests/aggregation/bugs/server6118.js b/jstests/aggregation/bugs/server6118.js index 561d9d900ea..7edfda4821f 100644 --- a/jstests/aggregation/bugs/server6118.js +++ b/jstests/aggregation/bugs/server6118.js @@ -26,7 +26,7 @@ s.adminCommand( { split:"test.data", middle:{ _id:66 } } ); // Migrate the middle chunk to another shard s.adminCommand({ movechunk: "test.data", find: { _id: 50 }, - to: s.getOther(s.getServer("test")).name }); + to: s.getOther(s.getPrimaryShard("test")).name }); // Check that the results are in order. var result = d.data.aggregate({ $sort: { _id: 1 } }).toArray(); diff --git a/jstests/aggregation/bugs/server6179.js b/jstests/aggregation/bugs/server6179.js index 88ba8c235d5..4eba802e14e 100644 --- a/jstests/aggregation/bugs/server6179.js +++ b/jstests/aggregation/bugs/server6179.js @@ -26,7 +26,7 @@ s.adminCommand( { split:"test.data", middle:{ _id:66 } } ); // Migrate the middle chunk to another shard s.adminCommand({ movechunk: "test.data", find: { _id: 50 }, - to: s.getOther(s.getServer("test")).name }); + to: s.getOther(s.getPrimaryShard("test")).name }); // Check that we get results rather than an error var result = d.data.aggregate({$group: {_id: '$_id', i: {$first: '$i'}}}, diff --git a/jstests/noPassthroughWithMongod/ttl_sharded.js b/jstests/noPassthroughWithMongod/ttl_sharded.js index bb154cc8180..e1c550d74c6 100644 --- a/jstests/noPassthroughWithMongod/ttl_sharded.js +++ b/jstests/noPassthroughWithMongod/ttl_sharded.js @@ -34,7 +34,9 @@ t.ensureIndex( { x : 1 } , { expireAfterSeconds : 20000 } ); // split chunk in half by _id, and move one chunk to the other shard s.adminCommand( {split : ns , middle : {_id : 12 } } ); -s.adminCommand( {moveChunk : ns , find : {_id : 0} , to : s.getOther(s.getServer(dbname)).name } ); +s.adminCommand( {moveChunk : ns , + find : {_id : 0} , + to : s.getOther(s.getPrimaryShard(dbname)).name } ); // one shard will lose 12/12 docs, the other 6/12, so count will go // from 24 -> 18 or 12 -> 6 diff --git a/jstests/sharding/auto1.js b/jstests/sharding/auto1.js index 6e04080fe80..214e5aae1ed 100644 --- a/jstests/sharding/auto1.js +++ b/jstests/sharding/auto1.js @@ -24,7 +24,7 @@ for ( ; i<100; i++ ){ } assert.writeOK( bulk.execute() ); -primary = s.getServer( "test" ).getDB( "test" ); +primary = s.getPrimaryShard( "test" ).getDB( "test" ); counts = []; @@ -32,7 +32,8 @@ s.printChunks(); counts.push( s.config.chunks.count() ); assert.eq(100, db.foo.find().itcount()); -print( "datasize: " + tojson( s.getServer( "test" ).getDB( "admin" ).runCommand( { datasize : "test.foo" } ) ) ); +print( "datasize: " + tojson( s.getPrimaryShard( "test" ).getDB( "admin" ) + .runCommand( { datasize : "test.foo" } ) ) ); bulk = coll.initializeUnorderedBulkOp(); for ( ; i<200; i++ ){ diff --git a/jstests/sharding/auto2.js b/jstests/sharding/auto2.js index afca165f2a3..81f0c1f17ea 100644 --- a/jstests/sharding/auto2.js +++ b/jstests/sharding/auto2.js @@ -38,7 +38,8 @@ new Mongo(s.s.host).adminCommand("connpoolsync"); print("done inserting data" ); -print("datasize: " + tojson( s.getServer("test" ).getDB("admin" ).runCommand( { datasize : "test.foo" } ) ) ); +print("datasize: " + tojson( s.getPrimaryShard("test" ).getDB("admin" ) + .runCommand( { datasize : "test.foo" } ) ) ); s.printChunks(); function doCountsGlobal(){ diff --git a/jstests/sharding/balance_repl.js b/jstests/sharding/balance_repl.js index 08dc9395d3c..85d029fce72 100644 --- a/jstests/sharding/balance_repl.js +++ b/jstests/sharding/balance_repl.js @@ -42,8 +42,8 @@ assert.eq( 2100, db.foo.find().itcount() ); var coll = db.foo; coll.setSlaveOk(); -var serverName = s.getServerName( "test" ); -var other = s.config.shards.findOne( { _id : { $ne : serverName } } ); +var dbPrimaryShardId = s.getPrimaryShardIdForDatabase( "test" ); +var other = s.config.shards.findOne( { _id : { $ne : dbPrimaryShardId } } ); for ( i=0; i<20; i++ ) { // Needs to waitForDelete because we'll be performing a slaveOk query, diff --git a/jstests/sharding/count1.js b/jstests/sharding/count1.js index 3d9f3f874be..a79d3ebfdd4 100644 --- a/jstests/sharding/count1.js +++ b/jstests/sharding/count1.js @@ -32,7 +32,7 @@ s.adminCommand( { enablesharding : "test" } ); s.ensurePrimaryShard('test', 'shard0001'); s.adminCommand( { shardcollection : "test.foo" , key : { name : 1 } } ); -primary = s.getServer( "test" ).getDB( "test" ); +primary = s.getPrimaryShard( "test" ).getDB( "test" ); secondary = s.getOther( primary ).getDB( "test" ); assert.eq( 1 , s.config.chunks.count() , "sanity check A" ); diff --git a/jstests/sharding/count2.js b/jstests/sharding/count2.js index 387bee9f8e3..cbef67a2db9 100644 --- a/jstests/sharding/count2.js +++ b/jstests/sharding/count2.js @@ -28,7 +28,10 @@ assert.eq( 3, db2.count( { name : { $gte: "aaa" , $lt: "ddd" } } ) , "initial co s1.printChunks( "test.foo" ); -s1.adminCommand( { movechunk : "test.foo" , find : { name : "aaa" } , to : s1.getOther( s1.getServer( "test" ) ).name, _waitForDelete : true }); +s1.adminCommand( { movechunk : "test.foo", + find : { name : "aaa" }, + to : s1.getOther( s1.getPrimaryShard( "test" ) ).name, + _waitForDelete : true }); assert.eq( 3, db1.count( { name : { $gte: "aaa" , $lt: "ddd" } } ) , "post count mongos1" ); diff --git a/jstests/sharding/cursor1.js b/jstests/sharding/cursor1.js index fd26d0c02fb..8b799ce1aa6 100644 --- a/jstests/sharding/cursor1.js +++ b/jstests/sharding/cursor1.js @@ -11,7 +11,7 @@ s.ensurePrimaryShard('test', 'shard0001'); s.adminCommand( { shardcollection: "test.foo", key: { _id: 1 } } ); db = s.getDB( "test" ); -primary = s.getServer( "test" ).getDB( "test" ); +primary = s.getPrimaryShard( "test" ).getDB( "test" ); secondary = s.getOther( primary ).getDB( "test" ); var numObjs = 30; diff --git a/jstests/sharding/delete_during_migrate.js b/jstests/sharding/delete_during_migrate.js index cabed50b960..e44b4cd4078 100644 --- a/jstests/sharding/delete_during_migrate.js +++ b/jstests/sharding/delete_during_migrate.js @@ -37,7 +37,7 @@ startMongoProgramNoConnect( "mongo" , // migrate while deletions are happening var moveResult = s.adminCommand( { moveChunk : ns , find : { a : 1 } , - to : st.getOther( st.getServer( dbname ) ).name } ); + to : st.getOther( st.getPrimaryShard( dbname ) ).name } ); // check if migration worked assert( moveResult.ok , "migration didn't work while doing deletes" ); diff --git a/jstests/sharding/features1.js b/jstests/sharding/features1.js index 0e52c514ee8..727f3cb2f09 100644 --- a/jstests/sharding/features1.js +++ b/jstests/sharding/features1.js @@ -21,7 +21,9 @@ b = s._connections[1].getDB( "test" ); db.foo.ensureIndex( { y : 1 } ); s.adminCommand( { split : "test.foo" , middle : { num : 10 } } ); -s.adminCommand( { movechunk : "test.foo" , find : { num : 20 } , to : s.getOther( s.getServer( "test" ) ).name } ); +s.adminCommand( { movechunk : "test.foo", + find : { num : 20 }, + to : s.getOther( s.getPrimaryShard( "test" ) ).name } ); db.foo.save( { num : 5 } ); db.foo.save( { num : 15 } ); @@ -102,7 +104,7 @@ assert( s.admin.runCommand( { shardcollection : "test.foo4" , key : { num : 1 } s.adminCommand( { split : "test.foo4" , middle : { num : 10 } } ); s.admin.runCommand({ movechunk: "test.foo4", find: { num: 20 }, - to: s.getOther( s.getServer( "test" ) ).name }); + to: s.getOther( s.getPrimaryShard( "test" ) ).name }); assert.writeOK(db.foo4.save( { num : 5 } )); assert.writeOK(db.foo4.save( { num : 15 } )); @@ -169,7 +171,9 @@ s.adminCommand( { split : "test.foo6" , middle : { a : 2 } } ); //Remove when SERVER-10232 is fixed assert.soon( function() { - var cmdRes = s.admin.runCommand( { movechunk : "test.foo6" , find : { a : 3 } , to : s.getOther( s.getServer( "test" ) ).name } ); + var cmdRes = s.admin.runCommand( { movechunk : "test.foo6", + find : { a : 3 }, + to : s.getOther( s.getPrimaryShard( "test" ) ).name } ); return cmdRes.ok; }, 'move chunk test.foo6', 60000, 1000 ); diff --git a/jstests/sharding/features2.js b/jstests/sharding/features2.js index b9dc4d6309c..f632e24e80c 100644 --- a/jstests/sharding/features2.js +++ b/jstests/sharding/features2.js @@ -138,7 +138,7 @@ doMR( "after" ); s.adminCommand({split:'test.mr' , middle:{x:3}} ); s.adminCommand({split:'test.mr' , middle:{x:4}} ); -s.adminCommand({movechunk:'test.mr', find:{x:3}, to: s.getServer('test').name } ); +s.adminCommand({movechunk:'test.mr', find:{x:3}, to: s.getPrimaryShard('test').name } ); doMR( "after extra split" ); diff --git a/jstests/sharding/findandmodify1.js b/jstests/sharding/findandmodify1.js index 3a93610f57e..14b5786a379 100644 --- a/jstests/sharding/findandmodify1.js +++ b/jstests/sharding/findandmodify1.js @@ -5,7 +5,7 @@ var s = new ShardingTest({ name: "find_and_modify_sharded", shards: 2 }); s.adminCommand( { enablesharding : "test" } ); db = s.getDB( "test" ); s.ensurePrimaryShard('test', 'shard0001'); -primary = s.getServer( "test" ).getDB( "test" ); +primary = s.getPrimaryShard( "test" ).getDB( "test" ); secondary = s.getOther( primary ).getDB( "test" ); numObjs = 20; diff --git a/jstests/sharding/findandmodify2.js b/jstests/sharding/findandmodify2.js index 81fa6de93fd..2d0b8c6a7fc 100644 --- a/jstests/sharding/findandmodify2.js +++ b/jstests/sharding/findandmodify2.js @@ -3,7 +3,7 @@ s.adminCommand( { enablesharding : "test" } ); var db = s.getDB( "test" ); s.ensurePrimaryShard('test', 'shard0001'); -var primary = s.getServer( "test" ).getDB( "test" ); +var primary = s.getPrimaryShard( "test" ).getDB( "test" ); var secondary = s.getOther( primary ).getDB( "test" ); var n = 100; diff --git a/jstests/sharding/key_many.js b/jstests/sharding/key_many.js index 4d89c1fcf6e..85cde37ba1d 100644 --- a/jstests/sharding/key_many.js +++ b/jstests/sharding/key_many.js @@ -21,7 +21,7 @@ assert.commandWorked(s.s0.adminCommand({ enableSharding: 'test' })); s.ensurePrimaryShard('test', 'shard0001'); var db = s.getDB('test'); -var primary = s.getServer("test").getDB("test"); +var primary = s.getPrimaryShard("test").getDB("test"); var secondary = s.getOther(primary).getDB("test"); var curT; diff --git a/jstests/sharding/key_string.js b/jstests/sharding/key_string.js index 6e9f92d09b0..c5b2e88b694 100644 --- a/jstests/sharding/key_string.js +++ b/jstests/sharding/key_string.js @@ -6,7 +6,7 @@ s.adminCommand( { enablesharding : "test" } ); s.ensurePrimaryShard('test', 'shard0001'); s.adminCommand( { shardcollection : "test.foo" , key : { name : 1 } } ); -primary = s.getServer( "test" ).getDB( "test" ); +primary = s.getPrimaryShard( "test" ).getDB( "test" ); seconday = s.getOther( primary ).getDB( "test" ); assert.eq( 1 , s.config.chunks.count() , "sanity check A" ); diff --git a/jstests/sharding/large_chunk.js b/jstests/sharding/large_chunk.js index 06333b3cec3..ae02733395b 100644 --- a/jstests/sharding/large_chunk.js +++ b/jstests/sharding/large_chunk.js @@ -38,7 +38,7 @@ s.adminCommand( { shardcollection : "test.foo" , key : { _id : 1 } } ); assert.eq( 1 , s.config.chunks.count() , "step 1 - need one large chunk" ); -primary = s.getServer( "test" ).getDB( "test" ); +primary = s.getPrimaryShard( "test" ).getDB( "test" ); secondary = s.getOther( primary ).getDB( "test" ); // Make sure that we don't move that chunk if it goes past what we consider the maximum chunk size diff --git a/jstests/sharding/limit_push.js b/jstests/sharding/limit_push.js index b1583cc21b7..5e7f1c32ab3 100644 --- a/jstests/sharding/limit_push.js +++ b/jstests/sharding/limit_push.js @@ -17,7 +17,10 @@ s.adminCommand( { shardcollection : "test.limit_push" , key : { x : 1 } } ); // Now split the and move the data between the shards s.adminCommand( { split : "test.limit_push", middle : { x : 50 }} ); -s.adminCommand( { moveChunk: "test.limit_push", find : { x : 51}, to : s.getOther( s.getServer( "test" ) ).name, _waitForDelete : true }); +s.adminCommand( { moveChunk: "test.limit_push", + find : { x : 51}, + to : s.getOther( s.getPrimaryShard( "test" ) ).name, + _waitForDelete : true }); // Check that the chunck have split correctly assert.eq( 2 , s.config.chunks.count() , "wrong number of chunks"); diff --git a/jstests/sharding/migrateBig.js b/jstests/sharding/migrateBig.js index 6d58cb44449..73a292033bc 100644 --- a/jstests/sharding/migrateBig.js +++ b/jstests/sharding/migrateBig.js @@ -26,12 +26,14 @@ s.printShardingStatus(); s.adminCommand( { split : "test.foo" , middle : { x : 30 } } ); s.adminCommand( { split : "test.foo" , middle : { x : 66 } } ); -s.adminCommand( { movechunk : "test.foo" , find : { x : 90 } , to : s.getOther( s.getServer( "test" ) ).name } ); +s.adminCommand( { movechunk : "test.foo" , + find : { x : 90 } , + to : s.getOther( s.getPrimaryShard( "test" ) ).name } ); s.printShardingStatus(); -print( "YO : " + s.getServer( "test" ).host ); -direct = new Mongo( s.getServer( "test" ).host ); +print( "YO : " + s.getPrimaryShard( "test" ).host ); +direct = new Mongo( s.getPrimaryShard( "test" ).host ); print( "direct : " + direct ); directDB = direct.getDB( "test" ); @@ -42,7 +44,11 @@ for ( done=0; done<2*1024*1024; done+=big.length ){ s.printShardingStatus(); -assert.throws( function(){ s.adminCommand( { movechunk : "test.foo" , find : { x : 50 } , to : s.getOther( s.getServer( "test" ) ).name } ); } , [] , "move should fail" ); +assert.throws( function(){ + s.adminCommand({ movechunk : "test.foo" , + find : { x : 50 } , + to : s.getOther( s.getPrimaryShard( "test" ) ).name }); +}, [], "move should fail" ); for ( i=0; i<20; i+= 2 ) { try { @@ -59,7 +65,11 @@ s.printShardingStatus(); s.config.settings.update( { _id: "balancer" }, { $set : { stopped: false } } , true ); -assert.soon( function(){ var x = s.chunkDiff( "foo" , "test" ); print( "chunk diff: " + x ); return x < 2; } , "no balance happened" , 8 * 60 * 1000 , 2000 ); +assert.soon( function(){ + var x = s.chunkDiff( "foo" , "test" ); + print( "chunk diff: " + x ); + return x < 2; +}, "no balance happened" , 8 * 60 * 1000 , 2000 ); assert.soon( function(){ return !s.isAnyBalanceInFlight(); } ); diff --git a/jstests/sharding/movePrimary1.js b/jstests/sharding/movePrimary1.js index dd72dba7168..cd0478b1a1e 100644 --- a/jstests/sharding/movePrimary1.js +++ b/jstests/sharding/movePrimary1.js @@ -10,7 +10,7 @@ initDB = function( name ){ c.save( { a : 3 } ); assert.eq( 3 , c.count() ); - return s.getServer( name ); + return s.getPrimaryShard( name ); }; from = initDB( "test1" ); diff --git a/jstests/sharding/multi_mongos2.js b/jstests/sharding/multi_mongos2.js index 41458c3b223..43be2ecd9da 100644 --- a/jstests/sharding/multi_mongos2.js +++ b/jstests/sharding/multi_mongos2.js @@ -21,14 +21,17 @@ assert.eq(1, s2.getDB('test').existing.count({_id:1})); s2.adminCommand( { shardcollection : "test.existing" , key : { _id : 1 } } ); assert.commandWorked(s2.adminCommand({ split: "test.existing", middle: { _id: 5 }})); -res = s2.getDB( "admin" ).runCommand( { moveChunk: "test.existing" , find : { _id : 1 } , to : s1.getOther( s1.getServer( "test" ) ).name } ); +res = s2.getDB( "admin" ).runCommand( { moveChunk: "test.existing" , + find : { _id : 1 } , + to : s1.getOther( s1.getPrimaryShard( "test" ) ).name } ); assert.eq(1 , res.ok, tojson(res)); s1.startBalancer(); printjson( s2.adminCommand( {"getShardVersion" : "test.existing" } ) ); -printjson( new Mongo(s1.getServer( "test" ).name).getDB( "admin" ).adminCommand( {"getShardVersion" : "test.existing" } ) ); +printjson( new Mongo(s1.getPrimaryShard( "test" ).name).getDB( "admin" ) + .adminCommand( {"getShardVersion" : "test.existing" } ) ); assert.eq(1, s1.getDB('test').existing.count({_id:1})); // SERVER-2828 assert.eq(1, s2.getDB('test').existing.count({_id:1})); @@ -58,7 +61,9 @@ s1.stopBalancer(); s2.adminCommand( { shardcollection : "test.existing3" , key : { _id : 1 } } ); assert.commandWorked(s2.adminCommand({ split: "test.existing3", middle: { _id: 5 }})); -res = s1.getDB( "admin" ).runCommand( { moveChunk: "test.existing3" , find : { _id : 1 } , to : s1.getOther( s1.getServer( "test" ) ).name } ); +res = s1.getDB( "admin" ).runCommand( { moveChunk: "test.existing3", + find : { _id : 1 }, + to : s1.getOther( s1.getPrimaryShard( "test" ) ).name } ); assert.eq(1 , res.ok, tojson(res)); s1.startBalancer(); diff --git a/jstests/sharding/multi_mongos2a.js b/jstests/sharding/multi_mongos2a.js index 691c3c4a3c1..3dea44fc4c5 100644 --- a/jstests/sharding/multi_mongos2a.js +++ b/jstests/sharding/multi_mongos2a.js @@ -20,7 +20,9 @@ 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 } ); +res = s2.getDB( "admin" ).runCommand( { moveChunk: "test.existing", + find : { _id : 1 }, + to : s1.getOther( s1.getPrimaryShard( "test" ) ).name } ); assert.eq(1 , res.ok, tojson(res)); diff --git a/jstests/sharding/prefix_shard_key.js b/jstests/sharding/prefix_shard_key.js index a473be73cb4..6e906add822 100644 --- a/jstests/sharding/prefix_shard_key.js +++ b/jstests/sharding/prefix_shard_key.js @@ -68,8 +68,10 @@ printjson( result2 ); assert.eq( 1, result2.ok , "splitting didn't succeed"); //test moving -var result3 = admin.runCommand({ movechunk: coll.getFullName(), find: { num: 20 }, - to: s.getOther(s.getServer("test")).name, _waitForDelete: true }); +var result3 = admin.runCommand({ movechunk: coll.getFullName(), + find: { num: 20 }, + to: s.getOther(s.getPrimaryShard("test")).name, + _waitForDelete: true }); printjson( result3 ); assert.eq( 1, result3.ok , "moveChunk didn't succeed"); @@ -97,7 +99,7 @@ for (var docs = 0; docs < 1000; docs++) { assert.eq(1000, db.user.find().itcount()); var result4 = admin.runCommand({ movechunk: 'test.user', find: { num: 70 }, - to: s.getOther(s.getServer("test")).name, _waitForDelete: true }); + to: s.getOther(s.getPrimaryShard("test")).name, _waitForDelete: true }); assert.commandWorked(result4); var expectedShardCount = { shard0000: 0, shard0001: 0 }; @@ -137,7 +139,7 @@ for( i=0; i < 3; i++ ){ // setup new collection on shard0 var coll2 = db.foo2; coll2.drop(); - if ( s.getServerName( coll2.getDB() ) != shards[0]._id ) { + if ( s.getPrimaryShardIdForDatabase( coll2.getDB() ) != shards[0]._id ) { var moveRes = admin.runCommand( { movePrimary : coll2.getDB() + "", to : shards[0]._id } ); assert.eq( moveRes.ok , 1 , "primary not moved correctly" ); } diff --git a/jstests/sharding/presplit.js b/jstests/sharding/presplit.js index 5a4a69cc5b3..d5efef30c34 100644 --- a/jstests/sharding/presplit.js +++ b/jstests/sharding/presplit.js @@ -26,7 +26,7 @@ assert.writeOK(bulk.execute()); // Make sure that there's only one chunk holding all the data. s.printChunks(); -primary = s.getServer( "test" ).getDB( "test" ); +primary = s.getPrimaryShard( "test" ).getDB( "test" ); assert.eq( 0 , s.config.chunks.count() , "single chunk assertion" ); assert.eq( num , primary.foo.count() ); diff --git a/jstests/sharding/shard2.js b/jstests/sharding/shard2.js index b94aa260c5c..f4946e13573 100644 --- a/jstests/sharding/shard2.js +++ b/jstests/sharding/shard2.js @@ -41,10 +41,11 @@ db.foo.save( { num : 1 , name : "eliot" } ); db.foo.save( { num : 2 , name : "sara" } ); db.foo.save( { num : -1 , name : "joe" } ); -assert.eq( 3 , s.getServer( "test" ).getDB( "test" ).foo.find().length() , "not right directly to db A" ); +assert.eq( 3 , s.getPrimaryShard( "test" ).getDB( "test" ).foo.find().length(), + "not right directly to db A" ); assert.eq( 3 , db.foo.find().length() , "not right on shard" ); -primary = s.getServer( "test" ).getDB( "test" ); +primary = s.getPrimaryShard( "test" ).getDB( "test" ); secondary = s.getOther( primary ).getDB( "test" ); assert.eq( 3 , primary.foo.find().length() , "primary wrong B" ); diff --git a/jstests/sharding/shard3.js b/jstests/sharding/shard3.js index f6bc9c50514..3b68d330eca 100644 --- a/jstests/sharding/shard3.js +++ b/jstests/sharding/shard3.js @@ -29,7 +29,7 @@ s.config.databases.find().forEach( printjson ); a = s.getDB( "test" ).foo; b = s2.getDB( "test" ).foo; -primary = s.getServer( "test" ).getDB( "test" ).foo; +primary = s.getPrimaryShard( "test" ).getDB( "test" ).foo; secondary = s.getOther( primary.name ).getDB( "test" ).foo; a.save( { num : 1 } ); @@ -45,7 +45,10 @@ assert.eq( 0 , secondary.count() , "s1" ); assert.eq( 1 , s.onNumShards( "foo" ) , "on 1 shards" ); s.adminCommand( { split : "test.foo" , middle : { num : 2 } } ); -s.adminCommand( { movechunk : "test.foo" , find : { num : 3 } , to : s.getOther( s.getServer( "test" ) ).name, _waitForDelete : true } ); +s.adminCommand( { movechunk : "test.foo", + find : { num : 3 }, + to : s.getOther( s.getPrimaryShard( "test" ) ).name, + _waitForDelete : true } ); assert( primary.find().toArray().length > 0 , "blah 1" ); assert( secondary.find().toArray().length > 0 , "blah 2" ); @@ -100,7 +103,7 @@ assert( b.findOne( { num : 1 } ) ); print( "GOING TO MOVE" ); assert( a.findOne( { num : 1 } ) , "pre move 1" ); s.printCollectionInfo( "test.foo" ); -myto = s.getOther( s.getServer( "test" ) ).name; +myto = s.getOther( s.getPrimaryShard( "test" ) ).name; print( "counts before move: " + tojson( s.shardCounts( "foo" ) ) ); s.adminCommand( { movechunk : "test.foo" , find : { num : 1 } , to : myto, _waitForDelete : true } ); print( "counts after move: " + tojson( s.shardCounts( "foo" ) ) ); @@ -130,7 +133,10 @@ s.adminCommand( { shardcollection : "test.foo" , key : { num : 1 } } ); a.save( { num : 2 } ); a.save( { num : 3 } ); s.adminCommand( { split : "test.foo" , middle : { num : 2 } } ); -s.adminCommand( { movechunk : "test.foo" , find : { num : 3 } , to : s.getOther( s.getServer( "test" ) ).name, _waitForDelete : true } ); +s.adminCommand( { movechunk : "test.foo" , + find : { num : 3 } , + to : s.getOther( s.getPrimaryShard( "test" ) ).name, + _waitForDelete : true } ); s.printShardingStatus(); s.printCollectionInfo( "test.foo" , "after dropDatabase setup" ); @@ -163,7 +169,10 @@ assert.eq( 3 , dba.foo.count() , "Ba" ); assert.eq( 3 , dbb.foo.count() , "Bb" ); s.adminCommand( { split : "test2.foo" , middle : { num : 2 } } ); -s.adminCommand( { movechunk : "test2.foo" , find : { num : 3 } , to : s.getOther( s.getServer( "test2" ) ).name, _waitForDelete : true } ); +s.adminCommand( { movechunk : "test2.foo", + find : { num : 3 } , + to : s.getOther( s.getPrimaryShard( "test2" ) ).name, + _waitForDelete : true } ); assert.eq( 2 , s.onNumShards( "foo" , "test2" ) , "B on 2 shards" ); diff --git a/jstests/sharding/shard4.js b/jstests/sharding/shard4.js index 14ce533f10f..bf91b816607 100644 --- a/jstests/sharding/shard4.js +++ b/jstests/sharding/shard4.js @@ -24,7 +24,10 @@ assert.eq( 7 , s.getDB( "test" ).foo.find().toArray().length , "normal A" ); assert.eq( 7 , s2.getDB( "test" ).foo.find().toArray().length , "other A" ); s.adminCommand( { split : "test.foo" , middle : { num : 4 } } ); -s.adminCommand( { movechunk : "test.foo" , find : { num : 3 } , to : s.getOther( s.getServer( "test" ) ).name, _waitForDelete : true } ); +s.adminCommand( { movechunk : "test.foo", + find : { num : 3 }, + to : s.getOther( s.getPrimaryShard( "test" ) ).name, + _waitForDelete : true } ); assert( s._connections[0].getDB( "test" ).foo.find().toArray().length > 0 , "blah 1" ); assert( s._connections[1].getDB( "test" ).foo.find().toArray().length > 0 , "blah 2" ); @@ -35,7 +38,6 @@ assert.eq( 7 , s.getDB( "test" ).foo.find().toArray().length , "normal B" ); assert.eq( 7 , s2.getDB( "test" ).foo.find().toArray().length , "other B" ); s.adminCommand( { split : "test.foo" , middle : { num : 2 } } ); -//s.adminCommand( { movechunk : "test.foo" , find : { num : 3 } , to : s.getOther( s.getServer( "test" ) ).name } ); s.printChunks(); print( "* A" ); diff --git a/jstests/sharding/shard5.js b/jstests/sharding/shard5.js index 47ba37c43db..c88cd355d73 100644 --- a/jstests/sharding/shard5.js +++ b/jstests/sharding/shard5.js @@ -27,7 +27,10 @@ assert.eq( 7 , s.getDB( "test" ).foo.find().toArray().length , "normal A" ); assert.eq( 7 , s2.getDB( "test" ).foo.find().toArray().length , "other A" ); s.adminCommand( { split : "test.foo" , middle : { num : 4 } } ); -s.adminCommand( { movechunk : "test.foo" , find : { num : 3 } , to : s.getOther( s.getServer( "test" ) ).name, _waitForDelete : true } ); +s.adminCommand( { movechunk : "test.foo", + find : { num : 3 }, + to : s.getOther( s.getPrimaryShard( "test" ) ).name, + _waitForDelete : true } ); assert( s._connections[0].getDB( "test" ).foo.find().toArray().length > 0 , "blah 1" ); assert( s._connections[1].getDB( "test" ).foo.find().toArray().length > 0 , "blah 2" ); @@ -38,7 +41,6 @@ assert.eq( 7 , s.getDB( "test" ).foo.find().toArray().length , "normal B" ); assert.eq( 7 , s2.getDB( "test" ).foo.find().toArray().length , "other B" ); s.adminCommand( { split : "test.foo" , middle : { num : 2 } } ); -//s.adminCommand( { movechunk : "test.foo" , find : { num : 3 } , to : s.getOther( s.getServer( "test" ) ).name } ); s.printChunks(); print( "* A" ); diff --git a/jstests/sharding/shard_targeting.js b/jstests/sharding/shard_targeting.js index 15105d880ff..ce8537d6fb4 100644 --- a/jstests/sharding/shard_targeting.js +++ b/jstests/sharding/shard_targeting.js @@ -24,7 +24,7 @@ for (var i=0; i<50; i++) { db.foo.insert({count: "" + i}); // chunk ["", MaxKey] } -var theOtherShard = s.getOther( s.getServer( "test" ) ).name; +var theOtherShard = s.getOther( s.getPrimaryShard( "test" ) ).name; s.printShardingStatus(); // Count documents on both shards diff --git a/jstests/sharding/sharding_migrate_cursor1.js b/jstests/sharding/sharding_migrate_cursor1.js index 86814ed17a8..0edeb2a0ac9 100644 --- a/jstests/sharding/sharding_migrate_cursor1.js +++ b/jstests/sharding/sharding_migrate_cursor1.js @@ -36,7 +36,7 @@ s.adminCommand( { shardcollection : "test.foo" , key : { _id : 1 } } ); assert.lt( numChunks , s.config.chunks.find().count() , "initial 1" ); -primary = s.getServer( "test" ).getDB( "test" ).foo; +primary = s.getPrimaryShard( "test" ).getDB( "test" ).foo; secondaryName = s.getOther( primary.name ); secondary = secondaryName.getDB( "test" ).foo; diff --git a/jstests/sharding/sharding_rs2.js b/jstests/sharding/sharding_rs2.js index 98af1f212ec..affe175eaa4 100644 --- a/jstests/sharding/sharding_rs2.js +++ b/jstests/sharding/sharding_rs2.js @@ -48,16 +48,16 @@ assert.eq(1, db.foo.count()); s.config.databases.find().forEach(printjson); s.config.shards.find().forEach(printjson); -var serverName = s.getServerName("test"); +var dbPrimaryShardId = s.getPrimaryShardIdForDatabase("test"); function countNodes(){ - var x = s.config.shards.findOne({ _id: serverName }); + var x = s.config.shards.findOne({ _id: dbPrimaryShardId }); return x.host.split(",").length; } assert.eq(2, countNodes(), "A1"); -var rs = s.getRSEntry(serverName); +var rs = s.getRSEntry(dbPrimaryShardId); rs.test.add(); try { rs.test.reInitiate(); @@ -160,7 +160,7 @@ assert.commandWorked(s.s0.adminCommand({ split: "test.foo", middle: { x: 50 } }) s.printShardingStatus(); -var other = s.config.shards.findOne({ _id: { $ne: serverName } }); +var other = s.config.shards.findOne({ _id: { $ne: dbPrimaryShardId } }); assert.commandWorked(s.getDB('admin').runCommand({ moveChunk: "test.foo", find: { x: 10 }, to: other._id, diff --git a/jstests/sharding/sharding_system_namespaces.js b/jstests/sharding/sharding_system_namespaces.js index 3cdcc11775e..27ba183dd64 100644 --- a/jstests/sharding/sharding_system_namespaces.js +++ b/jstests/sharding/sharding_system_namespaces.js @@ -54,7 +54,7 @@ if (Array.contains(storageEngines, "wiredTiger")) { st.printShardingStatus(); - var primaryShard = st.getServer("test"); + var primaryShard = st.getPrimaryShard("test"); anotherShard = st.getOther( primaryShard ); assert.commandWorked(db.adminCommand({ movechunk: coll + '', diff --git a/jstests/sharding/sort1.js b/jstests/sharding/sort1.js index 08ef71cfa93..2ff8e1a4daf 100644 --- a/jstests/sharding/sort1.js +++ b/jstests/sharding/sort1.js @@ -25,7 +25,7 @@ s.adminCommand( { split : "test.data" , middle : { 'sub.num' : 66 } } ); s.adminCommand({ movechunk : "test.data", find : { 'sub.num' : 50 }, - to : s.getOther( s.getServer( "test" ) ).name, + to : s.getOther( s.getPrimaryShard( "test" ) ).name, waitForDelete : true }); assert.lte( 3 , s.config.chunks.find().itcount() , "A1" ); @@ -49,11 +49,13 @@ for ( i=0; i<100; i++ ){ db.data.find().sort( { 'sub.num' : 1 } ).toArray(); -s.getServer("test").getDB( "test" ).data.find().sort( { 'sub.num' : 1 } ).toArray(); +s.getPrimaryShard("test").getDB( "test" ).data.find().sort( { 'sub.num' : 1 } ).toArray(); a = Date.timeFunc( function(){ z = db.data.find().sort( { 'sub.num' : 1 } ).toArray(); } , 200 ); assert.eq( 100 , z.length , "C1" ); -b = 1.5 * Date.timeFunc( function(){ z = s.getServer("test").getDB( "test" ).data.find().sort( { 'sub.num' : 1 } ).toArray(); } , 200 ); +b = 1.5 * Date.timeFunc( function(){ + z = s.getPrimaryShard("test").getDB("test").data.find().sort({'sub.num' : 1}).toArray(); + }, 200 ); assert.eq( 67 , z.length , "C2" ); print( "a: " + a + " b:" + b + " mongos slow down: " + Math.ceil( 100 * ( ( a - b ) / b ) ) + "%" ); |