diff options
author | jannaerin <golden.janna@gmail.com> | 2021-12-06 16:19:51 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2022-01-04 18:06:22 +0000 |
commit | da82e5278ca717d3228e4837a3e815c5ced876e0 (patch) | |
tree | 4a3bdda5c9a9d3d39a15dbcce1264a9e34dc72d2 /jstests/replsets/shard_merge_invalid_options.js | |
parent | 863684a584bfa5b4beeffb8d2a79e735299c1de7 (diff) | |
download | mongo-da82e5278ca717d3228e4837a3e815c5ced876e0.tar.gz |
SERVER-61474 Ban directoryPerDb and directoryForIndexes with Merge
Diffstat (limited to 'jstests/replsets/shard_merge_invalid_options.js')
-rw-r--r-- | jstests/replsets/shard_merge_invalid_options.js | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/jstests/replsets/shard_merge_invalid_options.js b/jstests/replsets/shard_merge_invalid_options.js new file mode 100644 index 00000000000..4d7eee88a40 --- /dev/null +++ b/jstests/replsets/shard_merge_invalid_options.js @@ -0,0 +1,74 @@ +/** + * Tests that the donorStartMigration and recipientSyncData commands throw when a node has options + * set that are incompatible with protocol shard merge. + * + * @tags: [requires_fcv_53, featureFlagShardMerge] + * ] + */ + +(function() { +"use strict"; + +load("jstests/replsets/libs/tenant_migration_util.js"); +load("jstests/libs/fail_point_util.js"); + +function runTest(nodeOptions, expectedError) { + let rst = new ReplSetTest({nodes: 1, nodeOptions: nodeOptions}); + rst.startSet(); + rst.initiate(); + + let primary = rst.getPrimary(); + let adminDB = primary.getDB("admin"); + const kDummyConnStr = "mongodb://localhost/?replicaSet=foo"; + const readPreference = {mode: 'primary'}; + const migrationCertificates = TenantMigrationUtil.makeMigrationCertificatesForTest(); + + // Enable below fail points to prevent starting the donor/recipient POS instance. + configureFailPoint(primary, "returnResponseCommittedForDonorStartMigrationCmd"); + configureFailPoint(primary, "returnResponseOkForRecipientSyncDataCmd"); + configureFailPoint(primary, "returnResponseOkForRecipientForgetMigrationCmd"); + + // Ensure the feature flag is enabled and FCV is latest + assert(TenantMigrationUtil.isShardMergeEnabled(adminDB)); + assert.eq(getFCVConstants().latest, + adminDB.system.version.findOne({_id: 'featureCompatibilityVersion'}).version); + + // Assert that donorStartMigration fails with the expected code + assert.commandFailedWithCode( + adminDB.runCommand({ + donorStartMigration: 1, + protocol: "shard merge", + migrationId: UUID(), + recipientConnectionString: kDummyConnStr, + readPreference: readPreference, + donorCertificateForRecipient: migrationCertificates.donorCertificateForRecipient, + recipientCertificateForDonor: migrationCertificates.recipientCertificateForDonor + }), + expectedError, + "Expected donorStartMigration to fail when protocol is 'shard merge' and node options " + + tojson(nodeOptions) + " are set, but did not"); + + // Assert that recipientSyncData fails with the expected code + assert.commandFailedWithCode( + adminDB.runCommand({ + recipientSyncData: 1, + protocol: "shard merge", + migrationId: UUID(), + donorConnectionString: kDummyConnStr, + readPreference: readPreference, + startMigrationDonorTimestamp: Timestamp(1, 1), + recipientCertificateForDonor: migrationCertificates.recipientCertificateForDonor + }), + expectedError, + "Expected recipientSyncData to fail when protocol is 'shard merge' and node options " + + tojson(nodeOptions) + " are set, but did not"); + + rst.stopSet(); +} + +// Shard merge is not allowed when directoryperdb is enabled +runTest({directoryperdb: ""}, ErrorCodes.InvalidOptions); + +// Shard merge is not allowed when directoryForIndexes is enabled +runTest({"wiredTigerDirectoryForIndexes": ""}, ErrorCodes.InvalidOptions); +})(); |