diff options
author | Judah Schvimer <judah@mongodb.com> | 2015-11-10 09:52:53 -0500 |
---|---|---|
committer | Judah Schvimer <judah@mongodb.com> | 2015-11-10 09:52:53 -0500 |
commit | 904c99891b47935ff7c0856f4456303f32c04f11 (patch) | |
tree | aa2759fd498a09d0ef3b52ddafb8a533d9017e5d /jstests/concurrency/fsm_workloads | |
parent | c836472353e736424c9bb87868508c9e633b892d (diff) | |
download | mongo-904c99891b47935ff7c0856f4456303f32c04f11.tar.gz |
SERVER-21310 Inject iterations and threadCount into data object in fsm workloads
Diffstat (limited to 'jstests/concurrency/fsm_workloads')
8 files changed, 37 insertions, 41 deletions
diff --git a/jstests/concurrency/fsm_workloads/convert_to_capped_collection.js b/jstests/concurrency/fsm_workloads/convert_to_capped_collection.js index ef575b17849..9f28512a837 100644 --- a/jstests/concurrency/fsm_workloads/convert_to_capped_collection.js +++ b/jstests/concurrency/fsm_workloads/convert_to_capped_collection.js @@ -12,12 +12,9 @@ load('jstests/concurrency/fsm_workload_helpers/drop_utils.js'); var $config = (function() { - var iter = 20; + // TODO: This workload may fail if an iteration multiplier is specified. var data = { - prefix: 'convert_to_capped_collection', - - // initial size should not be a power of 256 - size: Math.pow(2, iter + 5) + 1 + prefix: 'convert_to_capped_collection' }; var states = (function() { @@ -76,6 +73,11 @@ var $config = (function() { convertToCapped: { convertToCapped: 1 } }; + function setup(db, collName, cluster) { + // Initial size should not be a power of 256. + this.size = Math.pow(2, this.iterations + 5) + 1; + } + function teardown(db, collName, cluster) { var pattern = new RegExp('^' + this.prefix + '_\\d+$'); dropCollections(db, pattern); @@ -83,10 +85,11 @@ var $config = (function() { return { threadCount: 10, - iterations: iter, + iterations: 20, data: data, states: states, transitions: transitions, + setup: setup, teardown: teardown }; diff --git a/jstests/concurrency/fsm_workloads/list_indexes.js b/jstests/concurrency/fsm_workloads/list_indexes.js index 4b422cc6f3d..6ab3a8c28b9 100644 --- a/jstests/concurrency/fsm_workloads/list_indexes.js +++ b/jstests/concurrency/fsm_workloads/list_indexes.js @@ -8,8 +8,6 @@ */ var $config = (function() { - var threadCount = 10; - var states = (function() { // Picks a random index to drop and recreate. function modifyIndices(db, collName) { @@ -42,7 +40,7 @@ var $config = (function() { function setup(db, collName) { // Create indices {fooi: 1}. - for (var i = 0; i < threadCount; ++i) { + for (var i = 0; i < this.threadCount; ++i) { var spec = {}; spec['foo' + i] = 1; assertAlways.commandWorked(db[collName].ensureIndex(spec)); @@ -50,7 +48,7 @@ var $config = (function() { } return { - threadCount: threadCount, + threadCount: 10, iterations: 20, states: states, startState: 'modifyIndices', diff --git a/jstests/concurrency/fsm_workloads/remove_single_document.js b/jstests/concurrency/fsm_workloads/remove_single_document.js index c54cf02ec85..75442919f2d 100644 --- a/jstests/concurrency/fsm_workloads/remove_single_document.js +++ b/jstests/concurrency/fsm_workloads/remove_single_document.js @@ -33,12 +33,9 @@ var $config = (function() { remove: { remove: 1 } }; - var threadCount = 10; - var iterations = 20; - function setup(db, collName, cluster) { // insert enough documents so that each thread can remove exactly one per iteration - var num = threadCount * iterations; + var num = this.threadCount * this.iterations; for (var i = 0; i < num; ++i) { db[collName].insert({ i: i, rand: Random.rand() }); } @@ -46,8 +43,8 @@ var $config = (function() { } return { - threadCount: threadCount, - iterations: iterations, + threadCount: 10, + iterations: 20, states: states, transitions: transitions, setup: setup, diff --git a/jstests/concurrency/fsm_workloads/update_inc.js b/jstests/concurrency/fsm_workloads/update_inc.js index 6ecb1ff522d..32dca107456 100644 --- a/jstests/concurrency/fsm_workloads/update_inc.js +++ b/jstests/concurrency/fsm_workloads/update_inc.js @@ -68,20 +68,18 @@ var $config = (function() { find: { update: 1 } }; - var threadCount = 5; - function setup(db, collName, cluster) { var doc = { _id: this.id }; // Pre-populate the fields we need to avoid size change for capped collections. - for (var i = 0; i < threadCount; ++i) { + for (var i = 0; i < this.threadCount; ++i) { doc['t' + i] = 0; } db[collName].insert(doc); } return { - threadCount: threadCount, + threadCount: 5, iterations: 10, data: data, states: states, diff --git a/jstests/concurrency/fsm_workloads/update_multifield.js b/jstests/concurrency/fsm_workloads/update_multifield.js index 6df238051bf..f04f347d262 100644 --- a/jstests/concurrency/fsm_workloads/update_multifield.js +++ b/jstests/concurrency/fsm_workloads/update_multifield.js @@ -67,6 +67,10 @@ var $config = (function() { assertAlways.commandWorked(db[collName].ensureIndex({ z: 1 })); assertAlways.commandWorked(db[collName].ensureIndex({ x: 1, y: 1, z: 1 })); + // numDocs should be much less than threadCount, to make more threads use the same docs. + this.numDocs = Math.floor(this.threadCount / 3); + assertAlways.gt(this.numDocs, 0, 'numDocs should be a positive number'); + for (var i = 0; i < this.numDocs; ++i) { var res = db[collName].insert({ _id: i }); assertWhenOwnColl.writeOK(res); @@ -74,9 +78,8 @@ var $config = (function() { } } - var threadCount = 10; return { - threadCount: threadCount, + threadCount: 10, iterations: 10, startState: 'update', states: states, @@ -105,8 +108,6 @@ var $config = (function() { }, multi: false, isolated: false, - // numDocs should be much less than threadCount, to make more threads use the same docs - numDocs: Math.floor(threadCount / 3) }, setup: setup }; diff --git a/jstests/concurrency/fsm_workloads/update_rename.js b/jstests/concurrency/fsm_workloads/update_rename.js index c4ebaa3e812..c74a657f312 100644 --- a/jstests/concurrency/fsm_workloads/update_rename.js +++ b/jstests/concurrency/fsm_workloads/update_rename.js @@ -47,6 +47,10 @@ var $config = (function() { assertAlways.commandWorked(db[collName].ensureIndex(indexSpec)); }); + // numDocs should be much less than threadCount, to make more threads use the same docs. + this.numDocs = Math.floor(this.threadCount / 5); + assertAlways.gt(this.numDocs, 0, 'numDocs should be a positive number'); + for (var i = 0; i < this.numDocs; ++i) { var fieldName = fieldNames[i % fieldNames.length]; var doc = {}; @@ -57,17 +61,12 @@ var $config = (function() { } } - var threadCount = 20; return { - threadCount: threadCount, + threadCount: 20, iterations: 20, startState: 'update', states: states, transitions: transitions, - data: { - // numDocs should be much less than threadCount, to make more threads use the same docs - numDocs: Math.floor(threadCount / 5) - }, setup: setup }; diff --git a/jstests/concurrency/fsm_workloads/update_replace.js b/jstests/concurrency/fsm_workloads/update_replace.js index 25a35d5255d..9776d6f31da 100644 --- a/jstests/concurrency/fsm_workloads/update_replace.js +++ b/jstests/concurrency/fsm_workloads/update_replace.js @@ -54,6 +54,10 @@ var $config = (function() { assertAlways.commandWorked(db[collName].ensureIndex({ y: 1 })); // no index on z + // numDocs should be much less than threadCount, to make more threads use the same docs. + this.numDocs = Math.floor(this.threadCount / 3); + assertAlways.gt(this.numDocs, 0, 'numDocs should be a positive number'); + for (var i = 0; i < this.numDocs; ++i) { var res = db[collName].insert({ _id: i }); assertWhenOwnColl.writeOK(res); @@ -63,17 +67,12 @@ var $config = (function() { assertWhenOwnColl.eq(this.numDocs, db[collName].find().itcount()); } - var threadCount = 10; return { - threadCount: threadCount, + threadCount: 10, iterations: 10, startState: 'update', states: states, transitions: transitions, - data: { - // numDocs should be much less than threadCount, to make more threads use the same docs - numDocs: Math.floor(threadCount / 3) - }, setup: setup }; diff --git a/jstests/concurrency/fsm_workloads/update_simple.js b/jstests/concurrency/fsm_workloads/update_simple.js index 9b116f40c23..7e3c00de390 100644 --- a/jstests/concurrency/fsm_workloads/update_simple.js +++ b/jstests/concurrency/fsm_workloads/update_simple.js @@ -36,6 +36,11 @@ var $config = (function() { function setup(db, collName, cluster) { // index on 'value', the field being updated assertAlways.commandWorked(db[collName].ensureIndex({ value: 1 })); + + // numDocs should be much less than threadCount, to make more threads use the same docs. + this.numDocs = Math.floor(this.threadCount / 5); + assertAlways.gt(this.numDocs, 0, 'numDocs should be a positive number'); + for (var i = 0; i < this.numDocs; ++i) { // make sure the inserted docs have a 'value' field, so they won't need // to grow when this workload runs against a capped collection @@ -45,9 +50,8 @@ var $config = (function() { } } - var threadCount = 20; return { - threadCount: threadCount, + threadCount: 20, iterations: 20, startState: 'set', states: states, @@ -91,9 +95,6 @@ var $config = (function() { doUpdate: function doUpdate(db, collName, query, updater) { return db[collName].update(query, updater); }, - - // numDocs should be much less than threadCount, to make more threads use the same docs - numDocs: Math.floor(threadCount / 5) }, setup: setup }; |