diff options
Diffstat (limited to 'jstests')
-rw-r--r-- | jstests/core/apitest_dbcollection.js | 6 | ||||
-rw-r--r-- | jstests/multiVersion/downgrade_replset.js | 2 | ||||
-rw-r--r-- | jstests/multiVersion/libs/verify_collection_data.js | 78 | ||||
-rw-r--r-- | jstests/multiVersion/mmapv1_overrides_default_storage_engine.js | 96 | ||||
-rw-r--r-- | jstests/noPassthrough/dir_per_db_and_split.js | 2 | ||||
-rw-r--r-- | jstests/noPassthrough/split_collections_and_indexes.js | 2 | ||||
-rw-r--r-- | jstests/noPassthrough/wt_nojournal_fsync.js | 5 | ||||
-rw-r--r-- | jstests/noPassthrough/wt_nojournal_repl.js | 4 | ||||
-rw-r--r-- | jstests/noPassthroughWithMongod/index_check10.js | 2 | ||||
-rw-r--r-- | jstests/replsets/initSyncV1Index.js | 2 | ||||
-rw-r--r-- | jstests/sharding/stats.js | 3 | ||||
-rw-r--r-- | jstests/sharding/user_flags_sharded.js | 4 |
12 files changed, 75 insertions, 131 deletions
diff --git a/jstests/core/apitest_dbcollection.js b/jstests/core/apitest_dbcollection.js index 1434ef3170c..6d405e8c716 100644 --- a/jstests/core/apitest_dbcollection.js +++ b/jstests/core/apitest_dbcollection.js @@ -193,10 +193,8 @@ 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. - var storageEngine = jsTest.options().storageEngine; - if (storageEngine && storageEngine !== 'wiredTiger') { - return; - } + if (jsTest.options().storageEngine == undefined) { return; } + if (jsTest.options().storageEngine.toLowerCase() != "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 17581827f11..c3d8460eb0c 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: nodes, nodeOptions: {storageEngine: 'mmapv1'}}); +var rst = new ReplSetTest({name: name, nodes: 3}); rst.startSet(); rst.initiate(); diff --git a/jstests/multiVersion/libs/verify_collection_data.js b/jstests/multiVersion/libs/verify_collection_data.js index 72c3e01dac7..9e8423c1db2 100644 --- a/jstests/multiVersion/libs/verify_collection_data.js +++ b/jstests/multiVersion/libs/verify_collection_data.js @@ -68,47 +68,83 @@ createCollectionWithData = function (db, collectionName, dataGenerator) { // the saved state function CollectionDataValidator() { - 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]; - }; + var initialized = false; + var collectionStats = {}; + var indexData = []; + var collectionData = []; // 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(); + 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']); - _initialized = true; + // Delete keys that appear just because we shard + delete collectionStats["primary"]; + delete collectionStats["sharded"]; + + 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 newCollectionInfo = this.getCollectionInfo(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"]; + } - assert.docEq(_collectionInfo, newCollectionInfo, "collection metadata not equal"); + assert.docEq(collectionStats, newCollectionStats, "collection metadata not equal"); // Get the indexes for this collection var newIndexData = collection.getIndexes().sort(function(a,b) { @@ -116,13 +152,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 deleted file mode 100644 index 9cad40c23bd..00000000000 --- a/jstests/multiVersion/mmapv1_overrides_default_storage_engine.js +++ /dev/null @@ -1,96 +0,0 @@ -/** - * 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 8047ec9fda2..e03ad7e6746 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 || jsTest.options().storageEngine === "wiredTiger") { +if ( 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 73d2eede111..41916d6e9a0 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 || jsTest.options().storageEngine === "wiredTiger") { +if ( 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 46a881de16d..5673e1208ee 100644 --- a/jstests/noPassthrough/wt_nojournal_fsync.js +++ b/jstests/noPassthrough/wt_nojournal_fsync.js @@ -30,7 +30,10 @@ function writeDataAndRestart(doFsync) { } // This test can only be run if the storageEngine is wiredTiger -if (jsTest.options().storageEngine && jsTest.options().storageEngine !== "wiredTiger") { +// This check will have to change when we change the default storageEngine +if ( typeof(TestData) != "object" || + !TestData.storageEngine || + TestData.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 01bd23b10da..79ec8f797a2 100644 --- a/jstests/noPassthrough/wt_nojournal_repl.js +++ b/jstests/noPassthrough/wt_nojournal_repl.js @@ -26,7 +26,9 @@ var contains = function(logLines, func) { } // This test can only be run if the storageEngine is wiredTiger -if (jsTest.options().storageEngine && jsTest.options().storageEngine !== "wiredTiger") { +if ( typeof(TestData) != "object" || + !TestData.storageEngine || + TestData.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 5ace6951652..f507c687731 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 === 'mmapv1' || indexVersion !== 0) { + if (!storageEngine || storageEngine === 'mmapv1' || indexVersion !== 0) { doIt(indexVersion); } } diff --git a/jstests/replsets/initSyncV1Index.js b/jstests/replsets/initSyncV1Index.js index 10b91949942..c3daa471b44 100644 --- a/jstests/replsets/initSyncV1Index.js +++ b/jstests/replsets/initSyncV1Index.js @@ -6,7 +6,7 @@ 'use strict'; var storageEngine = jsTest.options().storageEngine; - if (storageEngine !== 'mmapv1') { + if (storageEngine && storageEngine !== 'mmapv1') { return; } diff --git a/jstests/sharding/stats.js b/jstests/sharding/stats.js index 52ec40556d7..6c21e3861da 100644 --- a/jstests/sharding/stats.js +++ b/jstests/sharding/stats.js @@ -132,8 +132,7 @@ 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 - || jsTest.options().storageEngine === "wiredTiger"); + var isWiredTiger = (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 e5b5f8a41dd..2d7a341e4f4 100644 --- a/jstests/sharding/user_flags_sharded.js +++ b/jstests/sharding/user_flags_sharded.js @@ -1,7 +1,9 @@ // Test that when user flags are set on a collection, // then collection is sharded, flags get carried over. -if (jsTest.options().storageEngine === "mmapv1") { +if ( typeof(TestData) != "object" || + !TestData.storageEngine || + TestData.storageEngine == "mmapv1" ) { // the dbname and collection we'll be working with var dbname = "testDB"; |