summaryrefslogtreecommitdiff
path: root/jstests/concurrency/fsm_workloads/create_index_background.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/concurrency/fsm_workloads/create_index_background.js
parenta025d43f3ce2efc1fb1282a718f5d286fa0a4dc1 (diff)
downloadmongo-4ae691e8edc87d0e3cfb633bb91c328426be007b.tar.gz
SERVER-22468 Format JS code with approved style in jstests/
Diffstat (limited to 'jstests/concurrency/fsm_workloads/create_index_background.js')
-rw-r--r--jstests/concurrency/fsm_workloads/create_index_background.js98
1 files changed, 43 insertions, 55 deletions
diff --git a/jstests/concurrency/fsm_workloads/create_index_background.js b/jstests/concurrency/fsm_workloads/create_index_background.js
index 4dcb1e9ec7b..046709ebdd3 100644
--- a/jstests/concurrency/fsm_workloads/create_index_background.js
+++ b/jstests/concurrency/fsm_workloads/create_index_background.js
@@ -8,7 +8,7 @@
* index has completed and the test no longer needs to execute more transitions.
* The first thread (tid = 0) will be the one that creates the background index.
*/
-load('jstests/concurrency/fsm_workload_helpers/server_types.js'); // for isMongos
+load('jstests/concurrency/fsm_workload_helpers/server_types.js'); // for isMongos
var $config = (function() {
@@ -21,7 +21,7 @@ var $config = (function() {
getHighestX: function getHighestX(coll, tid) {
// Find highest value of x.
var highest = 0;
- var cursor = coll.find({ tid: tid }).sort({ x: -1 }).limit(-1);
+ var cursor = coll.find({tid: tid}).sort({x: -1}).limit(-1);
assertWhenOwnColl(function() {
highest = cursor.next().x;
});
@@ -35,7 +35,7 @@ var $config = (function() {
// Add thread-specific documents
var bulk = db[collName].initializeUnorderedBulkOp();
for (var i = 0; i < this.nDocumentsToSeed; ++i) {
- bulk.insert({ x: i, tid: this.tid });
+ bulk.insert({x: i, tid: this.tid});
}
var res = bulk.execute();
assertAlways.writeOK(res);
@@ -47,9 +47,9 @@ var $config = (function() {
// Before creating the background index make sure insert or update
// CRUD operations are active.
assertWhenOwnColl.soon(function() {
- return coll.find({ crud: { $exists: true } }).itcount() > 0;
+ return coll.find({crud: {$exists: true}}).itcount() > 0;
}, 'No documents with "crud" field have been inserted or updated', 60 * 1000);
- res = coll.ensureIndex({ x: 1 }, { background: true });
+ res = coll.ensureIndex({x: 1}, {background: true});
assertAlways.commandWorked(res, tojson(res));
}
}
@@ -58,15 +58,15 @@ var $config = (function() {
// Insert documents with an increasing value of index x.
var coll = db[collName];
var res;
- var count = coll.find({ tid: this.tid }).itcount();
+ var count = coll.find({tid: this.tid}).itcount();
var highest = this.getHighestX(coll, this.tid);
for (var i = 0; i < this.nDocumentsToCreate; ++i) {
- res = coll.insert({ x: i + highest + 1, tid: this.tid, crud: 1 });
+ res = coll.insert({x: i + highest + 1, tid: this.tid, crud: 1});
assertAlways.writeOK(res);
assertAlways.eq(res.nInserted, 1, tojson(res));
}
- assertWhenOwnColl.eq(coll.find({ tid: this.tid }).itcount(),
+ assertWhenOwnColl.eq(coll.find({tid: this.tid}).itcount(),
this.nDocumentsToCreate + count,
'createDocs itcount mismatch');
}
@@ -75,21 +75,19 @@ var $config = (function() {
// Read random documents from the collection on index x.
var coll = db[collName];
var res;
- var count = coll.find({ tid: this.tid }).itcount();
- assertWhenOwnColl.gte(count,
- this.nDocumentsToRead,
- 'readDocs not enough documents for tid ' + this.tid);
+ var count = coll.find({tid: this.tid}).itcount();
+ assertWhenOwnColl.gte(
+ count, this.nDocumentsToRead, 'readDocs not enough documents for tid ' + this.tid);
var highest = this.getHighestX(coll, this.tid);
for (var i = 0; i < this.nDocumentsToRead; ++i) {
// Do randomized reads on index x. A document is not guaranteed
// to match the randomized 'x' predicate.
- res = coll.find({ x: Random.randInt(highest), tid: this.tid }).itcount();
- assertWhenOwnColl.contains(res, [ 0, 1 ], tojson(res));
+ res = coll.find({x: Random.randInt(highest), tid: this.tid}).itcount();
+ assertWhenOwnColl.contains(res, [0, 1], tojson(res));
}
- assertWhenOwnColl.eq(coll.find({ tid: this.tid }).itcount(),
- count,
- 'readDocs itcount mismatch');
+ assertWhenOwnColl.eq(
+ coll.find({tid: this.tid}).itcount(), count, 'readDocs itcount mismatch');
}
function updateDocs(db, collName) {
@@ -98,7 +96,7 @@ var $config = (function() {
if (!isMongos(db)) {
var coll = db[collName];
var res;
- var count = coll.find({ tid: this.tid }).itcount();
+ var count = coll.find({tid: this.tid}).itcount();
assertWhenOwnColl.gte(count,
this.nDocumentsToUpdate,
'updateDocs not enough documents for tid ' + this.tid);
@@ -107,18 +105,17 @@ var $config = (function() {
for (var i = 0; i < this.nDocumentsToUpdate; ++i) {
// Do randomized updates on index x. A document is not guaranteed
// to match the randomized 'x' predicate.
- res = coll.update({ x: Random.randInt(highest), tid: this.tid },
- { $inc: { crud: 1 } });
+ res = coll.update({x: Random.randInt(highest), tid: this.tid},
+ {$inc: {crud: 1}});
assertAlways.writeOK(res);
if (db.getMongo().writeMode() === 'commands') {
- assertWhenOwnColl.contains(res.nModified, [ 0, 1 ], tojson(res));
+ assertWhenOwnColl.contains(res.nModified, [0, 1], tojson(res));
}
- assertWhenOwnColl.contains(res.nMatched, [ 0, 1 ], tojson(res));
+ assertWhenOwnColl.contains(res.nMatched, [0, 1], tojson(res));
assertWhenOwnColl.eq(res.nUpserted, 0, tojson(res));
}
- assertWhenOwnColl.eq(coll.find({ tid: this.tid }).itcount(),
- count,
- 'updateDocs itcount mismatch');
+ assertWhenOwnColl.eq(
+ coll.find({tid: this.tid}).itcount(), count, 'updateDocs itcount mismatch');
}
}
@@ -126,7 +123,7 @@ var $config = (function() {
// Remove random documents from the collection on index x.
var coll = db[collName];
var res;
- var count = coll.find({ tid: this.tid }).itcount();
+ var count = coll.find({tid: this.tid}).itcount();
// Set the maximum number of documents we can delete to ensure that there
// are documents to read or update after deleteDocs completes.
@@ -145,12 +142,12 @@ var $config = (function() {
for (var i = 0; i < nDeleteDocs; ++i) {
// Do randomized deletes on index x. A document is not guaranteed
// to match the randomized 'x' predicate.
- res = coll.remove({ x: Random.randInt(highest), tid: this.tid });
+ res = coll.remove({x: Random.randInt(highest), tid: this.tid});
assertAlways.writeOK(res);
- assertWhenOwnColl.contains(res.nRemoved, [ 0, 1 ], tojson(res));
+ assertWhenOwnColl.contains(res.nRemoved, [0, 1], tojson(res));
nActualDeletes += res.nRemoved;
}
- assertWhenOwnColl.eq(coll.find({ tid: this.tid }).itcount(),
+ assertWhenOwnColl.eq(coll.find({tid: this.tid}).itcount(),
count - nActualDeletes,
'deleteDocs itcount mismatch');
}
@@ -166,16 +163,11 @@ var $config = (function() {
})();
var transitions = {
- init:
- { createDocs: 1 },
- createDocs:
- { createDocs: 0.25, readDocs: 0.25, updateDocs: 0.25, deleteDocs: 0.25 },
- readDocs:
- { createDocs: 0.25, readDocs: 0.25, updateDocs: 0.25, deleteDocs: 0.25 },
- updateDocs:
- { createDocs: 0.25, readDocs: 0.25, updateDocs: 0.25, deleteDocs: 0.25 },
- deleteDocs:
- { createDocs: 0.25, readDocs: 0.25, updateDocs: 0.25, deleteDocs: 0.25 },
+ init: {createDocs: 1},
+ createDocs: {createDocs: 0.25, readDocs: 0.25, updateDocs: 0.25, deleteDocs: 0.25},
+ readDocs: {createDocs: 0.25, readDocs: 0.25, updateDocs: 0.25, deleteDocs: 0.25},
+ updateDocs: {createDocs: 0.25, readDocs: 0.25, updateDocs: 0.25, deleteDocs: 0.25},
+ deleteDocs: {createDocs: 0.25, readDocs: 0.25, updateDocs: 0.25, deleteDocs: 0.25},
};
var internalQueryExecYieldIterations;
@@ -185,12 +177,12 @@ var $config = (function() {
var nSetupDocs = this.nDocumentsToSeed * 200;
var coll = db[collName];
- var res = coll.ensureIndex({ tid: 1 });
+ var res = coll.ensureIndex({tid: 1});
assertAlways.commandWorked(res, tojson(res));
var bulk = coll.initializeUnorderedBulkOp();
for (var i = 0; i < nSetupDocs; ++i) {
- bulk.insert({ x: i });
+ bulk.insert({x: i});
}
res = bulk.execute();
assertAlways.writeOK(res);
@@ -199,11 +191,11 @@ var $config = (function() {
// Increase the following parameters to reduce the number of yields.
cluster.executeOnMongodNodes(function(db) {
var res;
- res = db.adminCommand({ setParameter: 1, internalQueryExecYieldIterations: 100000 });
+ res = db.adminCommand({setParameter: 1, internalQueryExecYieldIterations: 100000});
assertAlways.commandWorked(res);
internalQueryExecYieldIterations = res.was;
- res = db.adminCommand({ setParameter: 1, internalQueryExecYieldPeriodMS: 10000 });
+ res = db.adminCommand({setParameter: 1, internalQueryExecYieldPeriodMS: 10000});
assertAlways.commandWorked(res);
internalQueryExecYieldPeriodMS = res.was;
});
@@ -211,18 +203,14 @@ var $config = (function() {
function teardown(db, collName, cluster) {
cluster.executeOnMongodNodes(function(db) {
- assertAlways.commandWorked(
- db.adminCommand({
- setParameter: 1,
- internalQueryExecYieldIterations: internalQueryExecYieldIterations
- })
- );
- assertAlways.commandWorked(
- db.adminCommand({
- setParameter: 1,
- internalQueryExecYieldPeriodMS: internalQueryExecYieldPeriodMS
- })
- );
+ assertAlways.commandWorked(db.adminCommand({
+ setParameter: 1,
+ internalQueryExecYieldIterations: internalQueryExecYieldIterations
+ }));
+ assertAlways.commandWorked(db.adminCommand({
+ setParameter: 1,
+ internalQueryExecYieldPeriodMS: internalQueryExecYieldPeriodMS
+ }));
});
}