summaryrefslogtreecommitdiff
path: root/jstests/sharding/bulk_shard_insert.js
diff options
context:
space:
mode:
authorJonathan Abrahams <jonathan@mongodb.com>2016-03-09 12:17:50 -0500
committerJonathan Abrahams <jonathan@mongodb.com>2016-03-09 12:18:14 -0500
commit4ae691e8edc87d0e3cfb633bb91c328426be007b (patch)
tree52079a593f54382ca13a2e741633eab1b6271893 /jstests/sharding/bulk_shard_insert.js
parenta025d43f3ce2efc1fb1282a718f5d286fa0a4dc1 (diff)
downloadmongo-4ae691e8edc87d0e3cfb633bb91c328426be007b.tar.gz
SERVER-22468 Format JS code with approved style in jstests/
Diffstat (limited to 'jstests/sharding/bulk_shard_insert.js')
-rw-r--r--jstests/sharding/bulk_shard_insert.js118
1 files changed, 59 insertions, 59 deletions
diff --git a/jstests/sharding/bulk_shard_insert.js b/jstests/sharding/bulk_shard_insert.js
index 7d42d8b41a2..943fe270ba0 100644
--- a/jstests/sharding/bulk_shard_insert.js
+++ b/jstests/sharding/bulk_shard_insert.js
@@ -1,81 +1,81 @@
// Test bulk inserts with sharding
(function() {
-// Setup randomized test
-var seed = new Date().getTime();
-// seed = 0
+ // Setup randomized test
+ var seed = new Date().getTime();
+ // seed = 0
-Random.srand( seed );
-print( "Seeded with " + seed );
+ Random.srand(seed);
+ print("Seeded with " + seed);
-var st = new ShardingTest({ name : jsTestName(), shards : 4, chunkSize: 1 });
+ var st = new ShardingTest({name: jsTestName(), shards: 4, chunkSize: 1});
-// Setup sharded collection
-var mongos = st.s0;
-var db = mongos.getDB( jsTestName() );
-var coll = db.coll;
-st.shardColl( coll, { _id : 1 }, false );
+ // Setup sharded collection
+ var mongos = st.s0;
+ var db = mongos.getDB(jsTestName());
+ var coll = db.coll;
+ st.shardColl(coll, {_id: 1}, false);
-// Insert lots of bulk documents
-var numDocs = 1000000;
+ // Insert lots of bulk documents
+ var numDocs = 1000000;
-var bulkSize = Math.floor( Random.rand() * 1000 ) + 2;
-bulkSize = 4000;
-var docSize = 128; /* bytes */
-print( "\n\n\nBulk size is " + bulkSize );
+ var bulkSize = Math.floor(Random.rand() * 1000) + 2;
+ bulkSize = 4000;
+ var docSize = 128; /* bytes */
+ print("\n\n\nBulk size is " + bulkSize);
-var data = "x";
-while( Object.bsonsize({ x : data }) < docSize ){
- data += data;
-}
+ var data = "x";
+ while (Object.bsonsize({x: data}) < docSize) {
+ data += data;
+ }
-print( "\n\n\nDocument size is " + Object.bsonsize({ x : data }) );
+ print("\n\n\nDocument size is " + Object.bsonsize({x: data}));
-var docsInserted = 0;
-var balancerOn = false;
+ var docsInserted = 0;
+ var balancerOn = false;
-while (docsInserted < numDocs) {
- var currBulkSize = ( numDocs - docsInserted > bulkSize ) ? bulkSize : ( numDocs - docsInserted );
-
- var bulk = [];
- for( var i = 0; i < currBulkSize; i++ ){
- bulk.push({hi: "there", at: docsInserted, i: i, x: data});
- }
-
- assert.writeOK(coll.insert( bulk ));
-
- if( Math.floor( docsInserted / 10000 ) != Math.floor( ( docsInserted + currBulkSize ) / 10000 ) ){
- print( "Inserted " + (docsInserted + currBulkSize) + " documents." );
- st.printShardingStatus();
- }
-
- docsInserted += currBulkSize;
-
- if( docsInserted > numDocs / 2 && ! balancerOn ){
- print( "Turning on balancer after half documents inserted." );
- st.startBalancer();
- balancerOn = true;
- }
-}
+ while (docsInserted < numDocs) {
+ var currBulkSize =
+ (numDocs - docsInserted > bulkSize) ? bulkSize : (numDocs - docsInserted);
+
+ var bulk = [];
+ for (var i = 0; i < currBulkSize; i++) {
+ bulk.push({hi: "there", at: docsInserted, i: i, x: data});
+ }
-// Check we inserted all the documents
-st.printShardingStatus();
+ assert.writeOK(coll.insert(bulk));
+
+ if (Math.floor(docsInserted / 10000) != Math.floor((docsInserted + currBulkSize) / 10000)) {
+ print("Inserted " + (docsInserted + currBulkSize) + " documents.");
+ st.printShardingStatus();
+ }
+
+ docsInserted += currBulkSize;
+
+ if (docsInserted > numDocs / 2 && !balancerOn) {
+ print("Turning on balancer after half documents inserted.");
+ st.startBalancer();
+ balancerOn = true;
+ }
+ }
-var count = coll.find().count();
-var itcount = count; //coll.find().itcount()
+ // Check we inserted all the documents
+ st.printShardingStatus();
-print("Inserted " + docsInserted + " count : " + count + " itcount : " + itcount);
+ var count = coll.find().count();
+ var itcount = count; // coll.find().itcount()
-st.startBalancer();
+ print("Inserted " + docsInserted + " count : " + count + " itcount : " + itcount);
-var count = coll.find().count();
-var itcount = coll.find().itcount();
+ st.startBalancer();
-print( "Inserted " + docsInserted + " count : " + count + " itcount : " + itcount );
+ var count = coll.find().count();
+ var itcount = coll.find().itcount();
+ print("Inserted " + docsInserted + " count : " + count + " itcount : " + itcount);
-// SERVER-3645
-// assert.eq( docsInserted, count )
-assert.eq(docsInserted, itcount);
+ // SERVER-3645
+ // assert.eq( docsInserted, count )
+ assert.eq(docsInserted, itcount);
})();