diff options
author | Jonathan Abrahams <jonathan@mongodb.com> | 2016-03-09 12:17:50 -0500 |
---|---|---|
committer | Jonathan Abrahams <jonathan@mongodb.com> | 2016-03-09 12:18:14 -0500 |
commit | 4ae691e8edc87d0e3cfb633bb91c328426be007b (patch) | |
tree | 52079a593f54382ca13a2e741633eab1b6271893 /jstests/sharding/findandmodify2.js | |
parent | a025d43f3ce2efc1fb1282a718f5d286fa0a4dc1 (diff) | |
download | mongo-4ae691e8edc87d0e3cfb633bb91c328426be007b.tar.gz |
SERVER-22468 Format JS code with approved style in jstests/
Diffstat (limited to 'jstests/sharding/findandmodify2.js')
-rw-r--r-- | jstests/sharding/findandmodify2.js | 83 |
1 files changed, 42 insertions, 41 deletions
diff --git a/jstests/sharding/findandmodify2.js b/jstests/sharding/findandmodify2.js index 2d0b8c6a7fc..afa727e77b9 100644 --- a/jstests/sharding/findandmodify2.js +++ b/jstests/sharding/findandmodify2.js @@ -1,10 +1,11 @@ -var s = new ShardingTest({ name: "find_and_modify_sharded_2", shards: 2, mongos: 1, other: { chunkSize: 1 }}); -s.adminCommand( { enablesharding : "test" } ); +var s = new ShardingTest( + {name: "find_and_modify_sharded_2", shards: 2, mongos: 1, other: {chunkSize: 1}}); +s.adminCommand({enablesharding: "test"}); -var db = s.getDB( "test" ); +var db = s.getDB("test"); s.ensurePrimaryShard('test', 'shard0001'); -var primary = s.getPrimaryShard( "test" ).getDB( "test" ); -var secondary = s.getOther( primary ).getDB( "test" ); +var primary = s.getPrimaryShard("test").getDB("test"); +var secondary = s.getOther(primary).getDB("test"); var n = 100; var collection = "stuff"; @@ -18,7 +19,7 @@ var col_fam_upsert = col_fam + '_upsert'; var big = "x"; print("---------- Creating large payload..."); -for(var i=0;i<15;i++) { +for (var i = 0; i < 15; i++) { big += big; } print("---------- Done."); @@ -37,46 +38,39 @@ s.adminCommand({shardcollection: 'test.' + col_fam_upsert, key: {_id: 1}}); // update via findAndModify function via_fam() { - for (var i=0; i<n; i++){ - db[col_fam].save({ _id: i }); - } - - for (var i=0; i<n; i++){ - db[col_fam].findAndModify({query: {_id: i}, update: { $set: - { big: big } - }}); - } + for (var i = 0; i < n; i++) { + db[col_fam].save({_id: i}); + } + + for (var i = 0; i < n; i++) { + db[col_fam].findAndModify({query: {_id: i}, update: {$set: {big: big}}}); + } } // upsert via findAndModify function via_fam_upsert() { - for (var i=0; i<n; i++){ - db[col_fam_upsert].findAndModify({query: {_id: i}, update: { $set: - { big: big } - }, upsert: true}); - } + for (var i = 0; i < n; i++) { + db[col_fam_upsert].findAndModify( + {query: {_id: i}, update: {$set: {big: big}}, upsert: true}); + } } // update data using basic update function via_update() { - for (var i=0; i<n; i++){ - db[col_update].save({ _id: i }); - } - - for (var i=0; i<n; i++){ - db[col_update].update({_id: i}, { $set: - { big: big } - }); - } + for (var i = 0; i < n; i++) { + db[col_update].save({_id: i}); + } + + for (var i = 0; i < n; i++) { + db[col_update].update({_id: i}, {$set: {big: big}}); + } } // upsert data using basic update function via_update_upsert() { - for (var i=0; i<n; i++){ - db[col_update_upsert].update({_id: i}, { $set: - { big: big } - }, true); - } + for (var i = 0; i < n; i++) { + db[col_update_upsert].update({_id: i}, {$set: {big: big}}, true); + } } print("---------- Update via findAndModify..."); @@ -98,14 +92,21 @@ print("---------- Done."); print("---------- Printing chunks:"); s.printChunks(); - print("---------- Verifying that both codepaths resulted in splits..."); -assert.gte( s.config.chunks.count({ "ns": "test." + col_fam }), minChunks, "findAndModify update code path didn't result in splits" ); -assert.gte( s.config.chunks.count({ "ns": "test." + col_fam_upsert }), minChunks, "findAndModify upsert code path didn't result in splits" ); -assert.gte( s.config.chunks.count({ "ns": "test." + col_update }), minChunks, "update code path didn't result in splits" ); -assert.gte( s.config.chunks.count({ "ns": "test." + col_update_upsert }), minChunks, "upsert code path didn't result in splits" ); - -printjson( db[col_update].stats() ); +assert.gte(s.config.chunks.count({"ns": "test." + col_fam}), + minChunks, + "findAndModify update code path didn't result in splits"); +assert.gte(s.config.chunks.count({"ns": "test." + col_fam_upsert}), + minChunks, + "findAndModify upsert code path didn't result in splits"); +assert.gte(s.config.chunks.count({"ns": "test." + col_update}), + minChunks, + "update code path didn't result in splits"); +assert.gte(s.config.chunks.count({"ns": "test." + col_update_upsert}), + minChunks, + "upsert code path didn't result in splits"); + +printjson(db[col_update].stats()); // ensure that all chunks are smaller than chunksize // make sure not teensy |