summaryrefslogtreecommitdiff
path: root/jstests/concurrency
diff options
context:
space:
mode:
authorJonathan Abrahams <jonathan@mongodb.com>2015-05-19 14:19:01 -0400
committerJonathan Abrahams <jonathan@mongodb.com>2015-05-19 14:19:01 -0400
commit91d5a3999b0481869ef41f025b441092e48693fe (patch)
treed0fedfab8f96dda6e40af61b131a9b22737b02c2 /jstests/concurrency
parent4ed8331017c9c77b8cc34bf69648e3c7cc7488ba (diff)
downloadmongo-91d5a3999b0481869ef41f025b441092e48693fe.tar.gz
SERVER-18462: FSM enable capped collection tests
Diffstat (limited to 'jstests/concurrency')
-rw-r--r--jstests/concurrency/fsm_all.js5
-rw-r--r--jstests/concurrency/fsm_all_composed.js5
-rw-r--r--jstests/concurrency/fsm_all_master_slave.js5
-rw-r--r--jstests/concurrency/fsm_all_replication.js5
-rw-r--r--jstests/concurrency/fsm_all_sharded.js6
-rw-r--r--jstests/concurrency/fsm_all_sharded_replication.js5
-rw-r--r--jstests/concurrency/fsm_all_simultaneous.js5
-rw-r--r--jstests/concurrency/fsm_workloads/create_capped_collection.js115
-rw-r--r--jstests/concurrency/fsm_workloads/create_capped_collection_maxdocs.js45
9 files changed, 85 insertions, 111 deletions
diff --git a/jstests/concurrency/fsm_all.js b/jstests/concurrency/fsm_all.js
index b0a8771b932..e930a0b95d4 100644
--- a/jstests/concurrency/fsm_all.js
+++ b/jstests/concurrency/fsm_all.js
@@ -19,11 +19,6 @@ var blacklist = [
'auth_create_user.js',
'auth_drop_role.js',
'auth_drop_user.js', // SERVER-16739 OpenSSL libcrypto crash
-
- // These workloads are disabled because of recent changes in capped
- // collection behavior with wiredTiger (see: SERVER-16235)
- 'create_capped_collection.js',
- 'create_capped_collection_maxdocs.js',
].map(function(file) { return dir + '/' + file; });
runWorkloadsSerially(ls(dir).filter(function(file) {
diff --git a/jstests/concurrency/fsm_all_composed.js b/jstests/concurrency/fsm_all_composed.js
index dbdda0f5068..97aa4a08378 100644
--- a/jstests/concurrency/fsm_all_composed.js
+++ b/jstests/concurrency/fsm_all_composed.js
@@ -20,11 +20,6 @@ var blacklist = [
'auth_drop_role.js',
'auth_drop_user.js', // SERVER-16739 OpenSSL libcrypto crash
- // These workloads are disabled because of recent changes in capped
- // collection behavior with wiredTiger (see: SERVER-16235)
- 'create_capped_collection.js',
- 'create_capped_collection_maxdocs.js',
-
// These workloads take too long when composed because eval takes a
// global lock and the composer doesn't honor iteration counts:
'remove_single_document_eval.js',
diff --git a/jstests/concurrency/fsm_all_master_slave.js b/jstests/concurrency/fsm_all_master_slave.js
index 37a8e74a359..ce757f62d6b 100644
--- a/jstests/concurrency/fsm_all_master_slave.js
+++ b/jstests/concurrency/fsm_all_master_slave.js
@@ -19,11 +19,6 @@ var blacklist = [
'auth_create_user.js',
'auth_drop_role.js',
'auth_drop_user.js', // SERVER-16739 OpenSSL libcrypto crash
-
- // These workloads are disabled because of recent changes in capped
- // collection behavior with wiredTiger (see: SERVER-16235)
- 'create_capped_collection.js',
- 'create_capped_collection_maxdocs.js',
].map(function(file) { return dir + '/' + file; });
// SERVER-16196 re-enable executing workloads with master-slave replication
diff --git a/jstests/concurrency/fsm_all_replication.js b/jstests/concurrency/fsm_all_replication.js
index a15a40c6557..552cd2a91dc 100644
--- a/jstests/concurrency/fsm_all_replication.js
+++ b/jstests/concurrency/fsm_all_replication.js
@@ -19,11 +19,6 @@ var blacklist = [
'auth_create_user.js',
'auth_drop_role.js',
'auth_drop_user.js', // SERVER-16739 OpenSSL libcrypto crash
-
- // These workloads are disabled because of recent changes in capped
- // collection behavior with wiredTiger (see: SERVER-16235)
- 'create_capped_collection.js',
- 'create_capped_collection_maxdocs.js',
].map(function(file) { return dir + '/' + file; });
// SERVER-16196 re-enable executing workloads against replica sets
diff --git a/jstests/concurrency/fsm_all_sharded.js b/jstests/concurrency/fsm_all_sharded.js
index fd575720c05..d33ddb2f28e 100644
--- a/jstests/concurrency/fsm_all_sharded.js
+++ b/jstests/concurrency/fsm_all_sharded.js
@@ -23,12 +23,6 @@ var blacklist = [
'auth_create_user.js',
'auth_drop_role.js',
'auth_drop_user.js', // SERVER-16739 OpenSSL libcrypto crash
-
- // These workloads are disabled because of recent changes in capped
- // collection behavior with wiredTiger (see: SERVER-16235)
- 'create_capped_collection.js',
- 'create_capped_collection_maxdocs.js',
-
'agg_group_external.js', // uses >100MB of data, and is flaky
'agg_sort_external.js', // uses >100MB of data, and is flaky
'compact.js', // compact can only be run against a standalone mongod
diff --git a/jstests/concurrency/fsm_all_sharded_replication.js b/jstests/concurrency/fsm_all_sharded_replication.js
index ed2e1b39c42..a5f25365425 100644
--- a/jstests/concurrency/fsm_all_sharded_replication.js
+++ b/jstests/concurrency/fsm_all_sharded_replication.js
@@ -24,11 +24,6 @@ var blacklist = [
'auth_drop_role.js',
'auth_drop_user.js', // SERVER-16739 OpenSSL libcrypto crash
- // These workloads are disabled because of recent changes in capped
- // collection behavior with wiredTiger (see: SERVER-16235)
- 'create_capped_collection.js',
- 'create_capped_collection_maxdocs.js',
-
'agg_group_external.js', // uses >100MB of data, and is flaky
'agg_sort_external.js', // uses >100MB of data, and is flaky
'compact.js', // compact can only be run against a standalone mongod
diff --git a/jstests/concurrency/fsm_all_simultaneous.js b/jstests/concurrency/fsm_all_simultaneous.js
index 3b09529e612..487c097d314 100644
--- a/jstests/concurrency/fsm_all_simultaneous.js
+++ b/jstests/concurrency/fsm_all_simultaneous.js
@@ -19,11 +19,6 @@ var blacklist = [
'auth_create_user.js',
'auth_drop_role.js',
'auth_drop_user.js', // SERVER-16739 OpenSSL libcrypto crash
-
- // These workloads are disabled because of recent changes in capped
- // collection behavior with wiredTiger (see: SERVER-16235)
- 'create_capped_collection.js',
- 'create_capped_collection_maxdocs.js',
].map(function(file) { return dir + '/' + file; });
// SERVER-16196 re-enable executing workloads
diff --git a/jstests/concurrency/fsm_workloads/create_capped_collection.js b/jstests/concurrency/fsm_workloads/create_capped_collection.js
index 8066e3e4f7d..90f2426b221 100644
--- a/jstests/concurrency/fsm_workloads/create_capped_collection.js
+++ b/jstests/concurrency/fsm_workloads/create_capped_collection.js
@@ -7,6 +7,7 @@
* occurs once the collection reaches a certain size.
*/
load('jstests/concurrency/fsm_workload_helpers/drop_utils.js'); // for dropCollections
+load('jstests/concurrency/fsm_workload_helpers/server_types.js'); // for isMongod and isMMAPv1
var $config = (function() {
@@ -51,7 +52,72 @@ var $config = (function() {
// since the workload name is assumed to be unique.
prefix: 'create_capped_collection',
insert: insert,
- getObjectIds: getObjectIds
+ getObjectIds: getObjectIds,
+
+ // Define this function in data so that it can be used by workloads inheriting this one
+ verifySizeTruncation: function verifySizeTruncation(db, myCollName, options) {
+ var ids = [];
+ var count;
+
+ // Define a small document to be an eighth the size of the capped collection,
+ // and a large document to be half the size of the capped collection.
+ var smallDocSize = Math.floor(options.size / 8) - 1;
+ var largeDocSize = Math.floor(options.size / 2) - 1;
+
+ // Truncation in MMAPv1 has well defined behavior.
+ if (isMongod(db) && isMMAPv1(db)) {
+ ids.push(this.insert(db, myCollName, largeDocSize));
+
+ // Insert a large document and verify that a truncation has occurred.
+ // There should be 1 document in the collection and it should always be
+ // the most recently inserted document.
+
+ ids.push(this.insert(db, myCollName, largeDocSize));
+
+ count = db[myCollName].find().itcount();
+ assertWhenOwnDB.eq(count, 1, 'expected truncation to occur');
+ assertWhenOwnDB.eq(ids.slice(ids.length - count),
+ this.getObjectIds(db, myCollName),
+ 'expected truncation to remove the oldest document');
+
+ // Insert multiple small documents and verify that truncation has occurred. There
+ // should be at most 4 documents in the collection (fewer based on the maximum
+ // number of documents allowed if specified during collection creation), and they
+ // should be the most recently inserted documents.
+
+ ids.push(this.insert(db, myCollName, smallDocSize));
+ ids.push(this.insert(db, myCollName, smallDocSize));
+ ids.push(this.insert(db, myCollName, smallDocSize));
+
+ var prevCount = count;
+ count = db[myCollName].find().itcount();
+
+ var expectedCount = options.max && options.max < 4 ? options.max : 4;
+
+ assertWhenOwnDB.eq(count, expectedCount, 'expected truncation to occur');
+ assertWhenOwnDB.eq(ids.slice(ids.length - count),
+ this.getObjectIds(db, myCollName),
+ 'expected truncation to remove the oldest documents');
+ }
+
+ // Truncation of capped collections is generally unreliable. Instead of relying on it
+ // to occur after a certain size document is inserted we test its occurrence. We set a
+ // reasonable threshold of documents to insert before a user might expect truncation to
+ // occur and verify truncation occurred for the right documents.
+
+ var threshold = 1000;
+
+ for (var i = 0; i < threshold; ++i) {
+ ids.push(this.insert(db, myCollName, largeDocSize));
+ }
+
+ count = db[myCollName].find().itcount();
+
+ assertWhenOwnDB.lt(count, threshold, 'expected at least one truncation to occur');
+ assertWhenOwnDB.eq(ids.slice(ids.length - count),
+ this.getObjectIds(db, myCollName),
+ 'expected truncation to remove the oldest documents');
+ }
};
var states = (function() {
@@ -74,50 +140,7 @@ var $config = (function() {
var myCollName = uniqueCollectionName(this.prefix, this.tid, this.num++);
assertAlways.commandWorked(db.createCollection(myCollName, options));
- // Define a large document to be half the size of the capped collection,
- // and a small document to be an eighth the size of the capped collection.
- var largeDocSize = Math.floor(options.size / 2) - 1;
- var smallDocSize = Math.floor(options.size / 8) - 1;
-
- var ids = [];
- var count;
-
- ids.push(this.insert(db, myCollName, largeDocSize));
- ids.push(this.insert(db, myCollName, largeDocSize));
-
- assertWhenOwnDB.contains(db[myCollName].find().itcount(), [1, 2]);
-
- // Insert another large document and verify that at least one
- // truncation has occurred. There may be 1 or 2 documents in
- // the collection, depending on the storage engine, but they
- // should always be the most recently inserted documents.
-
- ids.push(this.insert(db, myCollName, largeDocSize));
-
- count = db[myCollName].find().itcount();
- assertWhenOwnDB.contains(count, [1, 2], 'expected truncation to occur');
- assertWhenOwnDB.eq(ids.slice(ids.length - count), this.getObjectIds(db, myCollName));
-
- // Insert multiple small documents and verify that at least one
- // truncation has occurred. There may be 4 or 5 documents in
- // the collection, depending on the storage engine, but they
- // should always be the most recently inserted documents.
-
- 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));
-
- var prevCount = count;
- count = db[myCollName].find().itcount();
-
- if (prevCount === 1) {
- assertWhenOwnDB.eq(4, count, 'expected truncation to occur');
- } else { // prevCount === 2
- assertWhenOwnDB.eq(5, count, 'expected truncation to occur');
- }
-
- assertWhenOwnDB.eq(ids.slice(ids.length - count), this.getObjectIds(db, myCollName));
+ this.verifySizeTruncation(db, myCollName, options);
}
return {
@@ -139,7 +162,7 @@ var $config = (function() {
return {
threadCount: 5,
- iterations: 20,
+ iterations: 5,
data: data,
states: states,
transitions: transitions,
diff --git a/jstests/concurrency/fsm_workloads/create_capped_collection_maxdocs.js b/jstests/concurrency/fsm_workloads/create_capped_collection_maxdocs.js
index 7153a78c2c7..ebdc1d55723 100644
--- a/jstests/concurrency/fsm_workloads/create_capped_collection_maxdocs.js
+++ b/jstests/concurrency/fsm_workloads/create_capped_collection_maxdocs.js
@@ -31,43 +31,30 @@ var $config = extendWorkload($config, function($config, $super) {
var myCollName = uniqueCollectionName(this.prefix, this.tid, this.num++);
assertAlways.commandWorked(db.createCollection(myCollName, options));
- // Define a large document to be half the size of the capped collection,
- // and a small document to be an eighth the size of the capped collection.
- var largeDocSize = Math.floor(options.size / 2) - 1;
+ // Define a small document to be an eighth the size of the capped collection.
var smallDocSize = Math.floor(options.size / 8) - 1;
- var ids = [];
- var count;
-
- ids.push(this.insert(db, myCollName, largeDocSize));
- ids.push(this.insert(db, myCollName, largeDocSize));
-
- assertWhenOwnDB.contains(db[myCollName].find().itcount(), [1, 2]);
-
- // Insert another large document and verify that at least one
- // truncation has occurred. There may be 1 or 2 documents in
- // the collection, depending on the storage engine, but they
- // should always be the most recently inserted documents.
+ // Verify size functionality still works as we expect
+ this.verifySizeTruncation(db, myCollName, options);
- ids.push(this.insert(db, myCollName, largeDocSize));
+ // 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.
- count = db[myCollName].find().itcount();
- assertWhenOwnDB.contains(count, [1, 2], 'expected truncation to occur due to size');
- assertWhenOwnDB.eq(ids.slice(ids.length - count), this.getObjectIds(db, myCollName));
-
- // Insert multiple small documents and verify that at least one
- // truncation has occurred. There should be 3 documents in the
- // collection, regardless of the storage engine. They should
- // always be the most recently inserted documents.
+ 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));
- 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));
+ 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;