diff options
Diffstat (limited to 'jstests')
45 files changed, 442 insertions, 412 deletions
diff --git a/jstests/aggregation/bugs/server533.js b/jstests/aggregation/bugs/server533.js index e9be67f635a..f719848b08a 100644 --- a/jstests/aggregation/bugs/server533.js +++ b/jstests/aggregation/bugs/server533.js @@ -17,10 +17,14 @@ for (var i = 0; i < nItems; i++) { assert.commandWorked(coll.insert({_id: i})); } -[0, 1, nItems, nItems + 1].forEach(function(size) { - var results = coll.aggregate([{$sample: {size: size}}]).toArray(); - assert.eq(results.length, Math.min(size, nItems)); -}); +[0, + 1, + nItems, + nItems + 1] + .forEach(function(size) { + var results = coll.aggregate([{$sample: {size: size}}]).toArray(); + assert.eq(results.length, Math.min(size, nItems)); + }); // Multiple $sample stages are allowed. var results = coll.aggregate([{$sample: {size: nItems}}, {$sample: {size: 1}}]).toArray(); diff --git a/jstests/change_streams/ddl_rename_cross_db.js b/jstests/change_streams/ddl_rename_cross_db.js index 9cf78ee9c4a..34bb5340204 100644 --- a/jstests/change_streams/ddl_rename_cross_db.js +++ b/jstests/change_streams/ddl_rename_cross_db.js @@ -42,8 +42,8 @@ function runTest(watchType, renameType) { cursorDst = testStreamDst.startWatchingChanges( {pipeline, collection: dstColl.getName(), doNotModifyInPassthroughs: true}); } else if (watchType == "database") { - cursorSrc = testStreamSrc.startWatchingChanges({pipeline, collection: /*all colls=*/1}); - cursorDst = testStreamDst.startWatchingChanges({pipeline, collection: /*all colls=*/1}); + cursorSrc = testStreamSrc.startWatchingChanges({pipeline, collection: /*all colls=*/ 1}); + cursorDst = testStreamDst.startWatchingChanges({pipeline, collection: /*all colls=*/ 1}); } if (renameType == "dropTarget" || renameType == "noDropTarget") { diff --git a/jstests/core/catalog/list_indexes_non_existent_ns.js b/jstests/core/catalog/list_indexes_non_existent_ns.js index 11a82746b06..8ad5d0cf154 100644 --- a/jstests/core/catalog/list_indexes_non_existent_ns.js +++ b/jstests/core/catalog/list_indexes_non_existent_ns.js @@ -1,18 +1,18 @@ -// Test the listIndexes command on non-existent collection.
-(function() {
-var dbTest = db.getSiblingDB("list_indexes_non_existent_db");
-assert.commandWorked(dbTest.dropDatabase());
-
-var coll;
-
-// Non-existent database
-coll = dbTest.getCollection("list_indexes_non_existent_db");
-assert.commandFailed(coll.runCommand("listIndexes"));
-
-// Creates the actual database that did not exist till now
-coll.insert({});
-
-// Non-existent collection
-coll = dbTest.getCollection("list_indexes_non_existent_collection");
-assert.commandFailed(coll.runCommand("listIndexes"));
-}());
+// Test the listIndexes command on non-existent collection. +(function() { +var dbTest = db.getSiblingDB("list_indexes_non_existent_db"); +assert.commandWorked(dbTest.dropDatabase()); + +var coll; + +// Non-existent database +coll = dbTest.getCollection("list_indexes_non_existent_db"); +assert.commandFailed(coll.runCommand("listIndexes")); + +// Creates the actual database that did not exist till now +coll.insert({}); + +// Non-existent collection +coll = dbTest.getCollection("list_indexes_non_existent_collection"); +assert.commandFailed(coll.runCommand("listIndexes")); +}()); diff --git a/jstests/core/mod_overflow.js b/jstests/core/mod_overflow.js index 81a36bfa24a..77f0a68ef3b 100644 --- a/jstests/core/mod_overflow.js +++ b/jstests/core/mod_overflow.js @@ -31,9 +31,9 @@ for (let divisor of [-1.0, NumberInt("-1"), NumberLong("-1"), NumberDecimal("-1" insertedDocs[0], {modVal: (divisor instanceof NumberDecimal ? NumberDecimal("-0") : NumberLong("0"))}), Object.merge(insertedDocs[1], { - modVal: (divisor instanceof NumberLong - ? NumberLong("0") - : divisor instanceof NumberDecimal ? NumberDecimal("-0") : 0) + modVal: (divisor instanceof NumberLong ? NumberLong("0") + : divisor instanceof NumberDecimal ? NumberDecimal("-0") + : 0) }) ]; assert.docEq( diff --git a/jstests/core/query/project/projection_meta_index_key.js b/jstests/core/query/project/projection_meta_index_key.js index 01f6d3c7876..c2c585a1b83 100644 --- a/jstests/core/query/project/projection_meta_index_key.js +++ b/jstests/core/query/project/projection_meta_index_key.js @@ -36,81 +36,84 @@ function testIndexKeyMetaProjection({ aggExpectedResult); } -[true, false].forEach((metadataAvailable) => { - let indexSpec; - if (metadataAvailable) { - indexSpec = {a: 1, b: 1}; - assert.commandWorked(coll.createIndex(indexSpec)); - } else { - indexSpec = {}; - assert.commandWorked(coll.dropIndexes()); - } +[true, + false] + .forEach((metadataAvailable) => { + let indexSpec; + if (metadataAvailable) { + indexSpec = {a: 1, b: 1}; + assert.commandWorked(coll.createIndex(indexSpec)); + } else { + indexSpec = {}; + assert.commandWorked(coll.dropIndexes()); + } - // $meta with an inclusion projection. - testIndexKeyMetaProjection({ - matchSpec: {a: {$gt: 20}}, - projSpec: {_id: 0, a: 1}, - indexSpec: indexSpec, - expectedResult: [Object.assign({a: 30}, metadataAvailable ? {c: {a: 30, b: 'z'}} : {})] - }); - - // $meta with an exclusion projection. - testIndexKeyMetaProjection({ - matchSpec: {a: {$gt: 20}}, - projSpec: {_id: 0, a: 0}, - indexSpec: indexSpec, - expectedResult: [Object.assign({b: 'z'}, metadataAvailable ? {c: {a: 30, b: 'z'}} : {})] - }); + // $meta with an inclusion projection. + testIndexKeyMetaProjection({ + matchSpec: {a: {$gt: 20}}, + projSpec: {_id: 0, a: 1}, + indexSpec: indexSpec, + expectedResult: [Object.assign({a: 30}, metadataAvailable ? {c: {a: 30, b: 'z'}} : {})] + }); - // $meta with _id only (inclusion). - testIndexKeyMetaProjection({ - matchSpec: {a: {$gt: 20}}, - projSpec: {_id: 1}, - indexSpec: indexSpec, - expectedResult: [Object.assign({_id: 3}, metadataAvailable ? {c: {a: 30, b: 'z'}} : {})] - }); + // $meta with an exclusion projection. + testIndexKeyMetaProjection({ + matchSpec: {a: {$gt: 20}}, + projSpec: {_id: 0, a: 0}, + indexSpec: indexSpec, + expectedResult: [Object.assign({b: 'z'}, metadataAvailable ? {c: {a: 30, b: 'z'}} : {})] + }); - // $meta with _id only (exclusion). Note that this type of projection is equivalent to a - // $meta-only projection, which is treated differently in find and aggregate (it's an inclusion - // projection in find, and exclusion in aggregate). - testIndexKeyMetaProjection({ - matchSpec: {a: {$gt: 20}}, - projSpec: {_id: 0}, - indexSpec: indexSpec, - expectedResult: - [Object.assign({a: 30, b: 'z'}, metadataAvailable ? {c: {a: 30, b: 'z'}} : {})], - aggExpectedResult: [metadataAvailable ? {c: {a: 30, b: 'z'}} : {}] - }); + // $meta with _id only (inclusion). + testIndexKeyMetaProjection({ + matchSpec: {a: {$gt: 20}}, + projSpec: {_id: 1}, + indexSpec: indexSpec, + expectedResult: [Object.assign({_id: 3}, metadataAvailable ? {c: {a: 30, b: 'z'}} : {})] + }); - // $meta only (see comment above regarding $meta-only projection in find and aggregate). - testIndexKeyMetaProjection({ - matchSpec: {a: {$gt: 20}}, - indexSpec: indexSpec, - expectedResult: - [Object.assign({_id: 3, a: 30, b: 'z'}, metadataAvailable ? {c: {a: 30, b: 'z'}} : {})], - aggExpectedResult: [Object.assign({_id: 3}, metadataAvailable ? {c: {a: 30, b: 'z'}} : {})] - }); + // $meta with _id only (exclusion). Note that this type of projection is equivalent to a + // $meta-only projection, which is treated differently in find and aggregate (it's an + // inclusion projection in find, and exclusion in aggregate). + testIndexKeyMetaProjection({ + matchSpec: {a: {$gt: 20}}, + projSpec: {_id: 0}, + indexSpec: indexSpec, + expectedResult: + [Object.assign({a: 30, b: 'z'}, metadataAvailable ? {c: {a: 30, b: 'z'}} : {})], + aggExpectedResult: [metadataAvailable ? {c: {a: 30, b: 'z'}} : {}] + }); - // $meta with sort (when an index is available this should result in a non-blocking sort - // and the index key metadata should be available). - // - // If a collection is sharded, we will split the pipeline and dispatch only a $project stage, - // containing inclusion projection, to each shard, and apply the $meta projection on mongos. - // However, given than no information has been passed to the shard to request to include - // indexKey metadata to a document, the $meta expression won't be able to extract the - // indexKey. So, this scenario currently is not supported and we need to make sure that we - // run this test on an unsharded collection only. - if (!FixtureHelpers.isSharded(coll)) { + // $meta only (see comment above regarding $meta-only projection in find and aggregate). testIndexKeyMetaProjection({ - projSpec: {_id: 1}, - sortSpec: {a: 1}, + matchSpec: {a: {$gt: 20}}, indexSpec: indexSpec, - expectedResult: [ - Object.assign({_id: 1}, metadataAvailable ? {c: {a: 10, b: 'x'}} : {}), - Object.assign({_id: 2}, metadataAvailable ? {c: {a: 20, b: 'y'}} : {}), - Object.assign({_id: 3}, metadataAvailable ? {c: {a: 30, b: 'z'}} : {}) - ] + expectedResult: [Object.assign({_id: 3, a: 30, b: 'z'}, + metadataAvailable ? {c: {a: 30, b: 'z'}} : {})], + aggExpectedResult: + [Object.assign({_id: 3}, metadataAvailable ? {c: {a: 30, b: 'z'}} : {})] }); - } -}); + + // $meta with sort (when an index is available this should result in a non-blocking sort + // and the index key metadata should be available). + // + // If a collection is sharded, we will split the pipeline and dispatch only a $project + // stage, containing inclusion projection, to each shard, and apply the $meta projection on + // mongos. However, given than no information has been passed to the shard to request to + // include indexKey metadata to a document, the $meta expression won't be able to extract + // the indexKey. So, this scenario currently is not supported and we need to make sure that + // we run this test on an unsharded collection only. + if (!FixtureHelpers.isSharded(coll)) { + testIndexKeyMetaProjection({ + projSpec: {_id: 1}, + sortSpec: {a: 1}, + indexSpec: indexSpec, + expectedResult: [ + Object.assign({_id: 1}, metadataAvailable ? {c: {a: 10, b: 'x'}} : {}), + Object.assign({_id: 2}, metadataAvailable ? {c: {a: 20, b: 'y'}} : {}), + Object.assign({_id: 3}, metadataAvailable ? {c: {a: 30, b: 'z'}} : {}) + ] + }); + } + }); }()); diff --git a/jstests/core/timeseries/timeseries_index_spec.js b/jstests/core/timeseries/timeseries_index_spec.js index 833915266af..d2ac8e58687 100644 --- a/jstests/core/timeseries/timeseries_index_spec.js +++ b/jstests/core/timeseries/timeseries_index_spec.js @@ -55,7 +55,7 @@ TimeseriesTest.run(() => { for (const index of userIndexes) { if (index.name === indexName) { sawIndex = true; - checkIndexSpec(index, /*userIndex=*/true, shouldHaveOriginalSpec); + checkIndexSpec(index, /*userIndex=*/ true, shouldHaveOriginalSpec); } } @@ -63,7 +63,7 @@ TimeseriesTest.run(() => { for (const index of bucketIndexes) { if (index.name === indexName) { sawIndex = true; - checkIndexSpec(index, /*userIndex=*/false, shouldHaveOriginalSpec); + checkIndexSpec(index, /*userIndex=*/ false, shouldHaveOriginalSpec); } } @@ -74,35 +74,35 @@ TimeseriesTest.run(() => { }; assert.commandWorked(coll.createIndex({[timeFieldName]: 1}, {name: "timefield_downgradable"})); - verifyAndDropIndex(/*shouldHaveOriginalSpec=*/false, "timefield_downgradable"); + verifyAndDropIndex(/*shouldHaveOriginalSpec=*/ false, "timefield_downgradable"); assert.commandWorked(coll.createIndex({[metaFieldName]: 1}, {name: "metafield_downgradable"})); - verifyAndDropIndex(/*shouldHaveOriginalSpec=*/false, "metafield_downgradable"); + verifyAndDropIndex(/*shouldHaveOriginalSpec=*/ false, "metafield_downgradable"); assert.commandWorked(coll.createIndex({[timeFieldName]: 1, [metaFieldName]: 1}, {name: "time_meta_field_downgradable"})); - verifyAndDropIndex(/*shouldHaveOriginalSpec=*/false, "time_meta_field_downgradable"); + verifyAndDropIndex(/*shouldHaveOriginalSpec=*/ false, "time_meta_field_downgradable"); if (FeatureFlagUtil.isEnabled(db, "TimeseriesMetricIndexes")) { assert.commandWorked(coll.createIndex({x: 1}, {name: "x_1"})); - verifyAndDropIndex(/*shouldHaveOriginalSpec=*/true, "x_1"); + verifyAndDropIndex(/*shouldHaveOriginalSpec=*/ true, "x_1"); assert.commandWorked( coll.createIndex({x: 1}, {name: "x_partial", partialFilterExpression: {x: {$gt: 5}}})); - verifyAndDropIndex(/*shouldHaveOriginalSpec=*/true, "x_partial"); + verifyAndDropIndex(/*shouldHaveOriginalSpec=*/ true, "x_partial"); assert.commandWorked(coll.createIndex( {[timeFieldName]: 1}, {name: "time_partial", partialFilterExpression: {x: {$gt: 5}}})); - verifyAndDropIndex(/*shouldHaveOriginalSpec=*/true, "time_partial"); + verifyAndDropIndex(/*shouldHaveOriginalSpec=*/ true, "time_partial"); assert.commandWorked(coll.createIndex( {[metaFieldName]: 1}, {name: "meta_partial", partialFilterExpression: {x: {$gt: 5}}})); - verifyAndDropIndex(/*shouldHaveOriginalSpec=*/true, "meta_partial"); + verifyAndDropIndex(/*shouldHaveOriginalSpec=*/ true, "meta_partial"); assert.commandWorked( coll.createIndex({[metaFieldName]: 1, x: 1}, {name: "meta_x_partial", partialFilterExpression: {x: {$gt: 5}}})); - verifyAndDropIndex(/*shouldHaveOriginalSpec=*/true, "meta_x_partial"); + verifyAndDropIndex(/*shouldHaveOriginalSpec=*/ true, "meta_x_partial"); } // Creating an index directly on the buckets collection is permitted. However, these types of diff --git a/jstests/core/timeseries/timeseries_sparse_index.js b/jstests/core/timeseries/timeseries_sparse_index.js index 813d50b565d..16b2fef3704 100644 --- a/jstests/core/timeseries/timeseries_sparse_index.js +++ b/jstests/core/timeseries/timeseries_sparse_index.js @@ -93,7 +93,7 @@ TimeseriesTest.run((insert) => { const coll = db.getCollection(collName); const bucketsColl = db.getCollection("system.buckets." + collName); - setup(viewDefinition, /*shouldSucceed=*/true); + setup(viewDefinition, /*shouldSucceed=*/ true); // Check definition on view let userIndexes = coll.getIndexes(); @@ -117,14 +117,14 @@ TimeseriesTest.run((insert) => { testIndex({[`${metaFieldName}.abc`]: 1}, {"meta.abc": 1}, 0); // Cannot create sparse indexes on time-series measurements. - setup({x: 1}, /*shouldSucceed=*/false); - setup({y: -1}, /*shouldSucceed=*/false); - setup({x: 1, y: 1}, /*shouldSucceed=*/false); - setup({z: 1}, /*shouldSucceed=*/false); + setup({x: 1}, /*shouldSucceed=*/ false); + setup({y: -1}, /*shouldSucceed=*/ false); + setup({x: 1, y: 1}, /*shouldSucceed=*/ false); + setup({z: 1}, /*shouldSucceed=*/ false); // Compound sparse indexes are not allowed if measurements are involved. - setup({x: 1, [`${metaFieldName}.loc`]: "2dsphere"}, /*shouldSucceed=*/false); - setup({[`${timeFieldName}`]: 1, x: 1}, /*shouldSucceed=*/false); + setup({x: 1, [`${metaFieldName}.loc`]: "2dsphere"}, /*shouldSucceed=*/ false); + setup({[`${timeFieldName}`]: 1, x: 1}, /*shouldSucceed=*/ false); // Test compound time and metadata sparse indexes. testIndex({[`${timeFieldName}`]: 1, [`${metaFieldName}.tag`]: 1}, diff --git a/jstests/disk/wt_startup_with_missing_user_collection.js b/jstests/disk/wt_startup_with_missing_user_collection.js index 866fa8ea714..23752fa20ba 100644 --- a/jstests/disk/wt_startup_with_missing_user_collection.js +++ b/jstests/disk/wt_startup_with_missing_user_collection.js @@ -38,8 +38,8 @@ IndexBuildTest.waitForIndexBuildToScanCollection( assert.commandWorked(testDB.adminCommand({fsync: 1})); const collUri = getUriForColl(testDB.getCollection("a")); -const indexIdUri = getUriForIndex(testDB.getCollection("a"), /*indexName=*/"_id_"); -const indexXUri = getUriForIndex(testDB.getCollection("a"), /*indexName=*/"x_1"); +const indexIdUri = getUriForIndex(testDB.getCollection("a"), /*indexName=*/ "_id_"); +const indexXUri = getUriForIndex(testDB.getCollection("a"), /*indexName=*/ "x_1"); MongoRunner.stopMongod(mongod); awaitIndexBuild(); diff --git a/jstests/disk/wt_table_checks.js b/jstests/disk/wt_table_checks.js index 17eea4b8ebb..cb8003c9281 100644 --- a/jstests/disk/wt_table_checks.js +++ b/jstests/disk/wt_table_checks.js @@ -53,7 +53,7 @@ for (let i = 0; i < 10; i++) { assert.commandWorked(conn.getDB(i.toString()).createCollection(i.toString())); } -checkTableLogSettings(conn, /*enabled=*/true); +checkTableLogSettings(conn, /*enabled=*/ true); MongoRunner.stopMongod(conn); /** @@ -90,7 +90,7 @@ checkLog.containsJson(conn, 5548302); // Changing table logging settings. assert(checkLog.checkContainsWithCountJson(conn, 22432, undefined, 0)); -checkTableLogSettings(conn, /*enabled=*/false); +checkTableLogSettings(conn, /*enabled=*/ false); MongoRunner.stopMongod(conn, null, {skipValidation: true}); /** @@ -122,6 +122,6 @@ checkLog.containsJson(conn, 22432); // Skipping table logging checks. assert(checkLog.checkContainsWithCountJson(conn, 5548302, undefined, 0)); -checkTableLogSettings(conn, /*enabled=*/true); +checkTableLogSettings(conn, /*enabled=*/ true); MongoRunner.stopMongod(conn); }()); diff --git a/jstests/libs/clustered_collections/clustered_capped_utils.js b/jstests/libs/clustered_collections/clustered_capped_utils.js index d6bf8f5aad9..5045fa3d07e 100644 --- a/jstests/libs/clustered_collections/clustered_capped_utils.js +++ b/jstests/libs/clustered_collections/clustered_capped_utils.js @@ -42,7 +42,7 @@ var ClusteredCappedUtils = class { assert.commandWorked(coll.insertMany(docs, {ordered: true})); // This test runs with default read concern 'local'. - TTLUtil.waitForPass(db, /*waitForMajorityCommit=*/false); + TTLUtil.waitForPass(db, /*waitForMajorityCommit=*/ false); // Only the recent documents survived. assert.eq(coll.find().itcount(), batchSize); @@ -143,7 +143,7 @@ var ClusteredCappedUtils = class { // TTL delete the two old documents. assert.commandWorked(db.adminCommand({setParameter: 1, ttlMonitorEnabled: true})); - TTLUtil.waitForPass(db, /*waitForMajorityCommit=*/isReplicated); + TTLUtil.waitForPass(db, /*waitForMajorityCommit=*/ isReplicated); assert.eq(2, db.getCollection(collName).find().itcount()); // Confirm that the tailable getMore can resume from where it was, since the document the @@ -212,7 +212,7 @@ var ClusteredCappedUtils = class { // TTL delete the two old documents, while the tailable cursor is still on the first one. assert.commandWorked(db.adminCommand({setParameter: 1, ttlMonitorEnabled: true})); - TTLUtil.waitForPass(db, /*waitForMajorityCommit=*/isReplicated); + TTLUtil.waitForPass(db, /*waitForMajorityCommit=*/ isReplicated); assert.eq(1, db.getCollection(collName).find().itcount()); // Confirm that the tailable cursor returns CappedPositionLost, as the document it was @@ -300,7 +300,7 @@ var ClusteredCappedUtils = class { // Expire the documents. assert.commandWorked(db.adminCommand({setParameter: 1, ttlMonitorEnabled: true})); // No need to wait for majority commit, as default 'local' read concern is used. - TTLUtil.waitForPass(db, /*waitForMajorityCommit=*/false); + TTLUtil.waitForPass(db, /*waitForMajorityCommit=*/ false); assert.eq(0, db.getCollection(collName).find().itcount()); // The TTL deletion has been replicated to the oplog. diff --git a/jstests/noPassthrough/absent_ns_field_in_index_specs.js b/jstests/noPassthrough/absent_ns_field_in_index_specs.js index 6aadcbd3912..55d5aee150a 100644 --- a/jstests/noPassthrough/absent_ns_field_in_index_specs.js +++ b/jstests/noPassthrough/absent_ns_field_in_index_specs.js @@ -36,7 +36,7 @@ let specSecondary = assert.eq(false, specPrimary.hasOwnProperty('ns')); assert.eq(false, specSecondary.hasOwnProperty('ns')); -replSet.stopSet(/*signal=*/null, /*forRestart=*/true); +replSet.stopSet(/*signal=*/ null, /*forRestart=*/ true); // Both nodes should have no 'ns' field in the index spec on restart. const options = { diff --git a/jstests/noPassthrough/bson_max_limit.js b/jstests/noPassthrough/bson_max_limit.js index 001b05a49bd..60ad231ee51 100644 --- a/jstests/noPassthrough/bson_max_limit.js +++ b/jstests/noPassthrough/bson_max_limit.js @@ -69,11 +69,11 @@ function executeTest(db) { // Reset. Test retryable findAndModify's. let sessionDb = db.getMongo().startSession({}).getDatabase("test"); - retryableFindAndModify(db, "coll", {_id: 1}, false, false, false, /*remove=*/true); - retryableFindAndModify(db, "coll", {_id: 1}, doc, false, /*upsert=*/true, false); + retryableFindAndModify(db, "coll", {_id: 1}, false, false, false, /*remove=*/ true); + retryableFindAndModify(db, "coll", {_id: 1}, doc, false, /*upsert=*/ true, false); retryableFindAndModify(db, "coll", {_id: 1}, {$unset: {a: 1}}, false, false, false); retryableFindAndModify( - db, "coll", {_id: 1}, {$set: {a: bigStr}}, /*new(Image)=*/true, false, false); + db, "coll", {_id: 1}, {$set: {a: bigStr}}, /*new(Image)=*/ true, false, false); } { diff --git a/jstests/noPassthrough/check_for_oplog_cap_maintainer_thread.js b/jstests/noPassthrough/check_for_oplog_cap_maintainer_thread.js index 7d46ec1e974..57eea4205ce 100644 --- a/jstests/noPassthrough/check_for_oplog_cap_maintainer_thread.js +++ b/jstests/noPassthrough/check_for_oplog_cap_maintainer_thread.js @@ -22,7 +22,7 @@ const primary = rst.getPrimary(); checkLog.containsJson(primary, 5295000); // OplogCapMaintainerThread started. checkLog.containsJson(primary, 22382); // Oplog stones calculated. -rst.stopSet(/*signal=*/null, /*forRestart=*/true); +rst.stopSet(/*signal=*/ null, /*forRestart=*/ true); // A subset of startup options prevent the oplog cap maintainer thread from being started. These // startup options are currently limited to readOnly, recoverFromOplogAsStandalone and repair. diff --git a/jstests/noPassthrough/collection_catalog_two_phase_drops.js b/jstests/noPassthrough/collection_catalog_two_phase_drops.js index 7eb7b854ba7..e53da1c1dc7 100644 --- a/jstests/noPassthrough/collection_catalog_two_phase_drops.js +++ b/jstests/noPassthrough/collection_catalog_two_phase_drops.js @@ -53,8 +53,8 @@ for (let i = 0; i < 5; i++) { assert.commandWorked(coll.createIndex({x: 1})); const collUri = getUriForColl(coll); -const idIndexUri = getUriForIndex(coll, /*indexName=*/"_id_"); -const xIndexUri = getUriForIndex(coll, /*indexName=*/"x_1"); +const idIndexUri = getUriForIndex(coll, /*indexName=*/ "_id_"); +const xIndexUri = getUriForIndex(coll, /*indexName=*/ "x_1"); jsTestLog("Idents: " + tojson({collection: collUri, idIndex: idIndexUri, xIndex: xIndexUri})); diff --git a/jstests/noPassthrough/column_store_index_load.js b/jstests/noPassthrough/column_store_index_load.js index 1c45a5e7257..69a1b281e2f 100644 --- a/jstests/noPassthrough/column_store_index_load.js +++ b/jstests/noPassthrough/column_store_index_load.js @@ -155,7 +155,7 @@ assert.between(0.7 * approxMemoryUsage, indexBulkBuilderSection.memUsage, 1.3 * approxMemoryUsage, tojson(indexBulkBuilderSection), - /*inclusive=*/true); + /*inclusive=*/ true); assert.eq(Object.keys(indexBulkBuilderSection).length, 10, tojson(indexBulkBuilderSection)); // Perform the external bulk load. The server config won't allow a memory limit lower than 50MB, so @@ -181,13 +181,13 @@ assert.between(expectedSpilledRanges - 1, indexBulkBuilderSection.spilledRanges, expectedSpilledRanges + 1, tojson(indexBulkBuilderSection), - /*inclusive=*/true); + /*inclusive=*/ true); // We can only approximate the memory usage and bytes that will be spilled. assert.between(0, indexBulkBuilderSection.bytesSpilled, approxMemoryUsage, tojson(indexBulkBuilderSection), - /*inclusive=*/true); + /*inclusive=*/ true); assert.gte(indexBulkBuilderSection.bytesSpilledUncompressed, indexBulkBuilderSection.bytesSpilled, tojson(indexBulkBuilderSection)); @@ -202,7 +202,7 @@ assert.between(approxMemoryUsage * 0.7, indexBulkBuilderSection.memUsage, approxMemoryUsage * 1.3, tojson(indexBulkBuilderSection), - /*inclusive=*/true); + /*inclusive=*/ true); // Perfom the online load. onlineLoadColl.drop(); diff --git a/jstests/noPassthrough/drop_indexes_aborts_index_builder_matching_input.js b/jstests/noPassthrough/drop_indexes_aborts_index_builder_matching_input.js index d58477f67b1..48dac331485 100644 --- a/jstests/noPassthrough/drop_indexes_aborts_index_builder_matching_input.js +++ b/jstests/noPassthrough/drop_indexes_aborts_index_builder_matching_input.js @@ -40,7 +40,7 @@ const awaitSecondIndexBuild = IndexBuildTest.startIndexBuild( IndexBuildTest.waitForIndexBuildToScanCollection(testDB, collName, "c_1"); IndexBuildTest.assertIndexes( - coll, /*numIndexes=*/4, /*readyIndexes=*/["_id_", "a_1"], /*notReadyIndexes=*/["b_1", "c_1"]); + coll, /*numIndexes=*/ 4, /*readyIndexes=*/["_id_", "a_1"], /*notReadyIndexes=*/["b_1", "c_1"]); // 'dropIndexes' will only abort in-progress index builds if the 'index' parameter specifies all of // the indexes that a single builder is building together. @@ -60,8 +60,10 @@ IndexBuildTest.resumeIndexBuilds(testDB.getMongo()); awaitFirstIndexBuild(); awaitSecondIndexBuild(); -IndexBuildTest.assertIndexes( - coll, /*numIndexes=*/4, /*readyIndexes=*/["_id_", "a_1", "b_1", "c_1"], /*notReadyIndexes=*/[]); +IndexBuildTest.assertIndexes(coll, + /*numIndexes=*/ 4, + /*readyIndexes=*/["_id_", "a_1", "b_1", "c_1"], + /*notReadyIndexes=*/[]); MongoRunner.stopMongod(conn); }()); diff --git a/jstests/noPassthrough/drop_pending_retry.js b/jstests/noPassthrough/drop_pending_retry.js index 0e228702b36..f726345d405 100644 --- a/jstests/noPassthrough/drop_pending_retry.js +++ b/jstests/noPassthrough/drop_pending_retry.js @@ -40,7 +40,7 @@ assert.commandWorked(db.createCollection("toDrop")); assert.commandWorked(db.createCollection("toWrite")); const collUri = getUriForColl(db.getCollection("toDrop")); -const indexUri = getUriForIndex(db.getCollection("toDrop"), /*indexName=*/"_id_"); +const indexUri = getUriForIndex(db.getCollection("toDrop"), /*indexName=*/ "_id_"); assert(db.getCollection("toDrop").drop()); diff --git a/jstests/noPassthrough/drop_ready_index_while_building_an_index.js b/jstests/noPassthrough/drop_ready_index_while_building_an_index.js index 7f03686f0ca..4be7f0384a6 100644 --- a/jstests/noPassthrough/drop_ready_index_while_building_an_index.js +++ b/jstests/noPassthrough/drop_ready_index_while_building_an_index.js @@ -41,18 +41,20 @@ IndexBuildTest.waitForIndexBuildToScanCollection(db, collName, "y_1"); IndexBuildTest.waitForIndexBuildToScanCollection(secondaryDB, collName, "y_1"); IndexBuildTest.assertIndexes( - coll, /*numIndexes=*/3, /*readyIndexes=*/["_id_", "x_1"], /*notReadyIndexes=*/["y_1"]); -IndexBuildTest.assertIndexes( - secondaryColl, /*numIndexes=*/3, /*readyIndexes=*/["_id_", "x_1"], /*notReadyIndexes=*/["y_1"]); + coll, /*numIndexes=*/ 3, /*readyIndexes=*/["_id_", "x_1"], /*notReadyIndexes=*/["y_1"]); +IndexBuildTest.assertIndexes(secondaryColl, + /*numIndexes=*/ 3, + /*readyIndexes=*/["_id_", "x_1"], + /*notReadyIndexes=*/["y_1"]); // Drop the ready index while another index build is in-progress. assert.commandWorked(coll.dropIndex("x_1")); rst.awaitReplication(); IndexBuildTest.assertIndexes( - coll, /*numIndexes=*/2, /*readyIndexes=*/["_id_"], /*notReadyIndexes=*/["y_1"]); + coll, /*numIndexes=*/ 2, /*readyIndexes=*/["_id_"], /*notReadyIndexes=*/["y_1"]); IndexBuildTest.assertIndexes( - secondaryColl, /*numIndexes=*/2, /*readyIndexes=*/["_id_"], /*notReadyIndexes=*/["y_1"]); + secondaryColl, /*numIndexes=*/ 2, /*readyIndexes=*/["_id_"], /*notReadyIndexes=*/["y_1"]); IndexBuildTest.resumeIndexBuilds(primary); IndexBuildTest.resumeIndexBuilds(secondary); @@ -61,9 +63,9 @@ awaitIndexBuild(); rst.awaitReplication(); IndexBuildTest.assertIndexes( - coll, /*numIndexes=*/2, /*readyIndexes=*/["_id_", "y_1"], /*notReadyIndexes=*/[]); + coll, /*numIndexes=*/ 2, /*readyIndexes=*/["_id_", "y_1"], /*notReadyIndexes=*/[]); IndexBuildTest.assertIndexes( - secondaryColl, /*numIndexes=*/2, /*readyIndexes=*/["_id_", "y_1"], /*notReadyIndexes=*/[]); + secondaryColl, /*numIndexes=*/ 2, /*readyIndexes=*/["_id_", "y_1"], /*notReadyIndexes=*/[]); rst.stopSet(); }()); diff --git a/jstests/noPassthrough/index_build_restart_standalone.js b/jstests/noPassthrough/index_build_restart_standalone.js index bed34286d0f..4adbc3055cb 100644 --- a/jstests/noPassthrough/index_build_restart_standalone.js +++ b/jstests/noPassthrough/index_build_restart_standalone.js @@ -58,7 +58,7 @@ assert.commandWorked(secondary.adminCommand({fsync: 1})); jsTest.log("Checkpoints taken. Stopping replica set to restart individual nodes in standalone."); TestData.skipCheckDBHashes = true; -rst.stopSet(/*signal=*/null, /*forRestart=*/true); +rst.stopSet(/*signal=*/ null, /*forRestart=*/ true); TestData.skipCheckDBHashes = false; function restartStandalone(node) { diff --git a/jstests/noPassthrough/initial_sync_drops_ready_indexes_while_having_index_builds.js b/jstests/noPassthrough/initial_sync_drops_ready_indexes_while_having_index_builds.js index ee9e3ecf305..64d754009ee 100644 --- a/jstests/noPassthrough/initial_sync_drops_ready_indexes_while_having_index_builds.js +++ b/jstests/noPassthrough/initial_sync_drops_ready_indexes_while_having_index_builds.js @@ -101,11 +101,11 @@ IndexBuildTest.resumeIndexBuilds(secondary); awaitIndexBuild(); IndexBuildTest.assertIndexes( - coll, /*numIndexes=*/2, /*readyIndexes=*/["_id_", "b_1"], /*notReadyIndexes=*/[]); + coll, /*numIndexes=*/ 2, /*readyIndexes=*/["_id_", "b_1"], /*notReadyIndexes=*/[]); const secondaryColl = secondary.getDB(dbName).getCollection(collName); IndexBuildTest.assertIndexes( - secondaryColl, /*numIndexes=*/2, /*readyIndexes=*/["_id_", "b_1"], /*notReadyIndexes=*/[]); + secondaryColl, /*numIndexes=*/ 2, /*readyIndexes=*/["_id_", "b_1"], /*notReadyIndexes=*/[]); rst.stopSet(); }()); diff --git a/jstests/noPassthrough/libs/index_build.js b/jstests/noPassthrough/libs/index_build.js index 481f6500d2e..fa898cc5348 100644 --- a/jstests/noPassthrough/libs/index_build.js +++ b/jstests/noPassthrough/libs/index_build.js @@ -247,7 +247,7 @@ var IndexBuildTest = class { */ static buildIndexOnNodeAsStandalone(rst, node, port, dbName, collName, indexSpec, indexName) { jsTestLog('Restarting as standalone: ' + node.host); - rst.stop(node, /*signal=*/null, /*opts=*/null, {forRestart: true, waitpid: true}); + rst.stop(node, /*signal=*/ null, /*opts=*/ null, {forRestart: true, waitpid: true}); const standalone = MongoRunner.runMongod({ restart: true, dbpath: node.dbpath, diff --git a/jstests/noPassthrough/list_indexes_index_build_info.js b/jstests/noPassthrough/list_indexes_index_build_info.js index f379fdf9a16..69d2c1cc7f1 100644 --- a/jstests/noPassthrough/list_indexes_index_build_info.js +++ b/jstests/noPassthrough/list_indexes_index_build_info.js @@ -178,7 +178,7 @@ const awaitIndexBuild = IndexBuildTest.startIndexBuild(conn, {b: 1}, {name: buildingIndexName}, [], - /*commitQuorum=*/"votingMembers"); + /*commitQuorum=*/ "votingMembers"); const buildingOpId = IndexBuildTest.waitForIndexBuildToScanCollection(db, collName, buildingIndexName); @@ -191,7 +191,7 @@ const awaitIndexBuildNonResumable = {c: 1}, {name: buildingIndexNameNonResumable}, [], - /*commitQuorum=*/0); + /*commitQuorum=*/ 0); const buildingOpIdNonResumable = IndexBuildTest.waitForIndexBuildToScanCollection(db, collName, buildingIndexNameNonResumable); diff --git a/jstests/noPassthrough/mirrored_reads_slow_query.js b/jstests/noPassthrough/mirrored_reads_slow_query.js index fadb4676882..ef022901f95 100644 --- a/jstests/noPassthrough/mirrored_reads_slow_query.js +++ b/jstests/noPassthrough/mirrored_reads_slow_query.js @@ -29,18 +29,18 @@ function verifySlowLogsIndicateMirroredReads(rst, cmd) { assert(checkLog.checkContainsWithCountJson(primaryAdminDb, logId, {mirrored: true}, - /*expectedCount=*/0, - /*severity=*/null, - /*isRelaxed=*/true)); + /*expectedCount=*/ 0, + /*severity=*/ null, + /*isRelaxed=*/ true)); assert.soon(() => { // Check that the secondary slow log message is printed with mirrored: true. return checkLog.checkContainsWithCountJson( secondaryAdminDb, logId, {mirrored: true, ns: kDbName.concat(".", kCollName)}, - /*expectedCount=*/1, - /*severity=*/null, - /*isRelaxed=*/true); + /*expectedCount=*/ 1, + /*severity=*/ null, + /*isRelaxed=*/ true); }); assert.commandWorked(secondaryAdminDb.adminCommand({clearLog: "global"})); } diff --git a/jstests/noPassthrough/point_in_time_lookups.js b/jstests/noPassthrough/point_in_time_lookups.js index 81c698540ce..16ab35d642c 100644 --- a/jstests/noPassthrough/point_in_time_lookups.js +++ b/jstests/noPassthrough/point_in_time_lookups.js @@ -112,118 +112,122 @@ const runPointInTimeTests = function() { (function oldestTimestampTests() { // Point-in-time reads on a collection before it was created should have like reading from a // non-existent collection. - find(coll().getName(), /*withIndex=*/false, oldestTS, /*numDocs=*/0); - find(coll().getName(), /*withIndex=*/true, oldestTS, /*numDocs=*/0); - find("renamed", /*withIndex=*/false, oldestTS, /*numDocs=*/0); - find("renamed", /*withIndex=*/true, oldestTS, /*numDocs=*/0); + find(coll().getName(), /*withIndex=*/ false, oldestTS, /*numDocs=*/ 0); + find(coll().getName(), /*withIndex=*/ true, oldestTS, /*numDocs=*/ 0); + find("renamed", /*withIndex=*/ false, oldestTS, /*numDocs=*/ 0); + find("renamed", /*withIndex=*/ true, oldestTS, /*numDocs=*/ 0); })(); (function createTimestampTests() { // Reading at 'createTS' from the original collection should not find any document yet. // Using the index at this point returns BadValue from hint as it does not exist yet. - find(coll().getName(), /*withIndex=*/false, createTS, /*numDocs=*/0); - find(coll().getName(), /*withIndex=*/true, createTS, /*numDocs=*/0, /*expectedError=*/true); + find(coll().getName(), /*withIndex=*/ false, createTS, /*numDocs=*/ 0); + find(coll().getName(), + /*withIndex=*/ true, + createTS, + /*numDocs=*/ 0, + /*expectedError=*/ true); // Reading at 'createTS' from the renamed collection should not find any document as it was // non-existent. - find("renamed", /*withIndex=*/false, createTS, /*numDocs=*/0); - find("renamed", /*withIndex=*/true, createTS, /*numDocs=*/0); + find("renamed", /*withIndex=*/ false, createTS, /*numDocs=*/ 0); + find("renamed", /*withIndex=*/ true, createTS, /*numDocs=*/ 0); })(); (function firstInsertTimestampTests() { // Reading at 'firstInsertTS' from the original collection should find a document. Using the // index at this point returns BadValue from hint as it does not exist yet. - find(coll().getName(), /*withIndex=*/false, firstInsertTS, /*numDocs=*/1); + find(coll().getName(), /*withIndex=*/ false, firstInsertTS, /*numDocs=*/ 1); find(coll().getName(), - /*withIndex=*/true, + /*withIndex=*/ true, firstInsertTS, - /*numDocs=*/0, - /*expectedError=*/true); + /*numDocs=*/ 0, + /*expectedError=*/ true); // Reading at 'firstInsertTS' from the renamed collection should not find any document as it // was non-existent. - find("renamed", /*withIndex=*/false, firstInsertTS, /*numDocs=*/0); - find("renamed", /*withIndex=*/true, firstInsertTS, /*numDocs=*/0); + find("renamed", /*withIndex=*/ false, firstInsertTS, /*numDocs=*/ 0); + find("renamed", /*withIndex=*/ true, firstInsertTS, /*numDocs=*/ 0); })(); (function indexTimestampTests() { // Reading at 'indexTS' from the original collection should find a document. This includes // with the index as it now exists. - find(coll().getName(), /*withIndex=*/false, indexTS, /*numDocs=*/1); - find(coll().getName(), /*withIndex=*/true, indexTS, /*numDocs=*/1); + find(coll().getName(), /*withIndex=*/ false, indexTS, /*numDocs=*/ 1); + find(coll().getName(), /*withIndex=*/ true, indexTS, /*numDocs=*/ 1); // Reading at 'indexTS' from the renamed collection should not find any document as it was // non-existent. - find("renamed", /*withIndex=*/false, indexTS, /*numDocs=*/0); - find("renamed", /*withIndex=*/true, indexTS, /*numDocs=*/0); + find("renamed", /*withIndex=*/ false, indexTS, /*numDocs=*/ 0); + find("renamed", /*withIndex=*/ true, indexTS, /*numDocs=*/ 0); })(); (function secondInsertTimestampTests() { // Reading at 'secondInsertTS' from the original collection should find two documents. This // includes with the index as it now exists. - find(coll().getName(), /*withIndex=*/false, secondInsertTS, /*numDocs=*/2); - find(coll().getName(), /*withIndex=*/true, secondInsertTS, /*numDocs=*/2); + find(coll().getName(), /*withIndex=*/ false, secondInsertTS, /*numDocs=*/ 2); + find(coll().getName(), /*withIndex=*/ true, secondInsertTS, /*numDocs=*/ 2); // Reading at 'secondInsertTS' from the renamed collection should not find any document as // it was non-existent. - find("renamed", /*withIndex=*/false, secondInsertTS, /*numDocs=*/0); - find("renamed", /*withIndex=*/true, secondInsertTS, /*numDocs=*/0); + find("renamed", /*withIndex=*/ false, secondInsertTS, /*numDocs=*/ 0); + find("renamed", /*withIndex=*/ true, secondInsertTS, /*numDocs=*/ 0); })(); (function renameTimestampTests() { // Reading at 'renameTS' from the original collection should not find any document as it was // non-existent at this time. - find(coll().getName(), /*withIndex=*/false, renameTS, /*numDocs=*/0); - find(coll().getName(), /*withIndex=*/true, renameTS, /*numDocs=*/0); + find(coll().getName(), /*withIndex=*/ false, renameTS, /*numDocs=*/ 0); + find(coll().getName(), /*withIndex=*/ true, renameTS, /*numDocs=*/ 0); // Reading at 'renameTS' from the renamed collection should find two documents. This // includes with the index as it now exists. - find("renamed", /*withIndex=*/false, renameTS, /*numDocs=*/2); - find("renamed", /*withIndex=*/true, renameTS, /*numDocs=*/2); + find("renamed", /*withIndex=*/ false, renameTS, /*numDocs=*/ 2); + find("renamed", /*withIndex=*/ true, renameTS, /*numDocs=*/ 2); })(); (function dropTimestampTests() { // Reading at 'dropTS' from the original collection should not find any document as it was // non-existent at this time. - find(coll().getName(), /*withIndex=*/false, dropTS, /*numDocs=*/0); - find(coll().getName(), /*withIndex=*/true, dropTS, /*numDocs=*/0); + find(coll().getName(), /*withIndex=*/ false, dropTS, /*numDocs=*/ 0); + find(coll().getName(), /*withIndex=*/ true, dropTS, /*numDocs=*/ 0); // Reading at 'dropTS' from the renamed collection should not find any document as it was // non-existent at this time. - find("renamed", /*withIndex=*/false, dropTS, /*numDocs=*/0); - find("renamed", /*withIndex=*/true, dropTS, /*numDocs=*/0); + find("renamed", /*withIndex=*/ false, dropTS, /*numDocs=*/ 0); + find("renamed", /*withIndex=*/ true, dropTS, /*numDocs=*/ 0); })(); (function recreatedTimestampTests() { // Reading at 'recreatedTS' from the original collection should not find any document yet. // Using the index at this point returns BadValue from hint as it does not exist yet. - find(coll().getName(), /*withIndex=*/false, recreatedTS, /*numDocs=*/0); + find(coll().getName(), /*withIndex=*/ false, recreatedTS, /*numDocs=*/ 0); find(coll().getName(), - /*withIndex=*/true, + /*withIndex=*/ true, recreatedTS, - /*numDocs=*/0, - /*expectedError=*/true); + /*numDocs=*/ 0, + /*expectedError=*/ true); // Reading at 'recreatedTS' from the renamed collection should not find any document as it // was non-existent. - find("renamed", /*withIndex=*/false, recreatedTS, /*numDocs=*/0); - find("renamed", /*withIndex=*/true, recreatedTS, /*numDocs=*/0); + find("renamed", /*withIndex=*/ false, recreatedTS, /*numDocs=*/ 0); + find("renamed", /*withIndex=*/ true, recreatedTS, /*numDocs=*/ 0); })(); (function thirdInsertTimestampTests() { // Reading at 'thirdInsertTS' from the original collection should find a document. Using the // index at this point returns BadValue from hint as it does not exist yet. - find(coll().getName(), /*withIndex=*/false, thirdInsertTS, /*numDocs=*/1); + find(coll().getName(), /*withIndex=*/ false, thirdInsertTS, /*numDocs=*/ 1); find(coll().getName(), - /*withIndex=*/true, + /*withIndex=*/ true, thirdInsertTS, - /*numDocs=*/0, - /*expectedError=*/true); + /*numDocs=*/ 0, + /*expectedError=*/ true); // Reading at 'thirdInsertTS' from the renamed collection should not find any document as it // was non-existent. - find("renamed", /*withIndex=*/false, thirdInsertTS, /*numDocs=*/0); - find("renamed", /*withIndex=*/true, thirdInsertTS, /*numDocs=*/0); + find("renamed", /*withIndex=*/ false, thirdInsertTS, /*numDocs=*/ 0); + find("renamed", /*withIndex=*/ true, thirdInsertTS, /*numDocs=*/ 0); })(); }; diff --git a/jstests/noPassthrough/read_only_allow_disk_use.js b/jstests/noPassthrough/read_only_allow_disk_use.js index 8162d6c736d..a6fc5ea4013 100644 --- a/jstests/noPassthrough/read_only_allow_disk_use.js +++ b/jstests/noPassthrough/read_only_allow_disk_use.js @@ -125,7 +125,7 @@ rst.startSet(); rst.initiate(); const primary = rst.getPrimary(); prepareData(primary); -rst.stopSet(/*signal=*/null, /*forRestart=*/true); +rst.stopSet(/*signal=*/ null, /*forRestart=*/ true); const tightMemoryLimits = { internalDocumentSourceGroupMaxMemoryBytes: memoryLimitBytes, diff --git a/jstests/noPassthrough/rename_collection_across_dbs.js b/jstests/noPassthrough/rename_collection_across_dbs.js index 919e0cd25ad..5c2c3b8810a 100644 --- a/jstests/noPassthrough/rename_collection_across_dbs.js +++ b/jstests/noPassthrough/rename_collection_across_dbs.js @@ -15,7 +15,7 @@ let dbName2 = testName + '1-2'; const collName = "test"; const collCount = 10; const maxInsertsCount = collCount; -const maxInsertsSize = /*single object size=*/14 * maxInsertsCount * 3; +const maxInsertsSize = /*single object size=*/ 14 * maxInsertsCount * 3; let srcNs = dbName1 + '.' + collName; let dstNs = dbName2 + '.' + collName; diff --git a/jstests/noPassthrough/resumable_timeseries_index_build_collection_scan_phase.js b/jstests/noPassthrough/resumable_timeseries_index_build_collection_scan_phase.js index 4357afd8621..749735e62f0 100644 --- a/jstests/noPassthrough/resumable_timeseries_index_build_collection_scan_phase.js +++ b/jstests/noPassthrough/resumable_timeseries_index_build_collection_scan_phase.js @@ -54,7 +54,7 @@ ResumableIndexBuildTest.run( bucketColl.getName(), [[{"control.min.time": 1}, {"control.max.time": 1}]], [{name: "hangIndexBuildDuringCollectionScanPhaseAfterInsertion", logIdWithBuildUUID: 20386}], - /*iteration=*/0, + /*iteration=*/ 0, ["collection scan"], [{numScannedAfterResume: 2}]); diff --git a/jstests/noPassthrough/salvage_incomplete_rolling_index_builds.js b/jstests/noPassthrough/salvage_incomplete_rolling_index_builds.js index e6c3e017e9e..27534d6a755 100644 --- a/jstests/noPassthrough/salvage_incomplete_rolling_index_builds.js +++ b/jstests/noPassthrough/salvage_incomplete_rolling_index_builds.js @@ -68,7 +68,7 @@ jsTestLog("Standalone server will listen on port: " + standalonePort); function buildIndexOnNodeAsStandalone(node) { jsTestLog("A. Restarting as standalone: " + node.host); - replTest.stop(node, /*signal=*/null, /*opts=*/null, {forRestart: true, waitpid: true}); + replTest.stop(node, /*signal=*/ null, /*opts=*/ null, {forRestart: true, waitpid: true}); const standalone = MongoRunner.runMongod({ restart: true, dbpath: node.dbpath, diff --git a/jstests/noPassthrough/serverstatus_indexbulkbuilder.js b/jstests/noPassthrough/serverstatus_indexbulkbuilder.js index 603a28198da..01c914d136d 100644 --- a/jstests/noPassthrough/serverstatus_indexbulkbuilder.js +++ b/jstests/noPassthrough/serverstatus_indexbulkbuilder.js @@ -56,18 +56,18 @@ assert.between(expectedSpilledRanges, indexBulkBuilderSection.spilledRanges, 1 + expectedSpilledRanges, tojson(indexBulkBuilderSection), - /*inclusive=*/true); + /*inclusive=*/ true); assert.between(0, indexBulkBuilderSection.bytesSpilled, approxMemoryUsage, tojson(indexBulkBuilderSection), - /*inclusive=*/true); + /*inclusive=*/ true); // We write out a single byte for every spilled doc, which is included in the uncompressed size. assert.between(0, indexBulkBuilderSection.bytesSpilledUncompressed, approxMemoryUsage + spillOverhead, tojson(indexBulkBuilderSection), - /*inclusive=*/true); + /*inclusive=*/ true); assert.eq(indexBulkBuilderSection.numSorted, numDocs, tojson(indexBulkBuilderSection)); // Expect total bytes sorted to be greater than approxMemoryUsage because of the additional field in // the documents inserted which accounts for more bytes than in the rough calculation. @@ -76,7 +76,7 @@ assert.between(0, indexBulkBuilderSection.memUsage, approxMemoryUsage, tojson(indexBulkBuilderSection), - /*inclusive=*/true); + /*inclusive=*/ true); (function resumeIndexBuild() { jsTestLog( @@ -85,14 +85,14 @@ assert.between(0, const createIdx = IndexBuildTest.startIndexBuild(primary, coll.getFullName(), {b: 1}, - /*options=*/{}, + /*options=*/ {}, [ErrorCodes.InterruptedDueToReplStateChange]); IndexBuildTest.waitForIndexBuildToScanCollection(testDB, coll.getName(), 'b_1'); const buildUUID = extractUUIDFromObject( IndexBuildTest .assertIndexes(coll, 3, ['_id_', 'a_1'], ['b_1'], {includeBuildUUIDs: true})['b_1'] .buildUUID); - replSet.restart(/*nodeId=*/0); + replSet.restart(/*nodeId=*/ 0); createIdx(); primary = replSet.getPrimary(); testDB = primary.getDB('test'); @@ -112,14 +112,14 @@ assert.between(0, indexBulkBuilderSection.bytesSpilled, approxMemoryUsage, tojson(indexBulkBuilderSection), - /*inclusive=*/true); + /*inclusive=*/ true); assert.between(0, indexBulkBuilderSection.bytesSpilledUncompressed, // We write out some extra data for every spilled doc, which is included in the // uncompressed size. approxMemoryUsage + spillOverhead, tojson(indexBulkBuilderSection), - /*inclusive=*/true); + /*inclusive=*/ true); assert.eq(indexBulkBuilderSection.numSorted, 0, tojson(indexBulkBuilderSection)); assert.eq(indexBulkBuilderSection.bytesSorted, 0, tojson(indexBulkBuilderSection)); assert.eq(indexBulkBuilderSection.memUsage, 0, tojson(indexBulkBuilderSection)); @@ -154,19 +154,19 @@ assert.between(expectedSpilledRanges, indexBulkBuilderSection.spilledRanges, 1 + expectedSpilledRanges, tojson(indexBulkBuilderSection), - /*inclusive=*/true); + /*inclusive=*/ true); assert.between(0, indexBulkBuilderSection.bytesSpilled, approxMemoryUsage, tojson(indexBulkBuilderSection), - /*inclusive=*/true); + /*inclusive=*/ true); assert.between(0, indexBulkBuilderSection.bytesSpilledUncompressed, // We write out some extra data for every spilled doc, which is included in the // uncompressed size. approxMemoryUsage + spillOverhead, tojson(indexBulkBuilderSection), - /*inclusive=*/true); + /*inclusive=*/ true); // Expect at least all documents in the collection are sorted for three indexes but there may also // be internal indexes with additional sorts. assert.gte(indexBulkBuilderSection.numSorted, numDocs * 3, tojson(indexBulkBuilderSection)); @@ -179,7 +179,7 @@ assert.between(0, indexBulkBuilderSection.memUsage, approxMemoryUsage, tojson(indexBulkBuilderSection), - /*inclusive=*/true); + /*inclusive=*/ true); // Building multiple indexes in a single createIndex command increases count by the number of // indexes requested. @@ -199,19 +199,19 @@ assert.between(expectedSpilledRanges, indexBulkBuilderSection.spilledRanges, 1 + expectedSpilledRanges, tojson(indexBulkBuilderSection), - /*inclusive=*/true); + /*inclusive=*/ true); assert.between(0, indexBulkBuilderSection.bytesSpilled, approxMemoryUsage, tojson(indexBulkBuilderSection), - /*inclusive=*/true); + /*inclusive=*/ true); assert.between(0, indexBulkBuilderSection.bytesSpilledUncompressed, // We write out some extra data for every spilled doc, which is included in the // uncompressed size. approxMemoryUsage + spillOverhead, tojson(indexBulkBuilderSection), - /*inclusive=*/true); + /*inclusive=*/ true); assert.eq(indexBulkBuilderSection.numSorted, numDocs * 3, tojson(indexBulkBuilderSection)); // We are sorting on index keys and keystring sizes are encoded to its necessary bytes so we are // approximating that _id and b will be at least 3 bytes each to account for the integer value, the @@ -222,7 +222,7 @@ assert.between(0, indexBulkBuilderSection.memUsage, approxMemoryUsage, tojson(indexBulkBuilderSection), - /*inclusive=*/true); + /*inclusive=*/ true); replSet.stopSet(); })(); diff --git a/jstests/noPassthrough/ttl_invalid_expire_after_secs.js b/jstests/noPassthrough/ttl_invalid_expire_after_secs.js index 4972c1106a4..a103fa3bcc6 100644 --- a/jstests/noPassthrough/ttl_invalid_expire_after_secs.js +++ b/jstests/noPassthrough/ttl_invalid_expire_after_secs.js @@ -117,13 +117,13 @@ function test(expireAfterSecondsVal) { 'o.index.name': 't_1', 'o.index.expireAfterSeconds': newNodeSpec.expireAfterSeconds }, - /*limit=*/1) + /*limit=*/ 1) .toArray(); assert.eq(collModOplogEntries.length, 1, 'TTL index with ' + expireAfterSecondsVal + ' expireAfterSeconds was not fixed using collMod during step-up: ' + - tojson(rst.findOplog(primary, {op: {$ne: 'n'}}, /*limit=*/10).toArray())); + tojson(rst.findOplog(primary, {op: {$ne: 'n'}}, /*limit=*/ 10).toArray())); rst.stopSet(); } diff --git a/jstests/noPassthrough/validate_multikey_compound.js b/jstests/noPassthrough/validate_multikey_compound.js index f923b94e562..d15990b8425 100644 --- a/jstests/noPassthrough/validate_multikey_compound.js +++ b/jstests/noPassthrough/validate_multikey_compound.js @@ -44,7 +44,7 @@ assert.eq(2, docs[1]._id, 'unexpected document content in collection: ' + tojson // For the purpose of reproducing the validation error in a_1, it is important to skip validation // when restarting the primary node. Enabling validation here has an effect on the validate // command's behavior after restarting. -primary = rst.restart(primary, {skipValidation: true}, /*signal=*/undefined, /*wait=*/true); +primary = rst.restart(primary, {skipValidation: true}, /*signal=*/ undefined, /*wait=*/ true); testColl = primary.getCollection(testColl.getFullName()); jsTestLog('Checking documents in collection after restart'); diff --git a/jstests/noPassthrough/validate_multikey_restart.js b/jstests/noPassthrough/validate_multikey_restart.js index e57f84c2229..31f9a762846 100644 --- a/jstests/noPassthrough/validate_multikey_restart.js +++ b/jstests/noPassthrough/validate_multikey_restart.js @@ -47,7 +47,7 @@ assert.eq(1, // For the purpose of reproducing the validation error in a_1, it is important to skip validation // when restarting the primary node. Enabling validation here has an effect on the validate // command's behavior after restarting. -primary = rst.restart(primary, {skipValidation: true}, /*signal=*/undefined, /*wait=*/true); +primary = rst.restart(primary, {skipValidation: true}, /*signal=*/ undefined, /*wait=*/ true); testColl = primary.getCollection(testColl.getFullName()); jsTestLog('Checking documents in collection after restart'); diff --git a/jstests/noPassthrough/validate_multikey_stepdown.js b/jstests/noPassthrough/validate_multikey_stepdown.js index 9ca5012a656..e9b24969725 100644 --- a/jstests/noPassthrough/validate_multikey_stepdown.js +++ b/jstests/noPassthrough/validate_multikey_stepdown.js @@ -96,7 +96,7 @@ assert.eq( // For the purpose of reproducing the validation error in geo_2dsphere, it is important to skip // validation when restarting the primary node. Enabling validation here has an effect on the // validate command's behavior after restarting. -primary = rst.restart(primary, {skipValidation: true}, /*signal=*/undefined, /*wait=*/true); +primary = rst.restart(primary, {skipValidation: true}, /*signal=*/ undefined, /*wait=*/ true); testColl = primary.getCollection(testColl.getFullName()); jsTestLog('Checking documents in collection after restart'); diff --git a/jstests/noPassthroughWithMongod/btreedel.js b/jstests/noPassthroughWithMongod/btreedel.js index 868a26fafba..221c04a2fc5 100644 --- a/jstests/noPassthroughWithMongod/btreedel.js +++ b/jstests/noPassthroughWithMongod/btreedel.js @@ -1,46 +1,46 @@ -// btreedel.js
-// @tags: [SERVER-32869]
-
-t = db.foo;
-t.remove({});
-
-var bulk = t.initializeUnorderedBulkOp();
-for (var i = 0; i < 1000000; i++) {
- bulk.insert({_id: i, x: 'a b'});
-}
-assert.commandWorked(bulk.execute());
-
-print("1 insert done count: " + t.count());
-
-var c = t.find({y: null}).sort({_id: 1});
-for (var j = 0; j < 400000; j++) {
- c.next();
- if (j % 200000 == 0)
- printjson(c.next());
-}
-printjson(c.next());
-
-var d = t.find({_id: {$gt: 300000}}).sort({_id: -1});
-d.next();
-
-print("2");
-
-t.remove({_id: {$gt: 200000, $lt: 600000}});
-
-print("3");
-print(d.hasNext());
-
-n = 0;
-last = {};
-printjson(c.next());
-while (c.hasNext()) {
- n++;
- last = c.next();
-}
-
-print("4. n:" + n);
-printjson(last);
-
-assert(n > 100000);
-
-print("btreedel.js success");
+// btreedel.js +// @tags: [SERVER-32869] + +t = db.foo; +t.remove({}); + +var bulk = t.initializeUnorderedBulkOp(); +for (var i = 0; i < 1000000; i++) { + bulk.insert({_id: i, x: 'a b'}); +} +assert.commandWorked(bulk.execute()); + +print("1 insert done count: " + t.count()); + +var c = t.find({y: null}).sort({_id: 1}); +for (var j = 0; j < 400000; j++) { + c.next(); + if (j % 200000 == 0) + printjson(c.next()); +} +printjson(c.next()); + +var d = t.find({_id: {$gt: 300000}}).sort({_id: -1}); +d.next(); + +print("2"); + +t.remove({_id: {$gt: 200000, $lt: 600000}}); + +print("3"); +print(d.hasNext()); + +n = 0; +last = {}; +printjson(c.next()); +while (c.hasNext()) { + n++; + last = c.next(); +} + +print("4. n:" + n); +printjson(last); + +assert(n > 100000); + +print("btreedel.js success"); diff --git a/jstests/replsets/rollback_large_batched_multi_deletes.js b/jstests/replsets/rollback_large_batched_multi_deletes.js index 8d2cc181d31..d5f0f840a3c 100644 --- a/jstests/replsets/rollback_large_batched_multi_deletes.js +++ b/jstests/replsets/rollback_large_batched_multi_deletes.js @@ -63,7 +63,7 @@ const nodeOptions = { maxNumberOfBatchedOperationsInSingleOplogEntry: 2, }, }; -const rollbackTest = new RollbackTest(jsTestName(), /*replSet=*/undefined, nodeOptions); +const rollbackTest = new RollbackTest(jsTestName(), /*replSet=*/ undefined, nodeOptions); if (!FeatureFlagUtil.isEnabled(rollbackTest.getPrimary(), "InternalWritesAreReplicatedTransactionally")) { diff --git a/jstests/replsets/rollback_rename_collection_on_sync_source.js b/jstests/replsets/rollback_rename_collection_on_sync_source.js index d3a1511f24a..2084aecfd76 100644 --- a/jstests/replsets/rollback_rename_collection_on_sync_source.js +++ b/jstests/replsets/rollback_rename_collection_on_sync_source.js @@ -47,7 +47,7 @@ let rollbackNode = rollbackTest.transitionToRollbackOperations(); RollbackOps(rollbackNode); let syncSourceNode = rollbackTest.transitionToSyncSourceOperationsBeforeRollback(); -SyncSourceOps(syncSourceNode, /*withinDB=*/true); +SyncSourceOps(syncSourceNode, /*withinDB=*/ true); // Wait for rollback to finish. rollbackTest.transitionToSyncSourceOperationsDuringRollback(); @@ -66,7 +66,7 @@ RollbackOps(rollbackNodeAcrossDBs); let syncSourceNodeAcrossDBs = rollbackTestAcrossDBs.transitionToSyncSourceOperationsBeforeRollback(); -SyncSourceOps(syncSourceNodeAcrossDBs, /*withinDB=*/false); +SyncSourceOps(syncSourceNodeAcrossDBs, /*withinDB=*/ false); // Wait for rollback to finish. rollbackTestAcrossDBs.transitionToSyncSourceOperationsDuringRollback(); diff --git a/jstests/replsets/standalone_recover_to_oplog_timestamp.js b/jstests/replsets/standalone_recover_to_oplog_timestamp.js index dce810664d6..82ca4d7653a 100644 --- a/jstests/replsets/standalone_recover_to_oplog_timestamp.js +++ b/jstests/replsets/standalone_recover_to_oplog_timestamp.js @@ -37,7 +37,7 @@ const docs = [{_id: 1, a: 1}]; const operationTime = assert.commandWorked(primaryDB.runCommand({insert: collName, documents: docs})).operationTime; -rst.stopSet(/*signal=*/null, /*forRestart=*/true); +rst.stopSet(/*signal=*/ null, /*forRestart=*/ true); // Restart as standalone in queryableBackupMode and run replication recovery up to the last insert. const primaryStandalone = MongoRunner.runMongod({ diff --git a/jstests/replsets/temp_namespace.js b/jstests/replsets/temp_namespace.js index a6a7a839ea6..7cb78c24860 100644 --- a/jstests/replsets/temp_namespace.js +++ b/jstests/replsets/temp_namespace.js @@ -65,7 +65,7 @@ assert.eq(countIndexesFor(secondaryDB, /temp\d$/), 4); // indexes (2 _id + 2 x) assert.eq(countCollection(secondaryDB, /keep\d$/), 4); // restart secondary and reconnect -replTest.restart(replTest.getNodeId(secondary), {}, /*wait=*/true); +replTest.restart(replTest.getNodeId(secondary), {}, /*wait=*/ true); // wait for the secondary to achieve secondary status assert.soon(function() { diff --git a/jstests/sharding/change_streams/lookup_change_stream_post_image_compound_shard_key.js b/jstests/sharding/change_streams/lookup_change_stream_post_image_compound_shard_key.js index be654754e3c..96bb832fd9b 100644 --- a/jstests/sharding/change_streams/lookup_change_stream_post_image_compound_shard_key.js +++ b/jstests/sharding/change_streams/lookup_change_stream_post_image_compound_shard_key.js @@ -63,22 +63,24 @@ for (let id = 0; id < nDocs; ++id) { assert.commandWorked(mongosColl.update(documentKey, {$set: {updatedCount: 1}})); } -[changeStreamSingleColl, changeStreamWholeDb].forEach(function(changeStream) { - jsTestLog(`Testing updateLookup on namespace ${changeStream._ns}`); - for (let id = 0; id < nDocs; ++id) { - assert.soon(() => changeStream.hasNext()); - let next = changeStream.next(); - assert.eq(next.operationType, "insert"); - assert.eq(next.documentKey, Object.merge(shardKeyFromId(id), {_id: id})); - - assert.soon(() => changeStream.hasNext()); - next = changeStream.next(); - assert.eq(next.operationType, "update"); - assert.eq(next.documentKey, Object.merge(shardKeyFromId(id), {_id: id})); - assert.docEq(Object.merge(shardKeyFromId(id), {_id: id, updatedCount: 1}), - next.fullDocument); - } -}); +[changeStreamSingleColl, + changeStreamWholeDb] + .forEach(function(changeStream) { + jsTestLog(`Testing updateLookup on namespace ${changeStream._ns}`); + for (let id = 0; id < nDocs; ++id) { + assert.soon(() => changeStream.hasNext()); + let next = changeStream.next(); + assert.eq(next.operationType, "insert"); + assert.eq(next.documentKey, Object.merge(shardKeyFromId(id), {_id: id})); + + assert.soon(() => changeStream.hasNext()); + next = changeStream.next(); + assert.eq(next.operationType, "update"); + assert.eq(next.documentKey, Object.merge(shardKeyFromId(id), {_id: id})); + assert.docEq(Object.merge(shardKeyFromId(id), {_id: id, updatedCount: 1}), + next.fullDocument); + } + }); // Test that the change stream can still see the updated post image, even if a chunk is // migrated. diff --git a/jstests/sharding/query/merge_stale_on_fields.js b/jstests/sharding/query/merge_stale_on_fields.js index 59066b5b59d..cbfb789fd25 100644 --- a/jstests/sharding/query/merge_stale_on_fields.js +++ b/jstests/sharding/query/merge_stale_on_fields.js @@ -81,10 +81,12 @@ function testEpochChangeDuringAgg({mergeSpec, failpoint, failpointData}) { // Use a failpoint to make the query feeding into the aggregate hang while we drop the // collection. - [st.rs0.getPrimary(), st.rs1.getPrimary()].forEach((mongod) => { - assert.commandWorked(mongod.adminCommand( - {configureFailPoint: failpoint, mode: "alwaysOn", data: failpointData || {}})); - }); + [st.rs0.getPrimary(), + st.rs1.getPrimary()] + .forEach((mongod) => { + assert.commandWorked(mongod.adminCommand( + {configureFailPoint: failpoint, mode: "alwaysOn", data: failpointData || {}})); + }); let parallelShellJoiner; try { diff --git a/jstests/sharding/read_does_not_create_namespaces.js b/jstests/sharding/read_does_not_create_namespaces.js index 21e50372c6b..57873da699d 100644 --- a/jstests/sharding/read_does_not_create_namespaces.js +++ b/jstests/sharding/read_does_not_create_namespaces.js @@ -1,15 +1,15 @@ -// This test ensures that just attempting to read from a non-existent database or collection won't
-// cause entries to be created in the catalog.
-(function() {
-
-var shardingTest = new ShardingTest({name: 'read_does_not_create_namespaces', shards: 1});
-var db = shardingTest.getDB('NonExistentDB');
-
-assert.isnull(db.nonExistentColl.findOne({}));
-
-// Neither the database nor the collection should have been created
-assert.isnull(shardingTest.getDB('config').databases.findOne({_id: 'NonExistentDB'}));
-assert.eq(-1, shardingTest.shard0.getDBNames().indexOf('NonExistentDB'));
-
-shardingTest.stop();
-})();
+// This test ensures that just attempting to read from a non-existent database or collection won't +// cause entries to be created in the catalog. +(function() { + +var shardingTest = new ShardingTest({name: 'read_does_not_create_namespaces', shards: 1}); +var db = shardingTest.getDB('NonExistentDB'); + +assert.isnull(db.nonExistentColl.findOne({})); + +// Neither the database nor the collection should have been created +assert.isnull(shardingTest.getDB('config').databases.findOne({_id: 'NonExistentDB'})); +assert.eq(-1, shardingTest.shard0.getDBNames().indexOf('NonExistentDB')); + +shardingTest.stop(); +})(); diff --git a/jstests/sharding/rename_across_mongos.js b/jstests/sharding/rename_across_mongos.js index 0c378c5054a..e14d5207f60 100644 --- a/jstests/sharding/rename_across_mongos.js +++ b/jstests/sharding/rename_across_mongos.js @@ -1,28 +1,28 @@ -(function() {
-
-'use strict';
-
-var st = new ShardingTest({name: 'rename_across_mongos', shards: 1, mongos: 2});
-var dbName = 'RenameDB';
-
-st.s0.getDB(dbName).dropDatabase();
-st.s1.getDB(dbName).dropDatabase();
-
-// Create collection on first mongos and insert a document
-assert.commandWorked(st.s0.getDB(dbName).runCommand({create: 'CollNameBeforeRename'}));
-assert.commandWorked(st.s0.getDB(dbName).CollNameBeforeRename.insert({Key: 1, Value: 1}));
-
-if (st.configRS) {
- // Ensure that the second mongos will see the newly created database metadata when
- // it tries to do the collection rename.
- st.configRS.awaitLastOpCommitted();
-}
-
-// Rename collection on second mongos and ensure the document is found
-assert.commandWorked(
- st.s1.getDB(dbName).CollNameBeforeRename.renameCollection('CollNameAfterRename'));
-assert.eq([{Key: 1, Value: 1}],
- st.s1.getDB(dbName).CollNameAfterRename.find({}, {_id: false}).toArray());
-
-st.stop();
-})();
+(function() { + +'use strict'; + +var st = new ShardingTest({name: 'rename_across_mongos', shards: 1, mongos: 2}); +var dbName = 'RenameDB'; + +st.s0.getDB(dbName).dropDatabase(); +st.s1.getDB(dbName).dropDatabase(); + +// Create collection on first mongos and insert a document +assert.commandWorked(st.s0.getDB(dbName).runCommand({create: 'CollNameBeforeRename'})); +assert.commandWorked(st.s0.getDB(dbName).CollNameBeforeRename.insert({Key: 1, Value: 1})); + +if (st.configRS) { + // Ensure that the second mongos will see the newly created database metadata when + // it tries to do the collection rename. + st.configRS.awaitLastOpCommitted(); +} + +// Rename collection on second mongos and ensure the document is found +assert.commandWorked( + st.s1.getDB(dbName).CollNameBeforeRename.renameCollection('CollNameAfterRename')); +assert.eq([{Key: 1, Value: 1}], + st.s1.getDB(dbName).CollNameAfterRename.find({}, {_id: false}).toArray()); + +st.stop(); +})(); diff --git a/jstests/sharding/update_compound_shard_key.js b/jstests/sharding/update_compound_shard_key.js index e81c5a7c633..9e2ee7f5a9e 100644 --- a/jstests/sharding/update_compound_shard_key.js +++ b/jstests/sharding/update_compound_shard_key.js @@ -108,15 +108,18 @@ function assertWouldChangeOwningShardUpdateResult(res, expectedUpdatedDoc) { // // Test behaviours common to update and upsert. -[false, true].forEach(function(isUpsert) { - // Full shard key in query matches the update document. - assertUpdateWorked({x: 4, y: 3, z: 3}, {x: 4, y: 3, z: 3, a: 0}, isUpsert, 0); - assertUpdateWorked({x: 4, _id: 0, z: 3, y: 3}, {x: 4, y: 3, z: 3, a: 0}, isUpsert, 0); - - // Case when upsert needs to insert a new document and the new document should belong in the - // same shard as the targeted shard. For non-upserts, it will be a no-op. - assertUpdateWorkedWithNoMatchingDoc({x: 4, y: 0, z: 0}, {x: 1, z: 3, y: 110, a: 90}, isUpsert); -}); +[false, + true] + .forEach(function(isUpsert) { + // Full shard key in query matches the update document. + assertUpdateWorked({x: 4, y: 3, z: 3}, {x: 4, y: 3, z: 3, a: 0}, isUpsert, 0); + assertUpdateWorked({x: 4, _id: 0, z: 3, y: 3}, {x: 4, y: 3, z: 3, a: 0}, isUpsert, 0); + + // Case when upsert needs to insert a new document and the new document should belong in the + // same shard as the targeted shard. For non-upserts, it will be a no-op. + assertUpdateWorkedWithNoMatchingDoc( + {x: 4, y: 0, z: 0}, {x: 1, z: 3, y: 110, a: 90}, isUpsert); + }); // // Test behaviours specific to non-upsert updates. @@ -250,16 +253,18 @@ if (WriteWithoutShardKeyTestUtil.isWriteWithoutShardKeyFeatureEnabled(st.s)) { // // Test behaviours common to update and upsert. -[false, true].forEach(function(isUpsert) { - // Full shard key in query. - assertUpdateWorked({x: 4, _id: 0, z: 3, y: 3}, {"$set": {opStyle: 1}}, isUpsert, 0); - assertUpdateWorked({x: 4, z: 3, y: 3}, {"$set": {opStyle: 2}}, isUpsert, 0); - - // Case when upsert needs to insert a new document and the new document should belong in the - // same shard as the targetted shard. For non-upserts, it will be a no op. - assertUpdateWorkedWithNoMatchingDoc( - {x: 4, y: 0, z: 0}, {"$set": {x: 1, z: 3, y: 111, a: 90}}, isUpsert); -}); +[false, + true] + .forEach(function(isUpsert) { + // Full shard key in query. + assertUpdateWorked({x: 4, _id: 0, z: 3, y: 3}, {"$set": {opStyle: 1}}, isUpsert, 0); + assertUpdateWorked({x: 4, z: 3, y: 3}, {"$set": {opStyle: 2}}, isUpsert, 0); + + // Case when upsert needs to insert a new document and the new document should belong in the + // same shard as the targetted shard. For non-upserts, it will be a no op. + assertUpdateWorkedWithNoMatchingDoc( + {x: 4, y: 0, z: 0}, {"$set": {x: 1, z: 3, y: 111, a: 90}}, isUpsert); + }); // Test behaviours specific to non-upsert updates. @@ -366,41 +371,45 @@ if (WriteWithoutShardKeyTestUtil.isWriteWithoutShardKeyFeatureEnabled(st.s)) { // // Test behaviours common to update and upsert. -[false, true].forEach(function(isUpsert) { - // Full shard key in query. - assertUpdateWorked( - {_id: 0, x: 4, z: 3, y: 3}, [{$addFields: {pipelineUpdate: isUpsert}}], isUpsert, 0); - assert.eq(1, - st.s.getDB(kDbName) - .coll.find({_id: 0, x: 4, z: 3, y: 3, pipelineUpdate: isUpsert}) - .itcount()); - assertUpdateWorkedWithNoMatchingDoc( - {_id: 15, x: 44, z: 3, y: 3}, [{$addFields: {pipelineUpdate: true}}], isUpsert); - assert.eq(isUpsert ? 1 : 0, - st.s.getDB(kDbName) - .coll.find({_id: 15, x: 44, z: 3, y: 3, pipelineUpdate: true}) - .itcount()); - - assertUpdateWorkedWithNoMatchingDoc( - {x: 45, z: 4, y: 3}, [{$addFields: {pipelineUpdate: true}}], isUpsert); - assert.eq(isUpsert ? 1 : 0, - st.s.getDB(kDbName).coll.find({x: 45, z: 4, y: 3, pipelineUpdate: true}).itcount()); - - // Case when upsert needs to insert a new document and the new document should belong in the - // same shard as the targeted shard. - assertUpdateWorkedWithNoMatchingDoc({x: 4, y: 0, z: 0}, - [{ - "$project": { - x: {$literal: 3}, - y: {$literal: 33}, - z: {$literal: 3}, - pipelineUpdate: {$literal: true} - } - }], - isUpsert); - assert.eq(isUpsert ? 1 : 0, - st.s.getDB(kDbName).coll.find({x: 3, z: 3, y: 33, pipelineUpdate: true}).itcount()); -}); +[false, + true] + .forEach(function(isUpsert) { + // Full shard key in query. + assertUpdateWorked( + {_id: 0, x: 4, z: 3, y: 3}, [{$addFields: {pipelineUpdate: isUpsert}}], isUpsert, 0); + assert.eq(1, + st.s.getDB(kDbName) + .coll.find({_id: 0, x: 4, z: 3, y: 3, pipelineUpdate: isUpsert}) + .itcount()); + assertUpdateWorkedWithNoMatchingDoc( + {_id: 15, x: 44, z: 3, y: 3}, [{$addFields: {pipelineUpdate: true}}], isUpsert); + assert.eq(isUpsert ? 1 : 0, + st.s.getDB(kDbName) + .coll.find({_id: 15, x: 44, z: 3, y: 3, pipelineUpdate: true}) + .itcount()); + + assertUpdateWorkedWithNoMatchingDoc( + {x: 45, z: 4, y: 3}, [{$addFields: {pipelineUpdate: true}}], isUpsert); + assert.eq( + isUpsert ? 1 : 0, + st.s.getDB(kDbName).coll.find({x: 45, z: 4, y: 3, pipelineUpdate: true}).itcount()); + + // Case when upsert needs to insert a new document and the new document should belong in the + // same shard as the targeted shard. + assertUpdateWorkedWithNoMatchingDoc({x: 4, y: 0, z: 0}, + [{ + "$project": { + x: {$literal: 3}, + y: {$literal: 33}, + z: {$literal: 3}, + pipelineUpdate: {$literal: true} + } + }], + isUpsert); + assert.eq( + isUpsert ? 1 : 0, + st.s.getDB(kDbName).coll.find({x: 3, z: 3, y: 33, pipelineUpdate: true}).itcount()); + }); // Test behaviours specific to non-upsert updates. diff --git a/jstests/slow1/geo_array1.js b/jstests/slow1/geo_array1.js index c15b6a7deec..c62ac597a19 100644 --- a/jstests/slow1/geo_array1.js +++ b/jstests/slow1/geo_array1.js @@ -60,8 +60,8 @@ rst.initiate(); const primary = rst.getPrimary(); -test(primary, /*index=*/true); -test(primary, /*index=*/false); +test(primary, /*index=*/ true); +test(primary, /*index=*/ false); rst.stopSet(); })(); diff --git a/jstests/third_party/fast_check/fc-3.1.0.js b/jstests/third_party/fast_check/fc-3.1.0.js index 4f59b47fbc1..02e2089c52e 100644 --- a/jstests/third_party/fast_check/fc-3.1.0.js +++ b/jstests/third_party/fast_check/fc-3.1.0.js @@ -2,9 +2,10 @@ var fc = (function() { 'use strict'; var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis - : typeof window !== 'undefined' - ? window - : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; + : typeof window !== 'undefined' ? window + : typeof global !== 'undefined' ? global + : typeof self !== 'undefined' ? self + : {}; function getDefaultExportFromCjs(x) { return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') @@ -1530,7 +1531,8 @@ var fc = (function() { } else { rangeSizeArrayIntValue.data[1] += 1; } - (0, UnsafeUniformArrayIntDistributionInternal_1.unsafeUniformArrayIntDistributionInternal)( + (0, + UnsafeUniformArrayIntDistributionInternal_1.unsafeUniformArrayIntDistributionInternal)( sharedData, rangeSizeArrayIntValue.data, rng); return sharedData[0] * 0x100000000 + sharedData[1] + from; } @@ -2006,9 +2008,9 @@ var fc = (function() { } const mapper = (k) => `${ k === '__proto__' ? '["__proto__"]' - : typeof k === 'symbol' - ? `[${stringifyInternal(k, currentValues, getAsyncContent)}]` - : JSON.stringify(k)}:${ + : typeof k === 'symbol' + ? `[${stringifyInternal(k, currentValues, getAsyncContent)}]` + : JSON.stringify(k)}:${ stringifyInternal(value[k], currentValues, getAsyncContent)}`; const stringifiedProperties = [ ...Object.keys(value).map(mapper), @@ -2584,8 +2586,8 @@ var fc = (function() { const statusIcon = currentTree.status === ExecutionStatus_1.ExecutionStatus.Success ? '\x1b[32m\u221A\x1b[0m' : currentTree.status === ExecutionStatus_1.ExecutionStatus.Failure - ? '\x1b[31m\xD7\x1b[0m' - : '\x1b[33m!\x1b[0m'; + ? '\x1b[31m\xD7\x1b[0m' + : '\x1b[33m!\x1b[0m'; const leftPadding = Array(currentDepth).join('. '); summaryLines.push(`${leftPadding}${statusIcon} ${stringifyOne(currentTree.value)}`); for (const tree of currentTree.children.slice().reverse()) { @@ -3491,8 +3493,7 @@ var fc = (function() { `Unable to offset size based on the unknown defaulted one: ${defaultSize}`); } const resultingSizeInSize = defaultSizeInSize + sizeInRelative - 4; - return resultingSizeInSize < 0 - ? orderedSize[0] + return resultingSizeInSize < 0 ? orderedSize[0] : resultingSizeInSize >= orderedSize.length ? orderedSize[orderedSize.length - 1] : orderedSize[resultingSizeInSize]; } @@ -3501,9 +3502,9 @@ var fc = (function() { size, minLength, maxLength, specifiedMaxLength) { const {baseSize: defaultSize = exports.DefaultSize, defaultSizeToMaxWhenMaxSpecified} = (0, GlobalParameters_1.readConfigureGlobal)() || {}; - const definedSize = size !== undefined - ? size - : specifiedMaxLength && defaultSizeToMaxWhenMaxSpecified ? 'max' : defaultSize; + const definedSize = size !== undefined ? size + : specifiedMaxLength && defaultSizeToMaxWhenMaxSpecified ? 'max' + : defaultSize; if (definedSize === 'max') { return maxLength; } @@ -3517,9 +3518,9 @@ var fc = (function() { } const {baseSize: defaultSize = exports.DefaultSize, defaultSizeToMaxWhenMaxSpecified} = (0, GlobalParameters_1.readConfigureGlobal)() || {}; - const definedSize = depthSizeOrSize !== undefined - ? depthSizeOrSize - : specifiedMaxDepth && defaultSizeToMaxWhenMaxSpecified ? 'max' : defaultSize; + const definedSize = depthSizeOrSize !== undefined ? depthSizeOrSize + : specifiedMaxDepth && defaultSizeToMaxWhenMaxSpecified ? 'max' + : defaultSize; if (definedSize === 'max') { return 0; } @@ -4683,8 +4684,9 @@ var fc = (function() { nat$1.nat = void 0; const IntegerArbitrary_1$3 = IntegerArbitrary$1; function nat(arg) { - const max = - typeof arg === 'number' ? arg : arg && arg.max !== undefined ? arg.max : 0x7fffffff; + const max = typeof arg === 'number' ? arg + : arg && arg.max !== undefined ? arg.max + : 0x7fffffff; if (max < 0) { throw new Error('fc.nat value should be greater than or equal to 0'); } |