summaryrefslogtreecommitdiff
path: root/jstests
diff options
context:
space:
mode:
authorMax Hirschhorn <max.hirschhorn@mongodb.com>2015-05-28 12:15:47 -0400
committerMax Hirschhorn <max.hirschhorn@mongodb.com>2015-05-28 12:15:47 -0400
commit610fab503c216c163c568065a861c2ef95513b3d (patch)
treed187b31340a843b2e1df849a81ff9ddbc9fb7236 /jstests
parent3bec3c4ec50342ecf3bec7f0581b8479ab27aa04 (diff)
downloadmongo-610fab503c216c163c568065a861c2ef95513b3d.tar.gz
SERVER-17861 Change the default storage engine to wiredTiger.
WiredTiger is used as the default storage engine if the dbpath does not contain any data files. Otherwise, the storage engine specified in the storage.bson metadata file is used when the --storageEngine flag is omitted from the command line invocation.
Diffstat (limited to 'jstests')
-rw-r--r--jstests/core/apitest_dbcollection.js6
-rw-r--r--jstests/multiVersion/downgrade_replset.js2
-rw-r--r--jstests/multiVersion/libs/verify_collection_data.js78
-rw-r--r--jstests/multiVersion/mmapv1_overrides_default_storage_engine.js96
-rw-r--r--jstests/noPassthrough/dir_per_db_and_split.js2
-rw-r--r--jstests/noPassthrough/split_collections_and_indexes.js2
-rw-r--r--jstests/noPassthrough/wt_nojournal_fsync.js5
-rw-r--r--jstests/noPassthrough/wt_nojournal_repl.js4
-rw-r--r--jstests/noPassthroughWithMongod/index_check10.js2
-rw-r--r--jstests/replsets/initSyncV1Index.js2
-rw-r--r--jstests/sharding/stats.js3
-rw-r--r--jstests/sharding/user_flags_sharded.js4
12 files changed, 131 insertions, 75 deletions
diff --git a/jstests/core/apitest_dbcollection.js b/jstests/core/apitest_dbcollection.js
index 765c4e186b0..4142ef8d7dc 100644
--- a/jstests/core/apitest_dbcollection.js
+++ b/jstests/core/apitest_dbcollection.js
@@ -193,8 +193,10 @@ assert(db.getCollection( "test_db" ).getIndexes().length == 0,24);
'indexDetails missing from ' + 'db.collection.stats(' + tojson(options) +
') result: ' + tojson(collectionStats));
// Currently, indexDetails is only supported with WiredTiger.
- if (jsTest.options().storageEngine == undefined) { return; }
- if (jsTest.options().storageEngine.toLowerCase() != "wiredtiger") { return; }
+ var storageEngine = jsTest.options().storageEngine;
+ if (storageEngine && storageEngine !== 'wiredTiger') {
+ return;
+ }
assert.eq(1, Object.keys(collectionStats.indexDetails).length,
'indexDetails must have exactly one entry');
assert(collectionStats.indexDetails[indexName],
diff --git a/jstests/multiVersion/downgrade_replset.js b/jstests/multiVersion/downgrade_replset.js
index c3d8460eb0c..17581827f11 100644
--- a/jstests/multiVersion/downgrade_replset.js
+++ b/jstests/multiVersion/downgrade_replset.js
@@ -12,7 +12,7 @@ var nodes = {n1: {binVersion: newVersion},
n2: {binVersion: newVersion},
n3: {binVersion: newVersion}};
-var rst = new ReplSetTest({name: name, nodes: 3});
+var rst = new ReplSetTest({name: name, nodes: nodes, nodeOptions: {storageEngine: 'mmapv1'}});
rst.startSet();
rst.initiate();
diff --git a/jstests/multiVersion/libs/verify_collection_data.js b/jstests/multiVersion/libs/verify_collection_data.js
index 9e8423c1db2..72c3e01dac7 100644
--- a/jstests/multiVersion/libs/verify_collection_data.js
+++ b/jstests/multiVersion/libs/verify_collection_data.js
@@ -68,83 +68,47 @@ createCollectionWithData = function (db, collectionName, dataGenerator) {
// the saved state
function CollectionDataValidator() {
- var initialized = false;
- var collectionStats = {};
- var indexData = [];
- var collectionData = [];
+ var _initialized = false;
+ var _collectionInfo = {};
+ var _indexData = [];
+ var _collectionData = [];
+
+ // Returns the options of the specified collection.
+ this.getCollectionInfo = function(collection) {
+ var infoObj = collection.getDB().getCollectionInfos({name: collection.getName()});
+ assert.eq(1, infoObj.length, "expected collection '" + collection.getName() + "'to exist");
+ return infoObj[0];
+ };
// Saves the current state of the collection passed in
this.recordCollectionData = function (collection) {
+ // Save the metadata for this collection for later comparison.
+ _collectionInfo = this.getCollectionInfo(collection);
// Save the indexes for this collection for later comparison
- indexData = collection.getIndexes().sort(function(a,b) {
+ _indexData = collection.getIndexes().sort(function(a,b) {
if (a.name > b.name) return 1;
else return -1;
});
// Save the data for this collection for later comparison
- collectionData = collection.find().sort({"_id":1}).toArray();
-
- // Save the metadata for this collection for later comparison.
- // NOTE: We do this last since the data and indexes affect this output
- collectionStats = collection.stats();
-
- // XXX: in 2.4 avgObjSize was a double, but in 2.6 it is an int
- collectionStats['avgObjSize'] = Math.floor(collectionStats['avgObjSize']);
+ _collectionData = collection.find().sort({"_id":1}).toArray();
- // Delete keys that appear just because we shard
- delete collectionStats["primary"];
- delete collectionStats["sharded"];
-
- initialized = true;
+ _initialized = true;
return collection;
}
this.validateCollectionData = function (collection) {
- if (!initialized) {
+ if (!_initialized) {
throw Error("validateCollectionWithAllData called, but data is not initialized");
}
// Get the metadata for this collection
- var newCollectionStats = collection.stats();
-
- // XXX: in 2.4 avgObjSize was a double, but in 2.6 it is an int
- newCollectionStats['avgObjSize'] = Math.floor(newCollectionStats['avgObjSize']);
-
- // as of 2.7.1, we no longer use systemFlags
- delete collectionStats.systemFlags;
- delete newCollectionStats.systemFlags;
-
- // as of 2.7.7, we no longer use paddingFactor and introduced paddingFactorNote
- delete collectionStats.paddingFactor;
- delete collectionStats.paddingFactorNote;
- delete newCollectionStats.paddingFactor;
- delete newCollectionStats.paddingFactorNote;
-
- // Delete keys that appear just because we shard
- delete newCollectionStats["primary"];
- delete newCollectionStats["sharded"];
-
- // as of 2.7.8, we added maxSize
- // TODO: when 2.6 is no longer tested, remove following two lines
- delete newCollectionStats["maxSize"];
- delete collectionStats["maxSize"];
-
- // Delete key added in 2.8-rc3
- delete collectionStats["indexDetails"];
- delete newCollectionStats["indexDetails"];
-
- // Delete capped:false added in 2.8.0-rc5
- if (newCollectionStats["capped"] == false) {
- delete newCollectionStats["capped"];
- }
- if (collectionStats["capped"] == false) {
- delete collectionStats["capped"];
- }
+ var newCollectionInfo = this.getCollectionInfo(collection);
- assert.docEq(collectionStats, newCollectionStats, "collection metadata not equal");
+ assert.docEq(_collectionInfo, newCollectionInfo, "collection metadata not equal");
// Get the indexes for this collection
var newIndexData = collection.getIndexes().sort(function(a,b) {
@@ -152,13 +116,13 @@ function CollectionDataValidator() {
else return -1;
});
for (var i = 0; i < newIndexData.length; i++) {
- assert.docEq(indexData[i], newIndexData[i], "indexes not equal");
+ assert.docEq(_indexData[i], newIndexData[i], "indexes not equal");
}
// Save the data for this collection for later comparison
var newCollectionData = collection.find().sort({"_id":1}).toArray();
for (var i = 0; i < newCollectionData.length; i++) {
- assert.docEq(collectionData[i], newCollectionData[i], "data not equal");
+ assert.docEq(_collectionData[i], newCollectionData[i], "data not equal");
}
return true;
}
diff --git a/jstests/multiVersion/mmapv1_overrides_default_storage_engine.js b/jstests/multiVersion/mmapv1_overrides_default_storage_engine.js
new file mode 100644
index 00000000000..9cad40c23bd
--- /dev/null
+++ b/jstests/multiVersion/mmapv1_overrides_default_storage_engine.js
@@ -0,0 +1,96 @@
+/**
+ * Test the upgrade process for 2.6 ~~> 3.2 and 3.0 ~~> 3.2, where mmapv1 should continue to be the
+ * default storage engine. Repeat the process with --directoryperdb set.
+ */
+(function() {
+ 'use strict';
+
+ var testCases = [
+ {
+ binVersion: '2.6',
+ },
+ {
+ binVersion: '2.6',
+ directoryperdb: '',
+ },
+ {
+ binVersion: '3.0',
+ },
+ {
+ binVersion: '3.0',
+ directoryperdb: '',
+ },
+ ];
+
+ // The mongod should start up with mmapv1 when the --storageEngine flag is omitted, or when
+ // --storageEngine=mmapv1 is explicitly specified.
+ testCases.forEach(function(testCase) {
+ [null, 'mmapv1'].forEach(function(storageEngine) {
+ jsTest.log('Upgrading from a ' + testCase.binVersion + ' instance with options='
+ + tojson(testCase) + ' to the latest version. This should succeed when the'
+ + ' latest version '
+ + (storageEngine ? ('explicitly specifies --storageEngine=' + storageEngine)
+ : 'omits the --storageEngine flag'));
+
+ var dbpath = MongoRunner.dataPath + 'mmapv1_overrides_default_storage_engine';
+ resetDbpath(dbpath);
+
+ var defaultOptions = {
+ dbpath: dbpath,
+ noCleanData: true,
+ };
+
+ // Start the old version.
+ var mongodOptions = Object.merge(defaultOptions, testCase);
+ var conn = MongoRunner.runMongod(mongodOptions);
+ assert.neq(null, conn,
+ 'mongod was unable to start up with options ' + tojson(mongodOptions));
+ assert.commandWorked(conn.getDB('test').runCommand({ping: 1}));
+ MongoRunner.stopMongod(conn);
+
+ // Start the newest version.
+ mongodOptions = Object.extend({}, defaultOptions);
+ if (storageEngine) {
+ mongodOptions.storageEngine = storageEngine;
+ }
+ if (testCase.hasOwnProperty('directoryperdb')) {
+ mongodOptions.directoryperdb = testCase.directoryperdb;
+ }
+ conn = MongoRunner.runMongod(mongodOptions);
+ assert.neq(null, conn,
+ 'mongod was unable to start up with options ' + tojson(mongodOptions));
+ assert.commandWorked(conn.getDB('test').runCommand({ping: 1}));
+ MongoRunner.stopMongod(conn);
+ });
+ });
+
+ // The mongod should not start up when --storageEngine=wiredTiger is specified.
+ testCases.forEach(function(testCase) {
+ jsTest.log('Upgrading from a ' + testCase.binVersion + ' instance with options='
+ + tojson(testCase) + ' to the latest version. This should fail when the latest'
+ + ' version specifies --storageEngine=wiredTiger');
+
+ var dbpath = MongoRunner.dataPath + 'mmapv1_overrides_default_storage_engine';
+ resetDbpath(dbpath);
+
+ var defaultOptions = {
+ dbpath: dbpath,
+ noCleanData: true,
+ };
+
+ // Start the old version.
+ var mongodOptions = Object.merge(defaultOptions, testCase);
+ var conn = MongoRunner.runMongod(mongodOptions);
+ assert.neq(null, conn,
+ 'mongod was unable to start up with options ' + tojson(mongodOptions));
+ assert.commandWorked(conn.getDB('test').runCommand({ping: 1}));
+ MongoRunner.stopMongod(conn);
+
+ // Start the newest version.
+ mongodOptions = Object.extend({storageEngine: 'wiredTiger'}, defaultOptions);
+ conn = MongoRunner.runMongod(mongodOptions);
+ assert.eq(null, conn,
+ 'mongod should not have been able to start up with options '
+ + tojson(mongodOptions));
+ });
+}());
diff --git a/jstests/noPassthrough/dir_per_db_and_split.js b/jstests/noPassthrough/dir_per_db_and_split.js
index e03ad7e6746..8047ec9fda2 100644
--- a/jstests/noPassthrough/dir_per_db_and_split.js
+++ b/jstests/noPassthrough/dir_per_db_and_split.js
@@ -1,5 +1,5 @@
-if ( jsTest.options().storageEngine == "wiredTiger" ) {
+if (!jsTest.options().storageEngine || jsTest.options().storageEngine === "wiredTiger") {
var baseDir = "jstests_per_db_and_split_c_and_i";
port = allocatePorts( 1 )[ 0 ];
diff --git a/jstests/noPassthrough/split_collections_and_indexes.js b/jstests/noPassthrough/split_collections_and_indexes.js
index 41916d6e9a0..73d2eede111 100644
--- a/jstests/noPassthrough/split_collections_and_indexes.js
+++ b/jstests/noPassthrough/split_collections_and_indexes.js
@@ -1,5 +1,5 @@
-if ( jsTest.options().storageEngine == "wiredTiger" ) {
+if (!jsTest.options().storageEngine || jsTest.options().storageEngine === "wiredTiger") {
var baseDir = "jstests_split_c_and_i";
port = allocatePorts( 1 )[ 0 ];
diff --git a/jstests/noPassthrough/wt_nojournal_fsync.js b/jstests/noPassthrough/wt_nojournal_fsync.js
index 5673e1208ee..46a881de16d 100644
--- a/jstests/noPassthrough/wt_nojournal_fsync.js
+++ b/jstests/noPassthrough/wt_nojournal_fsync.js
@@ -30,10 +30,7 @@ function writeDataAndRestart(doFsync) {
}
// This test can only be run if the storageEngine is wiredTiger
-// This check will have to change when we change the default storageEngine
-if ( typeof(TestData) != "object" ||
- !TestData.storageEngine ||
- TestData.storageEngine != "wiredTiger" ) {
+if (jsTest.options().storageEngine && jsTest.options().storageEngine !== "wiredTiger") {
jsTestLog("Skipping test because storageEngine is not wiredTiger");
}
else {
diff --git a/jstests/noPassthrough/wt_nojournal_repl.js b/jstests/noPassthrough/wt_nojournal_repl.js
index 79ec8f797a2..01bd23b10da 100644
--- a/jstests/noPassthrough/wt_nojournal_repl.js
+++ b/jstests/noPassthrough/wt_nojournal_repl.js
@@ -26,9 +26,7 @@ var contains = function(logLines, func) {
}
// This test can only be run if the storageEngine is wiredTiger
-if ( typeof(TestData) != "object" ||
- !TestData.storageEngine ||
- TestData.storageEngine != "wiredTiger" ) {
+if (jsTest.options().storageEngine && jsTest.options().storageEngine !== "wiredTiger") {
jsTestLog("Skipping test because storageEngine is not wiredTiger");
}
else {
diff --git a/jstests/noPassthroughWithMongod/index_check10.js b/jstests/noPassthroughWithMongod/index_check10.js
index f507c687731..5ace6951652 100644
--- a/jstests/noPassthroughWithMongod/index_check10.js
+++ b/jstests/noPassthroughWithMongod/index_check10.js
@@ -135,7 +135,7 @@ function doIt( indexVersion ) {
for( var z = 0; z < 5; ++z ) {
var indexVersion = z % 2;
var storageEngine = jsTest.options().storageEngine;
- if (!storageEngine || storageEngine === 'mmapv1' || indexVersion !== 0) {
+ if (storageEngine === 'mmapv1' || indexVersion !== 0) {
doIt(indexVersion);
}
}
diff --git a/jstests/replsets/initSyncV1Index.js b/jstests/replsets/initSyncV1Index.js
index c3daa471b44..10b91949942 100644
--- a/jstests/replsets/initSyncV1Index.js
+++ b/jstests/replsets/initSyncV1Index.js
@@ -6,7 +6,7 @@
'use strict';
var storageEngine = jsTest.options().storageEngine;
- if (storageEngine && storageEngine !== 'mmapv1') {
+ if (storageEngine !== 'mmapv1') {
return;
}
diff --git a/jstests/sharding/stats.js b/jstests/sharding/stats.js
index 6c21e3861da..52ec40556d7 100644
--- a/jstests/sharding/stats.js
+++ b/jstests/sharding/stats.js
@@ -132,7 +132,8 @@ collStatComp(coll_not_scaled, coll_scaled_1024, 1024, true);
assert.commandWorked(t.ensureIndex({a: 1}));
assert.eq(2, t.getIndexes().length);
- var isWiredTiger = (jsTest.options().storageEngine == "wiredTiger");
+ var isWiredTiger = (!jsTest.options().storageEngine
+ || jsTest.options().storageEngine === "wiredTiger");
var stats = assert.commandWorked(t.stats({indexDetails: true}));
var shardName;
diff --git a/jstests/sharding/user_flags_sharded.js b/jstests/sharding/user_flags_sharded.js
index 2d7a341e4f4..e5b5f8a41dd 100644
--- a/jstests/sharding/user_flags_sharded.js
+++ b/jstests/sharding/user_flags_sharded.js
@@ -1,9 +1,7 @@
// Test that when user flags are set on a collection,
// then collection is sharded, flags get carried over.
-if ( typeof(TestData) != "object" ||
- !TestData.storageEngine ||
- TestData.storageEngine == "mmapv1" ) {
+if (jsTest.options().storageEngine === "mmapv1") {
// the dbname and collection we'll be working with
var dbname = "testDB";