summaryrefslogtreecommitdiff
path: root/jstests/sharding/migrateBig_balancer.js
diff options
context:
space:
mode:
authorKaloian Manassiev <kaloian.manassiev@mongodb.com>2015-10-26 10:09:34 -0400
committerKaloian Manassiev <kaloian.manassiev@mongodb.com>2015-10-27 08:24:24 -0400
commit38e5c4febb788441f19044a4d3d2b89e1ab70bf0 (patch)
tree19da129e382ed59e845838f67a4711d558c3f1c3 /jstests/sharding/migrateBig_balancer.js
parentba8757e0afd1577a090785f014fc07b55e219d9a (diff)
downloadmongo-38e5c4febb788441f19044a4d3d2b89e1ab70bf0.tar.gz
SERVER-21009 Get rid of some unused/unnecessary methods in ShardingTest
Removes shardGo in lieu of shardColl and removes setBalancer because it duplicates functionality, which is already in sh.
Diffstat (limited to 'jstests/sharding/migrateBig_balancer.js')
-rw-r--r--jstests/sharding/migrateBig_balancer.js68
1 files changed, 68 insertions, 0 deletions
diff --git a/jstests/sharding/migrateBig_balancer.js b/jstests/sharding/migrateBig_balancer.js
new file mode 100644
index 00000000000..a46614a3699
--- /dev/null
+++ b/jstests/sharding/migrateBig_balancer.js
@@ -0,0 +1,68 @@
+(function() {
+
+var st = new ShardingTest({ name: 'migrateBig_balancer',
+ shards: 2,
+ other: { enableBalancer: true } });
+var mongos = st.s;
+
+var admin = mongos.getDB("admin");
+db = mongos.getDB("test");
+var coll = db.getCollection("stuff")
+
+assert.commandWorked(admin.runCommand({ enablesharding : coll.getDB().getName() }));
+st.ensurePrimaryShard(coll.getDB().getName(), 'shard0001');
+
+var data = "x"
+var nsq = 16
+var n = 255
+
+for( var i = 0; i < nsq; i++ ) data += data
+
+dataObj = {}
+for( var i = 0; i < n; i++ ) dataObj["data-" + i] = data
+
+var bulk = coll.initializeUnorderedBulkOp();
+for( var i = 0; i < 40; i++ ) {
+ bulk.insert({ data: dataObj });
+}
+assert.writeOK(bulk.execute());
+
+assert.eq( 40 , coll.count() , "prep1" );
+
+printjson( coll.stats() )
+
+admin.printShardingStatus()
+
+admin.runCommand({ shardcollection : "" + coll, key : { _id : 1 } })
+
+assert.lt( 5 , mongos.getDB( "config" ).chunks.find( { ns : "test.stuff" } ).count() , "not enough chunks" );
+
+assert.soon(
+ function() {
+ // On *extremely* slow or variable systems, we've seen migrations fail in the critical section and
+ // kill the server. Do an explicit check for this. SERVER-8781
+ // TODO: Remove once we can better specify what systems to run what tests on.
+ try {
+ assert.commandWorked(st.shard0.getDB("admin").runCommand({ ping: 1 }));
+ assert.commandWorked(st.shard1.getDB("admin").runCommand({ ping: 1 }));
+ }
+ catch(e) {
+ print("An error occurred contacting a shard during balancing," +
+ " this may be due to slow disk I/O, aborting test.");
+ throw e;
+ }
+
+ res = mongos.getDB( "config" ).chunks.group( { cond : { ns : "test.stuff" } ,
+ key : { shard : 1 } ,
+ reduce : function( doc , out ){ out.nChunks++; } ,
+ initial : { nChunks : 0 } } );
+
+ printjson( res );
+ return res.length > 1 && Math.abs( res[0].nChunks - res[1].nChunks ) <= 3;
+
+ } ,
+ "never migrated" , 10 * 60 * 1000 , 1000 );
+
+st.stop();
+
+})();