diff options
Diffstat (limited to 'jstests/concurrency/fsm_workloads/findAndModify_remove_queue.js')
-rw-r--r-- | jstests/concurrency/fsm_workloads/findAndModify_remove_queue.js | 43 |
1 files changed, 26 insertions, 17 deletions
diff --git a/jstests/concurrency/fsm_workloads/findAndModify_remove_queue.js b/jstests/concurrency/fsm_workloads/findAndModify_remove_queue.js index 9df0e8c8636..c08fc5775aa 100644 --- a/jstests/concurrency/fsm_workloads/findAndModify_remove_queue.js +++ b/jstests/concurrency/fsm_workloads/findAndModify_remove_queue.js @@ -14,17 +14,22 @@ load('jstests/concurrency/fsm_workload_helpers/server_types.js'); // for isMong var $config = (function() { - var data = { + var data = { // Use the workload name as the database name, since the workload name is assumed to be // unique. uniqueDBName: 'findAndModify_remove_queue', newDocForInsert: function newDocForInsert(i) { - return { _id: i, rand: Random.rand() }; + return { + _id: i, + rand: Random.rand() + }; }, getIndexSpec: function getIndexSpec() { - return { rand: 1 }; + return { + rand: 1 + }; }, opName: 'removed', @@ -33,10 +38,12 @@ var $config = (function() { // Use a separate database to avoid conflicts with other FSM workloads. var ownedDB = db.getSiblingDB(db.getName() + this.uniqueDBName); - var updateDoc = { $push: {} }; + var updateDoc = { + $push: {} + }; updateDoc.$push[this.opName] = id; - var res = ownedDB[collName].update({ _id: this.tid }, updateDoc, { upsert: true }); + var res = ownedDB[collName].update({_id: this.tid}, updateDoc, {upsert: true}); assertAlways.writeOK(res); assertAlways.contains(res.nMatched, [0, 1], tojson(res)); @@ -45,8 +52,7 @@ var $config = (function() { assertAlways.eq(0, res.nModified, tojson(res)); } assertAlways.eq(1, res.nUpserted, tojson(res)); - } - else { + } else { if (ownedDB.getMongo().writeMode() === 'commands') { assertAlways.eq(1, res.nModified, tojson(res)); } @@ -61,7 +67,7 @@ var $config = (function() { var res = db.runCommand({ findAndModify: db[collName].getName(), query: {}, - sort: { rand: -1 }, + sort: {rand: -1}, remove: true }); assertAlways.commandWorked(res); @@ -86,7 +92,7 @@ var $config = (function() { })(); var transitions = { - remove: { remove: 1 } + remove: {remove: 1} }; function setup(db, collName, cluster) { @@ -98,8 +104,10 @@ var $config = (function() { var doc = this.newDocForInsert(i); // Require that documents inserted by this workload use _id values that can be compared // using the default JS comparator. - assertAlways.neq(typeof doc._id, 'object', 'default comparator of' + - ' Array.prototype.sort() is not well-ordered for JS objects'); + assertAlways.neq(typeof doc._id, + 'object', + 'default comparator of' + + ' Array.prototype.sort() is not well-ordered for JS objects'); bulk.insert(doc); } var res = bulk.execute(); @@ -152,9 +160,8 @@ var $config = (function() { break; } - var msg = 'threads ' + tojson(smallest.indices) + - ' claim to have ' + opName + - ' a document with _id = ' + tojson(smallest.value); + var msg = 'threads ' + tojson(smallest.indices) + ' claim to have ' + opName + + ' a document with _id = ' + tojson(smallest.value); assertWhenOwnColl.eq(1, smallest.indices.length, msg); indices[smallest.indices[0]]++; @@ -176,8 +183,7 @@ var $config = (function() { smallestValueIsSet = true; smallestValue = value; smallestIndices = [i]; - } - else if (value === smallestValue) { + } else if (value === smallestValue) { smallestIndices.push(i); } } @@ -185,7 +191,10 @@ var $config = (function() { if (!smallestValueIsSet) { return null; } - return { value: smallestValue, indices: smallestIndices }; + return { + value: smallestValue, + indices: smallestIndices + }; } } |