diff options
author | alabid <alabidan@gmail.com> | 2015-01-05 09:47:07 -0500 |
---|---|---|
committer | alabid <alabidan@gmail.com> | 2015-02-05 16:14:37 -0500 |
commit | f6a65290f22f126b8a2eb616f800582c5c43b6c8 (patch) | |
tree | 896349307949ad6ab649307f6af5f5564f99d2c8 /jstests/concurrency/fsm_workloads/collmod.js | |
parent | aa352eab214771b8cb239a9056f8899e73cf9819 (diff) | |
download | mongo-f6a65290f22f126b8a2eb616f800582c5c43b6c8.tar.gz |
SERVER-16648 Additional FSM-based concurrency workloads with some cleanup and blacklisting
Includes workloads for:
explain
compact
reindex
collMod
count
distinct
touch
$where
Added to blacklists in FSM runners
Fixed the way we check for storage engines
Added two options for arbitrary function execution against cluster:
- Specified via ClusterOptions as setupFunctions to be run on the
cluster before workloads are run
- As part of setup and teardown with the cluster provided as a third
argument to these workload functions
Diffstat (limited to 'jstests/concurrency/fsm_workloads/collmod.js')
-rw-r--r-- | jstests/concurrency/fsm_workloads/collmod.js | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/jstests/concurrency/fsm_workloads/collmod.js b/jstests/concurrency/fsm_workloads/collmod.js new file mode 100644 index 00000000000..758a02634d9 --- /dev/null +++ b/jstests/concurrency/fsm_workloads/collmod.js @@ -0,0 +1,75 @@ +'use strict'; + +/** + * collmod.js + * + * Base workload for collMod command. + * Generates some random data and inserts it into a collection with a + * TTL index. Runs a collMod command to change the value of the + * expireAfterSeconds setting to a random integer. + * + * All threads update the same TTL index on the same collection. + */ +var $config = (function() { + + var data = { + numDocs: 1000, + maxTTL: 5000 // max time to live + }; + + var states = (function() { + + function collMod(db, collName) { + var newTTL = Random.randInt(this.maxTTL); + var res = db.runCommand({ collMod: this.threadCollName, + index: { + keyPattern: { createdAt: 1 }, + expireAfterSeconds: newTTL + } + }); + assertAlways.commandWorked(res); + // only assert if new expireAfterSeconds differs from old one + if (res.hasOwnProperty('expireAfterSeconds_new')) { + assertWhenOwnDB.eq(res.expireAfterSeconds_new, newTTL); + } + } + + return { + collMod: collMod + }; + + })(); + + var transitions = { + collMod: { collMod: 1 } + }; + + function setup(db, collName, cluster) { + // other workloads that extend this one might have set 'this.threadCollName' + this.threadCollName = this.threadCollName || collName; + var bulk = db[this.threadCollName].initializeUnorderedBulkOp(); + for (var i = 0; i < this.numDocs; ++i) { + bulk.insert({ createdAt: new Date() }); + } + + var res = bulk.execute(); + assertAlways.writeOK(res); + assertAlways.eq(this.numDocs, res.nInserted); + + // create TTL index + res = db[this.threadCollName].ensureIndex({ createdAt: 1 }, + { expireAfterSeconds: 3600 }); + assertAlways.commandWorked(res); + } + + return { + threadCount: 10, + iterations: 20, + data: data, + startState: 'collMod', + states: states, + transitions: transitions, + setup: setup + }; + +})(); |