diff options
author | Tommaso Tocci <tommaso.tocci@mongodb.com> | 2022-11-11 18:18:59 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2022-11-11 19:44:45 +0000 |
commit | 1bbfe2237bd99d31446bed80b8e5ea5b1f5c2d14 (patch) | |
tree | 8a5363b8988a657a44266673224a46c6e891ff65 /jstests | |
parent | 016c6eb217c686732fb288e16e6c344ef6fea1f7 (diff) | |
download | mongo-1bbfe2237bd99d31446bed80b8e5ea5b1f5c2d14.tar.gz |
SERVER-71097 Stop downloading 4.0 in multiversion suite
Diffstat (limited to 'jstests')
5 files changed, 2 insertions, 330 deletions
diff --git a/jstests/multiVersion/genericBinVersion/skip_level_upgrade.js b/jstests/multiVersion/genericBinVersion/skip_level_upgrade.js index c68e0d7fcbd..103d31a4239 100644 --- a/jstests/multiVersion/genericBinVersion/skip_level_upgrade.js +++ b/jstests/multiVersion/genericBinVersion/skip_level_upgrade.js @@ -31,8 +31,8 @@ const defaultOptions = { // This lists all binary versions older than the last-lts version. const versions = [ - {binVersion: '4.0', testCollection: 'four_zero'}, - {binVersion: '4.2', testCollection: 'four_two'} + {binVersion: '4.2', testCollection: 'four_two'}, + {binVersion: '5.0', testCollection: 'five_zero'}, ]; // Iterate through versions specified in the versions list, and follow the steps outlined at diff --git a/jstests/multiVersion/genericSetFCVUsage/major_version_upgrade.js b/jstests/multiVersion/genericSetFCVUsage/major_version_upgrade.js index ba350d56e6d..85949d3d064 100644 --- a/jstests/multiVersion/genericSetFCVUsage/major_version_upgrade.js +++ b/jstests/multiVersion/genericSetFCVUsage/major_version_upgrade.js @@ -31,7 +31,6 @@ const defaultOptions = { // This lists all supported releases and needs to be kept up to date as versions are added and // dropped. const versions = [ - {binVersion: '4.0', featureCompatibilityVersion: '4.0', testCollection: 'four_zero'}, {binVersion: '4.2', featureCompatibilityVersion: '4.2', testCollection: 'four_two'}, {binVersion: '4.4', featureCompatibilityVersion: '4.4', testCollection: 'four_four'}, {binVersion: '5.0', featureCompatibilityVersion: '5.0', testCollection: 'five_zero'}, diff --git a/jstests/multiVersion/libs/causal_consistency_helpers.js b/jstests/multiVersion/libs/causal_consistency_helpers.js deleted file mode 100644 index 72a446badf7..00000000000 --- a/jstests/multiVersion/libs/causal_consistency_helpers.js +++ /dev/null @@ -1,70 +0,0 @@ -/** - * Helper functions for testing causal consistency. - * - * @tags: [requires_majority_read_concern] - */ - -function assertAfterClusterTimeReadFails(db, collName) { - assert.commandFailed(db.runCommand( - {find: collName, readConcern: {level: "majority", afterClusterTime: Timestamp(1, 1)}})); -} - -function assertAfterClusterTimeReadSucceeds(db, collName) { - assert.commandWorked(db.runCommand( - {find: collName, readConcern: {level: "majority", afterClusterTime: Timestamp(1, 1)}})); -} - -function assertDoesNotContainLogicalOrOperationTime(res) { - assertDoesNotContainLogicalTime(res); - assertDoesNotContainOperationTime(res); -} - -function assertDoesNotContainLogicalTime(res) { - assert.eq(res.$clusterTime, undefined); -} - -function assertDoesNotContainOperationTime(res) { - assert.eq(res.operationTime, undefined); -} - -function assertContainsLogicalAndOperationTime(res, opts) { - assertContainsLogicalTime(res, opts); - assertContainsOperationTime(res, opts); -} - -function assertContainsLogicalTime(res, opts) { - assert.hasFields(res, ["$clusterTime"]); - assert.hasFields(res.$clusterTime, ["clusterTime", "signature"]); - assert.hasFields(res.$clusterTime.signature, ["hash", "keyId"]); - - if (opts.signed !== undefined) { - // Signed cluster times have a keyId greater than 0. - if (opts.signed) { - assert(res.$clusterTime.signature.keyId > NumberLong(0)); - } else { - assert.eq(res.$clusterTime.signature.keyId, NumberLong(0)); - } - } - - if (opts.initialized !== undefined) { - // Initialized operation times are greater than a null timestamp. - if (opts.initialized) { - assert.eq(bsonWoCompare(res.$clusterTime.clusterTime, Timestamp(0, 0)), 1); - } else { - assert.eq(bsonWoCompare(res.$clusterTime.clusterTime, Timestamp(0, 0)), 0); - } - } -} - -function assertContainsOperationTime(res, opts) { - assert.hasFields(res, ["operationTime"]); - - if (opts.initialized !== undefined) { - // Initialized operation times are greater than a null timestamp. - if (opts.initialized) { - assert.eq(bsonWoCompare(res.operationTime, Timestamp(0, 0)), 1); - } else { - assert.eq(bsonWoCompare(res.operationTime, Timestamp(0, 0)), 0); - } - } -} diff --git a/jstests/multiVersion/libs/index_format_downgrade.js b/jstests/multiVersion/libs/index_format_downgrade.js deleted file mode 100644 index 4c30ef7ed00..00000000000 --- a/jstests/multiVersion/libs/index_format_downgrade.js +++ /dev/null @@ -1,51 +0,0 @@ -/** - * For FCV 4.2, MongoDB uses a new internal format for unique indexes that is incompatible with 4.0. - * The new format applies to both existing unique indexes as well as newly created/rebuilt unique - * indexes. This helper function rebuilds all unique indexes on an instance after downgrading to FCV - * 4.0, for backwards compatibility with binary 4.0. Because this is an internal change, the index - * version is retained through rebuilding. - */ -function downgradeUniqueIndexes(db) { - // Obtain a list of v:1 and v:2 unique indexes. - const unique_idx_v1 = []; - const unique_idx_v2 = []; - db.adminCommand("listDatabases").databases.forEach(function(d) { - let mdb = db.getSiblingDB(d.name); - mdb.getCollectionInfos().forEach(function(c) { - let currentCollection = mdb.getCollection(c.name); - currentCollection.getIndexes().forEach(function(i) { - if (i.unique) { - if (i.v === 1) { - unique_idx_v1.push(i); - } else { - unique_idx_v2.push(i); - } - return; - } - }); - }); - }); - // Drop and recreate all v:1 indexes - for (let idx of unique_idx_v1) { - let [dbName, collName] = idx.ns.split("."); - let res = db.getSiblingDB(dbName).runCommand({dropIndexes: collName, index: idx.name}); - assert.commandWorked(res); - res = db.getSiblingDB(dbName).runCommand({ - createIndexes: collName, - indexes: [{"key": idx.key, "name": idx.name, "unique": true, "v": 1}] - }); - assert.commandWorked(res); - } - - // Drop and recreate all v:2 indexes - for (let idx of unique_idx_v2) { - let [dbName, collName] = idx.ns.split("."); - let res = db.getSiblingDB(dbName).runCommand({dropIndexes: collName, index: idx.name}); - assert.commandWorked(res); - res = db.getSiblingDB(dbName).runCommand({ - createIndexes: collName, - indexes: [{"key": idx.key, "name": idx.name, "unique": true, "v": 2}] - }); - assert.commandWorked(res); - } -} diff --git a/jstests/multiVersion/libs/verify_collection_data.js b/jstests/multiVersion/libs/verify_collection_data.js deleted file mode 100644 index 808a3517362..00000000000 --- a/jstests/multiVersion/libs/verify_collection_data.js +++ /dev/null @@ -1,206 +0,0 @@ -// This file contains test helpers to manage and validate collection state. This is useful for -// round trip testing of entire collections. -// -// There are three stages represented in this file: -// 1. Data generation - CollectionDataGenerator class. This contains helpers to generate test data -// for a collection. -// 2. Data persistence - createCollectionWithData function. This class takes a -// CollectionDataGenerator and inserts the generated data into the given -// collection. -// 3. Data validation - CollectionDataValidator class. This class contains functions for saving -// the state of a collection and comparing a collection's state to the -// previously saved state. -// -// Common use case: -// 1. Create a CollectionDataGenerator -// 2. Save collection data using the createCollectionWithData function -// 3. Record collection state in an instance of the CollectionDataValidator class -// 4. Do round trip or other testing -// 5. Validate that collection has not changed using the CollectionDataValidator class - -load('./jstests/multiVersion/libs/data_generators.js'); - -// Function to actually add the data generated by the given dataGenerator to a collection -createCollectionWithData = function(db, collectionName, dataGenerator) { - // Drop collection if exists - // TODO: add ability to control this - db.getCollection(collectionName).drop(); - - print("db.createCollection(\"" + collectionName + "\", " + - JSON.stringify(dataGenerator.collectionMetadata.get()) + ");"); - assert.eq(db.createCollection(collectionName, dataGenerator.collectionMetadata.get()).ok, 1); - - var collection = db.getCollection(collectionName); - - var numIndexes = 0; - while (dataGenerator.indexes.hasNext()) { - var nextIndex = dataGenerator.indexes.next(); - print("collection.createIndex(" + JSON.stringify(nextIndex.spec) + ", " + - JSON.stringify(nextIndex.options) + ");"); - var createIndexResult = collection.createIndex(nextIndex.spec, nextIndex.options); - assert.commandWorked(createIndexResult); - numIndexes++; - } - - // Make sure we actually added all the indexes we think we added. +1 for the _id index. - assert.eq(collection.getIndexes().length, numIndexes + 1); - - var numInserted = 0; - while (dataGenerator.data.hasNext()) { - var nextDoc = dataGenerator.data.next(); - // Use _id as our ordering field just so we don't have to deal with sorting. This only - // matters here since we can use indexes - nextDoc._id = numInserted; - print("collection.insert(" + JSON.stringify(nextDoc) + ");"); - assert.commandWorked(collection.insert(nextDoc)); - numInserted++; - } - - assert.eq(collection.find().count(), numInserted, "counts not equal after inserts"); - - return db.getCollection(collectionName); -}; - -// Class to save the state of a collection and later compare the current state of a collection to -// the saved state -function CollectionDataValidator() { - var _initialized = false; - var _collectionInfo = {}; - var _indexData = []; - var _collectionData = []; - var _dbVersion = ""; - - // 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) { - 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(); - - _dbVersion = collection.getDB().version(); - - _initialized = true; - - return collection; - }; - - this.validateCollectionData = function( - collection, dbVersionForCollection, options = {indexSpecFieldsToSkip: []}) { - if (!_initialized) { - throw Error("validateCollectionWithAllData called, but data is not initialized"); - } - - if (!Array.isArray(options.indexSpecFieldsToSkip)) { - throw new Error("Option 'indexSpecFieldsToSkip' must be an array"); - } - - // Get the metadata for this collection - var newCollectionInfo = this.getCollectionInfo(collection); - assert.docEq(_collectionInfo, newCollectionInfo, "collection metadata not equal"); - - // Get the indexes for this collection - var newIndexData = collection.getIndexes().sort(function(a, b) { - if (a.name > b.name) - return 1; - else - return -1; - }); - for (var i = 0; i < newIndexData.length; i++) { - let recordedIndex = Object.extend({}, _indexData[i]); - let newIndex = Object.extend({}, newIndexData[i]); - - options.indexSpecFieldsToSkip.forEach(fieldName => { - delete recordedIndex[fieldName]; - delete newIndex[fieldName]; - }); - - assert.docEq(recordedIndex, newIndex, "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"); - } - return true; - }; -} - -// Tests of the functions and classes in this file -function collectionDataValidatorTests() { - // TODO: These tests are hackish and depend on implementation details, but they are good enough - // for now to convince us that the CollectionDataValidator is actually checking something - var myValidator; - var myGenerator; - var collection; - - myGenerator = new CollectionDataGenerator({"capped": true}); - collection = createCollectionWithData(db, "test", myGenerator); - myValidator = new CollectionDataValidator(); - myValidator.recordCollectionData(collection); - db.test.dropIndex(db.test.getIndexKeys().filter(function(key) { - return key.a != null; - })[0]); - assert.throws(myValidator.validateCollectionData, - [collection], - "Validation function should have thrown since we modified the collection"); - - myGenerator = new CollectionDataGenerator({"capped": true}); - collection = createCollectionWithData(db, "test", myGenerator); - myValidator = new CollectionDataValidator(); - myValidator.recordCollectionData(collection); - db.test.update({_id: 0}, {dummy: 1}); - assert.throws(myValidator.validateCollectionData, - [collection], - "Validation function should have thrown since we modified the collection"); - - myGenerator = new CollectionDataGenerator({"capped": true}); - collection = createCollectionWithData(db, "test", myGenerator); - myValidator = new CollectionDataValidator(); - myValidator.recordCollectionData(collection); - assert(myValidator.validateCollectionData(collection), "Validation function failed"); - - myGenerator = new CollectionDataGenerator({"capped": false}); - collection = createCollectionWithData(db, "test", myGenerator); - myValidator = new CollectionDataValidator(); - myValidator.recordCollectionData(collection); - db.test.dropIndex(db.test.getIndexKeys().filter(function(key) { - return key.a != null; - })[0]); - assert.throws(myValidator.validateCollectionData, - [collection], - "Validation function should have thrown since we modified the collection"); - - myGenerator = new CollectionDataGenerator({"capped": false}); - collection = createCollectionWithData(db, "test", myGenerator); - myValidator = new CollectionDataValidator(); - myValidator.recordCollectionData(collection); - db.test.update({_id: 0}, {dummy: 1}); - assert.throws(myValidator.validateCollectionData, - [collection], - "Validation function should have thrown since we modified the collection"); - - myGenerator = new CollectionDataGenerator({"capped": false}); - collection = createCollectionWithData(db, "test", myGenerator); - myValidator = new CollectionDataValidator(); - myValidator.recordCollectionData(collection); - assert(myValidator.validateCollectionData(collection), "Validation function failed"); - - print("collection data validator tests passed!"); -} |