summaryrefslogtreecommitdiff
path: root/jstests/concurrency/fsm_workloads/create_capped_collection_maxdocs.js
diff options
context:
space:
mode:
Diffstat (limited to 'jstests/concurrency/fsm_workloads/create_capped_collection_maxdocs.js')
-rw-r--r--jstests/concurrency/fsm_workloads/create_capped_collection_maxdocs.js80
1 files changed, 39 insertions, 41 deletions
diff --git a/jstests/concurrency/fsm_workloads/create_capped_collection_maxdocs.js b/jstests/concurrency/fsm_workloads/create_capped_collection_maxdocs.js
index b3a836b8b0b..e29ed65a274 100644
--- a/jstests/concurrency/fsm_workloads/create_capped_collection_maxdocs.js
+++ b/jstests/concurrency/fsm_workloads/create_capped_collection_maxdocs.js
@@ -10,57 +10,55 @@
load('jstests/concurrency/fsm_libs/extend_workload.js'); // for extendWorkload
load('jstests/concurrency/fsm_workloads/create_capped_collection.js'); // for $config
-var $config = extendWorkload(
- $config,
- function($config, $super) {
+var $config = extendWorkload($config, function($config, $super) {
- // Use the workload name as a prefix for the collection name,
- // since the workload name is assumed to be unique.
- $config.data.prefix = 'create_capped_collection_maxdocs';
+ // Use the workload name as a prefix for the collection name,
+ // since the workload name is assumed to be unique.
+ $config.data.prefix = 'create_capped_collection_maxdocs';
- var options = {
- capped: true,
- size: 8192, // multiple of 256; larger than 4096 default
- max: 3
- };
+ var options = {
+ capped: true,
+ size: 8192, // multiple of 256; larger than 4096 default
+ max: 3
+ };
- function uniqueCollectionName(prefix, tid, num) {
- return prefix + tid + '_' + num;
- }
+ function uniqueCollectionName(prefix, tid, num) {
+ return prefix + tid + '_' + num;
+ }
- // TODO: how to avoid having too many files open?
- function create(db, collName) {
- var myCollName = uniqueCollectionName(this.prefix, this.tid, this.num++);
- assertAlways.commandWorked(db.createCollection(myCollName, options));
+ // TODO: how to avoid having too many files open?
+ function create(db, collName) {
+ var myCollName = uniqueCollectionName(this.prefix, this.tid, this.num++);
+ assertAlways.commandWorked(db.createCollection(myCollName, options));
- // Define a small document to be an eighth the size of the capped collection.
- var smallDocSize = Math.floor(options.size / 8) - 1;
+ // Define a small document to be an eighth the size of the capped collection.
+ var smallDocSize = Math.floor(options.size / 8) - 1;
- // Verify size functionality still works as we expect
- this.verifySizeTruncation(db, myCollName, options);
+ // Verify size functionality still works as we expect
+ this.verifySizeTruncation(db, myCollName, options);
- // Insert multiple small documents and verify that at least one truncation has occurred.
- // There should never be more than 3 documents in the collection, regardless of the
- // storage
- // engine. They should always be the most recently inserted documents.
+ // Insert multiple small documents and verify that at least one truncation has occurred.
+ // There should never be more than 3 documents in the collection, regardless of the
+ // storage
+ // engine. They should always be the most recently inserted documents.
- var ids = [];
- var count;
+ var ids = [];
+ var count;
- ids.push(this.insert(db, myCollName, smallDocSize));
- ids.push(this.insert(db, myCollName, smallDocSize));
+ ids.push(this.insert(db, myCollName, smallDocSize));
+ ids.push(this.insert(db, myCollName, smallDocSize));
- for (var i = 0; i < 50; i++) {
- ids.push(this.insert(db, myCollName, smallDocSize));
- count = db[myCollName].find().itcount();
- assertWhenOwnDB.eq(3, count, 'expected truncation to occur due to number of docs');
- assertWhenOwnDB.eq(ids.slice(ids.length - count),
- this.getObjectIds(db, myCollName),
- 'expected truncation to remove the oldest documents');
- }
+ for (var i = 0; i < 50; i++) {
+ ids.push(this.insert(db, myCollName, smallDocSize));
+ count = db[myCollName].find().itcount();
+ assertWhenOwnDB.eq(3, count, 'expected truncation to occur due to number of docs');
+ assertWhenOwnDB.eq(ids.slice(ids.length - count),
+ this.getObjectIds(db, myCollName),
+ 'expected truncation to remove the oldest documents');
}
+ }
- $config.states.create = create;
+ $config.states.create = create;
- return $config;
- });
+ return $config;
+});