diff options
author | Vishnu Kaushik <vishnu.kaushik@mongodb.com> | 2021-07-14 20:45:15 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-07-15 14:36:32 +0000 |
commit | bccb9351e4d162c7675db9412b35cd916629a14e (patch) | |
tree | 008f1dcaffb291e2749d9b8cbe04345a7a899cbd /jstests/multiVersion | |
parent | 34116ccb3c6fa3187017f84b424979d8a1f0e33d (diff) | |
download | mongo-bccb9351e4d162c7675db9412b35cd916629a14e.tar.gz |
SERVER-58295 delete accidentally re-introduced tests
Diffstat (limited to 'jstests/multiVersion')
5 files changed, 0 insertions, 1066 deletions
diff --git a/jstests/multiVersion/delete_haystack_indexes_on_upgrade.js b/jstests/multiVersion/delete_haystack_indexes_on_upgrade.js deleted file mode 100644 index 455b6783dce..00000000000 --- a/jstests/multiVersion/delete_haystack_indexes_on_upgrade.js +++ /dev/null @@ -1,222 +0,0 @@ -/** - * Verifies that haystack indexes are removed during the upgrade process from 4.4 to 4.9 for a - * standalone and a replica set. - * - * TODO SERVER-51871: Since this test is specific to the upgrade process from 4.4 to 4.9/5.0, it - * can be deleted once 5.0 becomes last-lts. - * - * @tags: [ - * disabled_due_to_server_58295 - * ] - */ -(function() { -"use strict"; -load("jstests/multiVersion/libs/multi_rs.js"); // For 'upgradeSet()' -load("jstests/multiVersion/libs/multi_cluster.js"); // For 'upgradeCluster()' -load('jstests/multiVersion/libs/verify_versions.js'); // For 'assert.binVersion()' -load('jstests/noPassthrough/libs/index_build.js'); // For 'assertIndexes()' - -const dbName = "test"; -const collName = jsTestName(); -const geoIndexKey = { - loc: "geoHaystack", - x: 1 -}; -const geoIndexName = "geo"; -const nonGeoIndexKey = { - y: 1 -}; -const nonGeoIndexName = "y"; - -// Set of indexes to insert. -const indexList = ["_id_", nonGeoIndexName, geoIndexName]; - -// Set of indexes that will be present after upgrade is complete. -const nonGeoIndexList = ["_id_", nonGeoIndexName]; - -function insertDocuments(coll) { - const documentList = - [{_id: 0, loc: [1, 2], x: 'foo', y: 2}, {_id: 1, loc: [1.5, 1.5], x: 'bar', y: 1}]; - assert.commandWorked(coll.insert(documentList)); -} - -function createIndexes(coll) { - assert.commandWorked(coll.createIndex(geoIndexKey, {name: geoIndexName, bucketSize: 1})); - assert.commandWorked(coll.createIndex(nonGeoIndexKey, {name: nonGeoIndexName})); -} - -// Verify that haystack indexes are deleted when upgrading a standalone. -function runStandaloneTest() { - // Set up a v4.4 mongod. - const dbPath = MongoRunner.dataPath + "/delete_haystack"; - let mongo = MongoRunner.runMongod({dbpath: dbPath, binVersion: "last-lts"}); - assert.neq(null, mongo, "mongod was unable to start up"); - let testDB = mongo.getDB(dbName); - let coll = testDB[collName]; - insertDocuments(coll); - createIndexes(coll); - IndexBuildTest.assertIndexes(testDB[collName], indexList.length, indexList); - MongoRunner.stopMongod(mongo); - - // Restart the mongod in the latest version. - mongo = MongoRunner.runMongod( - {dbpath: dbPath, binVersion: "latest", restart: true, cleanData: false}); - assert.neq(null, mongo, "mongod was unable to start up"); - testDB = mongo.getDB(dbName); - coll = testDB[collName]; - - // The haystack index should still be present before the FCV is set and the validate command - // should succeed. - IndexBuildTest.assertIndexes(coll, indexList.length, indexList); - const validate = assert.commandWorked(coll.validate({full: true})); - assert.eq(true, validate.valid); - - // Set the FCV. - const adminDB = mongo.getDB("admin"); - checkFCV(adminDB, lastLTSFCV); - assert.commandWorked(mongo.adminCommand({setFeatureCompatibilityVersion: latestFCV})); - checkFCV(adminDB, latestFCV); - - // The haystack index should no longer be present after the FCV is set. - IndexBuildTest.assertIndexes(coll, nonGeoIndexList.length, nonGeoIndexList); - MongoRunner.stopMongod(mongo); -} - -/** - * Verifies that every node in 'replSetTest' has the indexes in 'expectedIndexes'. - */ -function verifyIndexesPresentOnAllNodes(replSetTest, expectedIndexes) { - replSetTest.awaitNodesAgreeOnPrimary(); - for (const node of [replSetTest.getPrimary(), replSetTest.getSecondary()]) { - const db = node.getDB(dbName); - const coll = db[collName]; - IndexBuildTest.assertIndexes(coll, expectedIndexes.length, expectedIndexes); - } -} - -// Verify that haystack indexes get deleted when upgrading a replica set. -function runReplicaSetTest() { - // Set up a replica-set in v4.4. - const rst = new ReplSetTest({nodes: 2, nodeOptions: {binVersion: "last-lts"}}); - rst.startSet(); - rst.initiate(); - - const initialPrimary = rst.getPrimary(); - const primaryDB = initialPrimary.getDB(dbName); - const primaryColl = primaryDB[collName]; - insertDocuments(primaryColl); - createIndexes(primaryColl); - - // Wait until both nodes finish inserting the documents and building the index. - rst.awaitReplication(); - - verifyIndexesPresentOnAllNodes(rst, indexList); - - // Upgrade the replica set. - rst.upgradeSet({binVersion: "latest"}); - rst.awaitNodesAgreeOnPrimary(); - - // Verify that all nodes are in the latest version. - for (const node of rst.nodes) { - assert.binVersion(node, "latest"); - } - - verifyIndexesPresentOnAllNodes(rst, indexList); - - // Set the FCV. - const upgradedPrimary = rst.getPrimary(); - const adminDB = upgradedPrimary.getDB("admin"); - checkFCV(adminDB, lastLTSFCV); - assert.commandWorked(adminDB.runCommand({setFeatureCompatibilityVersion: latestFCV})); - checkFCV(adminDB, latestFCV); - - // Neither the primary nor the secondary should have the haystack index. - verifyIndexesPresentOnAllNodes(rst, nonGeoIndexList); - - rst.stopSet(); -} - -// Even though the 'geoSearch' command is not allowed on sharded clusters, haystack indexes can -// still be created on a sharded cluster. As such, we verify that haystack indexes get deleted -// when upgrading a sharded cluster. -function runShardingTest() { - // Set up a sharded cluster in v4.4. - const st = new ShardingTest({ - shards: 2, - rs: {nodes: 2, binVersion: "last-lts"}, - other: {mongosOptions: {binVersion: "last-lts"}, configOptions: {binVersion: "last-lts"}} - }); - - let mongos = st.s; - const ns = dbName + "." + collName; - - // Create a sharded collection with two chunks, one on each shard: [-inf, 1), [1, inf). This - // guarantees that each shard will have one of the two documents being inserted and both shards - // will create a geoHaystack index. - assert.commandWorked(mongos.adminCommand({enableSharding: dbName})); - assert.commandWorked(mongos.adminCommand({movePrimary: dbName, to: st.shard0.shardName})); - assert.commandWorked(mongos.adminCommand({shardCollection: ns, key: {_id: 1}})); - assert.commandWorked(mongos.adminCommand({split: ns, middle: {_id: 1}})); - - // Move the [1, inf) chunk to shard 1. - assert.commandWorked(mongos.adminCommand( - {moveChunk: ns, find: {_id: 1}, to: st.shard1.shardName, _waitForDelete: true})); - - const db = mongos.getDB(dbName); - const coll = db[collName]; - insertDocuments(coll); - createIndexes(coll); - - // Wait for both shards to finish replicating their document and building the indexes. - st.rs0.awaitReplication(); - st.rs1.awaitReplication(); - - /** - * Verify that each shard has each index in 'expectedIndexes'. - */ - function verifyIndexesOnAllShards(expectedIndexes) { - for (const shard of [st.rs0, st.rs1]) { - verifyIndexesPresentOnAllNodes(shard, expectedIndexes); - } - } - - verifyIndexesOnAllShards(indexList); - - // Upgrade the shards and the config servers. - st.upgradeCluster("latest", {upgradeShards: true, upgradeConfigs: true, upgradeMongos: false}); - st.waitUntilStable(); - - // Indexes should still be present. - verifyIndexesOnAllShards(indexList); - - // Upgrade the mongos. - st.upgradeCluster("latest", {upgradeShards: false, upgradeConfigs: false, upgradeMongos: true}); - st.waitUntilStable(); - - /** - * Verifies that the FCV across 'st' matches 'targetFCV'. - */ - function checkClusterFCV(targetFCV) { - checkFCV(st.configRS.getPrimary().getDB("admin"), targetFCV); - checkFCV(st.shard0.getDB("admin"), targetFCV); - checkFCV(st.shard1.getDB("admin"), targetFCV); - } - - // Set the FCV. - mongos = st.s; - const adminDB = mongos.getDB("admin"); - checkClusterFCV(lastLTSFCV); - verifyIndexesOnAllShards(indexList); - assert.commandWorked(adminDB.runCommand({setFeatureCompatibilityVersion: latestFCV})); - checkClusterFCV(latestFCV); - - // None of the nodes in the cluster should have the haystack index. - verifyIndexesOnAllShards(nonGeoIndexList); - - st.stop(); -} - -runStandaloneTest(); -runReplicaSetTest(); -runShardingTest(); -})();
\ No newline at end of file diff --git a/jstests/multiVersion/doc_validation_error_upgrade_downgrade.js b/jstests/multiVersion/doc_validation_error_upgrade_downgrade.js deleted file mode 100644 index 111d4e3dd8d..00000000000 --- a/jstests/multiVersion/doc_validation_error_upgrade_downgrade.js +++ /dev/null @@ -1,212 +0,0 @@ -/** - * Tests document validation behavior during an upgrade of a sharded cluster from 4.4 to 4.7+ and - * during a corresponding downgrade as well as document validation behavior of mongod in FCV 4.4 - * mode. - * - * TODO SERVER-50524: this test is specific to the 4.4 - 4.7+ upgrade process, and can be removed - * when 5.0 becomes last-lts. - * - * @tags: [ - * disabled_due_to_server_58295 - * ] - */ -(function() { -"use strict"; -load("jstests/multiVersion/libs/multi_cluster.js"); // For upgradeCluster. -load("jstests/libs/doc_validation_utils.js"); // For assertDocumentValidationFailure. -const collName = jsTestName(); - -/** - * Performs a direct and an indirect (through aggregation stage $out) insertion of documents that - * fail validation and checks the responses. 'sourceDB' is a database that is a source of documents - * being copied into database 'targetDB' using aggregation stage $out. Both databases have a - * collection named 'collName' and the collection in 'targetDB' has a validator set. 'assertFn' is a - * function that verifies that the command result is a document validation error and conforms to - * some FCV. The first parameter of the function is either a raw command response, or a wrapper of a - * result of write commands ('BulkWriteResult' or 'WriteResult'), and the second - a collection - * which documents are being inserted into. - */ -function testDocumentValidation(sourceDB, targetDB, assertFn) { - const sourceColl = sourceDB[collName]; - - // Insert a document into a collection in 'sourceDB'. - assert.commandWorked(sourceColl.remove({})); - assert.commandWorked(sourceColl.insert({a: 2})); - - // Issue an 'aggregate' command that copies all documents from the source collection to the - // target collection. - const res = sourceDB.runCommand( - {aggregate: collName, pipeline: [{$out: {db: "targetDB", coll: collName}}], cursor: {}}); - - // Verify that document insertion failed due to document validation error. - assertFn(res, sourceColl); - - // Verify that a direct document insertion to a collection with a document validator fails due - // to document validation error. - assertFn(targetDB[collName].insert({a: 2}), targetDB[collName]); -} - -/** - * Assert that 'res' corresponds to DocumentValidationFailure, and verify that its format conforms - * to FCV4.4 - field 'errInfo' is not present. - */ -function assertFCV44DocumentValidationFailure(res, coll) { - assert.commandFailedWithCode(res, ErrorCodes.DocumentValidationFailure, tojson(res)); - if (res instanceof BulkWriteResult) { - const errors = res.getWriteErrors(); - for (const error of errors) { - assert(!error.hasOwnProperty("errInfo"), tojson(error)); - } - } else { - const error = res instanceof WriteResult ? res.getWriteError() : res; - assert(!error.hasOwnProperty("errInfo"), tojson(error)); - } -} - -const validatorExpression = { - a: 1 -}; - -// Test document validation behavior of mongod in FCV 4.4 mode. -(function() { -const mongod = MongoRunner.runMongod(); -assert.neq(null, mongod, "mongod was unable to start up"); -const testDB = mongod.getDB("test"); - -// Set FCV to 4.4. -assert.commandWorked(mongod.adminCommand({setFeatureCompatibilityVersion: lastLTSFCV})); - -// Create a collection with a validator. -assert.commandWorked(testDB.createCollection(collName, {validator: validatorExpression})); - -// Verify that a document insertion fails due to document validation error that conforms to FCV4.4. -assertFCV44DocumentValidationFailure(testDB[collName].insert({a: 2}), testDB[collName]); -MongoRunner.stopMongod(mongod); -})(); - -// Test document validation behavior during an upgrade of a sharded cluster from 4.4 to 4.7+ and a -// corresponding downgrade. -(function() { -// Start a sharded cluster in which all processes are of the 4.4 binVersion. -const st = new ShardingTest({ - shards: 2, - rs: {nodes: 2, binVersion: "last-lts"}, - other: {mongosOptions: {binVersion: "last-lts"}, configOptions: {binVersion: "last-lts"}} -}); -const mongos = st.s; - -// Set cluster FCV to 4.4. -assert.commandWorked(mongos.adminCommand({setFeatureCompatibilityVersion: lastLTSFCV})); - -// Two databases 'sourceDB' and 'targetDB' are setup that have different shards set as primary to -// test if document validation related aspects of inter-shard communication work correctly. This -// communication is triggered by issuing the aggregate command that reads documents from a -// collection in a database in one shard ('sourceDB') and inserts them into a database in another -// shard ('targetDB'). First create a database "sourceDB" and assign it to the first shard. -let sourceDB = mongos.getDB("sourceDB"); -assert.commandWorked(sourceDB.createCollection(collName)); -st.ensurePrimaryShard("sourceDB", st.shard0.shardName); - -let targetDB = mongos.getDB("targetDB"); - -// Create a collection with a validator. -assert.commandWorked(targetDB.createCollection(collName, {validator: validatorExpression})); - -// Assign database "targetDB" to the second shard. -st.ensurePrimaryShard("targetDB", st.shard1.shardName); - -// Perform document insertion and verify output conformance to FCV4.4. -testDocumentValidation(sourceDB, targetDB, assertFCV44DocumentValidationFailure); - -// Upgrade config servers and the second shard to latest version. -st.upgradeCluster("latest", {upgradeShards: false, upgradeConfigs: true, upgradeMongos: false}); -st.rs1.upgradeSet({binVersion: "latest"}); - -// Perform document insertion and verify output conformance to FCV4.4. -testDocumentValidation(sourceDB, targetDB, assertFCV44DocumentValidationFailure); - -// Verify that collection validator expressions which throw an exception return said exception -// when the FCV is 4.4. -const exprValidator = { - $expr: {$divide: [10, 0]} -}; -assert.commandWorked(targetDB.runCommand({collMod: collName, validator: exprValidator})); -let exprResponse = targetDB[collName].insert({}); -assert.commandFailedWithCode(exprResponse, [16608, ErrorCodes.BadValue], tojson(exprResponse)); - -// Verify that the insert succeeds when the validator expression throws if the validationAction is -// set to 'warn' and the FCV is 4.4. -assert.commandWorked(targetDB.runCommand({collMod: collName, validationAction: "warn"})); -exprResponse = targetDB[collName].insert({}); -assert.commandWorked(exprResponse, tojson(exprResponse)); - -// Reset the collection validator to the original. -assert.commandWorked(targetDB.runCommand( - {collMod: collName, validator: validatorExpression, validationAction: "error"})); - -// Upgrade the remaining shard. -st.upgradeCluster("latest", {upgradeShards: true, upgradeConfigs: false, upgradeMongos: false}); - -// Perform document insertion and verify output conformance to FCV4.4. -testDocumentValidation(sourceDB, targetDB, assertFCV44DocumentValidationFailure); - -// Upgrade the mongos. -st.upgradeCluster("latest", {upgradeShards: false, upgradeConfigs: false, upgradeMongos: true}); -sourceDB = st.s.getDB("sourceDB"); -targetDB = st.s.getDB("targetDB"); - -// Perform document insertion and verify output conformance to FCV4.4. -testDocumentValidation(sourceDB, targetDB, assertFCV44DocumentValidationFailure); - -// Set FCV to 4.7. -assert.commandWorked(st.s.adminCommand({setFeatureCompatibilityVersion: latestFCV})); - -// Perform document insertion and verify that the server now provides the "errInfo" field, which -// contains the document validation failure details. -testDocumentValidation(sourceDB, targetDB, assertDocumentValidationFailure); - -// Verify that collection validator expressions which throw an exception fail with a -// DocumentValidationFailure error when the FCV is 4.7. -assert.commandWorked(targetDB.runCommand({collMod: collName, validator: exprValidator})); -exprResponse = targetDB[collName].insert({}); -assert.commandFailedWithCode( - exprResponse, ErrorCodes.DocumentValidationFailure, tojson(exprResponse)); - -// Verify that the insert succeeds when the validator expression throws if the validationAction is -// set to 'warn' and the FCV is 4.7. -assert.commandWorked(targetDB.runCommand({collMod: collName, validationAction: "warn"})); -exprResponse = targetDB[collName].insert({}); -assert.commandWorked(exprResponse, tojson(exprResponse)); - -// Reset the collection validator to the original. -assert.commandWorked(targetDB.runCommand( - {collMod: collName, validator: validatorExpression, validationAction: "error"})); - -// Start a downgrade. Set FCV to 4.4. -assert.commandWorked(st.s.adminCommand({setFeatureCompatibilityVersion: lastLTSFCV})); - -// Perform document insertion and verify output conformance to FCV4.4. -testDocumentValidation(sourceDB, targetDB, assertFCV44DocumentValidationFailure); - -// Downgrade the mongos. -st.upgradeCluster("last-lts", {upgradeShards: false, upgradeConfigs: false, upgradeMongos: true}); -sourceDB = st.s.getDB("sourceDB"); -targetDB = st.s.getDB("targetDB"); - -// Perform document insertion and verify output conformance to FCV4.4. -testDocumentValidation(sourceDB, targetDB, assertFCV44DocumentValidationFailure); - -// Downgrade the first shard. -st.rs0.upgradeSet({binVersion: "last-lts"}); - -// Perform document insertion and verify output conformance to FCV4.4. -testDocumentValidation(sourceDB, targetDB, assertFCV44DocumentValidationFailure); - -// Downgrade remaining shards and the config servers. -st.upgradeCluster("last-lts", {upgradeShards: true, upgradeConfigs: true, upgradeMongos: false}); - -// Perform document insertion and verify output conformance to FCV4.4. -testDocumentValidation(sourceDB, targetDB, assertFCV44DocumentValidationFailure); -st.stop(); -})(); -})(); diff --git a/jstests/multiVersion/haystack_indexes_maintained_correctly.js b/jstests/multiVersion/haystack_indexes_maintained_correctly.js deleted file mode 100644 index 5ff06000d73..00000000000 --- a/jstests/multiVersion/haystack_indexes_maintained_correctly.js +++ /dev/null @@ -1,212 +0,0 @@ -/** - * Verifies that haystack indexes cannot be created on 4.9+ binaries, but are maintained - * correctly in mixed version clusters. - * - * TODO SERVER-51871: This test can be deleted once 5.0 becomes last-lts. - * - * @tags: [ - * disabled_due_to_server_58295 - * ] - */ -(function() { -"use strict"; -load("jstests/multiVersion/libs/multi_rs.js"); // For 'upgradeSecondaries()/upgradePrimary()' -load('jstests/noPassthrough/libs/index_build.js'); // For 'assertIndexes()' -load("jstests/libs/fixture_helpers.js"); // For 'isSharded()' - -const dbName = "test"; -const collName = jsTestName(); -const geoIndexKey = { - loc: "geoHaystack", - x: 1 -}; -const geoIndexName = "geo"; -const indexList = ["_id_", geoIndexName]; -const nonGeoIndexList = ["_id_"]; - -function insertInitialDocuments(coll) { - const documentList = - [{_id: 0, loc: [1, 2], x: 'foo', y: 2}, {_id: 1, loc: [1.5, 1.5], x: 'bar', y: 1}]; - assert.commandWorked(coll.insert(documentList)); -} - -/** - * Calls 'validate()' on 'coll' and verifies that the documents which are inserted into 'coll' - * produce the correct number of index keys for the geoHaystack index in this test. - */ -function validateAndAssertCorrectIndexKeys(coll) { - const validateResult = assert.commandWorked(coll.validate({full: true})); - let validateOutput; - if (FixtureHelpers.isSharded(coll)) { - assert(validateResult.hasOwnProperty("raw")); - validateOutput = validateResult["raw"]; - } else { - validateOutput = validateResult; - } - - // There should be as many index keys as there are documents. - const expectedNumKeys = coll.find().itcount(); - let keys = 0; - if (FixtureHelpers.isSharded(coll)) { - for (const shard of Object.keys(validateOutput)) { - keys += validateOutput[shard]["keysPerIndex"][geoIndexName]; - assert.eq(0, validateOutput[shard]["errors"].length); - assert.eq(true, validateOutput[shard]["valid"]); - } - } else { - keys = validateOutput["keysPerIndex"][geoIndexName]; - assert.eq(0, validateOutput["errors"].length); - assert.eq(true, validateOutput["valid"]); - } - - assert.eq(expectedNumKeys, keys); -} - -// Verify that haystack indexes cannot be created on a standalone in the latest version regardless -// of the FCV. -function runStandaloneTest() { - const mongo = MongoRunner.runMongod({binVersion: "latest"}); - const testDB = mongo.getDB(dbName); - const coll = testDB[collName]; - for (const fcv of [lastLTSFCV, latestFCV]) { - assert.commandWorked(mongo.adminCommand({setFeatureCompatibilityVersion: fcv})); - assert.commandFailedWithCode( - coll.createIndex(geoIndexKey, {name: geoIndexName, bucketSize: 1}), - ErrorCodes.CannotCreateIndex); - } - MongoRunner.stopMongod(mongo); -} - -// Verify that haystack indexes are maintained properly on a mixed version replica set. -function runReplicaSetTest() { - // Set up a mixed version replica-set: both nodes will be initialized to the last-lts - // binary version (4.4), but the secondary will be initialized to the latest binary version. - const rst = new ReplSetTest({nodes: [{binVersion: "last-lts"}, {binVersion: "latest"}]}); - rst.startSet(); - rst.initiate(); - let primaryDB = rst.getPrimary().getDB(dbName); - let primaryColl = primaryDB[collName]; - insertInitialDocuments(primaryColl); - rst.awaitReplication(); - - // Creating a haystack index should still work. - assert.commandWorked(primaryDB.runCommand({ - "createIndexes": collName, - indexes: [{key: geoIndexKey, name: geoIndexName, bucketSize: 1}], - writeConcern: {w: 2} - })); - - // The haystack index should replicate correctly to the secondary. - const secondaryDB = rst.getSecondary().getDB(dbName); - const secondaryColl = secondaryDB[collName]; - IndexBuildTest.assertIndexes(secondaryColl, indexList.length, indexList); - - // Verify that documents which are inserted after the index is built produce valid index keys. - assert.commandWorked( - primaryColl.insert([{_id: 4, loc: [4, 4], x: "baz"}, {_id: 5, loc: [5, 5], x: "baz"}], - {writeConcern: {w: 2}})); - validateAndAssertCorrectIndexKeys(primaryColl); - validateAndAssertCorrectIndexKeys(secondaryColl); - - // Upgrade the primary and attempt to re-create the index after the upgrade. - assert.commandWorked( - primaryDB.runCommand({"dropIndexes": collName, index: geoIndexName, writeConcern: {w: 2}})); - rst.upgradePrimary(rst.getPrimary(), {binVersion: "latest"}); - rst.awaitNodesAgreeOnPrimary(); - - // Even though we haven't bumped the FCV, index creation should still fail on a primary in - // the latest version. - primaryDB = rst.getPrimary().getDB(dbName); - primaryColl = primaryDB[collName]; - assert.commandFailedWithCode( - primaryColl.createIndex(geoIndexKey, {name: geoIndexName, bucketSize: 1}), - ErrorCodes.CannotCreateIndex); - - rst.stopSet(); -} - -// Verify that haystack indexes are maintained properly in a mixed version sharded cluster. -function runShardingTest() { - // Set up a mixed version sharded cluster, where shard0's nodes are initialized to the last-lts - // binary version (4.4) and shard1's nodes are initialized to the latest binary version. - const st = new ShardingTest({ - shards: { - rs0: {nodes: [{binVersion: "last-lts"}, {binVersion: "last-lts"}]}, - rs1: {nodes: [{binVersion: "latest"}, {binVersion: "latest"}]} - }, - other: {mongosOptions: {binVersion: "last-lts"}} - }); - - // Test that indexes are maintained properly during chunk migration. More precisely, verify - // that when a chunk from a shard consisting of 4.4 nodes with a haystack index is moved to a - // shard consisting of nodes in the latest binary version, the haystack index is built - // correctly on the shard in the latest binary version. - const mongos = st.s; - const ns = dbName + "." + collName; - - // Create a sharded collection with two chunks: [MinKey, 1), [1, MaxKey], both on shard0. - assert.commandWorked(mongos.adminCommand({enableSharding: dbName})); - assert.commandWorked(mongos.adminCommand({movePrimary: dbName, to: st.shard0.shardName})); - assert.commandWorked(mongos.adminCommand({shardCollection: ns, key: {_id: 1}})); - assert.commandWorked(mongos.adminCommand({split: ns, middle: {_id: 1}})); - - // Insert some documents and create a haystack index. - const db = mongos.getDB(dbName); - const coll = db[collName]; - insertInitialDocuments(coll); - assert.commandWorked(coll.createIndex(geoIndexKey, {name: geoIndexName, bucketSize: 1})); - - // Wait for shard0 to finish replicating its documents and building the index. - st.rs0.awaitReplication(); - - // Move the [1, MaxKey] chunk to shard1. - assert.commandWorked(mongos.adminCommand( - {moveChunk: ns, find: {_id: 1}, to: st.shard1.shardName, _waitForDelete: true})); - st.rs1.awaitReplication(); - - // Verify that shard1 has the haystack index after the chunk was moved. - const shard1primary = st.rs1.getPrimary(); - const shard1DB = shard1primary.getDB(dbName); - const shard1Coll = shard1DB[collName]; - IndexBuildTest.assertIndexes(shard1Coll, indexList.length, indexList); - - validateAndAssertCorrectIndexKeys(coll); - - // Verify that inserting documents into a shard consisting of nodes in the latest version with - // an existing haystack index will create the correct index keys for the index. - assert.commandWorked( - coll.insert([{_id: 4, loc: [4, 4], x: "baz"}, {_id: 5, loc: [5, 5], x: "blah"}], - {writeConcern: {w: 2}})); - - validateAndAssertCorrectIndexKeys(coll); - - // Creating a new haystack index against a sharded cluster with at least one shard upgraded to - // the latest version should fail. - assert.commandWorked( - db.runCommand({"dropIndexes": collName, index: geoIndexName, writeConcern: {w: 2}})); - assert.commandFailedWithCode(coll.createIndex(geoIndexKey, {name: geoIndexName, bucketSize: 1}), - ErrorCodes.CannotCreateIndex); - - // Though the command failed, the haystack index will still be created on shard0 since it is in - // version 4.4. - const shard0DB = st.rs0.getPrimary().getDB(dbName); - const shard0coll = shard0DB[collName]; - IndexBuildTest.assertIndexes(shard0coll, indexList.length, indexList); - - // Since shard1 is in the latest version, it will not have the geoHaystack index. - IndexBuildTest.assertIndexes(shard1Coll, nonGeoIndexList.length, nonGeoIndexList); - - // Though the 'dropIndexes' command will fail because shard1 does not have the haystack - // index, it should still remove the haystack index on shard0. - assert.commandFailedWithCode( - mongos.getDB(dbName).runCommand( - {"dropIndexes": collName, index: geoIndexName, writeConcern: {w: 2}}), - ErrorCodes.IndexNotFound); - IndexBuildTest.assertIndexes(shard0coll, nonGeoIndexList.length, nonGeoIndexList); - st.stop(); -} - -runStandaloneTest(); -runReplicaSetTest(); -runShardingTest(); -})();
\ No newline at end of file diff --git a/jstests/multiVersion/index_signature_fcv.js b/jstests/multiVersion/index_signature_fcv.js deleted file mode 100644 index a188e2c1c5e..00000000000 --- a/jstests/multiVersion/index_signature_fcv.js +++ /dev/null @@ -1,352 +0,0 @@ -/** - * Verifies that the following FCV constraints are observed when building indexes: - * - * - Multiple indexes which differ only by partialFilterExpression can be built in FCV 4.7+. - * - Multiple indexes which differ only by unique or sparse can be built in FCV 4.9+. - * - Multiple indexes which differ only by wildcardProjection can be built in FCV 5.0+. - * - The planner can continue to use these indexes after downgrading to FCV 4.4. - * - These indexes can be dropped in FCV 4.4. - * - Indexes which differ only by partialFilterExpression cannot be created in FCV 4.4. - * - Indexes which differ only by either unique, sparse, or wildcardProjection cannot be created - * in FCV 4.4. - * - We do not fassert if the set is downgraded to binary 4.4 with "duplicate" indexes present. - * - * TODO SERVER-47766: this test is specific to the 4.4 - 4.7+ upgrade process, and can be removed - * when 5.0 becomes last-lts. - * - * @tags: [ - * disabled_due_to_server_58295 - * ] - */ -(function() { -"use strict"; - -load("jstests/libs/analyze_plan.js"); // For isIxscan and hasRejectedPlans. -load("jstests/multiVersion/libs/multi_rs.js"); // For upgradeSet. -load('jstests/noPassthrough/libs/index_build.js'); // For IndexBuildTest - -// Runs a createIndex command with the given key pattern and options. Then verifies that no index -// was built, since an index with the same signature already existed. -function assertIndexAlreadyExists(keyPattern, indexOptions) { - const numIndexesBefore = coll.getIndexes().length; - const cmdRes = assert.commandWorked(coll.createIndex(keyPattern, indexOptions)); - - // In a sharded cluster, the results from all shards are returned in cmdRes.raw. - assert(cmdRes.numIndexesBefore != null || Object.values(cmdRes.raw), tojson(cmdRes)); - const numIndexesAfter = - (cmdRes.numIndexesAfter != null ? cmdRes.numIndexesAfter - : Object.values(cmdRes.raw)[0].numIndexesAfter); - - assert.eq(numIndexesAfter, numIndexesBefore, cmdRes); -} - -const rst = new ReplSetTest({ - nodes: 2, - nodeOptions: {binVersion: "latest"}, -}); -rst.startSet(); -rst.initiate(); - -let primary = rst.getPrimary(); -let testDB = primary.getDB(jsTestName()); -let coll = testDB.test; -coll.insert({a: 100}); - -// Verifies that the given query is indexed, and that 'numAlternativePlans' were generated. -function assertIndexedQuery(query, numAlternativePlans) { - const explainOut = coll.explain().find(query).finish(); - assert(isIxscan(testDB, explainOut), explainOut); - assert.eq(getRejectedPlans(explainOut).length, numAlternativePlans, explainOut); -} - -// Creates a base index without any index options. -assert.commandWorked(coll.createIndex({a: 1}, {name: "base_index"})); - -// Verifies that multiple indexes differing from base_index only by 'partialFilterExpression' option -// can be created in FCV 4.7+. -testDB.adminCommand({setFeatureCompatibilityVersion: latestFCV}); -assert.commandWorked( - coll.createIndex({a: 1}, {name: "index1", partialFilterExpression: {a: {$gte: 0}}})); -assert.commandWorked( - coll.createIndex({a: 1}, {name: "index2", partialFilterExpression: {a: {$gte: 10}}})); -assert.commandWorked( - coll.createIndex({a: 1}, {name: "index3", partialFilterExpression: {a: {$gte: 100}}})); - -// Verifies that the planner considers all relevant partial indexes when answering a query in -// FCV 4.7+. -assertIndexedQuery({a: 1}, 1); -assertIndexedQuery({a: 11}, 2); -assertIndexedQuery({a: 101}, 3); - -// Verifies that an index differing from base_index only by 'unique' option can be created in -// FCV 4.9+. -assert.commandWorked(coll.createIndex({a: 1}, {name: "unique_index", unique: true})); - -// Verifies that the planner considers all relevant indexes when answering a query in FCV 4.9+. -assertIndexedQuery({a: 1}, 2); -assertIndexedQuery({a: 11}, 3); -assertIndexedQuery({a: 101}, 4); - -// Verifies that an index differing from base_index only by 'sparse' option can be created in -// FCV 4.9+. -assert.commandWorked(coll.createIndex({a: 1}, {name: "sparse_index", sparse: true})); - -// Verifies that the planner considers all relevant indexes when answering a query in FCV 4.9+. -assertIndexedQuery({a: 1}, 3); -assertIndexedQuery({a: 11}, 4); -assertIndexedQuery({a: 101}, 5); - -// Creates a base wildcard index without any index options. -assert.commandWorked(coll.createIndex({"$**": 1}, {name: "wc_all"})); - -// Verifies that an index differing from wc_all only by 'wildcardProjection' option can be created -// in FCV 5.0+. -assert.commandWorked(coll.createIndex({"$**": 1}, {name: "wc_a", wildcardProjection: {a: 1}})); - -// Verifies that the planner considers all relevant indexes when answering a query in FCV 5.0+. -assertIndexedQuery({a: 1}, 5); -assertIndexedQuery({a: 11}, 6); -assertIndexedQuery({a: 101}, 7); - -// Verifies that an index build restarted during startup recovery in FCV 4.7+ does not revert to -// FCV 4.4 behavior. -jsTestLog("Starting index build on primary and pausing before completion"); -IndexBuildTest.pauseIndexBuilds(primary); -IndexBuildTest.startIndexBuild( - primary, coll.getFullName(), {a: 1}, {name: "index4", partialFilterExpression: {a: {$lt: 0}}}); - -jsTestLog("Waiting for secondary to start the index build"); -let secondary = rst.getSecondary(); -let secondaryDB = secondary.getDB(jsTestName()); -IndexBuildTest.waitForIndexBuildToStart(secondaryDB); -rst.restart(secondary.nodeId); - -jsTestLog("Waiting for all nodes to finish building the index"); -IndexBuildTest.resumeIndexBuilds(primary); -IndexBuildTest.waitForIndexBuildToStop(testDB, coll.getName(), "index4"); -rst.awaitReplication(); - -// Resets connection in case leadership has changed. -primary = rst.getPrimary(); -testDB = primary.getDB(jsTestName()); -coll = testDB.test; - -// base_index & unique_index & sparse_index & wc_all & wc_a can be used. -assertIndexedQuery({a: -1}, 5); - -jsTestLog("Downgrade to the last LTS"); - -// Downgrades to the last LTS FCV -testDB.adminCommand({setFeatureCompatibilityVersion: lastLTSFCV}); - -// Verifies that attempting to build an index with the same name and identical value for -// 'partialFilterExpression' option as an existing index results in a no-op in FCV 4.4, and the -// command reports successful execution. -var cmdRes = assert.commandWorked( - coll.createIndex({a: 1}, {name: "index1", partialFilterExpression: {a: {$gte: 0}}})); -assert.eq(cmdRes.numIndexesBefore, cmdRes.numIndexesAfter); - -// Verifies that attempting to build an index with the same name and identical value for 'unique' -// option as an existing index results in a no-op in FCV 4.4, and the command reports successful -// execution. -cmdRes = assert.commandWorked(coll.createIndex({a: 1}, {name: "unique_index", unique: true})); -assert.eq(cmdRes.numIndexesBefore, cmdRes.numIndexesAfter); - -// Verifies that attempting to build an index with the same name and identical value for 'sparse' -// option as an existing index results in a no-op in FCV 4.4, and the command reports successful -// execution. -cmdRes = assert.commandWorked(coll.createIndex({a: 1}, {name: "sparse_index", sparse: true})); -assert.eq(cmdRes.numIndexesBefore, cmdRes.numIndexesAfter); - -// Verifies that attempting to build an index with the same name and identical value for -// 'wildcardProjection' option as an existing index results in a no-op in FCV 4.4, and the command -// reports successful execution. -cmdRes = - assert.commandWorked(coll.createIndex({"$**": 1}, {name: "wc_a", wildcardProjection: {a: 1}})); -assert.eq(cmdRes.numIndexesBefore, cmdRes.numIndexesAfter); - -// Verifies that these indexes are retained and can be used by the planner when we downgrade to -// FCV 4.4. -assertIndexedQuery({a: 1}, 5); -assertIndexedQuery({a: 11}, 6); -assertIndexedQuery({a: 101}, 7); - -// Verifies that indexes distinguished only by 'partialFilterExpression' can be dropped by name in -// FCV 4.4. -assert.commandWorked(coll.dropIndex("index2")); -assertIndexedQuery({a: 1}, 5); -assertIndexedQuery({a: 11}, 5); -assertIndexedQuery({a: 101}, 6); - -// Verifies that indexes distinguished only by 'unique' option can be dropped by name in FCV 4.4. -assert.commandWorked(coll.dropIndex("unique_index")); -assertIndexedQuery({a: 1}, 4); -assertIndexedQuery({a: 11}, 4); -assertIndexedQuery({a: 101}, 5); - -// Verifies that indexes distinguished only by 'sparse' option can be dropped by name in FCV 4.4. -assert.commandWorked(coll.dropIndex("sparse_index")); -assertIndexedQuery({a: 1}, 3); -assertIndexedQuery({a: 11}, 3); -assertIndexedQuery({a: 101}, 4); - -// Verifies that indexes distinguished only by 'wildcardProjection' option can be dropped by name in -// FCV 4.4. -assert.commandWorked(coll.dropIndex("wc_a")); -assertIndexedQuery({a: 1}, 2); -assertIndexedQuery({a: 11}, 2); -assertIndexedQuery({a: 101}, 3); - -// Verifies that an index distinguished only by 'partialFilterExpression' option cannot be created -// in FCV 4.4. -assert.commandFailedWithCode( - coll.createIndex({a: 1}, {name: "index2", partialFilterExpression: {a: {$gte: 10}}}), - ErrorCodes.IndexOptionsConflict); - -// Verifies that an index distinguished only by 'unique' option cannot be created in FCV 4.4. -assert.commandFailedWithCode(coll.createIndex({a: 1}, {name: "unique_index", unique: true}), - ErrorCodes.IndexOptionsConflict); - -// Verifies that an index distinguished only by 'sparse' option cannot be created in FCV 4.4. -assert.commandFailedWithCode(coll.createIndex({a: 1}, {name: "sparse_index", sparse: true}), - ErrorCodes.IndexOptionsConflict); - -// Verifies that an index distinguished only by 'wildcardProjection' option cannot be created in -// FCV 4.4. -assert.commandFailedWithCode( - coll.createIndex({"$**": 1}, {name: "wc_a", wildcardProjection: {a: 1}}), - ErrorCodes.IndexOptionsConflict); - -// We need to recreate the unique & sparse & wildcardProjection indexes that we just dropped before -// downgrading to the LTS binary. To do so, we need to temporarily upgrade the FCV to 'latest' -// again. -testDB.adminCommand({setFeatureCompatibilityVersion: latestFCV}); - -assert.commandWorked(coll.createIndex({a: 1}, {name: "unique_index", unique: true})); -assert.commandWorked(coll.createIndex({a: 1}, {name: "sparse_index", sparse: true})); -assert.commandWorked(coll.createIndex({"$**": 1}, {name: "wc_a", wildcardProjection: {a: 1}})); - -// Need to downgrade to the LTS FCV before downgrade to the LTS binary. -testDB.adminCommand({setFeatureCompatibilityVersion: lastLTSFCV}); - -// Verifies that downgrading to binary 4.4 with overlapping partialFilterExpression, unique, sparse, -// and wildcardProjection indexes present does not fassert. -rst.upgradeSet({binVersion: "last-lts"}); -testDB = rst.getPrimary().getDB(jsTestName()); -coll = testDB.test; - -// Verifies that the indexes still exist and can be used to answer queries on the binary 4.4 -// replset. -assertIndexedQuery({a: 1}, 5); -assertIndexedQuery({a: 11}, 5); -assertIndexedQuery({a: 101}, 6); - -// Verifies that indexes which are distinguished only by 4.7+ signature fields can be dropped by -// name on binary 4.4. -assert.commandWorked(coll.dropIndex("unique_index")); -assert.commandWorked(coll.dropIndex("sparse_index")); -assert.commandWorked(coll.dropIndex("wc_a")); - -// Verifies that an index which differs only by 'partialFilterExpression' option cannot be created -// on binary 4.4. -assert.commandFailedWithCode( - coll.createIndex({a: 1}, {name: "index2", partialFilterExpression: {a: {$gte: 10}}}), - ErrorCodes.IndexOptionsConflict); - -// Verifies that an index distinguished only by 'unique' option cannot be created in binary 4.4. -assert.commandFailedWithCode(coll.createIndex({a: 1}, {name: "unique_index", unique: true}), - ErrorCodes.IndexOptionsConflict); - -// Verifies that an index distinguished only by 'sparse' option cannot be created in binary 4.4. -assert.commandFailedWithCode(coll.createIndex({a: 1}, {name: "sparse_index", sparse: true}), - ErrorCodes.IndexOptionsConflict); - -// Verifies that an index distinguished only by 'wildcardProjection' option cannot be created in -// binary 4.4. -assert.commandFailedWithCode( - coll.createIndex({"$**": 1}, {name: "wc_a", wildcardProjection: {a: 1}}), - ErrorCodes.IndexOptionsConflict); - -// Prepares the next test case that verifies that non-normalized wildcard path projection in a -// previous version will be normalized and compared to a new wildcard index path projection. -assert.commandWorked(coll.dropIndex("wc_all")); - -// Path projections are not normalized before FCV 4.7. -assert.commandWorked(coll.createIndex( - {"$**": 1}, {name: "wc_a_sub_b_c", wildcardProjection: {_id: 0, "a.b": 1, "a.c": 1}})); - -// Upgrades to the latest binary. The FCV stays as the last FCV even after binary upgrade. -rst.upgradeSet({binVersion: "latest"}); -testDB = rst.getPrimary().getDB(jsTestName()); -coll = testDB.test; - -// Before upgrading to the latest FCV, verifies that any attempt to create an wildcard index -// with a wildcard projection fails with the IndexOptionsConflict error since we already -// have the 'wc_a_sub_b_c' wildcard index and wildcardProjection is not part of the index signature -// in the last FCV. -assert.commandFailedWithCode(coll.createIndex({"$**": 1}, {name: "wc_all"}), - ErrorCodes.IndexOptionsConflict); -assert.commandFailedWithCode( - coll.createIndex({"$**": 1}, {name: "wc_a_sub_b_c", wildcardProjection: {a: {b: 1, c: 1}}}), - ErrorCodes.IndexOptionsConflict); -assert.commandFailedWithCode( - coll.createIndex({"$**": 1}, - {name: "wc_noid_a_sub_b_c", wildcardProjection: {_id: 0, a: {b: 1, c: 1}}}), - ErrorCodes.IndexOptionsConflict); -assert.commandFailedWithCode( - coll.createIndex({"$**": 1}, - {name: "wc_id_a_sub_b_c", wildcardProjection: {_id: 1, a: {b: 1, c: 1}}}), - ErrorCodes.IndexOptionsConflict); -assert.commandFailedWithCode( - coll.createIndex({"$**": 1}, {name: "wc_a_sub_b_c", wildcardProjection: {a: {c: 1, b: 1}}}), - ErrorCodes.IndexOptionsConflict); -assert.commandFailedWithCode( - coll.createIndex({"$**": 1}, {name: "wc_a_sub_b_c_1", wildcardProjection: {a: {c: 1, b: 1}}}), - ErrorCodes.IndexOptionsConflict); -assert.commandFailedWithCode( - coll.createIndex({"$**": 1}, {name: "wc_a_sub_b_c", wildcardProjection: {"a.c": 1, "a.b": 1}}), - ErrorCodes.IndexOptionsConflict); -assert.commandFailedWithCode( - coll.createIndex({"$**": 1}, - {name: "wc_a_sub_b_c_1", wildcardProjection: {"a.c": 1, "a.b": 1}}), - ErrorCodes.IndexOptionsConflict); - -// Upgrades to the lastest FCV -testDB.adminCommand({setFeatureCompatibilityVersion: latestFCV}); - -// Verifies that indexes with path projections which is identical after normalization can not be -// created. -assertIndexAlreadyExists({"$**": 1}, {name: "wc_a_sub_b_c", wildcardProjection: {a: {b: 1, c: 1}}}); -assert.commandFailedWithCode( - coll.createIndex({"$**": 1}, {name: "wc_a_sub_b_c_1", wildcardProjection: {a: {b: 1, c: 1}}}), - ErrorCodes.IndexOptionsConflict); -assertIndexAlreadyExists({"$**": 1}, - {name: "wc_a_sub_b_c", wildcardProjection: {_id: 0, a: {b: 1, c: 1}}}); -assert.commandFailedWithCode( - coll.createIndex({"$**": 1}, - {name: "wc_noid_a_sub_b_c", wildcardProjection: {_id: 0, a: {b: 1, c: 1}}}), - ErrorCodes.IndexOptionsConflict); -assertIndexAlreadyExists({"$**": 1}, {name: "wc_a_sub_b_c", wildcardProjection: {a: {c: 1, b: 1}}}); -assert.commandFailedWithCode( - coll.createIndex({"$**": 1}, {name: "wc_a_sub_b_c_1", wildcardProjection: {a: {c: 1, b: 1}}}), - ErrorCodes.IndexOptionsConflict); -assertIndexAlreadyExists({"$**": 1}, - {name: "wc_a_sub_b_c", wildcardProjection: {"a.c": 1, "a.b": 1}}); -assert.commandFailedWithCode( - coll.createIndex({"$**": 1}, - {name: "wc_a_sub_b_c_1", wildcardProjection: {"a.c": 1, "a.b": 1}}), - ErrorCodes.IndexOptionsConflict); - -// Only the 'wc_a_sub_b_c' index can be used. So, there's no alternative plan. Verifies this before -// creating an wildcard index with explicit inclusion of _id path projection. -assertIndexedQuery({"a.b": 10}, 0); - -// Verifies that an index with a path projection which is different only in _id path can be created. -assert.commandWorked(coll.createIndex( - {"$**": 1}, {name: "wc_id_a_sub_b_c", wildcardProjection: {_id: 1, a: {b: 1, c: 1}}})); - -// The 'wc_a_sub_b_c' and 'wc_id_a_sub_b_c' indexes can be used. So, there's one alternative plan. -assertIndexedQuery({"a.b": 10}, 1); - -rst.stopSet(); -})(); diff --git a/jstests/multiVersion/upgrade_index_with_weights.js b/jstests/multiVersion/upgrade_index_with_weights.js deleted file mode 100644 index d748353f506..00000000000 --- a/jstests/multiVersion/upgrade_index_with_weights.js +++ /dev/null @@ -1,68 +0,0 @@ -// Test to verify that upgrading a replica sets, which has an index with 'weights' parameter works -// correctly. -/** - * @tags: [ - * disabled_due_to_server_58295 - * ] - */ -(function() { -"use strict"; - -load("jstests/multiVersion/libs/multi_rs.js"); // For upgradeSet. - -TestData.skipCheckDBHashes = true; // Skip db hashes when restarting the replset. - -const nodeOptionsLastStable = { - binVersion: "last-lts" -}; -const nodeOptionsLatest = { - binVersion: "latest" -}; - -// Set up a new replSet consisting of 2 nodes, initially running on 4.4 binaries. -const rst = new ReplSetTest({nodes: 2, nodeOptions: nodeOptionsLastStable}); -rst.startSet(); -rst.initiate(); - -let testDB = rst.getPrimary().getDB(jsTestName()); -let coll = testDB.coll; -coll.drop(); - -// Verifies that the instance is running with the specified binary version and FCV. -function assertVersionAndFCV(db, versions, fcv) { - const majorMinorVersion = db.version().substring(0, 3); - assert(versions.includes(majorMinorVersion)); - assert.eq( - assert.commandWorked(db.adminCommand({getParameter: 1, featureCompatibilityVersion: 1})) - .featureCompatibilityVersion.version, - fcv); -} - -// Verify that the replset is on binary version 4.4 and FCV 4.4. -assertVersionAndFCV(testDB, ["4.4"], lastLTSFCV); - -assert.commandWorked(coll.createIndex({a: 1}, {name: "a_1", weights: {d: 1}})); -assert.commandWorked(coll.insert({a: 1})); -rst.awaitReplication(); - -// Upgrade the set to the latest binary version and FCV. -rst.upgradeSet(nodeOptionsLatest); -testDB = rst.getPrimary().getDB(jsTestName()); -coll = testDB.coll; -assert.commandWorked(testDB.adminCommand({setFeatureCompatibilityVersion: latestFCV})); -assertVersionAndFCV(testDB, ["4.9", "5.0"], latestFCV); -assert.commandFailedWithCode(coll.createIndex({b: 1}, {weights: {d: 1}}), - ErrorCodes.CannotCreateIndex); - -// Restart the secondary node clean, and verify that the index data is synced correctly. -const secondaryNode = rst.getSecondaries()[0]; -const secondaryNodeOptions = rst.nodeOptions[`n${rst.getNodeId(secondaryNode)}`]; -rst.restart(secondaryNode, Object.assign({startClean: true}, secondaryNodeOptions)); -coll = rst.getPrimary().getDB(jsTestName()).coll; -const index = coll.getIndexes().filter(index => (index["name"] == "a_1")); -assert.eq(index.length, 1, index); -assert.eq(index[0]["weights"], {d: 1}, index); - -rst.awaitReplication(); -rst.stopSet(); -}()); |