diff options
author | James Wahlin <james.wahlin@mongodb.com> | 2019-08-14 13:52:59 +0000 |
---|---|---|
committer | evergreen <evergreen@mongodb.com> | 2019-08-14 13:52:59 +0000 |
commit | 39c3a5d77b976e131d37476f2e7255d6058f5093 (patch) | |
tree | 01cc28719f215b17196ec913f475cd8efda9b37d /jstests/core | |
parent | 69d0dd1dc4fb1f78d21c47aa5dd82aa9077b69eb (diff) | |
download | mongo-39c3a5d77b976e131d37476f2e7255d6058f5093.tar.gz |
SERVER-42773 Replace uses of the assert.writeOK() Javascript assertion with assert.commandWorked()
Diffstat (limited to 'jstests/core')
255 files changed, 1445 insertions, 1423 deletions
diff --git a/jstests/core/SERVER-23626.js b/jstests/core/SERVER-23626.js index 9a25bda2291..31f963bd313 100644 --- a/jstests/core/SERVER-23626.js +++ b/jstests/core/SERVER-23626.js @@ -4,14 +4,14 @@ var t = db.jstests_server23626; t.mycoll.drop(); -assert.writeOK(t.mycoll.insert({_id: 0, a: Date.prototype})); +assert.commandWorked(t.mycoll.insert({_id: 0, a: Date.prototype})); assert.eq(1, t.mycoll.find({a: {$type: 'date'}}).itcount()); t.mycoll.drop(); -assert.writeOK(t.mycoll.insert({_id: 0, a: Function.prototype})); +assert.commandWorked(t.mycoll.insert({_id: 0, a: Function.prototype})); assert.eq(1, t.mycoll.find({a: {$type: 'javascript'}}).itcount()); t.mycoll.drop(); -assert.writeOK(t.mycoll.insert({_id: 0, a: RegExp.prototype})); +assert.commandWorked(t.mycoll.insert({_id: 0, a: RegExp.prototype})); assert.eq(1, t.mycoll.find({a: {$type: 'regex'}}).itcount()); }());
\ No newline at end of file diff --git a/jstests/core/add_skip_stage_before_fetch.js b/jstests/core/add_skip_stage_before_fetch.js index aaad7bb5db3..846cab46e1f 100644 --- a/jstests/core/add_skip_stage_before_fetch.js +++ b/jstests/core/add_skip_stage_before_fetch.js @@ -29,7 +29,7 @@ for (let i = 0; i < 10000; i++) { d: Math.floor(Math.random() * 1000) }); } -assert.writeOK(bulk.execute()); +assert.commandWorked(bulk.execute()); // The {a: 0, b: 2} query will match exactly one quarter of the documents in the collection: // 2500 in total. In the test queries below, we skip the first 2400, returning exactly 100 diff --git a/jstests/core/agg_hint.js b/jstests/core/agg_hint.js index 899bbd2217a..10b3c6192d8 100644 --- a/jstests/core/agg_hint.js +++ b/jstests/core/agg_hint.js @@ -72,7 +72,7 @@ function confirmAggUsesIndex({ // Specify hint as a string, representing index name. assert.commandWorked(coll.createIndex({x: 1})); for (let i = 0; i < 5; ++i) { - assert.writeOK(coll.insert({x: i})); + assert.commandWorked(coll.insert({x: i})); } confirmAggUsesIndex({ @@ -94,7 +94,7 @@ confirmAggUsesIndex({ coll.drop(); assert.commandWorked(coll.createIndex({x: 1})); for (let i = 0; i < 5; ++i) { - assert.writeOK(coll.insert({x: i})); + assert.commandWorked(coll.insert({x: i})); } confirmAggUsesIndex({ @@ -125,7 +125,7 @@ coll.drop(); assert.commandWorked(coll.createIndex({x: 1})); assert.commandWorked(coll.createIndex({y: 1})); for (let i = 0; i < 5; ++i) { - assert.writeOK(coll.insert({x: i, y: i})); + assert.commandWorked(coll.insert({x: i, y: i})); } confirmAggUsesIndex({ @@ -155,7 +155,7 @@ coll.drop(); assert.commandWorked(coll.createIndex({x: 1})); assert.commandWorked(coll.createIndex({x: 1, y: 1})); for (let i = 0; i < 5; ++i) { - assert.writeOK(coll.insert({x: i, y: i})); + assert.commandWorked(coll.insert({x: i, y: i})); } confirmAggUsesIndex({ @@ -183,7 +183,7 @@ coll.drop(); view.drop(); assert.commandWorked(coll.createIndex({x: 1})); for (let i = 0; i < 5; ++i) { - assert.writeOK(coll.insert({x: i})); + assert.commandWorked(coll.insert({x: i})); } assert.commandWorked(testDB.createView("view", "test", [{$match: {x: {$gte: 0}}}])); @@ -213,7 +213,7 @@ coll.drop(); view.drop(); assert.commandWorked(coll.createIndex({x: 1})); for (let i = 0; i < 5; ++i) { - assert.writeOK(coll.insert({x: i})); + assert.commandWorked(coll.insert({x: i})); } assert.commandWorked(testDB.createView("view", "test", [])); @@ -240,7 +240,7 @@ coll.drop(); view.drop(); assert.commandWorked(coll.createIndex({x: 1})); for (let i = 0; i < 5; ++i) { - assert.writeOK(coll.insert({x: i})); + assert.commandWorked(coll.insert({x: i})); } assert.commandWorked(testDB.createView("view", "test", [])); diff --git a/jstests/core/aggregation_getmore_batchsize.js b/jstests/core/aggregation_getmore_batchsize.js index c723d2ca45d..7cef863979d 100644 --- a/jstests/core/aggregation_getmore_batchsize.js +++ b/jstests/core/aggregation_getmore_batchsize.js @@ -10,7 +10,7 @@ db.getMongo().forceReadMode("commands"); var coll = db["aggregation_getmore_batchsize"]; // Insert some data to query for -assert.writeOK(coll.insert([{a: 1}, {a: 1}, {a: 1}, {a: 1}, {a: 1}, {a: 1}])); +assert.commandWorked(coll.insert([{a: 1}, {a: 1}, {a: 1}, {a: 1}, {a: 1}, {a: 1}])); // Create a cursor with a batch size of 2 (should require three full batches to return all // documents). diff --git a/jstests/core/apply_ops_dups.js b/jstests/core/apply_ops_dups.js index 85bc04437a6..63659c8082c 100644 --- a/jstests/core/apply_ops_dups.js +++ b/jstests/core/apply_ops_dups.js @@ -12,7 +12,7 @@ var t = db.apply_ops_dups; t.drop(); // Check that duplicate _id fields don't cause an error -assert.writeOK(t.insert({_id: 0, x: 1})); +assert.commandWorked(t.insert({_id: 0, x: 1})); assert.commandWorked(t.createIndex({x: 1}, {unique: true})); var a = assert.commandWorked(db.adminCommand({ applyOps: [ diff --git a/jstests/core/apply_ops_invalid_index_spec.js b/jstests/core/apply_ops_invalid_index_spec.js index d602cae29c1..6d1024d14d3 100644 --- a/jstests/core/apply_ops_invalid_index_spec.js +++ b/jstests/core/apply_ops_invalid_index_spec.js @@ -25,7 +25,7 @@ const cmdNs = db.getName() + '.$cmd'; const systemIndexesNs = db.getCollection('system.indexes').getFullName(); assert.commandWorked(db.createCollection(t.getName())); -assert.writeOK(t.save({_id: 100, a: 100})); +assert.commandWorked(t.save({_id: 100, a: 100})); // Tests that db.collection.createIndex() fails when given an index spec containing an unknown // field. diff --git a/jstests/core/awaitdata_getmore_cmd.js b/jstests/core/awaitdata_getmore_cmd.js index eb1fb194a32..d142615fa94 100644 --- a/jstests/core/awaitdata_getmore_cmd.js +++ b/jstests/core/awaitdata_getmore_cmd.js @@ -24,7 +24,7 @@ var coll = db[collName]; // Create a non-capped collection with 10 documents. coll.drop(); for (var i = 0; i < 10; i++) { - assert.writeOK(coll.insert({a: i})); + assert.commandWorked(coll.insert({a: i})); } // Find with tailable flag set should fail for a non-capped collection. @@ -44,7 +44,7 @@ assert.eq(cmdRes.cursor.firstBatch.length, 0); // Create a capped collection with 10 documents. assert.commandWorked(db.createCollection(collName, {capped: true, size: 2048})); for (var i = 0; i < 10; i++) { - assert.writeOK(coll.insert({a: i})); + assert.commandWorked(coll.insert({a: i})); } // GetMore should succeed if query has awaitData but no maxTimeMS is supplied. @@ -161,7 +161,7 @@ assert.eq(cmdRes.cursor.firstBatch.length, 0); // the user if a document was inserted, but it did not match the filter. let insertshell = startParallelShell(() => { // Signal to the original shell that the parallel shell has successfully started. - assert.writeOK(db.await_data.insert({_id: "signal parent shell"})); + assert.commandWorked(db.await_data.insert({_id: "signal parent shell"})); // Wait for the parent shell to start watching for the next document. assert.soon(() => db.currentOp({ @@ -171,7 +171,7 @@ let insertshell = startParallelShell(() => { () => tojson(db.currentOp().inprog)); // Now write a non-matching document to the collection. - assert.writeOK(db.await_data.insert({_id: "no match", x: 0})); + assert.commandWorked(db.await_data.insert({_id: "no match", x: 0})); // Make sure the getMore has not ended after a while. sleep(2000); @@ -182,7 +182,7 @@ let insertshell = startParallelShell(() => { tojson(db.currentOp().inprog)); // Now write a matching document to wake it up. - assert.writeOK(db.await_data.insert({_id: "match", x: 1})); + assert.commandWorked(db.await_data.insert({_id: "match", x: 1})); }); // Wait until we receive confirmation that the parallel shell has started. diff --git a/jstests/core/background_index_multikey.js b/jstests/core/background_index_multikey.js index 3db0c2d81f1..e9d0f0aa9ed 100644 --- a/jstests/core/background_index_multikey.js +++ b/jstests/core/background_index_multikey.js @@ -15,7 +15,7 @@ function testIndexBuilds(isBackground) { // Build index after multikey document is in the collection. let doc = {_id: 0, a: [1, 2]}; - assert.writeOK(coll.insert(doc)); + assert.commandWorked(coll.insert(doc)); assert.commandWorked(coll.createIndex({a: 1}, {background: isBackground})); assert.eq(1, coll.count({a: 1})); assert.eq(doc, coll.findOne({a: 1})); @@ -24,7 +24,7 @@ function testIndexBuilds(isBackground) { // Build index where multikey is in an embedded document. doc = {_id: 1, b: {c: [1, 2]}}; - assert.writeOK(coll.insert(doc)); + assert.commandWorked(coll.insert(doc)); assert.commandWorked(coll.createIndex({'b.c': 1}, {background: isBackground})); assert.eq(1, coll.count({'b.c': 1})); assert.eq(doc, coll.findOne({'b.c': 1})); @@ -33,7 +33,7 @@ function testIndexBuilds(isBackground) { // Add new multikey path to embedded path. doc = {_id: 2, b: [1, 2]}; - assert.writeOK(coll.insert(doc)); + assert.commandWorked(coll.insert(doc)); assert.eq(1, coll.count({b: 1})); assert.eq(doc, coll.findOne({b: 1})); assert.eq(1, coll.count({b: 2})); @@ -41,11 +41,11 @@ function testIndexBuilds(isBackground) { // Build index on a large collection that is not multikey, and then make it multikey. for (let i = 100; i < 1100; i++) { - assert.writeOK(coll.insert({_id: i, d: i})); + assert.commandWorked(coll.insert({_id: i, d: i})); } assert.commandWorked(coll.createIndex({d: 1}, {background: isBackground})); doc = {_id: 3, d: [1, 2]}; - assert.writeOK(coll.insert(doc)); + assert.commandWorked(coll.insert(doc)); assert.eq(1, coll.count({d: 1})); assert.eq(doc, coll.findOne({d: 1})); assert.eq(1, coll.count({d: 2})); @@ -53,7 +53,7 @@ function testIndexBuilds(isBackground) { // Build compound multikey index. doc = {_id: 4, e: [1, 2]}; - assert.writeOK(coll.insert(doc)); + assert.commandWorked(coll.insert(doc)); assert.commandWorked(coll.createIndex({'e': 1, 'f': 1}, {background: isBackground})); assert.eq(1, coll.count({e: 1})); assert.eq(doc, coll.findOne({e: 1})); @@ -62,7 +62,7 @@ function testIndexBuilds(isBackground) { // Add new multikey path to compound index. doc = {_id: 5, f: [1, 2]}; - assert.writeOK(coll.insert(doc)); + assert.commandWorked(coll.insert(doc)); assert.eq(1, coll.count({f: 1})); assert.eq(doc, coll.findOne({f: 1})); assert.eq(1, coll.count({f: 2})); diff --git a/jstests/core/batch_write_collation_estsize.js b/jstests/core/batch_write_collation_estsize.js index d0e4254d6b2..dd8612ef357 100644 --- a/jstests/core/batch_write_collation_estsize.js +++ b/jstests/core/batch_write_collation_estsize.js @@ -11,7 +11,7 @@ // Setup the test collection. db.batch_write_collation_estsize.drop(); -assert.writeOK(db.batch_write_collation_estsize.insert({str: "FOO"})); +assert.commandWorked(db.batch_write_collation_estsize.insert({str: "FOO"})); if (db.getMongo().writeMode() !== "commands") { // Cannot use the bulk API to set a collation when using legacy write ops. @@ -160,7 +160,7 @@ if (db.getMongo().writeMode() !== "commands") { assert.eq(1, res.deletedCount); // Reinsert a document to test deleteMany bulk write operation. - assert.writeOK(db.batch_write_collation_estsize.insert({str: "FOO"})); + assert.commandWorked(db.batch_write_collation_estsize.insert({str: "FOO"})); // Test deleteMany bulk write operation with collation specification. res = db.batch_write_collation_estsize.bulkWrite([{ diff --git a/jstests/core/batch_write_command_delete.js b/jstests/core/batch_write_command_delete.js index 4004a519412..2d7feb7fe23 100644 --- a/jstests/core/batch_write_command_delete.js +++ b/jstests/core/batch_write_command_delete.js @@ -123,7 +123,7 @@ for (var i = 0; i < maxWriteBatchSize; ++i) { insertBatch.insert({_id: i}); batch.push({q: {_id: i}, limit: 0}); } -assert.writeOK(insertBatch.execute()); +assert.commandWorked(insertBatch.execute()); request = { delete: coll.getName(), deletes: batch, @@ -144,7 +144,7 @@ for (var i = 0; i < maxWriteBatchSize + 1; ++i) { insertBatch.insert({_id: i}); batch.push({q: {_id: i}, limit: 0}); } -assert.writeOK(insertBatch.execute()); +assert.commandWorked(insertBatch.execute()); request = { delete: coll.getName(), deletes: batch, diff --git a/jstests/core/bindata_indexonly.js b/jstests/core/bindata_indexonly.js index f215a17e882..f0d645db7e7 100644 --- a/jstests/core/bindata_indexonly.js +++ b/jstests/core/bindata_indexonly.js @@ -11,10 +11,10 @@ load("jstests/libs/analyze_plan.js"); var coll = db.jstests_bindata_indexonly; coll.drop(); -assert.writeOK(coll.insert({_id: BinData(0, "AAAAAAAAAAAAAAAAAAAAAAAAAAAA"), a: 1})); -assert.writeOK(coll.insert({_id: BinData(0, "AQAAAAEBAAVlbl9VSwAAAAAAAAhv"), a: 2})); -assert.writeOK(coll.insert({_id: BinData(0, "AQAAAAEBAAVlbl9VSwAAAAAAAAhz"), a: 3})); -assert.writeOK(coll.insert({_id: BinData(0, "////////////////////////////"), a: 4})); +assert.commandWorked(coll.insert({_id: BinData(0, "AAAAAAAAAAAAAAAAAAAAAAAAAAAA"), a: 1})); +assert.commandWorked(coll.insert({_id: BinData(0, "AQAAAAEBAAVlbl9VSwAAAAAAAAhv"), a: 2})); +assert.commandWorked(coll.insert({_id: BinData(0, "AQAAAAEBAAVlbl9VSwAAAAAAAAhz"), a: 3})); +assert.commandWorked(coll.insert({_id: BinData(0, "////////////////////////////"), a: 4})); assert.commandWorked(coll.createIndex({_id: 1, a: 1})); assert.throws(function() { diff --git a/jstests/core/bittest.js b/jstests/core/bittest.js index 00785a5efcf..1ac5ddbe59b 100644 --- a/jstests/core/bittest.js +++ b/jstests/core/bittest.js @@ -19,11 +19,11 @@ function assertQueryCorrect(query, count) { // Tests on numbers. coll.drop(); -assert.writeOK(coll.insert({a: 0})); -assert.writeOK(coll.insert({a: 1})); -assert.writeOK(coll.insert({a: 54})); -assert.writeOK(coll.insert({a: 88})); -assert.writeOK(coll.insert({a: 255})); +assert.commandWorked(coll.insert({a: 0})); +assert.commandWorked(coll.insert({a: 1})); +assert.commandWorked(coll.insert({a: 54})); +assert.commandWorked(coll.insert({a: 88})); +assert.commandWorked(coll.insert({a: 255})); assert.commandWorked(coll.createIndex({a: 1})); // Tests with bitmask. @@ -74,9 +74,9 @@ assertQueryCorrect({a: {$bitsAllSet: 54, $bitsAllClear: 201}}, 1); // Tests on negative numbers. coll.drop(); -assert.writeOK(coll.insert({a: -0})); -assert.writeOK(coll.insert({a: -1})); -assert.writeOK(coll.insert({a: -54})); +assert.commandWorked(coll.insert({a: -0})); +assert.commandWorked(coll.insert({a: -1})); +assert.commandWorked(coll.insert({a: -54})); // Tests with bitmask. assertQueryCorrect({a: {$bitsAllSet: 0}}, 3); @@ -118,10 +118,10 @@ assertQueryCorrect({a: {$bitsAllSet: 74, $bitsAllClear: 53}}, 1); // Tests on BinData. coll.drop(); -assert.writeOK(coll.insert({a: BinData(0, "AAAAAAAAAAAAAAAAAAAAAAAAAAAA")})); -assert.writeOK(coll.insert({a: BinData(0, "AANgAAAAAAAAAAAAAAAAAAAAAAAA")})); -assert.writeOK(coll.insert({a: BinData(0, "JANgqwetkqwklEWRbWERKKJREtbq")})); -assert.writeOK(coll.insert({a: BinData(0, "////////////////////////////")})); +assert.commandWorked(coll.insert({a: BinData(0, "AAAAAAAAAAAAAAAAAAAAAAAAAAAA")})); +assert.commandWorked(coll.insert({a: BinData(0, "AANgAAAAAAAAAAAAAAAAAAAAAAAA")})); +assert.commandWorked(coll.insert({a: BinData(0, "JANgqwetkqwklEWRbWERKKJREtbq")})); +assert.commandWorked(coll.insert({a: BinData(0, "////////////////////////////")})); assert.commandWorked(coll.createIndex({a: 1})); // Tests with binary string bitmask. diff --git a/jstests/core/bulk_legacy_enforce_gle.js b/jstests/core/bulk_legacy_enforce_gle.js index 6359b277c0b..e9def78d241 100644 --- a/jstests/core/bulk_legacy_enforce_gle.js +++ b/jstests/core/bulk_legacy_enforce_gle.js @@ -16,7 +16,7 @@ const coll = db.bulk_legacy_enforce_gle; function insertDocument(doc) { let res = coll.insert(doc); if (res) { - assert.writeOK(res); + assert.commandWorked(res); } else { assert.gleOK(db.runCommand({getLastError: 1})); } @@ -25,7 +25,7 @@ function insertDocument(doc) { coll.drop(); let bulk = coll.initializeUnorderedBulkOp(); bulk.find({_id: 1}).upsert().updateOne({_id: 1}); -assert.writeOK(bulk.execute()); +assert.commandWorked(bulk.execute()); let gle = assert.gleOK(db.runCommand({getLastError: 1})); assert.eq(1, gle.n, tojson(gle)); diff --git a/jstests/core/bypass_doc_validation.js b/jstests/core/bypass_doc_validation.js index dcf1a0d28dc..8c9fd3e8419 100644 --- a/jstests/core/bypass_doc_validation.js +++ b/jstests/core/bypass_doc_validation.js @@ -47,8 +47,8 @@ function runBypassDocumentValidationTest(validator) { coll.drop({writeConcern: {w: "majority"}}); // Insert documents into the collection that would not be valid before setting 'validator'. - assert.writeOK(coll.insert({_id: 1})); - assert.writeOK(coll.insert({_id: 2})); + assert.commandWorked(coll.insert({_id: 1})); + assert.commandWorked(coll.insert({_id: 2})); assert.commandWorked(myDb.runCommand({collMod: collName, validator: validator})); const isMongos = db.runCommand({isdbgrid: 1}).isdbgrid; @@ -117,7 +117,7 @@ function runBypassDocumentValidationTest(validator) { assertFailsValidation(BulkWriteResult(res)); res = myDb.runCommand( {insert: collName, documents: [{}, {_id: 6}], bypassDocumentValidation: true}); - assert.writeOK(res); + assert.commandWorked(res); // Test the update command. res = myDb.runCommand({ @@ -132,7 +132,7 @@ function runBypassDocumentValidationTest(validator) { updates: [{q: {}, u: {$set: {update: 1}}}], bypassDocumentValidation: true }); - assert.writeOK(res); + assert.commandWorked(res); assert.eq(1, coll.count({update: 1})); // Pipeline-style update is only supported for commands and not for OP_UPDATE which cannot diff --git a/jstests/core/capped6.js b/jstests/core/capped6.js index 393d8589a60..c9d8867c3f0 100644 --- a/jstests/core/capped6.js +++ b/jstests/core/capped6.js @@ -70,7 +70,7 @@ function runCapTrunc(valueArray, valueArrayCurIndex, n, inc) { assert.gt(n, 0); assert.gte(valueArray.length, maxDocuments); for (var i = valueArrayCurIndex; i < maxDocuments; ++i) { - assert.writeOK(coll.insert(valueArray[i])); + assert.commandWorked(coll.insert(valueArray[i])); } count = coll.count(); diff --git a/jstests/core/capped_queries_and_id_index.js b/jstests/core/capped_queries_and_id_index.js index 1bf463f05ed..3fdecfa1e2f 100644 --- a/jstests/core/capped_queries_and_id_index.js +++ b/jstests/core/capped_queries_and_id_index.js @@ -7,18 +7,18 @@ coll.drop(); assert.commandWorked(db.createCollection("capped9", {capped: true, size: 1024 * 50})); -assert.writeOK(coll.insert({_id: 1, x: 2, y: 3})); +assert.commandWorked(coll.insert({_id: 1, x: 2, y: 3})); assert.eq(1, coll.find({x: 2}).itcount()); assert.eq(1, coll.find({y: 3}).itcount()); // SERVER-3064 proposes making the following queries/updates by _id result in an error. assert.eq(1, coll.find({_id: 1}).itcount()); -assert.writeOK(coll.update({_id: 1}, {$set: {y: 4}})); +assert.commandWorked(coll.update({_id: 1}, {$set: {y: 4}})); assert.eq(4, coll.findOne().y); assert.commandWorked(coll.createIndex({_id: 1})); assert.eq(1, coll.find({_id: 1}).itcount()); -assert.writeOK(coll.update({_id: 1}, {$set: {y: 5}})); +assert.commandWorked(coll.update({_id: 1}, {$set: {y: 5}})); assert.eq(5, coll.findOne().y); }()); diff --git a/jstests/core/capped_update.js b/jstests/core/capped_update.js index f11502b45fe..d15c6939fcd 100644 --- a/jstests/core/capped_update.js +++ b/jstests/core/capped_update.js @@ -16,10 +16,10 @@ assert.commandWorked( assert.eq(0, t.getIndexes().length, "the capped collection has indexes"); for (var j = 1; j <= 10; j++) { - assert.writeOK(t.insert({_id: j, s: "Hello, World!"})); + assert.commandWorked(t.insert({_id: j, s: "Hello, World!"})); } -assert.writeOK(t.update({_id: 3}, {s: "Hello, Mongo!"})); // Mongo is same length as World +assert.commandWorked(t.update({_id: 3}, {s: "Hello, Mongo!"})); // Mongo is same length as World assert.writeError(t.update({_id: 3}, {$set: {s: "Hello!"}})); assert.writeError(t.update({_id: 10}, {})); assert.writeError(t.update({_id: 10}, {s: "Hello, World!!!"})); @@ -27,7 +27,7 @@ assert.writeError(t.update({_id: 10}, {s: "Hello, World!!!"})); assert.commandWorked(t.getDB().runCommand({godinsert: t.getName(), obj: {a: 2}})); var doc = t.findOne({a: 2}); assert.eq(undefined, doc["_id"], "now has _id after godinsert"); -assert.writeOK(t.update({a: 2}, {$inc: {a: 1}})); +assert.commandWorked(t.update({a: 2}, {$inc: {a: 1}})); doc = t.findOne({a: 3}); assert.eq(undefined, doc["_id"], "now has _id after update"); })(); diff --git a/jstests/core/collation.js b/jstests/core/collation.js index a3a186349e7..e96a67c3754 100644 --- a/jstests/core/collation.js +++ b/jstests/core/collation.js @@ -249,7 +249,7 @@ if (db.getMongo().useReadCommands()) { coll.drop(); assert.commandWorked(coll.createIndex({a: 1}, {collation: {locale: "fr_CA"}})); assert.commandWorked(coll.createIndex({b: 1})); - assert.writeOK(coll.insert({a: "foo", b: "foo"})); + assert.commandWorked(coll.insert({a: "foo", b: "foo"})); assert.eq(1, coll.find().collation({locale: "fr_CA"}).hint({a: 1}).returnKey().itcount()); assert.neq("foo", coll.find().collation({locale: "fr_CA"}).hint({a: 1}).returnKey().next().a); assert.eq(1, coll.find().collation({locale: "fr_CA"}).hint({b: 1}).returnKey().itcount()); @@ -304,8 +304,8 @@ assert.eq(0, coll.aggregate([], {collation: {locale: "fr"}}).itcount()); // Aggregation should return correct results when collation specified and collection does exist. coll.drop(); -assert.writeOK(coll.insert({_id: 1, str: "foo"})); -assert.writeOK(coll.insert({_id: 2, str: "bar"})); +assert.commandWorked(coll.insert({_id: 1, str: "foo"})); +assert.commandWorked(coll.insert({_id: 2, str: "bar"})); assert.eq(0, coll.aggregate([{$match: {str: "FOO"}}]).itcount()); assert.eq(1, coll.aggregate([{$match: {str: "FOO"}}], {collation: {locale: "en_US", strength: 2}}) @@ -316,7 +316,7 @@ assert.eq(1, coll.drop(); assert.commandWorked( db.createCollection(coll.getName(), {collation: {locale: "en_US", strength: 2}})); -assert.writeOK(coll.insert({str: "foo"})); +assert.commandWorked(coll.insert({str: "foo"})); assert.eq(1, coll.aggregate([{$match: {str: "FOO"}}]).itcount()); // Aggregation should return correct results when "simple" collation specified and collection @@ -324,7 +324,7 @@ assert.eq(1, coll.aggregate([{$match: {str: "FOO"}}]).itcount()); coll.drop(); assert.commandWorked( db.createCollection(coll.getName(), {collation: {locale: "en_US", strength: 2}})); -assert.writeOK(coll.insert({str: "foo"})); +assert.commandWorked(coll.insert({str: "foo"})); assert.eq(0, coll.aggregate([{$match: {str: "FOO"}}], {collation: {locale: "simple"}}).itcount()); // Aggregation should select compatible index when no collation specified and collection has a @@ -356,8 +356,8 @@ assert.eq(0, coll.find({str: "FOO"}).collation({locale: "en_US"}).count()); // Count should return correct results when collation specified and collection does exist. coll.drop(); -assert.writeOK(coll.insert({_id: 1, str: "foo"})); -assert.writeOK(coll.insert({_id: 2, str: "bar"})); +assert.commandWorked(coll.insert({_id: 1, str: "foo"})); +assert.commandWorked(coll.insert({_id: 2, str: "bar"})); assert.eq(0, coll.find({str: "FOO"}).count()); assert.eq(0, coll.find({str: "FOO"}).collation({locale: "en_US"}).count()); assert.eq(1, coll.find({str: "FOO"}).collation({locale: "en_US", strength: 2}).count()); @@ -370,7 +370,7 @@ assert.eq(1, coll.count({str: "FOO"}, {collation: {locale: "en_US", strength: 2} coll.drop(); assert.commandWorked( db.createCollection(coll.getName(), {collation: {locale: "en_US", strength: 2}})); -assert.writeOK(coll.insert({str: "foo"})); +assert.commandWorked(coll.insert({str: "foo"})); assert.eq(1, coll.find({str: "FOO"}).count()); // Count should return correct results when "simple" collation specified and collection has a @@ -378,13 +378,13 @@ assert.eq(1, coll.find({str: "FOO"}).count()); coll.drop(); assert.commandWorked( db.createCollection(coll.getName(), {collation: {locale: "en_US", strength: 2}})); -assert.writeOK(coll.insert({str: "foo"})); +assert.commandWorked(coll.insert({str: "foo"})); assert.eq(0, coll.find({str: "FOO"}).collation({locale: "simple"}).count()); // Count should return correct results when collation specified and when run with explain. coll.drop(); -assert.writeOK(coll.insert({_id: 1, str: "foo"})); -assert.writeOK(coll.insert({_id: 2, str: "bar"})); +assert.commandWorked(coll.insert({_id: 1, str: "foo"})); +assert.commandWorked(coll.insert({_id: 2, str: "bar"})); explainRes = coll.explain("executionStats").find({str: "FOO"}).collation({locale: "en_US"}).count(); assert.commandWorked(explainRes); planStage = getPlanStage(explainRes.executionStats.executionStages, "COLLSCAN"); @@ -461,8 +461,8 @@ assert.eq(0, coll.distinct("str", {}, {collation: {locale: "en_US", strength: 2} // Distinct should return correct results when collation specified and no indexes exist. coll.drop(); -assert.writeOK(coll.insert({_id: 1, str: "foo"})); -assert.writeOK(coll.insert({_id: 2, str: "FOO"})); +assert.commandWorked(coll.insert({_id: 1, str: "foo"})); +assert.commandWorked(coll.insert({_id: 2, str: "FOO"})); var res = coll.distinct("str", {}, {collation: {locale: "en_US", strength: 2}}); assert.eq(1, res.length); assert.eq("foo", res[0].toLowerCase()); @@ -482,8 +482,8 @@ assert.eq(2, coll.distinct("str", {}, {collation: {locale: "en_US", strength: 3} coll.drop(); assert.commandWorked( db.createCollection(coll.getName(), {collation: {locale: "en_US", strength: 2}})); -assert.writeOK(coll.insert({str: "foo"})); -assert.writeOK(coll.insert({str: "FOO"})); +assert.commandWorked(coll.insert({str: "foo"})); +assert.commandWorked(coll.insert({str: "FOO"})); assert.eq(1, coll.distinct("str").length); assert.eq(2, coll.distinct("_id", {str: "foo"}).length); @@ -492,8 +492,8 @@ assert.eq(2, coll.distinct("_id", {str: "foo"}).length); coll.drop(); assert.commandWorked( db.createCollection(coll.getName(), {collation: {locale: "en_US", strength: 2}})); -assert.writeOK(coll.insert({str: "foo"})); -assert.writeOK(coll.insert({str: "FOO"})); +assert.commandWorked(coll.insert({str: "foo"})); +assert.commandWorked(coll.insert({str: "FOO"})); assert.eq(2, coll.distinct("str", {}, {collation: {locale: "simple"}}).length); assert.eq(1, coll.distinct("_id", {str: "foo"}, {collation: {locale: "simple"}}).length); @@ -588,13 +588,13 @@ if (db.getMongo().useReadCommands()) { // Find should return correct results when collation specified and filter is a match on _id. coll.drop(); - assert.writeOK(coll.insert({_id: 1, str: "foo"})); - assert.writeOK(coll.insert({_id: 2, str: "bar"})); - assert.writeOK(coll.insert({_id: "foo"})); + assert.commandWorked(coll.insert({_id: 1, str: "foo"})); + assert.commandWorked(coll.insert({_id: 2, str: "bar"})); + assert.commandWorked(coll.insert({_id: "foo"})); assert.eq(0, coll.find({_id: "FOO"}).itcount()); assert.eq(0, coll.find({_id: "FOO"}).collation({locale: "en_US"}).itcount()); assert.eq(1, coll.find({_id: "FOO"}).collation({locale: "en_US", strength: 2}).itcount()); - assert.writeOK(coll.remove({_id: "foo"})); + assert.commandWorked(coll.remove({_id: "foo"})); // Find should return correct results when collation specified and no indexes exist. assert.eq(0, coll.find({str: "FOO"}).itcount()); @@ -626,17 +626,17 @@ if (db.getMongo().useReadCommands()) { assert.eq( 1, coll.find({str: "foo"}).collation({locale: "en_US", strength: 2}).hint({str: 1}).itcount()); - assert.writeOK(coll.insert({_id: 3, str: "goo"})); + assert.commandWorked(coll.insert({_id: 3, str: "goo"})); assert.eq( 0, coll.find({str: "goo"}).collation({locale: "en_US", strength: 2}).hint({str: 1}).itcount()); - assert.writeOK(coll.remove({_id: 3})); + assert.commandWorked(coll.remove({_id: 3})); assert.commandWorked(coll.dropIndexes()); // Queries that use a index with a non-matching collation should add a sort // stage if needed. coll.drop(); - assert.writeOK(coll.insert([{a: "A"}, {a: "B"}, {a: "b"}, {a: "a"}])); + assert.commandWorked(coll.insert([{a: "A"}, {a: "B"}, {a: "b"}, {a: "a"}])); // Ensure results from an index that doesn't match the query collation are sorted to match // the requested collation. @@ -649,7 +649,7 @@ if (db.getMongo().useReadCommands()) { // Find should return correct results when collation specified and query contains $expr. coll.drop(); - assert.writeOK(coll.insert([{a: "A"}, {a: "B"}])); + assert.commandWorked(coll.insert([{a: "A"}, {a: "B"}])); assert.eq( 1, coll.find({$expr: {$eq: ["$a", "a"]}}).collation({locale: "en_US", strength: 2}).itcount()); @@ -660,9 +660,9 @@ if (db.getMongo().useReadCommands()) { coll.drop(); assert.commandWorked( db.createCollection(coll.getName(), {collation: {locale: "en_US", strength: 2}})); -assert.writeOK(coll.insert({str: "foo"})); -assert.writeOK(coll.insert({str: "FOO"})); -assert.writeOK(coll.insert({str: "bar"})); +assert.commandWorked(coll.insert({str: "foo"})); +assert.commandWorked(coll.insert({str: "FOO"})); +assert.commandWorked(coll.insert({str: "bar"})); assert.eq(3, coll.find({str: {$in: ["foo", "bar"]}}).itcount()); assert.eq(2, coll.find({str: "foo"}).itcount()); assert.eq(1, coll.find({str: {$ne: "foo"}}).itcount()); @@ -674,7 +674,7 @@ assert.eq([{str: "bar"}, {str: "foo"}, {str: "FOO"}], coll.drop(); assert.commandWorked( db.createCollection(coll.getName(), {collation: {locale: "en_US", strength: 2}})); -assert.writeOK(coll.insert({_id: "foo"})); +assert.commandWorked(coll.insert({_id: "foo"})); assert.eq(1, coll.find({_id: "FOO"}).itcount()); // Find on _id should use idhack stage when query inherits collection default collation. @@ -690,7 +690,7 @@ assert.neq(null, planStage); coll.drop(); assert.commandWorked( db.createCollection(coll.getName(), {collation: {locale: "en_US", strength: 2}})); -assert.writeOK(coll.insert([{a: "A"}, {a: "B"}])); +assert.commandWorked(coll.insert([{a: "A"}, {a: "B"}])); assert.eq(1, coll.find({$expr: {$eq: ["$a", "a"]}}).itcount()); if (db.getMongo().useReadCommands()) { @@ -699,9 +699,9 @@ if (db.getMongo().useReadCommands()) { coll.drop(); assert.commandWorked( db.createCollection(coll.getName(), {collation: {locale: "en_US", strength: 2}})); - assert.writeOK(coll.insert({str: "foo"})); - assert.writeOK(coll.insert({str: "FOO"})); - assert.writeOK(coll.insert({str: "bar"})); + assert.commandWorked(coll.insert({str: "foo"})); + assert.commandWorked(coll.insert({str: "FOO"})); + assert.commandWorked(coll.insert({str: "bar"})); assert.eq(2, coll.find({str: {$in: ["foo", "bar"]}}).collation({locale: "simple"}).itcount()); assert.eq(1, coll.find({str: "foo"}).collation({locale: "simple"}).itcount()); assert.eq( @@ -713,8 +713,8 @@ if (db.getMongo().useReadCommands()) { coll.drop(); assert.commandWorked( db.createCollection(coll.getName(), {collation: {locale: "en_US", strength: 3}})); - assert.writeOK(coll.insert({_id: "foo"})); - assert.writeOK(coll.insert({_id: "FOO"})); + assert.commandWorked(coll.insert({_id: "foo"})); + assert.commandWorked(coll.insert({_id: "FOO"})); assert.eq(2, coll.find({_id: "foo"}).collation({locale: "en_US", strength: 2}).itcount()); // Find on _id should use idhack stage when explicitly given query collation matches @@ -772,7 +772,7 @@ assert(isIxscan(db, explain.queryPlanner.winningPlan)); // Find should return correct results when collation specified and run with explain. coll.drop(); -assert.writeOK(coll.insert({str: "foo"})); +assert.commandWorked(coll.insert({str: "foo"})); explainRes = coll.explain("executionStats").find({str: "FOO"}).collation({locale: "en_US"}).finish(); assert.commandWorked(explainRes); @@ -867,8 +867,8 @@ if (!db.getMongo().useReadCommands()) { // find() shell helper should error if a collation is specified and the shell is not using // read commands. coll.drop(); - assert.writeOK(coll.insert({_id: 1, str: "foo"})); - assert.writeOK(coll.insert({_id: 2, str: "bar"})); + assert.commandWorked(coll.insert({_id: 1, str: "foo"})); + assert.commandWorked(coll.insert({_id: 2, str: "bar"})); assert.throws(function() { coll.find().collation({locale: "fr"}).itcount(); }); @@ -888,8 +888,8 @@ assert.eq( // Update-findAndModify should return correct results when collation specified. coll.drop(); -assert.writeOK(coll.insert({_id: 1, str: "foo"})); -assert.writeOK(coll.insert({_id: 2, str: "bar"})); +assert.commandWorked(coll.insert({_id: 1, str: "foo"})); +assert.commandWorked(coll.insert({_id: 2, str: "bar"})); assert.eq({_id: 1, str: "baz"}, coll.findAndModify({ query: {str: "FOO"}, update: {$set: {str: "baz"}}, @@ -911,8 +911,8 @@ assert.eq(1, planStage.nWouldModify); // Delete-findAndModify should return correct results when collation specified. coll.drop(); -assert.writeOK(coll.insert({_id: 1, str: "foo"})); -assert.writeOK(coll.insert({_id: 2, str: "bar"})); +assert.commandWorked(coll.insert({_id: 1, str: "foo"})); +assert.commandWorked(coll.insert({_id: 2, str: "bar"})); assert.eq({_id: 1, str: "foo"}, coll.findAndModify( {query: {str: "FOO"}, remove: true, collation: {locale: "en_US", strength: 2}})); @@ -933,7 +933,7 @@ assert.eq(1, planStage.nWouldDelete); coll.drop(); assert.commandWorked( db.createCollection(coll.getName(), {collation: {locale: "en_US", strength: 2}})); -assert.writeOK(coll.insert({_id: 1, str: "foo"})); +assert.commandWorked(coll.insert({_id: 1, str: "foo"})); assert.eq({_id: 1, str: "foo"}, coll.findAndModify({query: {str: "FOO"}, update: {$set: {x: 1}}})); assert.eq({_id: 1, str: "foo", x: 1}, coll.findAndModify({query: {str: "FOO"}, remove: true})); @@ -942,7 +942,7 @@ assert.eq({_id: 1, str: "foo", x: 1}, coll.findAndModify({query: {str: "FOO"}, r coll.drop(); assert.commandWorked( db.createCollection(coll.getName(), {collation: {locale: "en_US", strength: 2}})); -assert.writeOK(coll.insert({_id: 1, str: "foo"})); +assert.commandWorked(coll.insert({_id: 1, str: "foo"})); assert.eq(null, coll.findAndModify( {query: {str: "FOO"}, update: {$set: {x: 1}}, collation: {locale: "simple"}})); @@ -969,8 +969,8 @@ assert.throws(function() { // mapReduce should return correct results when collation specified and no indexes exist. coll.drop(); -assert.writeOK(coll.insert({_id: 1, str: "foo"})); -assert.writeOK(coll.insert({_id: 2, str: "bar"})); +assert.commandWorked(coll.insert({_id: 1, str: "foo"})); +assert.commandWorked(coll.insert({_id: 2, str: "bar"})); var mapReduceOut = coll.mapReduce( function() { emit(this.str, 1); @@ -987,7 +987,7 @@ assert.eq(mapReduceOut.results.length, 1); coll.drop(); assert.commandWorked( db.createCollection(coll.getName(), {collation: {locale: "en_US", strength: 2}})); -assert.writeOK(coll.insert({_id: 1, str: "foo"})); +assert.commandWorked(coll.insert({_id: 1, str: "foo"})); var mapReduceOut = coll.mapReduce( function() { emit(this.str, 1); @@ -1004,7 +1004,7 @@ assert.eq(mapReduceOut.results.length, 1); coll.drop(); assert.commandWorked( db.createCollection(coll.getName(), {collation: {locale: "en_US", strength: 2}})); -assert.writeOK(coll.insert({_id: 1, str: "foo"})); +assert.commandWorked(coll.insert({_id: 1, str: "foo"})); var mapReduceOut = coll.mapReduce( function() { emit(this.str, 1); @@ -1023,21 +1023,21 @@ assert.eq(mapReduceOut.results.length, 0); if (db.getMongo().writeMode() === "commands") { // Remove should succeed when collation specified and collection does not exist. coll.drop(); - assert.writeOK(coll.remove({str: "foo"}, {justOne: true, collation: {locale: "fr"}})); + assert.commandWorked(coll.remove({str: "foo"}, {justOne: true, collation: {locale: "fr"}})); // Remove should return correct results when collation specified. coll.drop(); - assert.writeOK(coll.insert({_id: 1, str: "foo"})); - assert.writeOK(coll.insert({_id: 2, str: "foo"})); + assert.commandWorked(coll.insert({_id: 1, str: "foo"})); + assert.commandWorked(coll.insert({_id: 2, str: "foo"})); writeRes = coll.remove({str: "FOO"}, {justOne: true, collation: {locale: "en_US", strength: 2}}); - assert.writeOK(writeRes); + assert.commandWorked(writeRes); assert.eq(1, writeRes.nRemoved); // Explain of remove should return correct results when collation specified. coll.drop(); - assert.writeOK(coll.insert({_id: 1, str: "foo"})); - assert.writeOK(coll.insert({_id: 2, str: "foo"})); + assert.commandWorked(coll.insert({_id: 1, str: "foo"})); + assert.commandWorked(coll.insert({_id: 2, str: "foo"})); explainRes = coll.explain("executionStats").remove({str: "FOO"}, { justOne: true, collation: {locale: "en_US", strength: 2} @@ -1053,9 +1053,9 @@ if (db.getMongo().writeMode() === "commands") { coll.drop(); assert.commandWorked( db.createCollection(coll.getName(), {collation: {locale: "en_US", strength: 2}})); -assert.writeOK(coll.insert({_id: 1, str: "foo"})); +assert.commandWorked(coll.insert({_id: 1, str: "foo"})); writeRes = coll.remove({str: "FOO"}, {justOne: true}); -assert.writeOK(writeRes); +assert.commandWorked(writeRes); assert.eq(1, writeRes.nRemoved); // Remove with idhack should return correct results when no collation specified and collection @@ -1063,9 +1063,9 @@ assert.eq(1, writeRes.nRemoved); coll.drop(); assert.commandWorked( db.createCollection(coll.getName(), {collation: {locale: "en_US", strength: 2}})); -assert.writeOK(coll.insert({_id: "foo"})); +assert.commandWorked(coll.insert({_id: "foo"})); writeRes = coll.remove({_id: "FOO"}, {justOne: true}); -assert.writeOK(writeRes); +assert.commandWorked(writeRes); assert.eq(1, writeRes.nRemoved); // Remove on _id should use idhack stage when query inherits collection default collation. @@ -1082,9 +1082,9 @@ if (db.getMongo().writeMode() === "commands") { coll.drop(); assert.commandWorked( db.createCollection(coll.getName(), {collation: {locale: "en_US", strength: 2}})); - assert.writeOK(coll.insert({_id: 1, str: "foo"})); + assert.commandWorked(coll.insert({_id: 1, str: "foo"})); writeRes = coll.remove({str: "FOO"}, {justOne: true, collation: {locale: "simple"}}); - assert.writeOK(writeRes); + assert.commandWorked(writeRes); assert.eq(0, writeRes.nRemoved); // Remove on _id should return correct results when "simple" collation specified and @@ -1092,9 +1092,9 @@ if (db.getMongo().writeMode() === "commands") { coll.drop(); assert.commandWorked( db.createCollection(coll.getName(), {collation: {locale: "en_US", strength: 2}})); - assert.writeOK(coll.insert({_id: "foo"})); + assert.commandWorked(coll.insert({_id: "foo"})); writeRes = coll.remove({_id: "FOO"}, {justOne: true, collation: {locale: "simple"}}); - assert.writeOK(writeRes); + assert.commandWorked(writeRes); assert.eq(0, writeRes.nRemoved); // Remove on _id should use idhack stage when explicit query collation matches collection @@ -1122,8 +1122,8 @@ if (db.getMongo().writeMode() !== "commands") { // remove() shell helper should error if a collation is specified and the shell is not using // write commands. coll.drop(); - assert.writeOK(coll.insert({_id: 1, str: "foo"})); - assert.writeOK(coll.insert({_id: 2, str: "foo"})); + assert.commandWorked(coll.insert({_id: 1, str: "foo"})); + assert.commandWorked(coll.insert({_id: 2, str: "foo"})); assert.throws(function() { coll.remove({str: "FOO"}, {justOne: true, collation: {locale: "en_US", strength: 2}}); }); @@ -1140,13 +1140,13 @@ if (db.getMongo().writeMode() !== "commands") { if (db.getMongo().writeMode() === "commands") { // Update should succeed when collation specified and collection does not exist. coll.drop(); - assert.writeOK( + assert.commandWorked( coll.update({str: "foo"}, {$set: {other: 99}}, {multi: true, collation: {locale: "fr"}})); // Update should return correct results when collation specified. coll.drop(); - assert.writeOK(coll.insert({_id: 1, str: "foo"})); - assert.writeOK(coll.insert({_id: 2, str: "foo"})); + assert.commandWorked(coll.insert({_id: 1, str: "foo"})); + assert.commandWorked(coll.insert({_id: 2, str: "foo"})); writeRes = coll.update({str: "FOO"}, {$set: {other: 99}}, {multi: true, collation: {locale: "en_US", strength: 2}}); @@ -1154,8 +1154,8 @@ if (db.getMongo().writeMode() === "commands") { // Explain of update should return correct results when collation specified. coll.drop(); - assert.writeOK(coll.insert({_id: 1, str: "foo"})); - assert.writeOK(coll.insert({_id: 2, str: "foo"})); + assert.commandWorked(coll.insert({_id: 1, str: "foo"})); + assert.commandWorked(coll.insert({_id: 2, str: "foo"})); explainRes = coll.explain("executionStats").update({str: "FOO"}, {$set: {other: 99}}, { multi: true, collation: {locale: "en_US", strength: 2} @@ -1171,9 +1171,9 @@ if (db.getMongo().writeMode() === "commands") { coll.drop(); assert.commandWorked( db.createCollection(coll.getName(), {collation: {locale: "en_US", strength: 2}})); -assert.writeOK(coll.insert({_id: 1, str: "foo"})); +assert.commandWorked(coll.insert({_id: 1, str: "foo"})); writeRes = coll.update({str: "FOO"}, {$set: {other: 99}}); -assert.writeOK(writeRes); +assert.commandWorked(writeRes); assert.eq(1, writeRes.nMatched); // Update with idhack should return correct results when no collation specified and collection @@ -1181,9 +1181,9 @@ assert.eq(1, writeRes.nMatched); coll.drop(); assert.commandWorked( db.createCollection(coll.getName(), {collation: {locale: "en_US", strength: 2}})); -assert.writeOK(coll.insert({_id: "foo"})); +assert.commandWorked(coll.insert({_id: "foo"})); writeRes = coll.update({_id: "FOO"}, {$set: {other: 99}}); -assert.writeOK(writeRes); +assert.commandWorked(writeRes); assert.eq(1, writeRes.nMatched); // Update on _id should use idhack stage when query inherits collection default collation. @@ -1200,9 +1200,9 @@ if (db.getMongo().writeMode() === "commands") { coll.drop(); assert.commandWorked( db.createCollection(coll.getName(), {collation: {locale: "en_US", strength: 2}})); - assert.writeOK(coll.insert({_id: 1, str: "foo"})); + assert.commandWorked(coll.insert({_id: 1, str: "foo"})); writeRes = coll.update({str: "FOO"}, {$set: {other: 99}}, {collation: {locale: "simple"}}); - assert.writeOK(writeRes); + assert.commandWorked(writeRes); assert.eq(0, writeRes.nModified); // Update on _id should return correct results when "simple" collation specified and @@ -1210,9 +1210,9 @@ if (db.getMongo().writeMode() === "commands") { coll.drop(); assert.commandWorked( db.createCollection(coll.getName(), {collation: {locale: "en_US", strength: 2}})); - assert.writeOK(coll.insert({_id: "foo"})); + assert.commandWorked(coll.insert({_id: "foo"})); writeRes = coll.update({_id: "FOO"}, {$set: {other: 99}}, {collation: {locale: "simple"}}); - assert.writeOK(writeRes); + assert.commandWorked(writeRes); assert.eq(0, writeRes.nModified); // Update on _id should use idhack stage when explicitly given query collation matches @@ -1242,8 +1242,8 @@ if (db.getMongo().writeMode() !== "commands") { // update() shell helper should error if a collation is specified and the shell is not using // write commands. coll.drop(); - assert.writeOK(coll.insert({_id: 1, str: "foo"})); - assert.writeOK(coll.insert({_id: 2, str: "foo"})); + assert.commandWorked(coll.insert({_id: 1, str: "foo"})); + assert.commandWorked(coll.insert({_id: 2, str: "foo"})); assert.throws(function() { coll.update({str: "FOO"}, {$set: {other: 99}}, @@ -1277,7 +1277,7 @@ assert.commandFailedWithCode(db.runCommand({ // $geoNear rejects the now-deprecated "collation" option. coll.drop(); -assert.writeOK(coll.insert({geo: {type: "Point", coordinates: [0, 0]}, str: "abc"})); +assert.commandWorked(coll.insert({geo: {type: "Point", coordinates: [0, 0]}, str: "abc"})); assert.commandFailedWithCode(db.runCommand({ aggregate: coll.getName(), cursor: {}, @@ -1335,7 +1335,7 @@ coll.drop(); assert.commandWorked( db.createCollection(coll.getName(), {collation: {locale: "en_US", strength: 2}})); assert.commandWorked(coll.ensureIndex({geo: "2dsphere"})); -assert.writeOK(coll.insert({geo: {type: "Point", coordinates: [0, 0]}, str: "abc"})); +assert.commandWorked(coll.insert({geo: {type: "Point", coordinates: [0, 0]}, str: "abc"})); assert.eq(1, coll.aggregate([geoNearStage]).itcount()); // $geoNear should return correct results when "simple" collation specified and collection has @@ -1344,7 +1344,7 @@ coll.drop(); assert.commandWorked( db.createCollection(coll.getName(), {collation: {locale: "en_US", strength: 2}})); assert.commandWorked(coll.ensureIndex({geo: "2dsphere"})); -assert.writeOK(coll.insert({geo: {type: "Point", coordinates: [0, 0]}, str: "abc"})); +assert.commandWorked(coll.insert({geo: {type: "Point", coordinates: [0, 0]}, str: "abc"})); assert.eq(0, coll.aggregate([geoNearStage], {collation: {locale: "simple"}}).itcount()); // @@ -1365,7 +1365,7 @@ if (db.getMongo().useReadCommands()) { // Find with $nearSphere should return correct results when collation specified and string // predicate not indexed. coll.drop(); - assert.writeOK(coll.insert({geo: {type: "Point", coordinates: [0, 0]}, str: "abc"})); + assert.commandWorked(coll.insert({geo: {type: "Point", coordinates: [0, 0]}, str: "abc"})); assert.commandWorked(coll.ensureIndex({geo: "2dsphere"})); assert.eq( 0, @@ -1438,8 +1438,8 @@ var bulk; if (db.getMongo().writeMode() !== "commands") { coll.drop(); - assert.writeOK(coll.insert({_id: 1, str: "foo"})); - assert.writeOK(coll.insert({_id: 2, str: "foo"})); + assert.commandWorked(coll.insert({_id: 1, str: "foo"})); + assert.commandWorked(coll.insert({_id: 2, str: "foo"})); // Can't use the bulk API to set a collation when using legacy write ops. bulk = coll.initializeUnorderedBulkOp(); @@ -1454,44 +1454,44 @@ if (db.getMongo().writeMode() !== "commands") { } else { // update(). coll.drop(); - assert.writeOK(coll.insert({_id: 1, str: "foo"})); - assert.writeOK(coll.insert({_id: 2, str: "foo"})); + assert.commandWorked(coll.insert({_id: 1, str: "foo"})); + assert.commandWorked(coll.insert({_id: 2, str: "foo"})); bulk = coll.initializeUnorderedBulkOp(); bulk.find({str: "FOO"}).collation({locale: "en_US", strength: 2}).update({$set: {other: 99}}); writeRes = bulk.execute(); - assert.writeOK(writeRes); + assert.commandWorked(writeRes); assert.eq(2, writeRes.nModified); // updateOne(). coll.drop(); - assert.writeOK(coll.insert({_id: 1, str: "foo"})); - assert.writeOK(coll.insert({_id: 2, str: "foo"})); + assert.commandWorked(coll.insert({_id: 1, str: "foo"})); + assert.commandWorked(coll.insert({_id: 2, str: "foo"})); bulk = coll.initializeUnorderedBulkOp(); bulk.find({str: "FOO"}).collation({locale: "en_US", strength: 2}).updateOne({ $set: {other: 99} }); writeRes = bulk.execute(); - assert.writeOK(writeRes); + assert.commandWorked(writeRes); assert.eq(1, writeRes.nModified); // replaceOne(). coll.drop(); - assert.writeOK(coll.insert({_id: 1, str: "foo"})); - assert.writeOK(coll.insert({_id: 2, str: "foo"})); + assert.commandWorked(coll.insert({_id: 1, str: "foo"})); + assert.commandWorked(coll.insert({_id: 2, str: "foo"})); bulk = coll.initializeUnorderedBulkOp(); bulk.find({str: "FOO"}).collation({locale: "en_US", strength: 2}).replaceOne({str: "oof"}); writeRes = bulk.execute(); - assert.writeOK(writeRes); + assert.commandWorked(writeRes); assert.eq(1, writeRes.nModified); // replaceOne() with upsert(). coll.drop(); - assert.writeOK(coll.insert({_id: 1, str: "foo"})); - assert.writeOK(coll.insert({_id: 2, str: "foo"})); + assert.commandWorked(coll.insert({_id: 1, str: "foo"})); + assert.commandWorked(coll.insert({_id: 2, str: "foo"})); bulk = coll.initializeUnorderedBulkOp(); bulk.find({str: "FOO"}).collation({locale: "en_US"}).upsert().replaceOne({str: "foo"}); writeRes = bulk.execute(); - assert.writeOK(writeRes); + assert.commandWorked(writeRes); assert.eq(1, writeRes.nUpserted); assert.eq(0, writeRes.nModified); @@ -1500,28 +1500,28 @@ if (db.getMongo().writeMode() !== "commands") { str: "foo" }); writeRes = bulk.execute(); - assert.writeOK(writeRes); + assert.commandWorked(writeRes); assert.eq(0, writeRes.nUpserted); assert.eq(1, writeRes.nModified); // removeOne(). coll.drop(); - assert.writeOK(coll.insert({_id: 1, str: "foo"})); - assert.writeOK(coll.insert({_id: 2, str: "foo"})); + assert.commandWorked(coll.insert({_id: 1, str: "foo"})); + assert.commandWorked(coll.insert({_id: 2, str: "foo"})); bulk = coll.initializeUnorderedBulkOp(); bulk.find({str: "FOO"}).collation({locale: "en_US", strength: 2}).removeOne(); writeRes = bulk.execute(); - assert.writeOK(writeRes); + assert.commandWorked(writeRes); assert.eq(1, writeRes.nRemoved); // remove(). coll.drop(); - assert.writeOK(coll.insert({_id: 1, str: "foo"})); - assert.writeOK(coll.insert({_id: 2, str: "foo"})); + assert.commandWorked(coll.insert({_id: 1, str: "foo"})); + assert.commandWorked(coll.insert({_id: 2, str: "foo"})); bulk = coll.initializeUnorderedBulkOp(); bulk.find({str: "FOO"}).collation({locale: "en_US", strength: 2}).remove(); writeRes = bulk.execute(); - assert.writeOK(writeRes); + assert.commandWorked(writeRes); assert.eq(2, writeRes.nRemoved); } @@ -1531,8 +1531,8 @@ if (db.getMongo().writeMode() !== "commands") { // deleteOne(). coll.drop(); -assert.writeOK(coll.insert({_id: 1, str: "foo"})); -assert.writeOK(coll.insert({_id: 2, str: "foo"})); +assert.commandWorked(coll.insert({_id: 1, str: "foo"})); +assert.commandWorked(coll.insert({_id: 2, str: "foo"})); if (db.getMongo().writeMode() === "commands") { var res = coll.deleteOne({str: "FOO"}, {collation: {locale: "en_US", strength: 2}}); assert.eq(1, res.deletedCount); @@ -1544,8 +1544,8 @@ if (db.getMongo().writeMode() === "commands") { // deleteMany(). coll.drop(); -assert.writeOK(coll.insert({_id: 1, str: "foo"})); -assert.writeOK(coll.insert({_id: 2, str: "foo"})); +assert.commandWorked(coll.insert({_id: 1, str: "foo"})); +assert.commandWorked(coll.insert({_id: 2, str: "foo"})); if (db.getMongo().writeMode() === "commands") { var res = coll.deleteMany({str: "FOO"}, {collation: {locale: "en_US", strength: 2}}); assert.eq(2, res.deletedCount); @@ -1557,14 +1557,14 @@ if (db.getMongo().writeMode() === "commands") { // findOneAndDelete(). coll.drop(); -assert.writeOK(coll.insert({_id: 1, str: "foo"})); +assert.commandWorked(coll.insert({_id: 1, str: "foo"})); assert.eq({_id: 1, str: "foo"}, coll.findOneAndDelete({str: "FOO"}, {collation: {locale: "en_US", strength: 2}})); assert.eq(null, coll.findOne({_id: 1})); // findOneAndReplace(). coll.drop(); -assert.writeOK(coll.insert({_id: 1, str: "foo"})); +assert.commandWorked(coll.insert({_id: 1, str: "foo"})); assert.eq({_id: 1, str: "foo"}, coll.findOneAndReplace( {str: "FOO"}, {str: "bar"}, {collation: {locale: "en_US", strength: 2}})); @@ -1572,7 +1572,7 @@ assert.neq(null, coll.findOne({str: "bar"})); // findOneAndUpdate(). coll.drop(); -assert.writeOK(coll.insert({_id: 1, str: "foo"})); +assert.commandWorked(coll.insert({_id: 1, str: "foo"})); assert.eq({_id: 1, str: "foo"}, coll.findOneAndUpdate( {str: "FOO"}, {$set: {other: 99}}, {collation: {locale: "en_US", strength: 2}})); @@ -1580,8 +1580,8 @@ assert.neq(null, coll.findOne({other: 99})); // replaceOne(). coll.drop(); -assert.writeOK(coll.insert({_id: 1, str: "foo"})); -assert.writeOK(coll.insert({_id: 2, str: "foo"})); +assert.commandWorked(coll.insert({_id: 1, str: "foo"})); +assert.commandWorked(coll.insert({_id: 2, str: "foo"})); if (db.getMongo().writeMode() === "commands") { var res = coll.replaceOne({str: "FOO"}, {str: "bar"}, {collation: {locale: "en_US", strength: 2}}); @@ -1594,8 +1594,8 @@ if (db.getMongo().writeMode() === "commands") { // updateOne(). coll.drop(); -assert.writeOK(coll.insert({_id: 1, str: "foo"})); -assert.writeOK(coll.insert({_id: 2, str: "foo"})); +assert.commandWorked(coll.insert({_id: 1, str: "foo"})); +assert.commandWorked(coll.insert({_id: 2, str: "foo"})); if (db.getMongo().writeMode() === "commands") { var res = coll.updateOne( {str: "FOO"}, {$set: {other: 99}}, {collation: {locale: "en_US", strength: 2}}); @@ -1609,8 +1609,8 @@ if (db.getMongo().writeMode() === "commands") { // updateMany(). coll.drop(); -assert.writeOK(coll.insert({_id: 1, str: "foo"})); -assert.writeOK(coll.insert({_id: 2, str: "foo"})); +assert.commandWorked(coll.insert({_id: 1, str: "foo"})); +assert.commandWorked(coll.insert({_id: 2, str: "foo"})); if (db.getMongo().writeMode() === "commands") { var res = coll.updateMany( {str: "FOO"}, {$set: {other: 99}}, {collation: {locale: "en_US", strength: 2}}); @@ -1624,8 +1624,8 @@ if (db.getMongo().writeMode() === "commands") { // updateOne with bulkWrite(). coll.drop(); -assert.writeOK(coll.insert({_id: 1, str: "foo"})); -assert.writeOK(coll.insert({_id: 2, str: "foo"})); +assert.commandWorked(coll.insert({_id: 1, str: "foo"})); +assert.commandWorked(coll.insert({_id: 2, str: "foo"})); if (db.getMongo().writeMode() === "commands") { var res = coll.bulkWrite([{ updateOne: { @@ -1649,8 +1649,8 @@ if (db.getMongo().writeMode() === "commands") { // updateMany with bulkWrite(). coll.drop(); -assert.writeOK(coll.insert({_id: 1, str: "foo"})); -assert.writeOK(coll.insert({_id: 2, str: "foo"})); +assert.commandWorked(coll.insert({_id: 1, str: "foo"})); +assert.commandWorked(coll.insert({_id: 2, str: "foo"})); if (db.getMongo().writeMode() === "commands") { var res = coll.bulkWrite([{ updateMany: { @@ -1674,8 +1674,8 @@ if (db.getMongo().writeMode() === "commands") { // replaceOne with bulkWrite(). coll.drop(); -assert.writeOK(coll.insert({_id: 1, str: "foo"})); -assert.writeOK(coll.insert({_id: 2, str: "foo"})); +assert.commandWorked(coll.insert({_id: 1, str: "foo"})); +assert.commandWorked(coll.insert({_id: 2, str: "foo"})); if (db.getMongo().writeMode() === "commands") { var res = coll.bulkWrite([{ replaceOne: { @@ -1699,8 +1699,8 @@ if (db.getMongo().writeMode() === "commands") { // deleteOne with bulkWrite(). coll.drop(); -assert.writeOK(coll.insert({_id: 1, str: "foo"})); -assert.writeOK(coll.insert({_id: 2, str: "foo"})); +assert.commandWorked(coll.insert({_id: 1, str: "foo"})); +assert.commandWorked(coll.insert({_id: 2, str: "foo"})); if (db.getMongo().writeMode() === "commands") { var res = coll.bulkWrite( [{deleteOne: {filter: {str: "FOO"}, collation: {locale: "en_US", strength: 2}}}]); @@ -1714,8 +1714,8 @@ if (db.getMongo().writeMode() === "commands") { // deleteMany with bulkWrite(). coll.drop(); -assert.writeOK(coll.insert({_id: 1, str: "foo"})); -assert.writeOK(coll.insert({_id: 2, str: "foo"})); +assert.commandWorked(coll.insert({_id: 1, str: "foo"})); +assert.commandWorked(coll.insert({_id: 2, str: "foo"})); if (db.getMongo().writeMode() === "commands") { var res = coll.bulkWrite( [{deleteMany: {filter: {str: "FOO"}, collation: {locale: "en_US", strength: 2}}}]); @@ -1729,8 +1729,8 @@ if (db.getMongo().writeMode() === "commands") { // Two deleteOne ops with bulkWrite using different collations. coll.drop(); -assert.writeOK(coll.insert({_id: 1, str: "foo"})); -assert.writeOK(coll.insert({_id: 2, str: "bar"})); +assert.commandWorked(coll.insert({_id: 1, str: "foo"})); +assert.commandWorked(coll.insert({_id: 2, str: "bar"})); if (db.getMongo().writeMode() === "commands") { var res = coll.bulkWrite([ {deleteOne: {filter: {str: "FOO"}, collation: {locale: "fr", strength: 2}}}, @@ -1751,7 +1751,7 @@ if (!isMongos) { coll.drop(); assert.commandWorked( db.createCollection("collation", {collation: {locale: "en_US", strength: 2}})); - assert.writeOK(coll.insert({_id: "foo", x: 5, str: "bar"})); + assert.commandWorked(coll.insert({_id: "foo", x: 5, str: "bar"})); // preCondition.q respects collection default collation. assert.commandFailed(db.runCommand({ @@ -1798,8 +1798,8 @@ if (!isMongos) { const originalCollectionInfos = db.getCollectionInfos({name: coll.getName()}); assert.eq(originalCollectionInfos.length, 1, tojson(originalCollectionInfos)); - assert.writeOK(coll.insert({_id: "FOO"})); - assert.writeOK(coll.insert({_id: "bar"})); + assert.commandWorked(coll.insert({_id: "FOO"})); + assert.commandWorked(coll.insert({_id: "bar"})); assert.eq([{_id: "FOO"}], coll.find({_id: "foo"}).toArray(), "query should have performed a case-insensitive match"); @@ -1822,14 +1822,14 @@ if (!isMongos) { // Test that the find command's min/max options respect the collation. if (db.getMongo().useReadCommands()) { coll.drop(); - assert.writeOK(coll.insert({str: "a"})); - assert.writeOK(coll.insert({str: "A"})); - assert.writeOK(coll.insert({str: "b"})); - assert.writeOK(coll.insert({str: "B"})); - assert.writeOK(coll.insert({str: "c"})); - assert.writeOK(coll.insert({str: "C"})); - assert.writeOK(coll.insert({str: "d"})); - assert.writeOK(coll.insert({str: "D"})); + assert.commandWorked(coll.insert({str: "a"})); + assert.commandWorked(coll.insert({str: "A"})); + assert.commandWorked(coll.insert({str: "b"})); + assert.commandWorked(coll.insert({str: "B"})); + assert.commandWorked(coll.insert({str: "c"})); + assert.commandWorked(coll.insert({str: "C"})); + assert.commandWorked(coll.insert({str: "d"})); + assert.commandWorked(coll.insert({str: "D"})); // This query should fail, since there is no index to support the min/max. let err = assert.throws(() => coll.find() @@ -1880,7 +1880,7 @@ if (db.getMongo().useReadCommands()) { // Ensure results from index with min/max query are sorted to match requested collation. coll.drop(); assert.commandWorked(coll.ensureIndex({a: 1, b: 1})); - assert.writeOK( + assert.commandWorked( coll.insert([{a: 1, b: 1}, {a: 1, b: 2}, {a: 1, b: "A"}, {a: 1, b: "a"}, {a: 2, b: 2}])); var expected = [{a: 1, b: 1}, {a: 1, b: 2}, {a: 1, b: "a"}, {a: 1, b: "A"}, {a: 2, b: 2}]; res = coll.find({}, {_id: 0}) diff --git a/jstests/core/collation_convert_to_capped.js b/jstests/core/collation_convert_to_capped.js index 237156e86d7..811d2849bc7 100644 --- a/jstests/core/collation_convert_to_capped.js +++ b/jstests/core/collation_convert_to_capped.js @@ -21,8 +21,8 @@ assert.commandWorked( const originalCollectionInfos = testDb.getCollectionInfos({name: coll.getName()}); assert.eq(originalCollectionInfos.length, 1, tojson(originalCollectionInfos)); -assert.writeOK(coll.insert({_id: "FOO"})); -assert.writeOK(coll.insert({_id: "bar"})); +assert.commandWorked(coll.insert({_id: "FOO"})); +assert.commandWorked(coll.insert({_id: "bar"})); assert.eq([{_id: "FOO"}], coll.find({_id: "foo"}).toArray(), "query should have performed a case-insensitive match"); diff --git a/jstests/core/collation_plan_cache.js b/jstests/core/collation_plan_cache.js index 07507938cc3..97d7f220f54 100644 --- a/jstests/core/collation_plan_cache.js +++ b/jstests/core/collation_plan_cache.js @@ -13,7 +13,7 @@ var coll = db.collation_plan_cache; coll.drop(); -assert.writeOK(coll.insert({a: 'foo', b: 5})); +assert.commandWorked(coll.insert({a: 'foo', b: 5})); // We need two indexes that each query can use so that a plan cache entry is created. assert.commandWorked(coll.createIndex({a: 1}, {collation: {locale: 'en_US'}})); diff --git a/jstests/core/collation_update.js b/jstests/core/collation_update.js index 32538e15653..1337bfcd271 100644 --- a/jstests/core/collation_update.js +++ b/jstests/core/collation_update.js @@ -20,8 +20,8 @@ const numericOrdering = { // Update modifiers respect collection default collation on simple _id query. coll.drop(); assert.commandWorked(db.createCollection(coll.getName(), numericOrdering)); -assert.writeOK(coll.insert({_id: 1, a: "124"})); -assert.writeOK(coll.update({_id: 1}, {$min: {a: "1234"}})); +assert.commandWorked(coll.insert({_id: 1, a: "124"})); +assert.commandWorked(coll.update({_id: 1}, {$min: {a: "1234"}})); assert.eq(coll.find({a: "124"}).count(), 1); // $min respects query collation. @@ -29,20 +29,20 @@ if (db.getMongo().writeMode() === "commands") { coll.drop(); // 1234 > 124, so no change should occur. - assert.writeOK(coll.insert({a: "124"})); - assert.writeOK(coll.update({a: "124"}, {$min: {a: "1234"}}, numericOrdering)); + assert.commandWorked(coll.insert({a: "124"})); + assert.commandWorked(coll.update({a: "124"}, {$min: {a: "1234"}}, numericOrdering)); assert.eq(coll.find({a: "124"}).count(), 1); // "1234" < "124" (non-numeric ordering), so an update should occur. - assert.writeOK(coll.update({a: "124"}, {$min: {a: "1234"}}, caseSensitive)); + assert.commandWorked(coll.update({a: "124"}, {$min: {a: "1234"}}, caseSensitive)); assert.eq(coll.find({a: "1234"}).count(), 1); } // $min respects collection default collation. coll.drop(); assert.commandWorked(db.createCollection(coll.getName(), numericOrdering)); -assert.writeOK(coll.insert({a: "124"})); -assert.writeOK(coll.update({a: "124"}, {$min: {a: "1234"}})); +assert.commandWorked(coll.insert({a: "124"})); +assert.commandWorked(coll.update({a: "124"}, {$min: {a: "1234"}})); assert.eq(coll.find({a: "124"}).count(), 1); // $max respects query collation. @@ -50,20 +50,20 @@ if (db.getMongo().writeMode() === "commands") { coll.drop(); // "1234" < "124", so an update should not occur. - assert.writeOK(coll.insert({a: "124"})); - assert.writeOK(coll.update({a: "124"}, {$max: {a: "1234"}}, caseSensitive)); + assert.commandWorked(coll.insert({a: "124"})); + assert.commandWorked(coll.update({a: "124"}, {$max: {a: "1234"}}, caseSensitive)); assert.eq(coll.find({a: "124"}).count(), 1); // 1234 > 124, so an update should occur. - assert.writeOK(coll.update({a: "124"}, {$max: {a: "1234"}}, numericOrdering)); + assert.commandWorked(coll.update({a: "124"}, {$max: {a: "1234"}}, numericOrdering)); assert.eq(coll.find({a: "1234"}).count(), 1); } // $max respects collection default collation. coll.drop(); assert.commandWorked(db.createCollection(coll.getName(), numericOrdering)); -assert.writeOK(coll.insert({a: "124"})); -assert.writeOK(coll.update({a: "124"}, {$max: {a: "1234"}})); +assert.commandWorked(coll.insert({a: "124"})); +assert.commandWorked(coll.update({a: "124"}, {$max: {a: "1234"}})); assert.eq(coll.find({a: "1234"}).count(), 1); // $addToSet respects query collation. @@ -71,21 +71,21 @@ if (db.getMongo().writeMode() === "commands") { coll.drop(); // "foo" == "FOO" (case-insensitive), so set isn't extended. - assert.writeOK(coll.insert({a: ["foo"]})); - assert.writeOK(coll.update({}, {$addToSet: {a: "FOO"}}, caseInsensitive)); + assert.commandWorked(coll.insert({a: ["foo"]})); + assert.commandWorked(coll.update({}, {$addToSet: {a: "FOO"}}, caseInsensitive)); var set = coll.findOne().a; assert.eq(set.length, 1); // "foo" != "FOO" (case-sensitive), so set is extended. - assert.writeOK(coll.update({}, {$addToSet: {a: "FOO"}}, caseSensitive)); + assert.commandWorked(coll.update({}, {$addToSet: {a: "FOO"}}, caseSensitive)); set = coll.findOne().a; assert.eq(set.length, 2); coll.drop(); // $each and $addToSet respect collation - assert.writeOK(coll.insert({a: ["foo", "bar", "FOO"]})); - assert.writeOK( + assert.commandWorked(coll.insert({a: ["foo", "bar", "FOO"]})); + assert.commandWorked( coll.update({}, {$addToSet: {a: {$each: ["FOO", "BAR", "str"]}}}, caseInsensitive)); set = coll.findOne().a; assert.eq(set.length, 4); @@ -98,8 +98,8 @@ if (db.getMongo().writeMode() === "commands") { coll.drop(); assert.commandWorked(db.createCollection(coll.getName(), caseInsensitive)); // "foo" == "FOO" (case-insensitive), so set isn't extended. -assert.writeOK(coll.insert({a: ["foo"]})); -assert.writeOK(coll.update({}, {$addToSet: {a: "FOO"}})); +assert.commandWorked(coll.insert({a: ["foo"]})); +assert.commandWorked(coll.update({}, {$addToSet: {a: "FOO"}})); var set = coll.findOne().a; assert.eq(set.length, 1); @@ -108,21 +108,21 @@ if (db.getMongo().writeMode() === "commands") { coll.drop(); // "foo" != "FOO" (case-sensitive), so it is not pulled. - assert.writeOK(coll.insert({a: ["foo", "FOO"]})); - assert.writeOK(coll.update({}, {$pull: {a: "foo"}}, caseSensitive)); + assert.commandWorked(coll.insert({a: ["foo", "FOO"]})); + assert.commandWorked(coll.update({}, {$pull: {a: "foo"}}, caseSensitive)); var arr = coll.findOne().a; assert.eq(arr.length, 1); assert(arr.includes("FOO")); // "foo" == "FOO" (case-insensitive), so "FOO" is pulled. - assert.writeOK(coll.update({}, {$pull: {a: "foo"}}, caseInsensitive)); + assert.commandWorked(coll.update({}, {$pull: {a: "foo"}}, caseInsensitive)); arr = coll.findOne().a; assert.eq(arr.length, 0); // collation-aware $pull removes all instances that match. coll.drop(); - assert.writeOK(coll.insert({a: ["foo", "FOO"]})); - assert.writeOK(coll.update({}, {$pull: {a: "foo"}}, caseInsensitive)); + assert.commandWorked(coll.insert({a: ["foo", "FOO"]})); + assert.commandWorked(coll.update({}, {$pull: {a: "foo"}}, caseInsensitive)); arr = coll.findOne().a; assert.eq(arr.length, 0); @@ -130,13 +130,13 @@ if (db.getMongo().writeMode() === "commands") { coll.drop(); // "124" > "1234" (case-sensitive), so it is not removed. - assert.writeOK(coll.insert({a: ["124", "1234"]})); - assert.writeOK(coll.update({}, {$pull: {a: {$lt: "1234"}}}, caseSensitive)); + assert.commandWorked(coll.insert({a: ["124", "1234"]})); + assert.commandWorked(coll.update({}, {$pull: {a: {$lt: "1234"}}}, caseSensitive)); arr = coll.findOne().a; assert.eq(arr.length, 2); // 124 < 1234 (numeric ordering), so it is removed. - assert.writeOK(coll.update({}, {$pull: {a: {$lt: "1234"}}}, numericOrdering)); + assert.commandWorked(coll.update({}, {$pull: {a: {$lt: "1234"}}}, numericOrdering)); arr = coll.findOne().a; assert.eq(arr.length, 1); assert(arr.includes("1234")); @@ -145,8 +145,8 @@ if (db.getMongo().writeMode() === "commands") { // $pull respects collection default collation. coll.drop(); assert.commandWorked(db.createCollection(coll.getName(), caseInsensitive)); -assert.writeOK(coll.insert({a: ["foo", "FOO"]})); -assert.writeOK(coll.update({}, {$pull: {a: "foo"}})); +assert.commandWorked(coll.insert({a: ["foo", "FOO"]})); +assert.commandWorked(coll.update({}, {$pull: {a: "foo"}})); var arr = coll.findOne().a; assert.eq(arr.length, 0); @@ -155,13 +155,13 @@ if (db.getMongo().writeMode() === "commands") { coll.drop(); // "foo" != "FOO" (case-sensitive), so no changes are made. - assert.writeOK(coll.insert({a: ["foo", "bar"]})); - assert.writeOK(coll.update({}, {$pullAll: {a: ["FOO", "BAR"]}}, caseSensitive)); + assert.commandWorked(coll.insert({a: ["foo", "bar"]})); + assert.commandWorked(coll.update({}, {$pullAll: {a: ["FOO", "BAR"]}}, caseSensitive)); var arr = coll.findOne().a; assert.eq(arr.length, 2); // "foo" == "FOO", "bar" == "BAR" (case-insensitive), so both are removed. - assert.writeOK(coll.update({}, {$pullAll: {a: ["FOO", "BAR"]}}, caseInsensitive)); + assert.commandWorked(coll.update({}, {$pullAll: {a: ["FOO", "BAR"]}}, caseInsensitive)); arr = coll.findOne().a; assert.eq(arr.length, 0); } @@ -169,8 +169,8 @@ if (db.getMongo().writeMode() === "commands") { // $pullAll respects collection default collation. coll.drop(); assert.commandWorked(db.createCollection(coll.getName(), caseInsensitive)); -assert.writeOK(coll.insert({a: ["foo", "bar"]})); -assert.writeOK(coll.update({}, {$pullAll: {a: ["FOO", "BAR"]}})); +assert.commandWorked(coll.insert({a: ["foo", "bar"]})); +assert.commandWorked(coll.update({}, {$pullAll: {a: ["FOO", "BAR"]}})); var arr = coll.findOne().a; assert.eq(arr.length, 0); @@ -179,8 +179,8 @@ if (db.getMongo().writeMode() === "commands") { coll.drop(); // "1230" < "1234" < "124" (case-sensitive) - assert.writeOK(coll.insert({a: ["1234", "124"]})); - assert.writeOK(coll.update({}, {$push: {a: {$each: ["1230"], $sort: 1}}}, caseSensitive)); + assert.commandWorked(coll.insert({a: ["1234", "124"]})); + assert.commandWorked(coll.update({}, {$push: {a: {$each: ["1230"], $sort: 1}}}, caseSensitive)); var arr = coll.findOne().a; assert.eq(arr.length, 3); assert.eq(arr[0], "1230"); @@ -189,8 +189,9 @@ if (db.getMongo().writeMode() === "commands") { // "124" < "1230" < "1234" (numeric ordering) coll.drop(); - assert.writeOK(coll.insert({a: ["1234", "124"]})); - assert.writeOK(coll.update({}, {$push: {a: {$each: ["1230"], $sort: 1}}}, numericOrdering)); + assert.commandWorked(coll.insert({a: ["1234", "124"]})); + assert.commandWorked( + coll.update({}, {$push: {a: {$each: ["1230"], $sort: 1}}}, numericOrdering)); arr = coll.findOne().a; assert.eq(arr.length, 3); assert.eq(arr[0], "124"); @@ -201,8 +202,8 @@ if (db.getMongo().writeMode() === "commands") { // $push with $sort respects collection default collation. coll.drop(); assert.commandWorked(db.createCollection(coll.getName(), numericOrdering)); -assert.writeOK(coll.insert({a: ["1234", "124"]})); -assert.writeOK(coll.update({}, {$push: {a: {$each: ["1230"], $sort: 1}}})); +assert.commandWorked(coll.insert({a: ["1234", "124"]})); +assert.commandWorked(coll.update({}, {$push: {a: {$each: ["1230"], $sort: 1}}})); var arr = coll.findOne().a; assert.eq(arr.length, 3); assert.eq(arr[0], "124"); @@ -214,16 +215,16 @@ if (db.getMongo().writeMode() === "commands") { coll.drop(); // "foo" != "FOO" (case-sensitive) so no update occurs. - assert.writeOK(coll.insert({a: ["foo", "FOO"]})); - assert.writeOK(coll.update({a: "FOO"}, {$set: {"a.$": "FOO"}}, caseSensitive)); + assert.commandWorked(coll.insert({a: ["foo", "FOO"]})); + assert.commandWorked(coll.update({a: "FOO"}, {$set: {"a.$": "FOO"}}, caseSensitive)); var arr = coll.findOne().a; assert.eq(arr.length, 2); assert.eq(arr[0], "foo"); assert.eq(arr[1], "FOO"); // "foo" == "FOO" (case-insensitive) so no update occurs. - assert.writeOK(coll.insert({a: ["foo", "FOO"]})); - assert.writeOK(coll.update({a: "FOO"}, {$set: {"a.$": "FOO"}}, caseInsensitive)); + assert.commandWorked(coll.insert({a: ["foo", "FOO"]})); + assert.commandWorked(coll.update({a: "FOO"}, {$set: {"a.$": "FOO"}}, caseInsensitive)); var arr = coll.findOne().a; assert.eq(arr.length, 2); assert.eq(arr[0], "FOO"); @@ -233,8 +234,8 @@ if (db.getMongo().writeMode() === "commands") { // $ positional operator respects collection default collation on $set. coll.drop(); assert.commandWorked(db.createCollection(coll.getName(), caseInsensitive)); -assert.writeOK(coll.insert({a: ["foo", "FOO"]})); -assert.writeOK(coll.update({a: "FOO"}, {$set: {"a.$": "FOO"}})); +assert.commandWorked(coll.insert({a: ["foo", "FOO"]})); +assert.commandWorked(coll.update({a: "FOO"}, {$set: {"a.$": "FOO"}})); var arr = coll.findOne().a; assert.eq(arr.length, 2); assert.eq(arr[0], "FOO"); diff --git a/jstests/core/collmod_without_uuid.js b/jstests/core/collmod_without_uuid.js index d3b2ca5a287..354d587b637 100644 --- a/jstests/core/collmod_without_uuid.js +++ b/jstests/core/collmod_without_uuid.js @@ -20,7 +20,7 @@ function checkUUIDs() { } db[collName].drop(); -assert.writeOK(db[collName].insert({})); +assert.commandWorked(db[collName].insert({})); checkUUIDs(); let cmd = {applyOps: [{ns: "test.$cmd", op: "c", o: {collMod: collName}}]}; let res = db.runCommand(cmd); diff --git a/jstests/core/commands_namespace_parsing.js b/jstests/core/commands_namespace_parsing.js index 88431388eca..e17ab50ea50 100644 --- a/jstests/core/commands_namespace_parsing.js +++ b/jstests/core/commands_namespace_parsing.js @@ -56,7 +56,7 @@ assert.commandWorked(isMaster); const isMongos = (isMaster.msg === "isdbgrid"); db.commands_namespace_parsing.drop(); -assert.writeOK(db.commands_namespace_parsing.insert({a: 1})); +assert.commandWorked(db.commands_namespace_parsing.insert({a: 1})); // Test aggregate fails with an invalid collection name. assertFailsWithInvalidNamespacesForField( diff --git a/jstests/core/compare_timestamps.js b/jstests/core/compare_timestamps.js index b88bb003483..54db4b0fd36 100644 --- a/jstests/core/compare_timestamps.js +++ b/jstests/core/compare_timestamps.js @@ -3,7 +3,7 @@ 'use strict'; var t = db.compare_timestamps; t.drop(); -assert.writeOK(t.insert({a: new Timestamp(0xffffffff, 3), b: "non-zero"})); -assert.writeOK(t.insert({a: new Timestamp(0, 0), b: "zero"})); +assert.commandWorked(t.insert({a: new Timestamp(0xffffffff, 3), b: "non-zero"})); +assert.commandWorked(t.insert({a: new Timestamp(0, 0), b: "zero"})); assert.eq(t.find().sort({a: 1}).limit(1).next().b, "zero", "timestamp must compare unsigned"); }()); diff --git a/jstests/core/constructors.js b/jstests/core/constructors.js index 0e28150e701..7657f3b4b1e 100644 --- a/jstests/core/constructors.js +++ b/jstests/core/constructors.js @@ -77,7 +77,7 @@ function whereConstructorTest(constructorList) { constructorList = addConstructorsWithNew(constructorList); t = db.where_constructors; t.drop(); - assert.writeOK(t.insert({x: 1})); + assert.commandWorked(t.insert({x: 1})); constructorList.valid.forEach(function(constructor) { try { diff --git a/jstests/core/convert_to_capped.js b/jstests/core/convert_to_capped.js index 58731299dae..73694bc52d0 100644 --- a/jstests/core/convert_to_capped.js +++ b/jstests/core/convert_to_capped.js @@ -17,7 +17,7 @@ testDb.dropDatabase(); // Create a collection with some data. let num = 10; for (let i = 0; i < num; ++i) { - assert.writeOK(coll.insert({_id: i})); + assert.commandWorked(coll.insert({_id: i})); } // Ensure we do not allow overflowing the size long long on the server (SERVER-33078). diff --git a/jstests/core/count_hint.js b/jstests/core/count_hint.js index 9bb485410ef..21c7a37b87d 100644 --- a/jstests/core/count_hint.js +++ b/jstests/core/count_hint.js @@ -13,8 +13,8 @@ var coll = db.jstests_count_hint; coll.drop(); -assert.writeOK(coll.insert({i: 1})); -assert.writeOK(coll.insert({i: 2})); +assert.commandWorked(coll.insert({i: 1})); +assert.commandWorked(coll.insert({i: 2})); assert.eq(2, coll.find().count()); diff --git a/jstests/core/coveredIndex1.js b/jstests/core/coveredIndex1.js index 2be0cae4bf9..a4c614a2b1c 100644 --- a/jstests/core/coveredIndex1.js +++ b/jstests/core/coveredIndex1.js @@ -15,12 +15,12 @@ coll.drop(); // Include helpers for analyzing explain output. load("jstests/libs/analyze_plan.js"); -assert.writeOK(coll.insert({order: 0, fn: "john", ln: "doe"})); -assert.writeOK(coll.insert({order: 1, fn: "jack", ln: "doe"})); -assert.writeOK(coll.insert({order: 2, fn: "john", ln: "smith"})); -assert.writeOK(coll.insert({order: 3, fn: "jack", ln: "black"})); -assert.writeOK(coll.insert({order: 4, fn: "bob", ln: "murray"})); -assert.writeOK(coll.insert({order: 5, fn: "aaa", ln: "bbb", obj: {a: 1, b: "blah"}})); +assert.commandWorked(coll.insert({order: 0, fn: "john", ln: "doe"})); +assert.commandWorked(coll.insert({order: 1, fn: "jack", ln: "doe"})); +assert.commandWorked(coll.insert({order: 2, fn: "john", ln: "smith"})); +assert.commandWorked(coll.insert({order: 3, fn: "jack", ln: "black"})); +assert.commandWorked(coll.insert({order: 4, fn: "bob", ln: "murray"})); +assert.commandWorked(coll.insert({order: 5, fn: "aaa", ln: "bbb", obj: {a: 1, b: "blah"}})); /** * Asserts that running the find command with query 'query' and projection 'projection' is diff --git a/jstests/core/covered_multikey.js b/jstests/core/covered_multikey.js index cb5e97d8dbb..297728545ab 100644 --- a/jstests/core/covered_multikey.js +++ b/jstests/core/covered_multikey.js @@ -15,7 +15,7 @@ load("jstests/libs/analyze_plan.js"); let coll = db.covered_multikey; coll.drop(); -assert.writeOK(coll.insert({a: 1, b: [2, 3, 4]})); +assert.commandWorked(coll.insert({a: 1, b: [2, 3, 4]})); assert.commandWorked(coll.createIndex({a: 1, b: 1})); assert.eq(1, coll.find({a: 1, b: 2}, {_id: 0, a: 1}).itcount()); @@ -25,8 +25,8 @@ assert(isIxscan(db, explainRes.queryPlanner.winningPlan)); assert(!planHasStage(db, explainRes.queryPlanner.winningPlan, "FETCH")); coll.drop(); -assert.writeOK(coll.insert({a: 1, b: [1, 2, 3], c: 3, d: 5})); -assert.writeOK(coll.insert({a: [1, 2, 3], b: 1, c: 4, d: 6})); +assert.commandWorked(coll.insert({a: 1, b: [1, 2, 3], c: 3, d: 5})); +assert.commandWorked(coll.insert({a: [1, 2, 3], b: 1, c: 4, d: 6})); assert.commandWorked(coll.createIndex({a: 1, b: 1, c: -1, d: -1})); let cursor = coll.find({a: 1, b: 1}, {_id: 0, c: 1, d: 1}).sort({c: -1, d: -1}); @@ -41,7 +41,7 @@ assert(!planHasStage(db, explainRes.queryPlanner.winningPlan, "FETCH")); // Verify that a query cannot be covered over a path which is multikey due to an empty array. coll.drop(); -assert.writeOK(coll.insert({a: []})); +assert.commandWorked(coll.insert({a: []})); assert.commandWorked(coll.createIndex({a: 1})); assert.eq({a: []}, coll.findOne({a: []}, {_id: 0, a: 1})); explainRes = coll.explain("queryPlanner").find({a: []}, {_id: 0, a: 1}).finish(); @@ -53,7 +53,7 @@ assert.eq(true, ixscanStage.isMultiKey); // Verify that a query cannot be covered over a path which is multikey due to a single-element // array. coll.drop(); -assert.writeOK(coll.insert({a: [2]})); +assert.commandWorked(coll.insert({a: [2]})); assert.commandWorked(coll.createIndex({a: 1})); assert.eq({a: [2]}, coll.findOne({a: 2}, {_id: 0, a: 1})); explainRes = coll.explain("queryPlanner").find({a: 2}, {_id: 0, a: 1}).finish(); @@ -65,9 +65,9 @@ assert.eq(true, ixscanStage.isMultiKey); // Verify that a query cannot be covered over a path which is multikey due to a single-element // array, where the path is made multikey by an update rather than an insert. coll.drop(); -assert.writeOK(coll.insert({a: 2})); +assert.commandWorked(coll.insert({a: 2})); assert.commandWorked(coll.createIndex({a: 1})); -assert.writeOK(coll.update({}, {$set: {a: [2]}})); +assert.commandWorked(coll.update({}, {$set: {a: [2]}})); assert.eq({a: [2]}, coll.findOne({a: 2}, {_id: 0, a: 1})); explainRes = coll.explain("queryPlanner").find({a: 2}, {_id: 0, a: 1}).finish(); assert(planHasStage(db, explainRes.queryPlanner.winningPlan, "IXSCAN")); @@ -78,12 +78,12 @@ assert.eq(true, ixscanStage.isMultiKey); // Verify that a trailing empty array makes a 2dsphere index multikey. coll.drop(); assert.commandWorked(coll.createIndex({"a.b": 1, c: "2dsphere"})); -assert.writeOK(coll.insert({a: {b: 1}, c: {type: "Point", coordinates: [0, 0]}})); +assert.commandWorked(coll.insert({a: {b: 1}, c: {type: "Point", coordinates: [0, 0]}})); explainRes = coll.explain().find().hint({"a.b": 1, c: "2dsphere"}).finish(); ixscanStage = getPlanStage(explainRes.queryPlanner.winningPlan, "IXSCAN"); assert.neq(null, ixscanStage); assert.eq(false, ixscanStage.isMultiKey); -assert.writeOK(coll.insert({a: {b: []}, c: {type: "Point", coordinates: [0, 0]}})); +assert.commandWorked(coll.insert({a: {b: []}, c: {type: "Point", coordinates: [0, 0]}})); explainRes = coll.explain().find().hint({"a.b": 1, c: "2dsphere"}).finish(); ixscanStage = getPlanStage(explainRes.queryPlanner.winningPlan, "IXSCAN"); assert.neq(null, ixscanStage); @@ -92,7 +92,7 @@ assert.eq(true, ixscanStage.isMultiKey); // Verify that a mid-path empty array makes a 2dsphere index multikey. coll.drop(); assert.commandWorked(coll.createIndex({"a.b": 1, c: "2dsphere"})); -assert.writeOK(coll.insert({a: [], c: {type: "Point", coordinates: [0, 0]}})); +assert.commandWorked(coll.insert({a: [], c: {type: "Point", coordinates: [0, 0]}})); explainRes = coll.explain().find().hint({"a.b": 1, c: "2dsphere"}).finish(); ixscanStage = getPlanStage(explainRes.queryPlanner.winningPlan, "IXSCAN"); assert.neq(null, ixscanStage); @@ -101,7 +101,7 @@ assert.eq(true, ixscanStage.isMultiKey); // Verify that a single-element array makes a 2dsphere index multikey. coll.drop(); assert.commandWorked(coll.createIndex({"a.b": 1, c: "2dsphere"})); -assert.writeOK(coll.insert({a: {b: [3]}, c: {type: "Point", coordinates: [0, 0]}})); +assert.commandWorked(coll.insert({a: {b: [3]}, c: {type: "Point", coordinates: [0, 0]}})); explainRes = coll.explain().find().hint({"a.b": 1, c: "2dsphere"}).finish(); ixscanStage = getPlanStage(explainRes.queryPlanner.winningPlan, "IXSCAN"); assert.neq(null, ixscanStage); diff --git a/jstests/core/currentop.js b/jstests/core/currentop.js index 636fdee2cb3..577ec6b159e 100644 --- a/jstests/core/currentop.js +++ b/jstests/core/currentop.js @@ -17,7 +17,7 @@ coll.drop(); assert.commandWorked(db.fsyncLock()); const awaitInsertShell = startParallelShell(function() { - assert.writeOK(db.jstests_currentop.insert({})); + assert.commandWorked(db.jstests_currentop.insert({})); }); // Wait until the write appears in the currentOp output reporting that it is waiting for a lock. diff --git a/jstests/core/cursora.js b/jstests/core/cursora.js index 3def8c6162f..a4c6e94595b 100644 --- a/jstests/core/cursora.js +++ b/jstests/core/cursora.js @@ -21,7 +21,7 @@ function run(n) { let bulk = t.initializeUnorderedBulkOp(); for (let i = 0; i < n; i++) bulk.insert({_id: i}); - assert.writeOK(bulk.execute()); + assert.commandWorked(bulk.execute()); const join = startParallelShell("sleep(50);" + "db.cursora.remove({});"); diff --git a/jstests/core/dbcase.js b/jstests/core/dbcase.js index 033608a3f6a..bcbb103d873 100644 --- a/jstests/core/dbcase.js +++ b/jstests/core/dbcase.js @@ -6,7 +6,7 @@ b = db.getSisterDB("dbcasetest_dbnameA"); a.dropDatabase(); b.dropDatabase(); -assert.writeOK(a.foo.save({x: 1})); +assert.commandWorked(a.foo.save({x: 1})); res = b.foo.save({x: 1}); assert.writeError(res); diff --git a/jstests/core/dbstats.js b/jstests/core/dbstats.js index aa413f905fc..ea424295ebf 100644 --- a/jstests/core/dbstats.js +++ b/jstests/core/dbstats.js @@ -29,7 +29,7 @@ const doc = { _id: 1, x: 1 }; -assert.writeOK(coll.insert(doc)); +assert.commandWorked(coll.insert(doc)); let dbStats = testDB.runCommand({dbStats: 1}); assert.commandWorked(dbStats); diff --git a/jstests/core/distinct1.js b/jstests/core/distinct1.js index 1d4ccaab16c..c35e4179879 100644 --- a/jstests/core/distinct1.js +++ b/jstests/core/distinct1.js @@ -6,11 +6,11 @@ coll.drop(); assert.eq(0, coll.distinct("a").length, "test empty"); -assert.writeOK(coll.insert({a: 1})); -assert.writeOK(coll.insert({a: 2})); -assert.writeOK(coll.insert({a: 2})); -assert.writeOK(coll.insert({a: 2})); -assert.writeOK(coll.insert({a: 3})); +assert.commandWorked(coll.insert({a: 1})); +assert.commandWorked(coll.insert({a: 2})); +assert.commandWorked(coll.insert({a: 2})); +assert.commandWorked(coll.insert({a: 2})); +assert.commandWorked(coll.insert({a: 3})); // Test that distinct returns all the distinct values. assert.eq([1, 2, 3], coll.distinct("a").sort(), "distinct returned unexpected results"); @@ -22,10 +22,10 @@ assert.eq([1, 2], assert(coll.drop()); -assert.writeOK(coll.insert({a: {b: "a"}, c: 12})); -assert.writeOK(coll.insert({a: {b: "b"}, c: 12})); -assert.writeOK(coll.insert({a: {b: "c"}, c: 12})); -assert.writeOK(coll.insert({a: {b: "c"}, c: 12})); +assert.commandWorked(coll.insert({a: {b: "a"}, c: 12})); +assert.commandWorked(coll.insert({a: {b: "b"}, c: 12})); +assert.commandWorked(coll.insert({a: {b: "c"}, c: 12})); +assert.commandWorked(coll.insert({a: {b: "c"}, c: 12})); // Test that distinct works on fields in embedded documents. assert.eq(["a", "b", "c"], @@ -34,8 +34,8 @@ assert.eq(["a", "b", "c"], assert(coll.drop()); -assert.writeOK(coll.insert({_id: 1, a: 1})); -assert.writeOK(coll.insert({_id: 2, a: 2})); +assert.commandWorked(coll.insert({_id: 1, a: 1})); +assert.commandWorked(coll.insert({_id: 2, a: 2})); // Test that distinct works on the _id field. assert.eq([1, 2], coll.distinct("_id").sort(), "distinct on _id returned unexpected results"); @@ -46,13 +46,13 @@ assert.eq( assert(coll.drop()); -assert.writeOK(coll.insert({a: 1, b: 2})); -assert.writeOK(coll.insert({a: 2, b: 2})); -assert.writeOK(coll.insert({a: 2, b: 1})); -assert.writeOK(coll.insert({a: 2, b: 2})); -assert.writeOK(coll.insert({a: 3, b: 2})); -assert.writeOK(coll.insert({a: 4, b: 1})); -assert.writeOK(coll.insert({a: 4, b: 1})); +assert.commandWorked(coll.insert({a: 1, b: 2})); +assert.commandWorked(coll.insert({a: 2, b: 2})); +assert.commandWorked(coll.insert({a: 2, b: 1})); +assert.commandWorked(coll.insert({a: 2, b: 2})); +assert.commandWorked(coll.insert({a: 3, b: 2})); +assert.commandWorked(coll.insert({a: 4, b: 1})); +assert.commandWorked(coll.insert({a: 4, b: 1})); // Test running the distinct command directly, rather than via shell helper. let res = assert.commandWorked(db.runCommand({distinct: collName, key: "a"})); diff --git a/jstests/core/distinct3.js b/jstests/core/distinct3.js index 23557820bec..ba1b3182542 100644 --- a/jstests/core/distinct3.js +++ b/jstests/core/distinct3.js @@ -20,7 +20,7 @@ for (i = 0; i < 50; ++i) { for (i = 0; i < 100; ++i) { bulk.insert({b: i, c: i + 50}); } -assert.writeOK(bulk.execute()); +assert.commandWorked(bulk.execute()); // Attempt to remove the last match for the {a:1} index scan while distinct is yielding. p = startParallelShell('for( i = 0; i < 100; ++i ) { ' + @@ -29,7 +29,7 @@ p = startParallelShell('for( i = 0; i < 100; ++i ) { ' for( j = 0; j < 20; ++j ) { ' + ' bulk.insert( { a:49, c:49, d:j } ); ' + ' } ' + - ' assert.writeOK(bulk.execute()); ' + + ' assert.commandWorked(bulk.execute()); ' + '} '); for (i = 0; i < 100; ++i) { diff --git a/jstests/core/distinct_compound_index.js b/jstests/core/distinct_compound_index.js index 6182267ea51..91debcdeeb0 100644 --- a/jstests/core/distinct_compound_index.js +++ b/jstests/core/distinct_compound_index.js @@ -9,10 +9,10 @@ var coll = db.distinct_multikey_index; coll.drop(); for (var i = 0; i < 10; i++) { - assert.writeOK(coll.save({a: 1, b: 1})); - assert.writeOK(coll.save({a: 1, b: 2})); - assert.writeOK(coll.save({a: 2, b: 1})); - assert.writeOK(coll.save({a: 2, b: 3})); + assert.commandWorked(coll.save({a: 1, b: 1})); + assert.commandWorked(coll.save({a: 1, b: 2})); + assert.commandWorked(coll.save({a: 2, b: 1})); + assert.commandWorked(coll.save({a: 2, b: 3})); } coll.createIndex({a: 1, b: 1}); diff --git a/jstests/core/distinct_multikey.js b/jstests/core/distinct_multikey.js index 72acd2c342c..7208b67fb64 100644 --- a/jstests/core/distinct_multikey.js +++ b/jstests/core/distinct_multikey.js @@ -9,9 +9,9 @@ load("jstests/libs/analyze_plan.js"); let coll = db.jstest_distinct_multikey; coll.drop(); assert.commandWorked(coll.createIndex({a: 1})); -assert.writeOK(coll.insert({a: [1, 2, 3]})); -assert.writeOK(coll.insert({a: [2, 3, 4]})); -assert.writeOK(coll.insert({a: [5, 6, 7]})); +assert.commandWorked(coll.insert({a: [1, 2, 3]})); +assert.commandWorked(coll.insert({a: [2, 3, 4]})); +assert.commandWorked(coll.insert({a: [5, 6, 7]})); // Test that distinct can correctly use a multikey index when there is no predicate. let result = coll.distinct("a"); @@ -31,8 +31,8 @@ assert(planHasStage(db, explain.queryPlanner.winningPlan, "IXSCAN")); // Test distinct over a dotted multikey field, with a predicate. coll.drop(); assert.commandWorked(coll.createIndex({"a.b": 1})); -assert.writeOK(coll.insert({a: {b: [1, 2, 3]}})); -assert.writeOK(coll.insert({a: {b: [2, 3, 4]}})); +assert.commandWorked(coll.insert({a: {b: [1, 2, 3]}})); +assert.commandWorked(coll.insert({a: {b: [2, 3, 4]}})); result = coll.distinct("a.b", {"a.b": 3}); assert.eq([1, 2, 3, 4], result.sort()); @@ -44,9 +44,9 @@ assert(planHasStage(db, explain.queryPlanner.winningPlan, "IXSCAN")); // multikey. coll.drop(); assert.commandWorked(coll.createIndex({a: 1})); -assert.writeOK(coll.insert({a: 1})); -assert.writeOK(coll.insert({a: 2})); -assert.writeOK(coll.insert({a: 3})); +assert.commandWorked(coll.insert({a: 1})); +assert.commandWorked(coll.insert({a: 2})); +assert.commandWorked(coll.insert({a: 3})); result = coll.distinct("a", {a: {$gte: 2}}); assert.eq([2, 3], result.sort()); @@ -58,9 +58,9 @@ assert(planHasStage(db, explain.queryPlanner.winningPlan, "DISTINCT_SCAN")); // multikey. coll.drop(); assert.commandWorked(coll.createIndex({a: 1, b: 1})); -assert.writeOK(coll.insert({a: 1, b: [2, 3]})); -assert.writeOK(coll.insert({a: 8, b: [3, 4]})); -assert.writeOK(coll.insert({a: 7, b: [4, 5]})); +assert.commandWorked(coll.insert({a: 1, b: [2, 3]})); +assert.commandWorked(coll.insert({a: 8, b: [3, 4]})); +assert.commandWorked(coll.insert({a: 7, b: [4, 5]})); result = coll.distinct("a", {a: {$gte: 2}}); assert.eq([7, 8], result.sort()); @@ -78,9 +78,9 @@ assert(planHasStage(db, explain.queryPlanner.winningPlan, "IXSCAN")); // Test distinct over a trailing non-multikey field, where the leading field is multikey. coll.drop(); assert.commandWorked(coll.createIndex({a: 1, b: 1})); -assert.writeOK(coll.insert({a: [2, 3], b: 1})); -assert.writeOK(coll.insert({a: [3, 4], b: 8})); -assert.writeOK(coll.insert({a: [3, 5], b: 7})); +assert.commandWorked(coll.insert({a: [2, 3], b: 1})); +assert.commandWorked(coll.insert({a: [3, 4], b: 8})); +assert.commandWorked(coll.insert({a: [3, 5], b: 7})); result = coll.distinct("b", {a: 3}); assert.eq([1, 7, 8], result.sort()); @@ -91,9 +91,9 @@ assert(planHasStage(db, explain.queryPlanner.winningPlan, "DISTINCT_SCAN")); // Test distinct over a trailing non-multikey dotted path where the leading field is multikey. coll.drop(); assert.commandWorked(coll.createIndex({a: 1, "b.c": 1})); -assert.writeOK(coll.insert({a: [2, 3], b: {c: 1}})); -assert.writeOK(coll.insert({a: [3, 4], b: {c: 8}})); -assert.writeOK(coll.insert({a: [3, 5], b: {c: 7}})); +assert.commandWorked(coll.insert({a: [2, 3], b: {c: 1}})); +assert.commandWorked(coll.insert({a: [3, 4], b: {c: 8}})); +assert.commandWorked(coll.insert({a: [3, 5], b: {c: 7}})); result = coll.distinct("b.c", {a: 3}); assert.eq([1, 7, 8], result.sort()); diff --git a/jstests/core/doc_validation.js b/jstests/core/doc_validation.js index 57f99adf48c..6d6af5dfe5d 100644 --- a/jstests/core/doc_validation.js +++ b/jstests/core/doc_validation.js @@ -38,10 +38,10 @@ function runInsertUpdateValidationTest(validator) { assert.commandWorked(db.createCollection(collName, {validator: validator})); // Insert and upsert documents that will pass validation. - assert.writeOK(coll.insert({_id: "valid1", a: 1})); - assert.writeOK(coll.update({_id: "valid2"}, {_id: "valid2", a: 2}, {upsert: true})); - assert.writeOK(coll.runCommand("findAndModify", - {query: {_id: "valid3"}, update: {$set: {a: 3}}, upsert: true})); + assert.commandWorked(coll.insert({_id: "valid1", a: 1})); + assert.commandWorked(coll.update({_id: "valid2"}, {_id: "valid2", a: 2}, {upsert: true})); + assert.commandWorked(coll.runCommand( + "findAndModify", {query: {_id: "valid3"}, update: {$set: {a: 3}}, upsert: true})); // Insert and upsert documents that will not pass validation. assertFailsValidation(coll.insert({_id: "invalid3", b: 1})); @@ -50,32 +50,32 @@ function runInsertUpdateValidationTest(validator) { "findAndModify", {query: {_id: "invalid4"}, update: {$set: {b: 3}}, upsert: true})); // Assert that we can remove the document that passed validation. - assert.writeOK(coll.remove({_id: "valid1"})); + assert.commandWorked(coll.remove({_id: "valid1"})); // Check that we can only update documents that pass validation. We insert a valid and an // invalid document, then set the validator. coll.drop(); - assert.writeOK(coll.insert({_id: "valid1", a: 1})); - assert.writeOK(coll.insert({_id: "invalid2", b: 1})); + assert.commandWorked(coll.insert({_id: "valid1", a: 1})); + assert.commandWorked(coll.insert({_id: "invalid2", b: 1})); assert.commandWorked(coll.runCommand("collMod", {validator: validator})); // Assert that updates on a conforming document succeed when they affect fields not involved // in validator. // Add a new field. - assert.writeOK(coll.update({_id: "valid1"}, {$set: {z: 1}})); - assert.writeOK( + assert.commandWorked(coll.update({_id: "valid1"}, {$set: {z: 1}})); + assert.commandWorked( coll.runCommand("findAndModify", {query: {_id: "valid1"}, update: {$set: {y: 2}}})); // In-place update. - assert.writeOK(coll.update({_id: "valid1"}, {$inc: {z: 1}})); - assert.writeOK( + assert.commandWorked(coll.update({_id: "valid1"}, {$inc: {z: 1}})); + assert.commandWorked( coll.runCommand("findAndModify", {query: {_id: "valid1"}, update: {$inc: {y: 1}}})); // Out-of-place update. - assert.writeOK(coll.update({_id: "valid1"}, {$set: {z: array}})); - assert.writeOK( + assert.commandWorked(coll.update({_id: "valid1"}, {$set: {z: array}})); + assert.commandWorked( coll.runCommand("findAndModify", {query: {_id: "valid1"}, update: {$set: {y: array}}})); // No-op update. - assert.writeOK(coll.update({_id: "valid1"}, {a: 1})); - assert.writeOK( + assert.commandWorked(coll.update({_id: "valid1"}, {a: 1})); + assert.commandWorked( coll.runCommand("findAndModify", {query: {_id: "valid1"}, update: {$set: {a: 1}}})); // Verify those same updates will fail on non-conforming document. @@ -90,40 +90,40 @@ function runInsertUpdateValidationTest(validator) { coll.runCommand("findAndModify", {query: {_id: "invalid2"}, update: {$set: {y: array}}})); // A no-op update of an invalid doc will succeed. - assert.writeOK(coll.update({_id: "invalid2"}, {$set: {b: 1}})); - assert.writeOK( + assert.commandWorked(coll.update({_id: "invalid2"}, {$set: {b: 1}})); + assert.commandWorked( coll.runCommand("findAndModify", {query: {_id: "invalid2"}, update: {$set: {b: 1}}})); // Verify that we can't make a conforming document fail validation, but can update a // non-conforming document to pass validation. coll.drop(); - assert.writeOK(coll.insert({_id: "valid1", a: 1})); - assert.writeOK(coll.insert({_id: "invalid2", b: 1})); - assert.writeOK(coll.insert({_id: "invalid3", b: 1})); + assert.commandWorked(coll.insert({_id: "valid1", a: 1})); + assert.commandWorked(coll.insert({_id: "invalid2", b: 1})); + assert.commandWorked(coll.insert({_id: "invalid3", b: 1})); assert.commandWorked(coll.runCommand("collMod", {validator: validator})); assertFailsValidation(coll.update({_id: "valid1"}, {$unset: {a: 1}})); - assert.writeOK(coll.update({_id: "invalid2"}, {$set: {a: 1}})); + assert.commandWorked(coll.update({_id: "invalid2"}, {$set: {a: 1}})); assertFailsValidation( coll.runCommand("findAndModify", {query: {_id: "valid1"}, update: {$unset: {a: 1}}})); - assert.writeOK( + assert.commandWorked( coll.runCommand("findAndModify", {query: {_id: "invalid3"}, update: {$set: {a: 1}}})); // Modify the collection to remove the document validator. assert.commandWorked(coll.runCommand("collMod", {validator: {}})); // Verify that no validation is applied to updates. - assert.writeOK(coll.update({_id: "valid1"}, {$set: {z: 1}})); - assert.writeOK(coll.update({_id: "invalid2"}, {$set: {z: 1}})); - assert.writeOK(coll.update({_id: "valid1"}, {$unset: {a: 1}})); - assert.writeOK(coll.update({_id: "invalid2"}, {$set: {a: 1}})); - assert.writeOK( + assert.commandWorked(coll.update({_id: "valid1"}, {$set: {z: 1}})); + assert.commandWorked(coll.update({_id: "invalid2"}, {$set: {z: 1}})); + assert.commandWorked(coll.update({_id: "valid1"}, {$unset: {a: 1}})); + assert.commandWorked(coll.update({_id: "invalid2"}, {$set: {a: 1}})); + assert.commandWorked( coll.runCommand("findAndModify", {query: {_id: "valid1"}, update: {$set: {z: 2}}})); - assert.writeOK( + assert.commandWorked( coll.runCommand("findAndModify", {query: {_id: "invalid2"}, update: {$set: {z: 2}}})); - assert.writeOK( + assert.commandWorked( coll.runCommand("findAndModify", {query: {_id: "valid1"}, update: {$unset: {a: 1}}})); - assert.writeOK( + assert.commandWorked( coll.runCommand("findAndModify", {query: {_id: "invalid2"}, update: {$set: {a: 1}}})); } @@ -143,14 +143,14 @@ function runCollationValidationTest(validator) { collName, {validator: validator, collation: {locale: "en_US", strength: 2}})); // An insert that matches the validator should succeed. - assert.writeOK(coll.insert({_id: 0, a: "xyz", b: "foo"})); + assert.commandWorked(coll.insert({_id: 0, a: "xyz", b: "foo"})); const isJSONSchema = validator.hasOwnProperty("$jsonSchema"); // A normal validator should respect the collation and the inserts should succeed. A JSON // Schema validator ignores the collation and the inserts should fail. const assertCorrectResult = - isJSONSchema ? res => assertFailsValidation(res) : res => assert.writeOK(res); + isJSONSchema ? res => assertFailsValidation(res) : res => assert.commandWorked(res); assertCorrectResult(coll.insert({a: "XYZ"})); assertCorrectResult(coll.insert({a: "XyZ", b: "foo"})); assertCorrectResult(coll.update({_id: 0}, {a: "xyZ", b: "foo"})); @@ -180,10 +180,10 @@ runCollationValidationTest({$jsonSchema: {properties: {a: {enum: ["xyz"]}}}}); // The validator is allowed to contain $expr. coll.drop(); assert.commandWorked(db.createCollection(collName, {validator: {$expr: {$eq: ["$a", 5]}}})); -assert.writeOK(coll.insert({a: 5})); +assert.commandWorked(coll.insert({a: 5})); assertFailsValidation(coll.insert({a: 4})); assert.commandWorked(db.runCommand({"collMod": collName, "validator": {$expr: {$eq: ["$a", 4]}}})); -assert.writeOK(coll.insert({a: 4})); +assert.commandWorked(coll.insert({a: 4})); assertFailsValidation(coll.insert({a: 5})); // The validator supports $expr with the date extraction expressions (with a timezone @@ -192,7 +192,7 @@ coll.drop(); assert.commandWorked(db.createCollection( collName, {validator: {$expr: {$eq: [1, {$dayOfMonth: {date: "$a", timezone: "America/New_York"}}]}}})); -assert.writeOK(coll.insert({a: ISODate("2017-10-01T22:00:00")})); +assert.commandWorked(coll.insert({a: ISODate("2017-10-01T22:00:00")})); assertFailsValidation(coll.insert({a: ISODate("2017-10-01T00:00:00")})); // The validator supports $expr with a $dateToParts expression. @@ -215,7 +215,7 @@ assert.commandWorked(db.createCollection(collName, { } } })); -assert.writeOK(coll.insert({a: ISODate("2017-10-01T22:00:00")})); +assert.commandWorked(coll.insert({a: ISODate("2017-10-01T22:00:00")})); assertFailsValidation(coll.insert({a: ISODate("2017-10-01T00:00:00")})); // The validator supports $expr with $dateToString expression. @@ -236,7 +236,7 @@ assert.commandWorked(db.createCollection(collName, { } } })); -assert.writeOK(coll.insert({date: new ISODate("2017-07-04T14:56:42.911Z"), tz: "UTC"})); +assert.commandWorked(coll.insert({date: new ISODate("2017-07-04T14:56:42.911Z"), tz: "UTC"})); assertFailsValidation( coll.insert({date: new ISODate("2017-07-04T14:56:42.911Z"), tz: "America/New_York"})); @@ -252,7 +252,7 @@ assert.commandWorked(db.createCollection(collName, { } } })); -assert.writeOK(coll.insert({_id: 0, year: 2017, month: 6, day: 19, timezone: "Asia/Tokyo"})); +assert.commandWorked(coll.insert({_id: 0, year: 2017, month: 6, day: 19, timezone: "Asia/Tokyo"})); assertFailsValidation( coll.insert({_id: 1, year: 2022, month: 1, day: 1, timezone: "America/New_York"})); @@ -268,16 +268,16 @@ assert.commandWorked(db.createCollection(collName, { } } })); -assert.writeOK(coll.insert({_id: 0, date: "2017-07-04T11:56:02"})); +assert.commandWorked(coll.insert({_id: 0, date: "2017-07-04T11:56:02"})); assertFailsValidation(coll.insert({_id: 1, date: "2015-02-02T11:00:00"})); // The validator can contain an $expr that may throw at runtime. coll.drop(); assert.commandWorked( db.createCollection(collName, {validator: {$expr: {$eq: ["$a", {$divide: [1, "$b"]}]}}})); -assert.writeOK(coll.insert({a: 1, b: 1})); +assert.commandWorked(coll.insert({a: 1, b: 1})); let res = coll.insert({a: 1, b: 0}); assert.writeError(res); assert.eq(res.getWriteError().code, 16608); -assert.writeOK(coll.insert({a: -1, b: -1})); +assert.commandWorked(coll.insert({a: -1, b: -1})); })(); diff --git a/jstests/core/dotted_path_in_null.js b/jstests/core/dotted_path_in_null.js index f32f60a9ff2..7c8baf42709 100644 --- a/jstests/core/dotted_path_in_null.js +++ b/jstests/core/dotted_path_in_null.js @@ -4,11 +4,11 @@ const coll = db.dotted_path_in_null; coll.drop(); -assert.writeOK(coll.insert({_id: 1, a: [{b: 5}]})); -assert.writeOK(coll.insert({_id: 2, a: [{}]})); -assert.writeOK(coll.insert({_id: 3, a: []})); -assert.writeOK(coll.insert({_id: 4, a: [{}, {b: 5}]})); -assert.writeOK(coll.insert({_id: 5, a: [5, {b: 5}]})); +assert.commandWorked(coll.insert({_id: 1, a: [{b: 5}]})); +assert.commandWorked(coll.insert({_id: 2, a: [{}]})); +assert.commandWorked(coll.insert({_id: 3, a: []})); +assert.commandWorked(coll.insert({_id: 4, a: [{}, {b: 5}]})); +assert.commandWorked(coll.insert({_id: 5, a: [5, {b: 5}]})); function getIds(query) { let ids = []; diff --git a/jstests/core/drop_index.js b/jstests/core/drop_index.js index 83e03c5a8fd..60dbec0e3ea 100644 --- a/jstests/core/drop_index.js +++ b/jstests/core/drop_index.js @@ -32,7 +32,7 @@ function assertIndexes(expectedIndexNames, msg) { } } -assert.writeOK(t.insert({_id: 1, a: 2, b: 3, c: 1, d: 1, e: 1})); +assert.commandWorked(t.insert({_id: 1, a: 2, b: 3, c: 1, d: 1, e: 1})); assertIndexes([], 'inserting test document'); assert.commandWorked(t.createIndex({a: 1})); diff --git a/jstests/core/elemMatchProjection.js b/jstests/core/elemMatchProjection.js index 390b7aa5d17..a35a11a0451 100644 --- a/jstests/core/elemMatchProjection.js +++ b/jstests/core/elemMatchProjection.js @@ -66,10 +66,10 @@ for (let i = 0; i < 100; i++) { bulk.insert({_id: nextId(), group: 13, x: [{a: 1, b: 1}, {a: 1, b: 2}]}); bulk.insert({_id: nextId(), group: 13, x: [{a: 1, b: 2}, {a: 1, b: 1}]}); } -assert.writeOK(bulk.execute()); +assert.commandWorked(bulk.execute()); -assert.writeOK(coll.createIndex({group: 1, 'y.d': 1})); -assert.writeOK(coll.createIndex({group: 1, covered: 1})); // for covered index test +assert.commandWorked(coll.createIndex({group: 1, 'y.d': 1})); +assert.commandWorked(coll.createIndex({group: 1, covered: 1})); // for covered index test // Tests for the $-positional operator. assert.eq(1, diff --git a/jstests/core/elemmatch_or_pushdown.js b/jstests/core/elemmatch_or_pushdown.js index 86888996b19..2edef4d0678 100644 --- a/jstests/core/elemmatch_or_pushdown.js +++ b/jstests/core/elemmatch_or_pushdown.js @@ -8,12 +8,12 @@ const coll = db.elemmatch_or_pushdown; coll.drop(); -assert.writeOK(coll.insert({_id: 0, a: 1, b: [{c: 4}]})); -assert.writeOK(coll.insert({_id: 1, a: 2, b: [{c: 4}]})); -assert.writeOK(coll.insert({_id: 2, a: 2, b: [{c: 5}]})); -assert.writeOK(coll.insert({_id: 3, a: 1, b: [{c: 5}]})); -assert.writeOK(coll.insert({_id: 4, a: 1, b: [{c: 6}]})); -assert.writeOK(coll.insert({_id: 5, a: 1, b: [{c: 7}]})); +assert.commandWorked(coll.insert({_id: 0, a: 1, b: [{c: 4}]})); +assert.commandWorked(coll.insert({_id: 1, a: 2, b: [{c: 4}]})); +assert.commandWorked(coll.insert({_id: 2, a: 2, b: [{c: 5}]})); +assert.commandWorked(coll.insert({_id: 3, a: 1, b: [{c: 5}]})); +assert.commandWorked(coll.insert({_id: 4, a: 1, b: [{c: 6}]})); +assert.commandWorked(coll.insert({_id: 5, a: 1, b: [{c: 7}]})); assert.commandWorked(coll.createIndex({a: 1, "b.c": 1})); assert.eq(coll.find({a: 1, b: {$elemMatch: {$or: [{c: 4}, {c: 5}]}}}).sort({_id: 1}).toArray(), @@ -24,14 +24,14 @@ assert.eq(coll.find({a: 1, $or: [{a: 2}, {b: {$elemMatch: {$or: [{c: 4}, {c: 5}] [{_id: 0, a: 1, b: [{c: 4}]}, {_id: 3, a: 1, b: [{c: 5}]}]); coll.drop(); -assert.writeOK(coll.insert({_id: 0, a: 5, b: [{c: [{f: 8}], d: 6}]})); -assert.writeOK(coll.insert({_id: 1, a: 4, b: [{c: [{f: 8}], d: 6}]})); -assert.writeOK(coll.insert({_id: 2, a: 5, b: [{c: [{f: 8}], d: 7}]})); -assert.writeOK(coll.insert({_id: 3, a: 4, b: [{c: [{f: 9}], d: 6}]})); -assert.writeOK(coll.insert({_id: 4, a: 5, b: [{c: [{f: 8}], e: 7}]})); -assert.writeOK(coll.insert({_id: 5, a: 4, b: [{c: [{f: 8}], e: 7}]})); -assert.writeOK(coll.insert({_id: 6, a: 5, b: [{c: [{f: 8}], e: 8}]})); -assert.writeOK(coll.insert({_id: 7, a: 5, b: [{c: [{f: 9}], e: 7}]})); +assert.commandWorked(coll.insert({_id: 0, a: 5, b: [{c: [{f: 8}], d: 6}]})); +assert.commandWorked(coll.insert({_id: 1, a: 4, b: [{c: [{f: 8}], d: 6}]})); +assert.commandWorked(coll.insert({_id: 2, a: 5, b: [{c: [{f: 8}], d: 7}]})); +assert.commandWorked(coll.insert({_id: 3, a: 4, b: [{c: [{f: 9}], d: 6}]})); +assert.commandWorked(coll.insert({_id: 4, a: 5, b: [{c: [{f: 8}], e: 7}]})); +assert.commandWorked(coll.insert({_id: 5, a: 4, b: [{c: [{f: 8}], e: 7}]})); +assert.commandWorked(coll.insert({_id: 6, a: 5, b: [{c: [{f: 8}], e: 8}]})); +assert.commandWorked(coll.insert({_id: 7, a: 5, b: [{c: [{f: 9}], e: 7}]})); assert.commandWorked(coll.createIndex({"b.d": 1, "b.c.f": 1})); assert.commandWorked(coll.createIndex({"b.e": 1, "b.c.f": 1})); diff --git a/jstests/core/ensure_sorted.js b/jstests/core/ensure_sorted.js index 037eda45c19..fbdde2609df 100644 --- a/jstests/core/ensure_sorted.js +++ b/jstests/core/ensure_sorted.js @@ -11,16 +11,16 @@ var coll = db.ensure_sorted; coll.drop(); assert.commandWorked(coll.createIndex({a: 1, b: 1})); -assert.writeOK(coll.insert({a: 1, b: 4})); -assert.writeOK(coll.insert({a: 2, b: 3})); -assert.writeOK(coll.insert({a: 3, b: 2})); -assert.writeOK(coll.insert({a: 4, b: 1})); +assert.commandWorked(coll.insert({a: 1, b: 4})); +assert.commandWorked(coll.insert({a: 2, b: 3})); +assert.commandWorked(coll.insert({a: 3, b: 2})); +assert.commandWorked(coll.insert({a: 4, b: 1})); var cursor = coll.find({a: {$lt: 5}}).sort({b: -1}).batchSize(2); cursor.next(); // {a: 1, b: 4}. cursor.next(); // {a: 2, b: 3}. -assert.writeOK(coll.update({b: 2}, {$set: {b: 5}})); +assert.commandWorked(coll.update({b: 2}, {$set: {b: 5}})); var result = cursor.next(); // We might either drop the document where "b" is 2 from the result set, or we might include the diff --git a/jstests/core/exhaust.js b/jstests/core/exhaust.js index 125c70cefe8..7e6c139d367 100644 --- a/jstests/core/exhaust.js +++ b/jstests/core/exhaust.js @@ -8,7 +8,7 @@ c.drop(); const docCount = 4; for (var i = 0; i < docCount; i++) { - assert.writeOK(c.insert({a: i})); + assert.commandWorked(c.insert({a: i})); } // Check that the query works without exhaust set diff --git a/jstests/core/existsa.js b/jstests/core/existsa.js index 66d0ded50d4..d1079310d71 100644 --- a/jstests/core/existsa.js +++ b/jstests/core/existsa.js @@ -7,9 +7,9 @@ const coll = db.jstests_existsa; coll.drop(); -assert.writeOK(coll.insert({})); -assert.writeOK(coll.insert({a: 1})); -assert.writeOK(coll.insert({a: {x: 1}, b: 1})); +assert.commandWorked(coll.insert({})); +assert.commandWorked(coll.insert({a: 1})); +assert.commandWorked(coll.insert({a: {x: 1}, b: 1})); let indexKeySpec = {}; let indexKeyField = ''; @@ -89,9 +89,9 @@ assertExists({$or: [{a: {$exists: true}}]}); // $exists:true not // Behavior is similar with $elemMatch. coll.drop(); -assert.writeOK(coll.insert({a: [{}]})); -assert.writeOK(coll.insert({a: [{b: 1}]})); -assert.writeOK(coll.insert({a: [{b: [1]}]})); +assert.commandWorked(coll.insert({a: [{}]})); +assert.commandWorked(coll.insert({a: [{b: 1}]})); +assert.commandWorked(coll.insert({a: [{b: [1]}]})); setIndex('a.b'); assertMissing({a: {$elemMatch: {b: {$exists: false}}}}); @@ -105,7 +105,7 @@ assertExistsUnindexed({'a.b': {$elemMatch: {$gt: 0, $not: {$exists: false}}}}, 1 // A non sparse index will not be disallowed. coll.drop(); -assert.writeOK(coll.insert({})); +assert.commandWorked(coll.insert({})); coll.ensureIndex({a: 1}); assert.eq(1, coll.find({a: {$exists: false}}).itcount()); })(); diff --git a/jstests/core/explain_agg_write_concern.js b/jstests/core/explain_agg_write_concern.js index cf28b097632..9ff556489fa 100644 --- a/jstests/core/explain_agg_write_concern.js +++ b/jstests/core/explain_agg_write_concern.js @@ -20,7 +20,7 @@ let outColl = db[collName + "_out"]; coll.drop(); outColl.drop(); -assert.writeOK(coll.insert({_id: 1})); +assert.commandWorked(coll.insert({_id: 1})); // Agg should accept write concern if the last stage is a $out. assert.commandWorked(db.runCommand({ diff --git a/jstests/core/explain_distinct.js b/jstests/core/explain_distinct.js index 1c4d6612acb..f591d24fded 100644 --- a/jstests/core/explain_distinct.js +++ b/jstests/core/explain_distinct.js @@ -32,8 +32,8 @@ assert(planHasStage(db, explain.queryPlanner.winningPlan, "EOF")); // Insert the data to perform distinct() on. for (var i = 0; i < 10; i++) { - assert.writeOK(coll.insert({a: 1, b: 1})); - assert.writeOK(coll.insert({a: 2, c: 1})); + assert.commandWorked(coll.insert({a: 1, b: 1})); + assert.commandWorked(coll.insert({a: 2, c: 1})); } assert.commandFailed(runDistinctExplain(coll, {}, {})); // Bad keyString. diff --git a/jstests/core/explain_execution_error.js b/jstests/core/explain_execution_error.js index f80af65b0c0..ec0dfba44bd 100644 --- a/jstests/core/explain_execution_error.js +++ b/jstests/core/explain_execution_error.js @@ -72,7 +72,7 @@ while (bigStr.length < (1024 * 1024)) { // Make a collection that is about 120 MB * number of shards. const numShards = FixtureHelpers.numberOfShardsForCollection(t); for (var i = 0; i < 120 * numShards; i++) { - assert.writeOK(t.insert({a: bigStr, b: 1, c: i})); + assert.commandWorked(t.insert({a: bigStr, b: 1, c: i})); } // A query which sorts the whole collection by "b" should throw an error due to hitting the diff --git a/jstests/core/explain_find_and_modify.js b/jstests/core/explain_find_and_modify.js index 8b7c65d519e..523a8d942a9 100644 --- a/jstests/core/explain_find_and_modify.js +++ b/jstests/core/explain_find_and_modify.js @@ -61,7 +61,7 @@ assert.commandFailed(db.runCommand({remove: true, new: true})); // 4. Explaining findAndModify should not modify any contents of the collection. var onlyDoc = {_id: 0, i: 1}; -assert.writeOK(t.insert(onlyDoc)); +assert.commandWorked(t.insert(onlyDoc)); // Explaining a delete should not delete anything. var matchingRemoveCmd = {findAndModify: cName, remove: true, query: {_id: onlyDoc._id}}; diff --git a/jstests/core/explain_multikey.js b/jstests/core/explain_multikey.js index 1ec20bb4552..e342203e503 100644 --- a/jstests/core/explain_multikey.js +++ b/jstests/core/explain_multikey.js @@ -31,7 +31,7 @@ function createIndexAndRunExplain(testOptions) { coll.drop(); assert.commandWorked(coll.createIndex(keyPattern)); - assert.writeOK(coll.insert(testOptions.docToInsert)); + assert.commandWorked(coll.insert(testOptions.docToInsert)); var explain = db.runCommand({explain: testOptions.commandObj}); assert.commandWorked(explain); diff --git a/jstests/core/expr.js b/jstests/core/expr.js index 78ef8b87f0c..4b39d05bc94 100644 --- a/jstests/core/expr.js +++ b/jstests/core/expr.js @@ -19,7 +19,7 @@ const isMongos = (isMaster.msg === "isdbgrid"); // coll.drop(); -assert.writeOK(coll.insert({a: 0})); +assert.commandWorked(coll.insert({a: 0})); assert.eq(1, coll.aggregate([{$match: {$expr: {$eq: ["$a", 0]}}}]).itcount()); assert.throws(function() { coll.aggregate([{$match: {$expr: {$eq: ["$a", "$$unbound"]}}}]); @@ -33,7 +33,7 @@ assert.throws(function() { // coll.drop(); -assert.writeOK(coll.insert({a: 0})); +assert.commandWorked(coll.insert({a: 0})); assert.eq(1, coll.find({$expr: {$eq: ["$a", 0]}}).count()); assert.throws(function() { coll.find({$expr: {$eq: ["$a", "$$unbound"]}}).count(); @@ -47,7 +47,7 @@ assert.throws(function() { // coll.drop(); -assert.writeOK(coll.insert({a: 0})); +assert.commandWorked(coll.insert({a: 0})); assert.eq(1, coll.distinct("a", {$expr: {$eq: ["$a", 0]}}).length); assert.throws(function() { coll.distinct("a", {$expr: {$eq: ["$a", "$$unbound"]}}); @@ -62,12 +62,12 @@ assert.throws(function() { // $expr is allowed in query. coll.drop(); -assert.writeOK(coll.insert({a: 0})); +assert.commandWorked(coll.insert({a: 0})); assert.eq(1, coll.find({$expr: {$eq: ["$a", 0]}}).itcount()); // $expr with time zone expression across getMore (SERVER-31664). coll.drop(); -assert.writeOK(coll.insert({a: ISODate("2017-10-01T22:00:00")})); +assert.commandWorked(coll.insert({a: ISODate("2017-10-01T22:00:00")})); let res = assert.commandWorked(db.runCommand({ find: coll.getName(), @@ -120,7 +120,7 @@ assert.throws(function() { // $expr is not allowed in $elemMatch projection. coll.drop(); -assert.writeOK(coll.insert({a: [{b: 5}]})); +assert.commandWorked(coll.insert({a: [{b: 5}]})); assert.throws(function() { coll.find({}, {a: {$elemMatch: {$expr: {$eq: ["$b", 5]}}}}).itcount(); }); @@ -131,7 +131,7 @@ assert.throws(function() { // $expr is allowed in the query when upsert=false. coll.drop(); -assert.writeOK(coll.insert({_id: 0, a: 0})); +assert.commandWorked(coll.insert({_id: 0, a: 0})); assert.eq({_id: 0, a: 0, b: 6}, coll.findAndModify( {query: {_id: 0, $expr: {$eq: ["$a", 0]}}, update: {$set: {b: 6}}, new: true})); @@ -149,7 +149,7 @@ assert.throws(function() { // $expr is not allowed in the query when upsert=true. coll.drop(); -assert.writeOK(coll.insert({_id: 0, a: 0})); +assert.commandWorked(coll.insert({_id: 0, a: 0})); assert.throws(function() { coll.findAndModify( {query: {_id: 0, $expr: {$eq: ["$a", 0]}}, update: {$set: {b: 6}}, upsert: true}); @@ -157,7 +157,7 @@ assert.throws(function() { // $expr is not allowed in $pull filter. coll.drop(); -assert.writeOK(coll.insert({_id: 0, a: [{b: 5}]})); +assert.commandWorked(coll.insert({_id: 0, a: [{b: 5}]})); assert.throws(function() { coll.findAndModify({query: {_id: 0}, update: {$pull: {a: {$expr: {$eq: ["$b", 5]}}}}}); }); @@ -165,7 +165,7 @@ assert.throws(function() { // $expr is not allowed in arrayFilters. if (db.getMongo().writeMode() === "commands") { coll.drop(); - assert.writeOK(coll.insert({_id: 0, a: [{b: 5}]})); + assert.commandWorked(coll.insert({_id: 0, a: [{b: 5}]})); assert.throws(function() { coll.findAndModify({ query: {_id: 0}, @@ -180,7 +180,7 @@ if (db.getMongo().writeMode() === "commands") { // coll.drop(); -assert.writeOK(coll.insert({geo: {type: "Point", coordinates: [0, 0]}, a: 0})); +assert.commandWorked(coll.insert({geo: {type: "Point", coordinates: [0, 0]}, a: 0})); assert.commandWorked(coll.ensureIndex({geo: "2dsphere"})); assert.eq(1, coll.aggregate({ @@ -215,7 +215,7 @@ assert.throws(() => coll.aggregate({ // coll.drop(); -assert.writeOK(coll.insert({a: 0})); +assert.commandWorked(coll.insert({a: 0})); let mapReduceOut = coll.mapReduce( function() { emit(this.a, 1); @@ -252,18 +252,18 @@ assert.throws(function() { // coll.drop(); -assert.writeOK(coll.insert({_id: 0, a: 0})); +assert.commandWorked(coll.insert({_id: 0, a: 0})); let writeRes = coll.remove({_id: 0, $expr: {$eq: ["$a", 0]}}); -assert.writeOK(writeRes); +assert.commandWorked(writeRes); assert.eq(1, writeRes.nRemoved); assert.writeError(coll.remove({_id: 0, $expr: {$eq: ["$a", "$$unbound"]}})); -assert.writeOK(coll.insert({_id: 0, a: 0})); +assert.commandWorked(coll.insert({_id: 0, a: 0})); assert.writeError(coll.remove({_id: 0, $expr: {$divide: [1, "$a"]}})); // Any writes preceding the write that fails to parse are executed. coll.drop(); -assert.writeOK(coll.insert({_id: 0})); -assert.writeOK(coll.insert({_id: 1})); +assert.commandWorked(coll.insert({_id: 0})); +assert.commandWorked(coll.insert({_id: 1})); writeRes = db.runCommand({ delete: coll.getName(), deletes: [{q: {_id: 0}, limit: 1}, {q: {$expr: "$$unbound"}, limit: 1}] @@ -278,8 +278,8 @@ assert.eq(writeRes.n, 1, tojson(writeRes)); // $expr is allowed in the query when upsert=false. coll.drop(); -assert.writeOK(coll.insert({_id: 0, a: 0})); -assert.writeOK(coll.update({_id: 0, $expr: {$eq: ["$a", 0]}}, {$set: {b: 6}})); +assert.commandWorked(coll.insert({_id: 0, a: 0})); +assert.commandWorked(coll.update({_id: 0, $expr: {$eq: ["$a", 0]}}, {$set: {b: 6}})); assert.eq({_id: 0, a: 0, b: 6}, coll.findOne({_id: 0})); // $expr with unbound variable fails. @@ -290,18 +290,18 @@ assert.writeError(coll.update({_id: 0, $expr: {$divide: [1, "$a"]}}, {$set: {b: // $expr is not allowed in the query when upsert=true. coll.drop(); -assert.writeOK(coll.insert({_id: 0, a: 5})); +assert.commandWorked(coll.insert({_id: 0, a: 5})); assert.writeError(coll.update({_id: 0, $expr: {$eq: ["$a", 5]}}, {$set: {b: 6}}, {upsert: true})); // $expr is not allowed in $pull filter. coll.drop(); -assert.writeOK(coll.insert({_id: 0, a: [{b: 5}]})); +assert.commandWorked(coll.insert({_id: 0, a: [{b: 5}]})); assert.writeError(coll.update({_id: 0}, {$pull: {a: {$expr: {$eq: ["$b", 5]}}}})); // $expr is not allowed in arrayFilters. if (db.getMongo().writeMode() === "commands") { coll.drop(); - assert.writeOK(coll.insert({_id: 0, a: [{b: 5}]})); + assert.commandWorked(coll.insert({_id: 0, a: [{b: 5}]})); assert.writeError(coll.update({_id: 0}, {$set: {"a.$[i].b": 6}}, {arrayFilters: [{"i.b": 5, $expr: {$eq: ["$i.b", 5]}}]})); @@ -309,8 +309,8 @@ if (db.getMongo().writeMode() === "commands") { // Any writes preceding the write that fails to parse are executed. coll.drop(); -assert.writeOK(coll.insert({_id: 0})); -assert.writeOK(coll.insert({_id: 1})); +assert.commandWorked(coll.insert({_id: 0})); +assert.commandWorked(coll.insert({_id: 1})); writeRes = db.runCommand({ update: coll.getName(), updates: [{q: {_id: 0}, u: {$set: {b: 6}}}, {q: {$expr: "$$unbound"}, u: {$set: {b: 6}}}] diff --git a/jstests/core/expr_index_use.js b/jstests/core/expr_index_use.js index d0eb55656b2..ece507f60d3 100644 --- a/jstests/core/expr_index_use.js +++ b/jstests/core/expr_index_use.js @@ -8,43 +8,43 @@ load("jstests/libs/analyze_plan.js"); const coll = db.expr_index_use; coll.drop(); -assert.writeOK(coll.insert({a: {b: 1}})); -assert.writeOK(coll.insert({a: {b: [1]}})); -assert.writeOK(coll.insert({a: [{b: 1}]})); -assert.writeOK(coll.insert({a: [{b: [1]}]})); +assert.commandWorked(coll.insert({a: {b: 1}})); +assert.commandWorked(coll.insert({a: {b: [1]}})); +assert.commandWorked(coll.insert({a: [{b: 1}]})); +assert.commandWorked(coll.insert({a: [{b: [1]}]})); assert.commandWorked(coll.createIndex({"a.b": 1})); -assert.writeOK(coll.insert({c: {d: 1}})); +assert.commandWorked(coll.insert({c: {d: 1}})); assert.commandWorked(coll.createIndex({"c.d": 1})); -assert.writeOK(coll.insert({e: [{f: 1}]})); +assert.commandWorked(coll.insert({e: [{f: 1}]})); assert.commandWorked(coll.createIndex({"e.f": 1})); -assert.writeOK(coll.insert({g: {h: [1]}})); +assert.commandWorked(coll.insert({g: {h: [1]}})); assert.commandWorked(coll.createIndex({"g.h": 1})); -assert.writeOK(coll.insert({i: 1, j: [1]})); +assert.commandWorked(coll.insert({i: 1, j: [1]})); assert.commandWorked(coll.createIndex({i: 1, j: 1})); -assert.writeOK(coll.insert({k: 1, l: "abc"})); +assert.commandWorked(coll.insert({k: 1, l: "abc"})); assert.commandWorked(coll.createIndex({k: 1, l: "text"})); -assert.writeOK(coll.insert({x: 0})); -assert.writeOK(coll.insert({x: 1, y: 1})); -assert.writeOK(coll.insert({x: 2, y: 2})); -assert.writeOK(coll.insert({x: 3, y: 10})); -assert.writeOK(coll.insert({y: 20})); +assert.commandWorked(coll.insert({x: 0})); +assert.commandWorked(coll.insert({x: 1, y: 1})); +assert.commandWorked(coll.insert({x: 2, y: 2})); +assert.commandWorked(coll.insert({x: 3, y: 10})); +assert.commandWorked(coll.insert({y: 20})); assert.commandWorked(coll.createIndex({x: 1, y: 1})); -assert.writeOK(coll.insert({w: 123})); -assert.writeOK(coll.insert({})); -assert.writeOK(coll.insert({w: null})); -assert.writeOK(coll.insert({w: undefined})); -assert.writeOK(coll.insert({w: NaN})); -assert.writeOK(coll.insert({w: "foo"})); -assert.writeOK(coll.insert({w: "FOO"})); -assert.writeOK(coll.insert({w: {z: 1}})); -assert.writeOK(coll.insert({w: {z: 2}})); +assert.commandWorked(coll.insert({w: 123})); +assert.commandWorked(coll.insert({})); +assert.commandWorked(coll.insert({w: null})); +assert.commandWorked(coll.insert({w: undefined})); +assert.commandWorked(coll.insert({w: NaN})); +assert.commandWorked(coll.insert({w: "foo"})); +assert.commandWorked(coll.insert({w: "FOO"})); +assert.commandWorked(coll.insert({w: {z: 1}})); +assert.commandWorked(coll.insert({w: {z: 2}})); assert.commandWorked(coll.createIndex({w: 1})); assert.commandWorked(coll.createIndex({"w.z": 1})); @@ -232,8 +232,8 @@ assert.throws( // there is an index with a matching collation and when there isn't. assert.commandWorked(db.runCommand({drop: coll.getName()})); assert.commandWorked(db.createCollection(coll.getName(), {collation: caseInsensitiveCollation})); -assert.writeOK(coll.insert({a: "foo", b: "bar"})); -assert.writeOK(coll.insert({a: "FOO", b: "BAR"})); +assert.commandWorked(coll.insert({a: "foo", b: "bar"})); +assert.commandWorked(coll.insert({a: "FOO", b: "BAR"})); assert.commandWorked(coll.createIndex({a: 1})); assert.commandWorked(coll.createIndex({b: 1}, {collation: {locale: "simple"}})); diff --git a/jstests/core/field_name_validation.js b/jstests/core/field_name_validation.js index 72d346a0f0c..3568103e768 100644 --- a/jstests/core/field_name_validation.js +++ b/jstests/core/field_name_validation.js @@ -20,10 +20,10 @@ coll.drop(); // // Test that dotted field names are allowed. -assert.writeOK(coll.insert({"a.b": 1})); -assert.writeOK(coll.insert({"_id.a": 1})); -assert.writeOK(coll.insert({a: {"a.b": 1}})); -assert.writeOK(coll.insert({_id: {"a.b": 1}})); +assert.commandWorked(coll.insert({"a.b": 1})); +assert.commandWorked(coll.insert({"_id.a": 1})); +assert.commandWorked(coll.insert({a: {"a.b": 1}})); +assert.commandWorked(coll.insert({_id: {"a.b": 1}})); // Test that _id cannot be a regex. assert.writeError(coll.insert({_id: /a/})); @@ -32,7 +32,7 @@ assert.writeError(coll.insert({_id: /a/})); assert.writeError(coll.insert({_id: [9]})); // Test that $-prefixed field names are allowed in embedded objects. -assert.writeOK(coll.insert({a: {$b: 1}})); +assert.commandWorked(coll.insert({a: {$b: 1}})); assert.eq(1, coll.find({"a.$b": 1}).itcount()); // Test that $-prefixed field names are not allowed at the top level. @@ -49,9 +49,9 @@ assert.writeErrorWithCode(coll.insert({_id: {$b: 1}}), ErrorCodes.DollarPrefixed assert.writeErrorWithCode(coll.insert({_id: {a: 1, $b: 1}}), ErrorCodes.DollarPrefixedFieldName); // Should not enforce the same restrictions on an embedded _id field. -assert.writeOK(coll.insert({a: {_id: [9]}})); -assert.writeOK(coll.insert({a: {_id: /a/}})); -assert.writeOK(coll.insert({a: {_id: {$b: 1}}})); +assert.commandWorked(coll.insert({a: {_id: [9]}})); +assert.commandWorked(coll.insert({a: {_id: /a/}})); +assert.commandWorked(coll.insert({a: {_id: {$b: 1}}})); // // Update command field name validation. @@ -59,20 +59,20 @@ assert.writeOK(coll.insert({a: {_id: {$b: 1}}})); coll.drop(); // Dotted fields are allowed in an update. -assert.writeOK(coll.update({}, {"a.b": 1}, {upsert: true})); +assert.commandWorked(coll.update({}, {"a.b": 1}, {upsert: true})); assert.eq(0, coll.find({"a.b": 1}).itcount()); assert.eq(1, coll.find({}).itcount()); // Dotted fields represent paths in $set. -assert.writeOK(coll.update({}, {$set: {"a.b": 1}}, {upsert: true})); +assert.commandWorked(coll.update({}, {$set: {"a.b": 1}}, {upsert: true})); assert.eq(1, coll.find({"a.b": 1}).itcount()); // Dotted fields represent paths in the query object. -assert.writeOK(coll.update({"a.b": 1}, {$set: {"a.b": 2}})); +assert.commandWorked(coll.update({"a.b": 1}, {$set: {"a.b": 2}})); assert.eq(1, coll.find({"a.b": 2}).itcount()); assert.eq(1, coll.find({a: {b: 2}}).itcount()); -assert.writeOK(coll.update({"a.b": 2}, {"a.b": 3})); +assert.commandWorked(coll.update({"a.b": 2}, {"a.b": 3})); assert.eq(0, coll.find({"a.b": 3}).itcount()); // $-prefixed field names are not allowed. @@ -132,7 +132,7 @@ assert.throws(function() { // coll.drop(); -assert.writeOK(coll.insert({_id: {a: 1, b: 2}, "c.d": 3})); +assert.commandWorked(coll.insert({_id: {a: 1, b: 2}, "c.d": 3})); // Dotted fields represent paths in an aggregation pipeline. assert.eq(coll.aggregate([{$match: {"_id.a": 1}}, {$project: {"_id.b": 1}}]).toArray(), diff --git a/jstests/core/filemd5.js b/jstests/core/filemd5.js index 9ea70283a73..5f5d876d11a 100644 --- a/jstests/core/filemd5.js +++ b/jstests/core/filemd5.js @@ -12,7 +12,7 @@ "use strict"; db.fs.chunks.drop(); -assert.writeOK(db.fs.chunks.insert({files_id: 1, n: 0, data: new BinData(0, "test")})); +assert.commandWorked(db.fs.chunks.insert({files_id: 1, n: 0, data: new BinData(0, "test")})); assert.commandFailedWithCode(db.runCommand({filemd5: 1, root: "fs"}), ErrorCodes.BadValue); @@ -21,8 +21,8 @@ assert.commandWorked(db.runCommand({filemd5: 1, root: "fs"})); assert.commandFailedWithCode(db.runCommand({filemd5: 1, root: "fs", partialOk: 1, md5state: 5}), 50847); -assert.writeOK(db.fs.chunks.insert({files_id: 2, n: 0})); +assert.commandWorked(db.fs.chunks.insert({files_id: 2, n: 0})); assert.commandFailedWithCode(db.runCommand({filemd5: 2, root: "fs"}), 50848); -assert.writeOK(db.fs.chunks.update({files_id: 2, n: 0}, {$set: {data: 5}})); +assert.commandWorked(db.fs.chunks.update({files_id: 2, n: 0}, {$set: {data: 5}})); assert.commandFailedWithCode(db.runCommand({filemd5: 2, root: "fs"}), 50849); }()); diff --git a/jstests/core/find4.js b/jstests/core/find4.js index 3721763b358..3d22f6d3fcb 100644 --- a/jstests/core/find4.js +++ b/jstests/core/find4.js @@ -4,7 +4,7 @@ const coll = db.find4; coll.drop(); -assert.writeOK(coll.insert({a: 1123, b: 54332})); +assert.commandWorked(coll.insert({a: 1123, b: 54332})); let o = coll.findOne(); assert.eq(1123, o.a, "A"); @@ -23,8 +23,8 @@ assert(!o.a, "I"); assert(coll.drop()); -assert.writeOK(coll.insert({a: 1, b: 1})); -assert.writeOK(coll.insert({a: 2, b: 2})); +assert.commandWorked(coll.insert({a: 1, b: 1})); +assert.commandWorked(coll.insert({a: 2, b: 2})); assert.eq("1-1,2-2", coll.find() .sort({a: 1}) diff --git a/jstests/core/find5.js b/jstests/core/find5.js index f7e52c0ccc6..f5333654ab2 100644 --- a/jstests/core/find5.js +++ b/jstests/core/find5.js @@ -6,8 +6,8 @@ const coll = db.find5; coll.drop(); -assert.writeOK(coll.insert({a: 1})); -assert.writeOK(coll.insert({b: 5})); +assert.commandWorked(coll.insert({a: 1})); +assert.commandWorked(coll.insert({b: 5})); assert.eq(2, coll.find({}, {b: 1}).count(), "A"); @@ -40,7 +40,7 @@ assert.eq(5, second.b, "C8"); assert(coll.drop()); -assert.writeOK(coll.insert({a: 1, b: {c: 2, d: 3, e: 4}})); +assert.commandWorked(coll.insert({a: 1, b: {c: 2, d: 3, e: 4}})); assert.eq(2, coll.findOne({}, {"b.c": 1}).b.c, "D"); const o = coll.findOne({}, {"b.c": 1, "b.d": 1}); @@ -51,6 +51,6 @@ assert(!o.b.e, "E 3"); assert(!coll.findOne({}, {"b.c": 1}).b.d, "F"); assert(coll.drop()); -assert.writeOK(coll.insert({a: {b: {c: 1}}})); +assert.commandWorked(coll.insert({a: {b: {c: 1}}})); assert.eq(1, coll.findOne({}, {"a.b.c": 1}).a.b.c, "G"); }()); diff --git a/jstests/core/find_and_modify_concurrent_update.js b/jstests/core/find_and_modify_concurrent_update.js index 9682bea4c65..bc7472259c4 100644 --- a/jstests/core/find_and_modify_concurrent_update.js +++ b/jstests/core/find_and_modify_concurrent_update.js @@ -20,7 +20,7 @@ for (var i = 0; i < 3; i++) { assert.commandWorked(t.ensureIndex({a: 1})); assert.commandWorked(t.ensureIndex({b: 1})); - assert.writeOK(t.insert({_id: 1, a: 1, b: 1})); + assert.commandWorked(t.insert({_id: 1, a: 1, b: 1})); var join = startParallelShell("db.find_and_modify_concurrent.update({a: 1, b: 1}, {$inc: {a: 1}});"); diff --git a/jstests/core/find_and_modify_empty_update.js b/jstests/core/find_and_modify_empty_update.js index 8bdd7fd43e0..d35b53539f4 100644 --- a/jstests/core/find_and_modify_empty_update.js +++ b/jstests/core/find_and_modify_empty_update.js @@ -17,22 +17,22 @@ assert.isnull(ret); // Test update:{} when a document matches the query. The document is "replaced with the empty // object" (i.e. all non-_id fields are unset). coll.remove({}); -assert.writeOK(coll.insert({_id: 0, a: 1})); +assert.commandWorked(coll.insert({_id: 0, a: 1})); ret = coll.findAndModify({query: {a: 1}, update: {}}); assert.eq(ret, {_id: 0, a: 1}); assert.eq(coll.findOne({_id: 0}), {_id: 0}); // Test update:{} with new:true. coll.remove({}); -assert.writeOK(coll.insert({_id: 0, a: 1})); +assert.commandWorked(coll.insert({_id: 0, a: 1})); ret = coll.findAndModify({query: {a: 1}, update: {}, new: true}); assert.eq(ret, {_id: 0}); assert.eq(coll.findOne({_id: 0}), {_id: 0}); // Test update:{} with a sort. coll.remove({}); -assert.writeOK(coll.insert({_id: 0, a: 1})); -assert.writeOK(coll.insert({_id: 1, a: 1})); +assert.commandWorked(coll.insert({_id: 0, a: 1})); +assert.commandWorked(coll.insert({_id: 1, a: 1})); ret = coll.findAndModify({query: {a: 1}, update: {}, sort: {_id: 1}}); assert.eq(ret, {_id: 0, a: 1}); assert.eq(coll.findOne({_id: 0}), {_id: 0}); diff --git a/jstests/core/find_dedup.js b/jstests/core/find_dedup.js index df9dbfa9d12..791ce338c45 100644 --- a/jstests/core/find_dedup.js +++ b/jstests/core/find_dedup.js @@ -20,11 +20,11 @@ function checkDedup(query, idArray) { // Deduping $or coll.drop(); coll.ensureIndex({a: 1, b: 1}); -assert.writeOK(coll.insert({_id: 1, a: 1, b: 1})); -assert.writeOK(coll.insert({_id: 2, a: 1, b: 1})); -assert.writeOK(coll.insert({_id: 3, a: 2, b: 2})); -assert.writeOK(coll.insert({_id: 4, a: 3, b: 3})); -assert.writeOK(coll.insert({_id: 5, a: 3, b: 3})); +assert.commandWorked(coll.insert({_id: 1, a: 1, b: 1})); +assert.commandWorked(coll.insert({_id: 2, a: 1, b: 1})); +assert.commandWorked(coll.insert({_id: 3, a: 2, b: 2})); +assert.commandWorked(coll.insert({_id: 4, a: 3, b: 3})); +assert.commandWorked(coll.insert({_id: 5, a: 3, b: 3})); checkDedup({ $or: [ {a: {$gte: 0, $lte: 2}, b: {$gte: 0, $lte: 2}}, @@ -36,8 +36,8 @@ checkDedup({ // Deduping multikey assert(coll.drop()); -assert.writeOK(coll.insert({_id: 1, a: [1, 2, 3], b: [4, 5, 6]})); -assert.writeOK(coll.insert({_id: 2, a: [1, 2, 3], b: [4, 5, 6]})); +assert.commandWorked(coll.insert({_id: 1, a: [1, 2, 3], b: [4, 5, 6]})); +assert.commandWorked(coll.insert({_id: 2, a: [1, 2, 3], b: [4, 5, 6]})); assert.eq(2, coll.count()); checkDedup({$or: [{a: {$in: [1, 2]}}, {b: {$in: [4, 5]}}]}, [1, 2]); diff --git a/jstests/core/find_getmore_bsonsize.js b/jstests/core/find_getmore_bsonsize.js index 6a19dec4302..9a57e9ef558 100644 --- a/jstests/core/find_getmore_bsonsize.js +++ b/jstests/core/find_getmore_bsonsize.js @@ -31,8 +31,8 @@ assert.eq(bigStr.length, 16 * oneMB); bigStr = bigStr.substring(0, (16 * oneMB) - oneKB); // Collection has one ~1 MB doc followed by one ~16 MB doc. -assert.writeOK(coll.insert({_id: 0, padding: smallStr})); -assert.writeOK(coll.insert({_id: 1, padding: bigStr})); +assert.commandWorked(coll.insert({_id: 0, padding: smallStr})); +assert.commandWorked(coll.insert({_id: 1, padding: bigStr})); // Find command should just return the first doc, as adding the last would create an invalid // command response document. @@ -78,7 +78,7 @@ while (bigStr.length < (16 * oneMB)) { bigStr = bigStr.substring(0, (16 * oneMB) - 32); var maxSizeDoc = {_id: 0, padding: bigStr}; assert.eq(Object.bsonsize(maxSizeDoc), 16 * oneMB); -assert.writeOK(coll.insert(maxSizeDoc)); +assert.commandWorked(coll.insert(maxSizeDoc)); cmdRes = db.runCommand({find: collName}); assert.commandWorked(cmdRes); diff --git a/jstests/core/find_getmore_cmd.js b/jstests/core/find_getmore_cmd.js index 55ad7a4a443..248721ebbef 100644 --- a/jstests/core/find_getmore_cmd.js +++ b/jstests/core/find_getmore_cmd.js @@ -12,7 +12,7 @@ var coll = db[collName]; coll.drop(); for (var i = 0; i < 150; i++) { - assert.writeOK(coll.insert({a: i})); + assert.commandWorked(coll.insert({a: i})); } // Verify result of a find command that specifies none of the optional arguments. diff --git a/jstests/core/fsync.js b/jstests/core/fsync.js index bd5526b8bc9..ec2a775c992 100644 --- a/jstests/core/fsync.js +++ b/jstests/core/fsync.js @@ -36,7 +36,7 @@ var fsyncLockDB = db.getSisterDB('fsyncLockTestDB'); fsyncLockDB.dropDatabase(); // Test that a single, regular write works as expected. -assert.writeOK(fsyncLockDB.coll.insert({x: 1})); +assert.commandWorked(fsyncLockDB.coll.insert({x: 1})); // Test that fsyncLock doesn't work unless invoked against the admin DB. var resFail = fsyncLockDB.runCommand({fsync: 1, lock: 1}); @@ -64,7 +64,7 @@ assert(db.currentOp().fsyncLock == null, "fsyncUnlock is not null in db.currentO // Make sure the db is unlocked and the initial write made it through. writeOpHandle(); -assert.writeOK(fsyncLockDB.coll.insert({x: 2})); +assert.commandWorked(fsyncLockDB.coll.insert({x: 2})); assert.eq(3, fsyncLockDB.coll.count({})); diff --git a/jstests/core/fts1.js b/jstests/core/fts1.js index 2ce50a22eeb..b1775ff0d30 100644 --- a/jstests/core/fts1.js +++ b/jstests/core/fts1.js @@ -13,10 +13,10 @@ assert.commandWorked(coll.createIndex({x: "text"}, {name: "x_text"})); assert.eq([], queryIDS(coll, "az"), "A0"); -assert.writeOK(coll.insert({_id: 1, x: "az b c"})); -assert.writeOK(coll.insert({_id: 2, x: "az b"})); -assert.writeOK(coll.insert({_id: 3, x: "b c"})); -assert.writeOK(coll.insert({_id: 4, x: "b c d"})); +assert.commandWorked(coll.insert({_id: 1, x: "az b c"})); +assert.commandWorked(coll.insert({_id: 2, x: "az b"})); +assert.commandWorked(coll.insert({_id: 3, x: "b c"})); +assert.commandWorked(coll.insert({_id: 4, x: "b c d"})); assert.eq([1, 2, 3, 4], queryIDS(coll, "c az").sort(), "A1"); assert.eq([4], queryIDS(coll, "d"), "A2"); diff --git a/jstests/core/fts_array.js b/jstests/core/fts_array.js index 16d51981908..93d4ba1cfb8 100644 --- a/jstests/core/fts_array.js +++ b/jstests/core/fts_array.js @@ -40,14 +40,14 @@ assert.writeErrorWithCode(coll.insert({words: "macerate", y: [{z: 1}, {z: 2}]}), // Verify that array fields are allowed when positionally indexed. coll.drop(); assert.commandWorked(coll.createIndex({"a.0": 1, words: "text"})); -assert.writeOK(coll.insert({a: [0, 1, 2], words: "dander"})); +assert.commandWorked(coll.insert({a: [0, 1, 2], words: "dander"})); assert.eq({a: [0, 1, 2], words: "dander"}, coll.findOne({"a.0": 0, $text: {$search: "dander"}}, {_id: 0, a: 1, words: 1})); assert.writeErrorWithCode(coll.insert({a: [[8, 9], 1, 2], words: "dander"}), ErrorCodes.CannotBuildIndexKeys); coll.drop(); assert.commandWorked(coll.createIndex({"a.0.1": 1, words: "text"})); -assert.writeOK(coll.insert({a: [[8, 9], 1, 2], words: "dander"})); +assert.commandWorked(coll.insert({a: [[8, 9], 1, 2], words: "dander"})); assert.eq({a: [[8, 9], 1, 2], words: "dander"}, coll.findOne({"a.0.1": 9, $text: {$search: "dander"}}, {_id: 0, a: 1, words: 1})); }()); diff --git a/jstests/core/fts_casesensitive.js b/jstests/core/fts_casesensitive.js index 5b0e0832130..6617822d43f 100644 --- a/jstests/core/fts_casesensitive.js +++ b/jstests/core/fts_casesensitive.js @@ -5,7 +5,7 @@ var coll = db.fts_casesensitive; coll.drop(); -assert.writeOK(coll.insert({_id: 0, a: "The Quick Brown Fox Jumps Over The Lazy Dog"})); +assert.commandWorked(coll.insert({_id: 0, a: "The Quick Brown Fox Jumps Over The Lazy Dog"})); assert.commandWorked(coll.ensureIndex({a: "text"})); assert.throws(function() { diff --git a/jstests/core/fts_diacritic_and_caseinsensitive.js b/jstests/core/fts_diacritic_and_caseinsensitive.js index 476fe9d2ca1..4b79837fed5 100644 --- a/jstests/core/fts_diacritic_and_caseinsensitive.js +++ b/jstests/core/fts_diacritic_and_caseinsensitive.js @@ -8,7 +8,7 @@ var coll = db.fts_diacritic_and_caseinsensitive; coll.drop(); -assert.writeOK(coll.insert( +assert.commandWorked(coll.insert( {_id: 0, a: "O próximo Vôo à Noite sobre o Atlântico, Põe Freqüentemente o único Médico."})); assert.commandWorked(coll.ensureIndex({a: "text"}, {default_language: "portuguese"})); diff --git a/jstests/core/fts_diacritic_and_casesensitive.js b/jstests/core/fts_diacritic_and_casesensitive.js index ae3c51c703b..5d5711f640e 100644 --- a/jstests/core/fts_diacritic_and_casesensitive.js +++ b/jstests/core/fts_diacritic_and_casesensitive.js @@ -9,7 +9,7 @@ var coll = db.fts_diacritic_and_casesensitive; coll.drop(); -assert.writeOK(coll.insert( +assert.commandWorked(coll.insert( {_id: 0, a: "O próximo Vôo à Noite sobre o Atlântico, Põe Freqüentemente o único Médico."})); assert.commandWorked(coll.ensureIndex({a: "text"}, {default_language: "portuguese"})); diff --git a/jstests/core/fts_diacriticsensitive.js b/jstests/core/fts_diacriticsensitive.js index a377b810ea6..c24b82350e0 100644 --- a/jstests/core/fts_diacriticsensitive.js +++ b/jstests/core/fts_diacriticsensitive.js @@ -8,7 +8,7 @@ var coll = db.fts_diacriticsensitive; coll.drop(); -assert.writeOK(coll.insert( +assert.commandWorked(coll.insert( {_id: 0, a: "O próximo vôo à noite sobre o Atlântico, põe freqüentemente o único médico."})); assert.commandWorked(coll.ensureIndex({a: "text"}, {default_language: "portuguese"})); diff --git a/jstests/core/fts_dotted_prefix_fields.js b/jstests/core/fts_dotted_prefix_fields.js index efbe3a91abf..4f634c57312 100644 --- a/jstests/core/fts_dotted_prefix_fields.js +++ b/jstests/core/fts_dotted_prefix_fields.js @@ -6,8 +6,10 @@ let coll = db.fts_dotted_prefix_fields; coll.drop(); assert.commandWorked(coll.createIndex({"a.x": 1, "a.y": 1, "b.x": 1, "b.y": 1, words: "text"})); -assert.writeOK(coll.insert({a: {x: 1, y: 2}, b: {x: 3, y: 4}, words: "lorem ipsum dolor sit"})); -assert.writeOK(coll.insert({a: {x: 1, y: 2}, b: {x: 5, y: 4}, words: "lorem ipsum dolor sit"})); +assert.commandWorked( + coll.insert({a: {x: 1, y: 2}, b: {x: 3, y: 4}, words: "lorem ipsum dolor sit"})); +assert.commandWorked( + coll.insert({a: {x: 1, y: 2}, b: {x: 5, y: 4}, words: "lorem ipsum dolor sit"})); assert.eq( 1, diff --git a/jstests/core/fts_explain.js b/jstests/core/fts_explain.js index 0b147e5987a..2470d8becf9 100644 --- a/jstests/core/fts_explain.js +++ b/jstests/core/fts_explain.js @@ -15,7 +15,7 @@ res = coll.ensureIndex({content: "text"}, {default_language: "none"}); assert.commandWorked(res); res = coll.insert({content: "some data"}); -assert.writeOK(res); +assert.commandWorked(res); const explain = coll.find({$text: {$search: "\"a\" -b -\"c\""}}, {content: 1, score: {$meta: "textScore"}}) diff --git a/jstests/core/fts_index.js b/jstests/core/fts_index.js index a1b47dad127..1a567668629 100644 --- a/jstests/core/fts_index.js +++ b/jstests/core/fts_index.js @@ -104,7 +104,7 @@ coll.drop(); // Can insert documents with valid language_override into text-indexed collection. assert.commandWorked(coll.ensureIndex({a: "text"})); coll.insert({a: ""}); -assert.writeOK(coll.insert({a: "", language: "spanish"})); +assert.commandWorked(coll.insert({a: "", language: "spanish"})); coll.drop(); // Can't insert documents with invalid language_override into text-indexed collection. diff --git a/jstests/core/fts_index2.js b/jstests/core/fts_index2.js index 51a92e09876..f2d5e23f23f 100644 --- a/jstests/core/fts_index2.js +++ b/jstests/core/fts_index2.js @@ -10,7 +10,7 @@ var coll2 = db.fts_index2.renamed; coll1.drop(); coll2.drop(); -assert.writeOK(coll1.insert({a: {b: "some content"}})); +assert.commandWorked(coll1.insert({a: {b: "some content"}})); assert.commandWorked(coll1.ensureIndex({"$**": "text"})); assert.eq(1, coll1.count({$text: {$search: "content"}})); diff --git a/jstests/core/fts_index3.js b/jstests/core/fts_index3.js index 1a700b3ed7b..d23b0e5418f 100644 --- a/jstests/core/fts_index3.js +++ b/jstests/core/fts_index3.js @@ -10,18 +10,18 @@ var coll = db.fts_index3; // verify that $text with the new value returns the document. coll.drop(); assert.commandWorked(coll.ensureIndex({a: "text"})); -assert.writeOK(coll.insert({a: "hello"})); +assert.commandWorked(coll.insert({a: "hello"})); assert.eq(1, coll.find({$text: {$search: "hello"}}).itcount()); -assert.writeOK(coll.update({}, {$set: {a: "world"}})); +assert.commandWorked(coll.update({}, {$set: {a: "world"}})); assert.eq(0, coll.find({$text: {$search: "hello"}}).itcount()); assert.eq(1, coll.find({$text: {$search: "world"}}).itcount()); // 2) Same as #1, but with a wildcard text index. coll.drop(); assert.commandWorked(coll.ensureIndex({"$**": "text"})); -assert.writeOK(coll.insert({a: "hello"})); +assert.commandWorked(coll.insert({a: "hello"})); assert.eq(1, coll.find({$text: {$search: "hello"}}).itcount()); -assert.writeOK(coll.update({}, {$set: {a: "world"}})); +assert.commandWorked(coll.update({}, {$set: {a: "world"}})); assert.eq(0, coll.find({$text: {$search: "hello"}}).itcount()); assert.eq(1, coll.find({$text: {$search: "world"}}).itcount()); @@ -29,18 +29,18 @@ assert.eq(1, coll.find({$text: {$search: "world"}}).itcount()); // index prefix field, and verify that $text with the new value returns the document. coll.drop(); assert.commandWorked(coll.ensureIndex({a: 1, b: "text"})); -assert.writeOK(coll.insert({a: 1, b: "hello"})); +assert.commandWorked(coll.insert({a: 1, b: "hello"})); assert.eq(1, coll.find({a: 1, $text: {$search: "hello"}}).itcount()); -assert.writeOK(coll.update({}, {$set: {a: 2}})); +assert.commandWorked(coll.update({}, {$set: {a: 2}})); assert.eq(0, coll.find({a: 1, $text: {$search: "hello"}}).itcount()); assert.eq(1, coll.find({a: 2, $text: {$search: "hello"}}).itcount()); // 4) Same as #3, but with a wildcard text index. coll.drop(); assert.commandWorked(coll.ensureIndex({a: 1, "$**": "text"})); -assert.writeOK(coll.insert({a: 1, b: "hello"})); +assert.commandWorked(coll.insert({a: 1, b: "hello"})); assert.eq(1, coll.find({a: 1, $text: {$search: "hello"}}).itcount()); -assert.writeOK(coll.update({}, {$set: {a: 2}})); +assert.commandWorked(coll.update({}, {$set: {a: 2}})); assert.eq(0, coll.find({a: 1, $text: {$search: "hello"}}).itcount()); assert.eq(1, coll.find({a: 2, $text: {$search: "hello"}}).itcount()); @@ -48,18 +48,18 @@ assert.eq(1, coll.find({a: 2, $text: {$search: "hello"}}).itcount()); // index suffix field, and verify that $text with the new value returns the document. coll.drop(); assert.commandWorked(coll.ensureIndex({a: "text", b: 1})); -assert.writeOK(coll.insert({a: "hello", b: 1})); +assert.commandWorked(coll.insert({a: "hello", b: 1})); assert.eq(1, coll.find({b: 1, $text: {$search: "hello"}}).itcount()); -assert.writeOK(coll.update({}, {$set: {b: 2}})); +assert.commandWorked(coll.update({}, {$set: {b: 2}})); assert.eq(0, coll.find({b: 1, $text: {$search: "hello"}}).itcount()); assert.eq(1, coll.find({b: 2, $text: {$search: "hello"}}).itcount()); // 6) Same as #5, but with a wildcard text index. coll.drop(); assert.commandWorked(coll.ensureIndex({"$**": "text", b: 1})); -assert.writeOK(coll.insert({a: "hello", b: 1})); +assert.commandWorked(coll.insert({a: "hello", b: 1})); assert.eq(1, coll.find({b: 1, $text: {$search: "hello"}}).itcount()); -assert.writeOK(coll.update({}, {$set: {b: 2}})); +assert.commandWorked(coll.update({}, {$set: {b: 2}})); assert.eq(0, coll.find({b: 1, $text: {$search: "hello"}}).itcount()); assert.eq(1, coll.find({b: 2, $text: {$search: "hello"}}).itcount()); @@ -67,20 +67,20 @@ assert.eq(1, coll.find({b: 2, $text: {$search: "hello"}}).itcount()); // (so as to change the stemming), and verify that $text with the new language returns the document. coll.drop(); assert.commandWorked(coll.ensureIndex({a: "text"})); -assert.writeOK(coll.insert({a: "testing", language: "es"})); +assert.commandWorked(coll.insert({a: "testing", language: "es"})); assert.eq(1, coll.find({$text: {$search: "testing", $language: "es"}}).itcount()); assert.eq(0, coll.find({$text: {$search: "testing", $language: "en"}}).itcount()); -assert.writeOK(coll.update({}, {$set: {language: "en"}})); +assert.commandWorked(coll.update({}, {$set: {language: "en"}})); assert.eq(0, coll.find({$text: {$search: "testing", $language: "es"}}).itcount()); assert.eq(1, coll.find({$text: {$search: "testing", $language: "en"}}).itcount()); // 8) Same as #7, but with a wildcard text index. coll.drop(); assert.commandWorked(coll.ensureIndex({"$**": "text"})); -assert.writeOK(coll.insert({a: "testing", language: "es"})); +assert.commandWorked(coll.insert({a: "testing", language: "es"})); assert.eq(1, coll.find({$text: {$search: "testing", $language: "es"}}).itcount()); assert.eq(0, coll.find({$text: {$search: "testing", $language: "en"}}).itcount()); -assert.writeOK(coll.update({}, {$set: {language: "en"}})); +assert.commandWorked(coll.update({}, {$set: {language: "en"}})); assert.eq(0, coll.find({$text: {$search: "testing", $language: "es"}}).itcount()); assert.eq(1, coll.find({$text: {$search: "testing", $language: "en"}}).itcount()); @@ -89,20 +89,20 @@ assert.eq(1, coll.find({$text: {$search: "testing", $language: "en"}}).itcount() // the document. coll.drop(); assert.commandWorked(coll.ensureIndex({"a.b": "text"})); -assert.writeOK(coll.insert({a: {b: "testing", language: "es"}})); +assert.commandWorked(coll.insert({a: {b: "testing", language: "es"}})); assert.eq(1, coll.find({$text: {$search: "testing", $language: "es"}}).itcount()); assert.eq(0, coll.find({$text: {$search: "testing", $language: "en"}}).itcount()); -assert.writeOK(coll.update({}, {$set: {"a.language": "en"}})); +assert.commandWorked(coll.update({}, {$set: {"a.language": "en"}})); assert.eq(0, coll.find({$text: {$search: "testing", $language: "es"}}).itcount()); assert.eq(1, coll.find({$text: {$search: "testing", $language: "en"}}).itcount()); // 10) Same as #9, but with a wildcard text index. coll.drop(); assert.commandWorked(coll.ensureIndex({"$**": "text"})); -assert.writeOK(coll.insert({a: {b: "testing", language: "es"}})); +assert.commandWorked(coll.insert({a: {b: "testing", language: "es"}})); assert.eq(1, coll.find({$text: {$search: "testing", $language: "es"}}).itcount()); assert.eq(0, coll.find({$text: {$search: "testing", $language: "en"}}).itcount()); -assert.writeOK(coll.update({}, {$set: {"a.language": "en"}})); +assert.commandWorked(coll.update({}, {$set: {"a.language": "en"}})); assert.eq(0, coll.find({$text: {$search: "testing", $language: "es"}}).itcount()); assert.eq(1, coll.find({$text: {$search: "testing", $language: "en"}}).itcount()); @@ -111,19 +111,19 @@ assert.eq(1, coll.find({$text: {$search: "testing", $language: "en"}}).itcount() // the new language returns the document. coll.drop(); assert.commandWorked(coll.ensureIndex({a: "text"}, {language_override: "idioma"})); -assert.writeOK(coll.insert({a: "testing", idioma: "es"})); +assert.commandWorked(coll.insert({a: "testing", idioma: "es"})); assert.eq(1, coll.find({$text: {$search: "testing", $language: "es"}}).itcount()); assert.eq(0, coll.find({$text: {$search: "testing", $language: "en"}}).itcount()); -assert.writeOK(coll.update({}, {$set: {idioma: "en"}})); +assert.commandWorked(coll.update({}, {$set: {idioma: "en"}})); assert.eq(0, coll.find({$text: {$search: "testing", $language: "es"}}).itcount()); assert.eq(1, coll.find({$text: {$search: "testing", $language: "en"}}).itcount()); // 12) Same as #11, but with a wildcard text index. coll.drop(); assert.commandWorked(coll.ensureIndex({"$**": "text"}, {language_override: "idioma"})); -assert.writeOK(coll.insert({a: "testing", idioma: "es"})); +assert.commandWorked(coll.insert({a: "testing", idioma: "es"})); assert.eq(1, coll.find({$text: {$search: "testing", $language: "es"}}).itcount()); assert.eq(0, coll.find({$text: {$search: "testing", $language: "en"}}).itcount()); -assert.writeOK(coll.update({}, {$set: {idioma: "en"}})); +assert.commandWorked(coll.update({}, {$set: {idioma: "en"}})); assert.eq(0, coll.find({$text: {$search: "testing", $language: "es"}}).itcount()); assert.eq(1, coll.find({$text: {$search: "testing", $language: "en"}}).itcount()); diff --git a/jstests/core/fts_index_version1.js b/jstests/core/fts_index_version1.js index 0b1c869a3a5..8ae979c7dbe 100644 --- a/jstests/core/fts_index_version1.js +++ b/jstests/core/fts_index_version1.js @@ -4,18 +4,18 @@ var coll = db.fts_index_version1; // Test basic English search. coll.drop(); assert.commandWorked(coll.ensureIndex({a: "text"}, {textIndexVersion: 1})); -assert.writeOK(coll.insert({a: "running"})); +assert.commandWorked(coll.insert({a: "running"})); assert.eq(1, coll.count({$text: {$search: "run"}})); // Test search with a "language alias" only recognized in textIndexVersion:1 (note that the stopword // machinery doesn't recognize these aliases). coll.drop(); assert.commandWorked(coll.ensureIndex({a: "text"}, {default_language: "eng", textIndexVersion: 1})); -assert.writeOK(coll.insert({a: "running"})); +assert.commandWorked(coll.insert({a: "running"})); assert.eq(1, coll.count({$text: {$search: "run"}})); // Test that textIndexVersion:1 indexes ignore subdocument language annotations. coll.drop(); assert.commandWorked(coll.ensureIndex({"a.b": "text"}, {textIndexVersion: 1})); -assert.writeOK(coll.insert({language: "none", a: {language: "english", b: "the"}})); +assert.commandWorked(coll.insert({language: "none", a: {language: "english", b: "the"}})); assert.eq(1, coll.count({$text: {$search: "the", $language: "none"}})); diff --git a/jstests/core/fts_index_version2.js b/jstests/core/fts_index_version2.js index f8c57f4e2d7..a74fe11a62f 100644 --- a/jstests/core/fts_index_version2.js +++ b/jstests/core/fts_index_version2.js @@ -8,7 +8,7 @@ var coll = db.fts_index_version2; coll.drop(); -assert.writeOK(coll.insert( +assert.commandWorked(coll.insert( {_id: 0, a: "O próximo Vôo à Noite sobre o Atlântico, Põe Freqüentemente o único Médico."})); assert.commandWorked( diff --git a/jstests/core/fts_partition_no_multikey.js b/jstests/core/fts_partition_no_multikey.js index 4c249522c30..1238bc60839 100644 --- a/jstests/core/fts_partition_no_multikey.js +++ b/jstests/core/fts_partition_no_multikey.js @@ -4,7 +4,7 @@ t.drop(); t.ensureIndex({x: 1, y: "text"}); -assert.writeOK(t.insert({x: 5, y: "this is fun"})); +assert.commandWorked(t.insert({x: 5, y: "this is fun"})); assert.writeError(t.insert({x: [], y: "this is fun"})); diff --git a/jstests/core/fts_score_sort.js b/jstests/core/fts_score_sort.js index 9a4cc1a120b..4b7189c1a4c 100644 --- a/jstests/core/fts_score_sort.js +++ b/jstests/core/fts_score_sort.js @@ -5,9 +5,9 @@ var t = db.getSiblingDB("test").getCollection("fts_score_sort"); t.drop(); -assert.writeOK(t.insert({_id: 0, a: "textual content"})); -assert.writeOK(t.insert({_id: 1, a: "additional content"})); -assert.writeOK(t.insert({_id: 2, a: "irrelevant content"})); +assert.commandWorked(t.insert({_id: 0, a: "textual content"})); +assert.commandWorked(t.insert({_id: 1, a: "additional content"})); +assert.commandWorked(t.insert({_id: 2, a: "irrelevant content"})); assert.commandWorked(t.ensureIndex({a: "text"})); // $meta sort specification should be rejected if it has additional keys. diff --git a/jstests/core/fts_spanish.js b/jstests/core/fts_spanish.js index 264e1d9125b..988b55cbb80 100644 --- a/jstests/core/fts_spanish.js +++ b/jstests/core/fts_spanish.js @@ -6,11 +6,12 @@ load("jstests/libs/fts.js"); const coll = db.text_spanish; coll.drop(); -assert.writeOK(coll.insert({_id: 1, title: "mi blog", text: "Este es un blog de prueba"})); -assert.writeOK(coll.insert({_id: 2, title: "mi segundo post", text: "Este es un blog de prueba"})); -assert.writeOK(coll.insert( +assert.commandWorked(coll.insert({_id: 1, title: "mi blog", text: "Este es un blog de prueba"})); +assert.commandWorked( + coll.insert({_id: 2, title: "mi segundo post", text: "Este es un blog de prueba"})); +assert.commandWorked(coll.insert( {_id: 3, title: "cuchillos son divertidos", text: "este es mi tercer blog stemmed"})); -assert.writeOK(coll.insert( +assert.commandWorked(coll.insert( {_id: 4, language: "en", title: "My fourth blog", text: "This stemmed blog is in english"})); // Create a text index, giving more weight to the "title" field. diff --git a/jstests/core/fts_trailing_fields.js b/jstests/core/fts_trailing_fields.js index 3f46cd1b1b7..9db8d905535 100644 --- a/jstests/core/fts_trailing_fields.js +++ b/jstests/core/fts_trailing_fields.js @@ -6,7 +6,7 @@ const coll = db.fts_trailing_fields; coll.drop(); assert.commandWorked(coll.createIndex({a: 1, b: "text", c: 1})); -assert.writeOK(coll.insert({a: 2, b: "lorem ipsum"})); +assert.commandWorked(coll.insert({a: 2, b: "lorem ipsum"})); assert.eq(0, coll.find({a: 2, $text: {$search: "lorem"}, c: {$exists: true}}).itcount()); assert.eq(1, coll.find({a: 2, $text: {$search: "lorem"}, c: null}).itcount()); @@ -16,7 +16,7 @@ assert.eq(1, coll.find({a: 2, $text: {$search: "lorem"}, c: {$exists: false}}).i // Same with an $elemMatch predicate on one of the trailing fields. coll.drop(); assert.commandWorked(coll.createIndex({a: 1, b: "text", "c.d": 1})); -assert.writeOK(coll.insert({a: 2, b: "lorem ipsum", c: {d: 3}})); +assert.commandWorked(coll.insert({a: 2, b: "lorem ipsum", c: {d: 3}})); assert.eq(0, coll.find({a: [1, 2], $text: {$search: "lorem"}}).itcount()); assert.eq(0, coll.find({a: 2, $text: {$search: "lorem"}, c: {$elemMatch: {d: 3}}}).itcount()); }()); diff --git a/jstests/core/function_string_representations.js b/jstests/core/function_string_representations.js index 106cdcda9f2..79dd5b31b39 100644 --- a/jstests/core/function_string_representations.js +++ b/jstests/core/function_string_representations.js @@ -13,7 +13,7 @@ var col = db.function_string_representations; col.drop(); -assert.writeOK(col.insert({ +assert.commandWorked(col.insert({ _id: "abc123", ord_date: new Date("Oct 04, 2012"), status: 'A', diff --git a/jstests/core/geo1.js b/jstests/core/geo1.js index 35bba816df5..bf61e4f7ad8 100644 --- a/jstests/core/geo1.js +++ b/jstests/core/geo1.js @@ -12,7 +12,7 @@ idx = { t.insert({zip: "06525", loc: [41.352964, 73.01212]}); t.insert({zip: "10024", loc: [40.786387, 73.97709]}); -assert.writeOK(t.insert({zip: "94061", loc: [37.463911, 122.23396]})); +assert.commandWorked(t.insert({zip: "94061", loc: [37.463911, 122.23396]})); // test "2d" has to be first assert.eq(1, t.getIndexKeys().length, "S1"); @@ -40,4 +40,4 @@ assert.eq("06525", t.find({loc: wb.loc})[0].zip, "C3"); t.drop(); t.ensureIndex({loc: "2d"}, {min: -500, max: 500, bits: 4}); -assert.writeOK(t.insert({loc: [200, 200]})); +assert.commandWorked(t.insert({loc: [200, 200]})); diff --git a/jstests/core/geo10.js b/jstests/core/geo10.js index 9b0fb42c2b5..13bb765c176 100644 --- a/jstests/core/geo10.js +++ b/jstests/core/geo10.js @@ -10,9 +10,9 @@ coll.drop(); assert.commandWorked(db.geo10.ensureIndex({c: '2d', t: 1}, {min: 0, max: Math.pow(2, 40)})); assert.eq(2, db.geo10.getIndexes().length, "A3"); -assert.writeOK(db.geo10.insert({c: [1, 1], t: 1})); -assert.writeOK(db.geo10.insert({c: [3600, 3600], t: 1})); -assert.writeOK(db.geo10.insert({c: [0.001, 0.001], t: 1})); +assert.commandWorked(db.geo10.insert({c: [1, 1], t: 1})); +assert.commandWorked(db.geo10.insert({c: [3600, 3600], t: 1})); +assert.commandWorked(db.geo10.insert({c: [0.001, 0.001], t: 1})); printjson( db.geo10 diff --git a/jstests/core/geo_2d_trailing_fields.js b/jstests/core/geo_2d_trailing_fields.js index 3cb25a6e9ce..e4428c44888 100644 --- a/jstests/core/geo_2d_trailing_fields.js +++ b/jstests/core/geo_2d_trailing_fields.js @@ -8,7 +8,7 @@ const isMaster = assert.commandWorked(db.adminCommand({isMaster: 1})); coll.drop(); assert.commandWorked(coll.createIndex({a: "2d", b: 1})); -assert.writeOK(coll.insert({a: [0, 0]})); +assert.commandWorked(coll.insert({a: [0, 0]})); // Verify that $near queries handle existence predicates over the trailing fields correctly. assert.eq(0, coll.find({a: {$near: [0, 0]}, b: {$exists: true}}).itcount()); @@ -23,7 +23,7 @@ assert.eq(1, coll.find({a: {$geoWithin: {$center: [[0, 0], 1]}}, b: {$exists: fa coll.drop(); assert.commandWorked(coll.createIndex({a: "2d", "b.c": 1})); -assert.writeOK(coll.insert({a: [0, 0], b: [{c: 2}, {c: 3}]})); +assert.commandWorked(coll.insert({a: [0, 0], b: [{c: 2}, {c: 3}]})); // Verify that $near queries correctly handle predicates which cannot be covered due to array // semantics. @@ -38,7 +38,7 @@ assert.eq(0, coll.drop(); assert.commandWorked(coll.createIndex({a: "2d", "b.c": 1})); -assert.writeOK(coll.insert({a: [0, 0], b: [{c: 1}, {c: 2}]})); +assert.commandWorked(coll.insert({a: [0, 0], b: [{c: 1}, {c: 2}]})); // Verify that non-near 2d queries correctly handle predicates which cannot be covered due to // array semantics. diff --git a/jstests/core/geo_allowedcomparisons.js b/jstests/core/geo_allowedcomparisons.js index 576e764820a..24b4ce95efa 100644 --- a/jstests/core/geo_allowedcomparisons.js +++ b/jstests/core/geo_allowedcomparisons.js @@ -34,7 +34,7 @@ t.ensureIndex({geo: "2d"}); // 2d doesn't know what to do w/this assert.writeError(t.insert({geo: geojsonPoint})); // Old points are OK. -assert.writeOK(t.insert({geo: oldPoint})); +assert.commandWorked(t.insert({geo: oldPoint})); // Lines not OK in 2d assert.writeError(t.insert({geo: geojsonLine})); // Shapes are not OK to insert in 2d diff --git a/jstests/core/geo_array0.js b/jstests/core/geo_array0.js index 3b74e42e533..9d25eae9c51 100644 --- a/jstests/core/geo_array0.js +++ b/jstests/core/geo_array0.js @@ -10,7 +10,7 @@ function test(index) { t.insert({zip: "10001", loc: [[10, 10], [50, 50]]}); t.insert({zip: "10002", loc: [[20, 20], [50, 50]]}); var res = t.insert({zip: "10003", loc: [[30, 30], [50, 50]]}); - assert.writeOK(res); + assert.commandWorked(res); if (index) { assert.commandWorked(t.ensureIndex({loc: "2d", zip: 1})); @@ -18,7 +18,7 @@ function test(index) { } res = t.insert({zip: "10004", loc: [[40, 40], [50, 50]]}); - assert.writeOK(res); + assert.commandWorked(res); // test normal access printjson(t.find({loc: {$within: {$box: [[0, 0], [45, 45]]}}}).toArray()); diff --git a/jstests/core/geo_big_polygon.js b/jstests/core/geo_big_polygon.js index 43738e58ae7..26b3f436780 100644 --- a/jstests/core/geo_big_polygon.js +++ b/jstests/core/geo_big_polygon.js @@ -39,11 +39,11 @@ var polarPoint = {type: "Point", coordinates: [85, 85]}; var lineEquator = {type: "LineString", coordinates: [[-20, 0], [20, 0]]}; -assert.writeOK(coll.insert({loc: poly10})); -assert.writeOK(coll.insert({loc: line10})); -assert.writeOK(coll.insert({loc: centerPoint})); -assert.writeOK(coll.insert({loc: polarPoint})); -assert.writeOK(coll.insert({loc: lineEquator})); +assert.commandWorked(coll.insert({loc: poly10})); +assert.commandWorked(coll.insert({loc: line10})); +assert.commandWorked(coll.insert({loc: centerPoint})); +assert.commandWorked(coll.insert({loc: polarPoint})); +assert.commandWorked(coll.insert({loc: lineEquator})); assert.eq(coll.find({}).count(), 5); jsTest.log("Starting query..."); @@ -70,7 +70,7 @@ var bigPoly10 = { crs: bigCRS }; -assert.writeOK(coll.insert({_id: "bigPoly10", loc: bigPoly10})); +assert.commandWorked(coll.insert({_id: "bigPoly10", loc: bigPoly10})); assert.eq(coll.find({loc: {$geoWithin: {$geometry: bigPoly20}}}).count(), 3); assert.eq(coll.find({loc: {$geoIntersects: {$geometry: bigPoly20}}}).count(), 4); @@ -81,7 +81,7 @@ assert.eq(coll.find({loc: {$geoIntersects: {$geometry: bigPoly20Comp}}}).count() assert.commandFailed(coll.ensureIndex({loc: "2dsphere"})); // 3. After removing big polygon, index builds successfully -assert.writeOK(coll.remove({_id: "bigPoly10"})); +assert.commandWorked(coll.remove({_id: "bigPoly10"})); assert.commandWorked(coll.ensureIndex({loc: "2dsphere"})); // 4. With index, insert fails. diff --git a/jstests/core/geo_big_polygon2.js b/jstests/core/geo_big_polygon2.js index 1c4e0d42b87..d41377bb46a 100644 --- a/jstests/core/geo_big_polygon2.js +++ b/jstests/core/geo_big_polygon2.js @@ -551,7 +551,7 @@ objects.forEach(function(o) { if (o.geo.crs && o.geo.crs == strictCRS) { assert.writeError(coll.insert(o), "insert " + o.name); } else { - assert.writeOK(coll.insert(o), "insert " + o.name); + assert.commandWorked(coll.insert(o), "insert " + o.name); } }); diff --git a/jstests/core/geo_big_polygon3.js b/jstests/core/geo_big_polygon3.js index 424510f521a..d9f850b7b2d 100644 --- a/jstests/core/geo_big_polygon3.js +++ b/jstests/core/geo_big_polygon3.js @@ -132,7 +132,7 @@ objects = [ // Insert GeoJson strictCRS objects // Since there is no 2dsphere index, they can be inserted objects.forEach(function(o) { - assert.writeOK(coll.insert(o), "Geo Json strictCRS insert" + o.name); + assert.commandWorked(coll.insert(o), "Geo Json strictCRS insert" + o.name); }); // Use Polygon to search for objects which should be ignored @@ -207,7 +207,7 @@ objects = [ // Insert GeoJson crs84CRS & epsg4326CRS objects objects.forEach(function(o) { - assert.writeOK(coll.insert(o), "Geo Json insert" + o.name); + assert.commandWorked(coll.insert(o), "Geo Json insert" + o.name); }); // Make sure stored crs84CRS & epsg4326CRS documents can be found diff --git a/jstests/core/geo_center_sphere1.js b/jstests/core/geo_center_sphere1.js index bd6c32196de..a533c0a598a 100644 --- a/jstests/core/geo_center_sphere1.js +++ b/jstests/core/geo_center_sphere1.js @@ -38,7 +38,7 @@ function test(index) { } gc(); // needed with low skip values } - assert.writeOK(bulk.execute()); + assert.commandWorked(bulk.execute()); if (index) { t.ensureIndex({loc: index}); diff --git a/jstests/core/geo_center_sphere2.js b/jstests/core/geo_center_sphere2.js index 761cb5b7403..af8074d75cb 100644 --- a/jstests/core/geo_center_sphere2.js +++ b/jstests/core/geo_center_sphere2.js @@ -95,7 +95,7 @@ for (var test = 0; test < numTests; test++) { docsOut: docsOut }); - assert.writeOK(bulk.execute()); + assert.commandWorked(bulk.execute()); assert.eq(docsIn + docsOut, numDocs); assert.eq(pointsIn + pointsOut, totalPoints); diff --git a/jstests/core/geo_distinct.js b/jstests/core/geo_distinct.js index 965ec6f7a18..2ea860ff981 100644 --- a/jstests/core/geo_distinct.js +++ b/jstests/core/geo_distinct.js @@ -14,10 +14,10 @@ let res; // coll.drop(); -assert.writeOK(coll.insert({loc: {type: 'Point', coordinates: [10, 20]}})); -assert.writeOK(coll.insert({loc: {type: 'Point', coordinates: [10, 20]}})); -assert.writeOK(coll.insert({loc: {type: 'Point', coordinates: [20, 30]}})); -assert.writeOK(coll.insert({loc: {type: 'Point', coordinates: [20, 30]}})); +assert.commandWorked(coll.insert({loc: {type: 'Point', coordinates: [10, 20]}})); +assert.commandWorked(coll.insert({loc: {type: 'Point', coordinates: [10, 20]}})); +assert.commandWorked(coll.insert({loc: {type: 'Point', coordinates: [20, 30]}})); +assert.commandWorked(coll.insert({loc: {type: 'Point', coordinates: [20, 30]}})); assert.eq(4, coll.count()); // Test distinct on GeoJSON points with/without a 2dsphere index. @@ -65,7 +65,7 @@ for (let i = 0; i < 50; ++i) { bulk.insert({zone: 4, loc: {type: 'Point', coordinates: [10, 10]}}); bulk.insert({zone: 5, loc: {type: 'Point', coordinates: [20, 20]}}); } -assert.writeOK(bulk.execute()); +assert.commandWorked(bulk.execute()); const originGeoJSON = { type: 'Point', diff --git a/jstests/core/geo_mindistance.js b/jstests/core/geo_mindistance.js index 4ca58b26003..a92aab55f18 100644 --- a/jstests/core/geo_mindistance.js +++ b/jstests/core/geo_mindistance.js @@ -195,9 +195,9 @@ assert.eq(n_docs_within(1000) - n_docs_within(500), t.drop(); assert.commandWorked(t.createIndex({loc: "2d"})); -assert.writeOK(t.insert({loc: [0, 40]})); -assert.writeOK(t.insert({loc: [0, 41]})); -assert.writeOK(t.insert({loc: [0, 42]})); +assert.commandWorked(t.insert({loc: [0, 40]})); +assert.commandWorked(t.insert({loc: [0, 41]})); +assert.commandWorked(t.insert({loc: [0, 42]})); // Test minDistance for 2d index with $near. assert.eq(3, t.find({loc: {$near: [0, 0]}}).itcount()); diff --git a/jstests/core/geo_multinest0.js b/jstests/core/geo_multinest0.js index f59e61c037f..644fcd0d074 100644 --- a/jstests/core/geo_multinest0.js +++ b/jstests/core/geo_multinest0.js @@ -11,14 +11,14 @@ t.insert({zip: "10001", data: [{loc: [10, 10], type: "home"}, {loc: [50, 50], ty t.insert({zip: "10002", data: [{loc: [20, 20], type: "home"}, {loc: [50, 50], type: "work"}]}); var res = t.insert({zip: "10003", data: [{loc: [30, 30], type: "home"}, {loc: [50, 50], type: "work"}]}); -assert.writeOK(res); +assert.commandWorked(res); assert.commandWorked(t.ensureIndex({"data.loc": "2d", zip: 1})); assert.eq(2, t.getIndexKeys().length); res = t.insert({zip: "10004", data: [{loc: [40, 40], type: "home"}, {loc: [50, 50], type: "work"}]}); -assert.writeOK(res); +assert.commandWorked(res); // test normal access @@ -44,7 +44,7 @@ assert.eq(2, t.getIndexKeys().length); res = t.insert({zip: "10004", data: [{loc: [40, 40], type: "home"}, {loc: [50, 50], type: "work"}]}); -assert.writeOK(res); +assert.commandWorked(res); // test normal access printjson(t.find({"data.loc": {$within: {$box: [[0, 0], [45, 45]]}}}).toArray()); diff --git a/jstests/core/geo_multinest1.js b/jstests/core/geo_multinest1.js index fc3e0d2d4d4..78021e4794f 100644 --- a/jstests/core/geo_multinest1.js +++ b/jstests/core/geo_multinest1.js @@ -11,14 +11,14 @@ t.insert({zip: "10001", data: [{loc: [10, 10], type: "home"}, {loc: [29, 29], ty t.insert({zip: "10002", data: [{loc: [20, 20], type: "home"}, {loc: [39, 39], type: "work"}]}); var res = t.insert({zip: "10003", data: [{loc: [30, 30], type: "home"}, {loc: [49, 49], type: "work"}]}); -assert.writeOK(res); +assert.commandWorked(res); assert.commandWorked(t.ensureIndex({"data.loc": "2d", zip: 1})); assert.eq(2, t.getIndexKeys().length); res = t.insert({zip: "10004", data: [{loc: [40, 40], type: "home"}, {loc: [59, 59], type: "work"}]}); -assert.writeOK(res); +assert.commandWorked(res); // test normal access diff --git a/jstests/core/geo_operator_crs.js b/jstests/core/geo_operator_crs.js index 063426b6b45..95dd130ebfd 100644 --- a/jstests/core/geo_operator_crs.js +++ b/jstests/core/geo_operator_crs.js @@ -18,7 +18,7 @@ var jsonZeroPt = {type: "Point", coordinates: [0, 0]}; var legacy90Pt = [90, 0]; var json90Pt = {type: "Point", coordinates: [90, 0]}; -assert.writeOK(coll.insert({geo: json90Pt})); +assert.commandWorked(coll.insert({geo: json90Pt})); var earthRadiusMeters = 6378.1 * 1000; var result = null; @@ -32,7 +32,7 @@ assert.close(result[0].dis, Math.PI / 2); result = runQuery(jsonZeroPt); assert.close(result[0].dis, (Math.PI / 2) * earthRadiusMeters); -assert.writeOK(coll.remove({})); +assert.commandWorked(coll.remove({})); assert.commandWorked(coll.dropIndexes()); // @@ -41,7 +41,7 @@ assert.commandWorked(coll.dropIndexes()); assert.commandWorked(coll.ensureIndex({geo: "2d"})); -assert.writeOK(coll.insert({geo: legacy90Pt})); +assert.commandWorked(coll.insert({geo: legacy90Pt})); result = runQuery(legacyZeroPt); assert.close(result[0].dis, Math.PI / 2); diff --git a/jstests/core/geo_polygon1_noindex.js b/jstests/core/geo_polygon1_noindex.js index d9831a6990c..5f43f736b45 100644 --- a/jstests/core/geo_polygon1_noindex.js +++ b/jstests/core/geo_polygon1_noindex.js @@ -45,7 +45,7 @@ pacman = [ [2, 0] // Bottom ]; -assert.writeOK(t.save({loc: [1, 3]})); // Add a point that's in +assert.commandWorked(t.save({loc: [1, 3]})); // Add a point that's in assert.eq(1, t.find({loc: {$within: {$polygon: pacman}}}).count(), "Pacman single point"); diff --git a/jstests/core/geo_polygon3.js b/jstests/core/geo_polygon3.js index f1e819e1920..fe62bee1f14 100644 --- a/jstests/core/geo_polygon3.js +++ b/jstests/core/geo_polygon3.js @@ -15,7 +15,7 @@ for (let n = 0; n < numTests; n++) { for (let x = 1; x < 9; x++) { for (let y = 1; y < 9; y++) { let o = {_id: num++, loc: [x, y]}; - assert.writeOK(t.insert(o)); + assert.commandWorked(t.insert(o)); } } @@ -51,14 +51,15 @@ for (let n = 0; n < numTests; n++) { [2, 0] // Bottom ]; - assert.writeOK(t.insert({loc: [1, 3]})); // Add a point that's in + assert.commandWorked(t.insert({loc: [1, 3]})); // Add a point that's in assert.commandWorked(t.createIndex({loc: "2d"}, {bits: 2 + n})); assert.eq(1, t.find({loc: {$within: {$polygon: pacman}}}).itcount(), "Pacman single point"); - assert.writeOK(t.insert({loc: [5, 3]})); // Add a point that's out right in the mouth opening - assert.writeOK(t.insert({loc: [3, 7]})); // Add a point above the center of the head - assert.writeOK(t.insert({loc: [3, -1]})); // Add a point below the center of the bottom + assert.commandWorked( + t.insert({loc: [5, 3]})); // Add a point that's out right in the mouth opening + assert.commandWorked(t.insert({loc: [3, 7]})); // Add a point above the center of the head + assert.commandWorked(t.insert({loc: [3, -1]})); // Add a point below the center of the bottom assert.eq(1, t.find({loc: {$within: {$polygon: pacman}}}).itcount(), "Pacman double point"); } diff --git a/jstests/core/geo_s2cursorlimitskip.js b/jstests/core/geo_s2cursorlimitskip.js index 87b3cf5b1b2..6614074e31b 100644 --- a/jstests/core/geo_s2cursorlimitskip.js +++ b/jstests/core/geo_s2cursorlimitskip.js @@ -35,7 +35,7 @@ function insertRandomPoints(num, minDist, maxDist) { var lat = sign() * (minDist + random() * (maxDist - minDist)); var lng = sign() * (minDist + random() * (maxDist - minDist)); var point = {geo: {type: "Point", coordinates: [lng, lat]}}; - assert.writeOK(t.insert(point)); + assert.commandWorked(t.insert(point)); } } diff --git a/jstests/core/geo_s2disjoint_holes.js b/jstests/core/geo_s2disjoint_holes.js index dd17dd29b1d..a79ea432d48 100644 --- a/jstests/core/geo_s2disjoint_holes.js +++ b/jstests/core/geo_s2disjoint_holes.js @@ -68,8 +68,8 @@ assert.eq(1, t.getIndexes().length); // But with no index we can insert bad polygons and bad multi-polygons. // t.drop(); -assert.writeOK(t.insert({p: poly})); -assert.writeOK(t.insert({p: multiPoly})); +assert.commandWorked(t.insert({p: poly})); +assert.commandWorked(t.insert({p: multiPoly})); t.drop(); diff --git a/jstests/core/geo_s2dupe_points.js b/jstests/core/geo_s2dupe_points.js index faa06cabb9b..1038c6df087 100644 --- a/jstests/core/geo_s2dupe_points.js +++ b/jstests/core/geo_s2dupe_points.js @@ -8,7 +8,7 @@ t.ensureIndex({geo: "2dsphere"}); function testDuplicates(shapeName, shapeWithDupes, shapeWithoutDupes) { // insert a doc with dupes - assert.writeOK(t.insert(shapeWithDupes)); + assert.commandWorked(t.insert(shapeWithDupes)); // duplicates are preserved when the document is fetched by _id assert.eq(shapeWithDupes, t.findOne({_id: shapeName})); diff --git a/jstests/core/geo_s2explain.js b/jstests/core/geo_s2explain.js index 97f45e89a68..6e6938e509a 100644 --- a/jstests/core/geo_s2explain.js +++ b/jstests/core/geo_s2explain.js @@ -6,7 +6,7 @@ t.drop(); var point1 = {loc: {type: "Point", coordinates: [10, 10]}}; var point2 = {loc: {type: "Point", coordinates: [10.001, 10]}}; -assert.writeOK(t.insert([point1, point2])); +assert.commandWorked(t.insert([point1, point2])); assert.commandWorked(t.ensureIndex({loc: "2dsphere"})); @@ -23,7 +23,7 @@ for (var i = 10; i < 70; i += 0.1) { points.push({loc: {type: "Point", coordinates: [i, i]}}); } -assert.writeOK(t.insert(points)); +assert.commandWorked(t.insert(points)); explain = t.find({loc: {$nearSphere: {type: "Point", coordinates: [10, 10]}}}) .limit(10) diff --git a/jstests/core/geo_s2index.js b/jstests/core/geo_s2index.js index 0b1644e41da..d909fab4489 100644 --- a/jstests/core/geo_s2index.js +++ b/jstests/core/geo_s2index.js @@ -106,11 +106,11 @@ res = t.insert({ assert.writeError(res); assert.eq(0, t.find().itcount()); res = t.insert({loc: {type: 'Point', coordinates: [40, 5]}}); -assert.writeOK(res); +assert.commandWorked(res); res = t.insert({ loc: {type: 'Point', coordinates: [40, 5], crs: {type: 'name', properties: {name: 'EPSG:4326'}}} }); -assert.writeOK(res); +assert.commandWorked(res); res = t.insert({ loc: { type: 'Point', @@ -118,7 +118,7 @@ res = t.insert({ crs: {type: 'name', properties: {name: 'urn:ogc:def:crs:OGC:1.3:CRS84'}} } }); -assert.writeOK(res); +assert.commandWorked(res); // We can pass level parameters and we verify that they're valid. // 0 <= coarsestIndexedLevel <= finestIndexedLevel <= 30. diff --git a/jstests/core/geo_s2indexversion1.js b/jstests/core/geo_s2indexversion1.js index 7b17796f29f..52d2d29a5bb 100644 --- a/jstests/core/geo_s2indexversion1.js +++ b/jstests/core/geo_s2indexversion1.js @@ -176,30 +176,30 @@ var geometryCollectionDoc = { res = coll.ensureIndex({geo: "2dsphere"}, {"2dsphereIndexVersion": 2}); assert.commandWorked(res); res = coll.insert(pointDoc); -assert.writeOK(res); +assert.commandWorked(res); res = coll.insert(lineStringDoc); -assert.writeOK(res); +assert.commandWorked(res); res = coll.insert(polygonDoc); -assert.writeOK(res); +assert.commandWorked(res); res = coll.insert(multiPointDoc); -assert.writeOK(res); +assert.commandWorked(res); res = coll.insert(multiLineStringDoc); -assert.writeOK(res); +assert.commandWorked(res); res = coll.insert(multiPolygonDoc); -assert.writeOK(res); +assert.commandWorked(res); res = coll.insert(geometryCollectionDoc); -assert.writeOK(res); +assert.commandWorked(res); coll.drop(); // {2dsphereIndexVersion: 1} indexes allow only Point, LineString, and Polygon. res = coll.ensureIndex({geo: "2dsphere"}, {"2dsphereIndexVersion": 1}); assert.commandWorked(res); res = coll.insert(pointDoc); -assert.writeOK(res); +assert.commandWorked(res); res = coll.insert(lineStringDoc); -assert.writeOK(res); +assert.commandWorked(res); res = coll.insert(polygonDoc); -assert.writeOK(res); +assert.commandWorked(res); res = coll.insert(multiPointDoc); assert.writeError(res); res = coll.insert(multiLineStringDoc); diff --git a/jstests/core/geo_s2meridian.js b/jstests/core/geo_s2meridian.js index 763067e8a34..65e2a9879e8 100644 --- a/jstests/core/geo_s2meridian.js +++ b/jstests/core/geo_s2meridian.js @@ -12,7 +12,7 @@ meridianCrossingLine = { geo: {type: "LineString", coordinates: [[-178.0, 10.0], [178.0, 10.0]]} }; -assert.writeOK(t.insert(meridianCrossingLine)); +assert.commandWorked(t.insert(meridianCrossingLine)); lineAlongMeridian = { type: "LineString", diff --git a/jstests/core/geo_s2multi.js b/jstests/core/geo_s2multi.js index d9a4032d070..b72177eea73 100644 --- a/jstests/core/geo_s2multi.js +++ b/jstests/core/geo_s2multi.js @@ -8,13 +8,13 @@ multiPointA = { "type": "MultiPoint", "coordinates": [[100.0, 0.0], [101.0, 1.0]] }; -assert.writeOK(t.insert({geo: multiPointA})); +assert.commandWorked(t.insert({geo: multiPointA})); multiLineStringA = { "type": "MultiLineString", "coordinates": [[[100.0, 0.0], [101.0, 1.0]], [[102.0, 2.0], [103.0, 3.0]]] }; -assert.writeOK(t.insert({geo: multiLineStringA})); +assert.commandWorked(t.insert({geo: multiLineStringA})); multiPolygonA = { "type": "MultiPolygon", @@ -26,7 +26,7 @@ multiPolygonA = { ] ] }; -assert.writeOK(t.insert({geo: multiPolygonA})); +assert.commandWorked(t.insert({geo: multiPolygonA})); assert.eq(3, t.find({ geo: {$geoIntersects: {$geometry: {"type": "Point", "coordinates": [100, 0]}}} @@ -65,7 +65,7 @@ partialPolygonA = { "type": "Polygon", "coordinates": [[[102.0, 2.0], [103.0, 2.0], [103.0, 3.0], [102.0, 3.0], [102.0, 2.0]]] }; -assert.writeOK(t.insert({geo: partialPolygonA})); +assert.commandWorked(t.insert({geo: partialPolygonA})); // Polygon contains itself, the partial poly, and the multipoint assert.eq(3, t.find({geo: {$geoWithin: {$geometry: multiPolygonA}}}).itcount()); diff --git a/jstests/core/geo_s2nongeoarray.js b/jstests/core/geo_s2nongeoarray.js index 4b210f8f779..62842c8c7b4 100644 --- a/jstests/core/geo_s2nongeoarray.js +++ b/jstests/core/geo_s2nongeoarray.js @@ -7,7 +7,7 @@ oldPoint = [40, 5]; var data = {geo: oldPoint, nonGeo: [123, 456], otherNonGeo: [{b: [1, 2]}, {b: [3, 4]}]}; t.drop(); -assert.writeOK(t.insert(data)); +assert.commandWorked(t.insert(data)); assert.commandWorked(t.ensureIndex({otherNonGeo: 1})); assert.eq(1, t.find({otherNonGeo: {b: [1, 2]}}).itcount()); assert.eq(0, t.find({otherNonGeo: 1}).itcount()); diff --git a/jstests/core/geo_s2ordering.js b/jstests/core/geo_s2ordering.js index dc9f660ae6c..ecbfbc95782 100644 --- a/jstests/core/geo_s2ordering.js +++ b/jstests/core/geo_s2ordering.js @@ -27,7 +27,7 @@ function makepoints(needle) { } } bulk.insert({nongeo: needle, geo: {type: "Point", coordinates: [0, 0]}}); - assert.writeOK(bulk.execute()); + assert.commandWorked(bulk.execute()); } function runTest(index) { diff --git a/jstests/core/geo_s2sparse.js b/jstests/core/geo_s2sparse.js index 2fb93200c44..d058afb9f9b 100644 --- a/jstests/core/geo_s2sparse.js +++ b/jstests/core/geo_s2sparse.js @@ -25,7 +25,7 @@ var bulkInsertDocs = function(coll, numDocs, makeDocFn) { bulk.insert(makeDocFn(i)); } - assert.writeOK(bulk.execute()); + assert.commandWorked(bulk.execute()); print("Bulk inserting " + numDocs + " documents completed"); }; diff --git a/jstests/core/geo_s2twofields.js b/jstests/core/geo_s2twofields.js index c50ca3c46b5..2e225c8cef6 100644 --- a/jstests/core/geo_s2twofields.js +++ b/jstests/core/geo_s2twofields.js @@ -31,7 +31,7 @@ for (var i = 0; i < maxPoints; ++i) { {from: {type: "Point", coordinates: fromCoord}, to: {type: "Point", coordinates: toCoord}}); } res = t.insert(arr); -assert.writeOK(res); +assert.commandWorked(res); assert.eq(t.count(), maxPoints); function semiRigorousTime(func) { diff --git a/jstests/core/geo_s2within_line_polygon_sphere.js b/jstests/core/geo_s2within_line_polygon_sphere.js index 17b89d25f9e..73e4a0f897d 100644 --- a/jstests/core/geo_s2within_line_polygon_sphere.js +++ b/jstests/core/geo_s2within_line_polygon_sphere.js @@ -14,10 +14,11 @@ function testGeoWithinCenterSphereLinePolygon(coll) { } // Basic tests. - assert.writeOK(coll.insert({name: "Point1", geoField: {type: "Point", coordinates: [1, 1]}})); - assert.writeOK(coll.insert( + assert.commandWorked( + coll.insert({name: "Point1", geoField: {type: "Point", coordinates: [1, 1]}})); + assert.commandWorked(coll.insert( {name: "LineString1", geoField: {type: "LineString", coordinates: [[1, 1], [2, 2]]}})); - assert.writeOK(coll.insert({ + assert.commandWorked(coll.insert({ name: "Polygon1", geoField: {type: "Polygon", coordinates: [[[1, 1], [2, 2], [2, 1], [1, 1]]]} })); @@ -35,7 +36,7 @@ function testGeoWithinCenterSphereLinePolygon(coll) { [[151.0997772216797, -33.86157820443923], [151.21719360351562, -33.8952122494965]] } }; - assert.writeOK(coll.insert(geoDoc)); + assert.commandWorked(coll.insert(geoDoc)); // Test for a LineString within a geowithin sphere. testGeoWithinCenterSphere([[151.16789425018004, -33.8508357122312], 0.0011167360027064348], @@ -58,7 +59,7 @@ function testGeoWithinCenterSphereLinePolygon(coll) { ] } }; - assert.writeOK(coll.insert(geoDoc)); + assert.commandWorked(coll.insert(geoDoc)); // Test for a LineString forming a closed loop rectangle within a geowithin sphere. testGeoWithinCenterSphere([[174.75211152791763, -36.88962755605813], 0.000550933650273084], @@ -86,7 +87,7 @@ function testGeoWithinCenterSphereLinePolygon(coll) { ]] } }; - assert.writeOK(coll.insert(geoDoc)); + assert.commandWorked(coll.insert(geoDoc)); // Test for a Polygon within a geowithin sphere. testGeoWithinCenterSphere([[174.78536621904806, -41.30510816038769], 0.0009483659386360411], @@ -127,7 +128,7 @@ function testGeoWithinCenterSphereLinePolygon(coll) { } }; - assert.writeOK(coll.insert(geoDoc)); + assert.commandWorked(coll.insert(geoDoc)); // Test for a MultiPolygon (two seperate polygons) within a geowithin sphere. testGeoWithinCenterSphere([[151.20821632978107, -33.865139891361636], 0.000981007241416606], @@ -161,7 +162,7 @@ function testGeoWithinCenterSphereLinePolygon(coll) { ]] } }; - assert.writeOK(coll.insert(geoDoc)); + assert.commandWorked(coll.insert(geoDoc)); // Test for a MultiPolygon (with a hole) within a geowithin sphere. testGeoWithinCenterSphere([[151.20936119647115, -33.875266834633265], 0.00020277354002627845], @@ -200,7 +201,7 @@ function testGeoWithinCenterSphereLinePolygon(coll) { "coordinates": [[96.328125, 5.61598581915534], [153.984375, -6.315298538330033]] } }; - assert.writeOK(coll.insert(geoDoc)); + assert.commandWorked(coll.insert(geoDoc)); // Test for a large query cap containing both of line vertices but not the line itself. // (should not return a match). @@ -223,7 +224,7 @@ function testGeoWithinCenterSphereLinePolygon(coll) { ]] } }; - assert.writeOK(coll.insert(geoDoc)); + assert.commandWorked(coll.insert(geoDoc)); // Test for a large query cap containing both of line vertices but not the line itself. // (should not return a match). diff --git a/jstests/core/geo_update1.js b/jstests/core/geo_update1.js index 4bb18256a57..54d123eff52 100644 --- a/jstests/core/geo_update1.js +++ b/jstests/core/geo_update1.js @@ -26,12 +26,12 @@ function p() { p(); var res = t.update({loc: {$within: {$center: [[5, 5], 2]}}}, {$inc: {z: 1}}, false, true); -assert.writeOK(res); +assert.commandWorked(res); p(); -assert.writeOK(t.update({}, {'$inc': {'z': 1}}, false, true)); +assert.commandWorked(t.update({}, {'$inc': {'z': 1}}, false, true)); p(); res = t.update({loc: {$within: {$center: [[5, 5], 2]}}}, {$inc: {z: 1}}, false, true); -assert.writeOK(res); +assert.commandWorked(res); p(); diff --git a/jstests/core/geo_update2.js b/jstests/core/geo_update2.js index fe59c55357b..27825416e02 100644 --- a/jstests/core/geo_update2.js +++ b/jstests/core/geo_update2.js @@ -25,13 +25,13 @@ function p() { p(); -assert.writeOK( +assert.commandWorked( t.update({"loc": {"$within": {"$center": [[5, 5], 2]}}}, {'$inc': {'z': 1}}, false, true)); p(); -assert.writeOK(t.update({}, {'$inc': {'z': 1}}, false, true)); +assert.commandWorked(t.update({}, {'$inc': {'z': 1}}, false, true)); p(); -assert.writeOK( +assert.commandWorked( t.update({"loc": {"$within": {"$center": [[5, 5], 2]}}}, {'$inc': {'z': 1}}, false, true)); p(); diff --git a/jstests/core/geo_validate.js b/jstests/core/geo_validate.js index 190f7886298..caee7720d58 100644 --- a/jstests/core/geo_validate.js +++ b/jstests/core/geo_validate.js @@ -48,7 +48,7 @@ assert.throws(function() { // // // Make sure we can do a $within search with a zero-radius circular region -assert.writeOK(coll.insert({geo: [0, 0]})); +assert.commandWorked(coll.insert({geo: [0, 0]})); assert.neq(null, coll.findOne({geo: {$within: {$center: [[0, 0], 0]}}})); assert.neq(null, coll.findOne({geo: {$within: {$centerSphere: [[0, 0], 0]}}})); assert.neq(null, coll.findOne({geo: {$within: {$center: [[0, 0], Infinity]}}})); diff --git a/jstests/core/geonear_key.js b/jstests/core/geonear_key.js index 0238e012577..b0afadaaa06 100644 --- a/jstests/core/geonear_key.js +++ b/jstests/core/geonear_key.js @@ -9,12 +9,12 @@ load("jstests/libs/analyze_plan.js"); const coll = db.jstests_geonear_key; coll.drop(); -assert.writeOK(coll.insert({_id: 0, a: [1, 1]})); -assert.writeOK(coll.insert({_id: 1, a: [1, 2]})); -assert.writeOK(coll.insert({_id: 2, b: {c: [1, 1]}})); -assert.writeOK(coll.insert({_id: 3, b: {c: [1, 2]}})); -assert.writeOK(coll.insert({_id: 4, b: {d: [1, 1]}})); -assert.writeOK(coll.insert({_id: 5, b: {d: [1, 2]}})); +assert.commandWorked(coll.insert({_id: 0, a: [1, 1]})); +assert.commandWorked(coll.insert({_id: 1, a: [1, 2]})); +assert.commandWorked(coll.insert({_id: 2, b: {c: [1, 1]}})); +assert.commandWorked(coll.insert({_id: 3, b: {c: [1, 2]}})); +assert.commandWorked(coll.insert({_id: 4, b: {d: [1, 1]}})); +assert.commandWorked(coll.insert({_id: 5, b: {d: [1, 2]}})); /** * Runs an aggregation consisting of a single $geoNear stage described by 'nearParams', and diff --git a/jstests/core/getmore_cmd_maxtimems.js b/jstests/core/getmore_cmd_maxtimems.js index 1b8e20ba962..e37ee16b77a 100644 --- a/jstests/core/getmore_cmd_maxtimems.js +++ b/jstests/core/getmore_cmd_maxtimems.js @@ -12,7 +12,7 @@ var coll = db[collName]; coll.drop(); for (var i = 0; i < 10; i++) { - assert.writeOK(coll.insert({a: i})); + assert.commandWorked(coll.insert({a: i})); } // Can't attach maxTimeMS to a getMore command for a non-tailable cursor over a non-capped @@ -25,7 +25,7 @@ assert.commandFailed(cmdRes); coll.drop(); assert.commandWorked(db.createCollection(collName, {capped: true, size: 1024})); for (var i = 0; i < 10; i++) { - assert.writeOK(coll.insert({a: i})); + assert.commandWorked(coll.insert({a: i})); } // Can't attach maxTimeMS to a getMore command for a non-tailable cursor over a capped diff --git a/jstests/core/getmore_invalidated_cursors.js b/jstests/core/getmore_invalidated_cursors.js index 43f27ed5e49..57aa832f391 100644 --- a/jstests/core/getmore_invalidated_cursors.js +++ b/jstests/core/getmore_invalidated_cursors.js @@ -19,7 +19,7 @@ function setupCollection() { for (let i = 0; i < nDocs; ++i) { bulk.insert({_id: i, x: i}); } - assert.writeOK(bulk.execute()); + assert.commandWorked(bulk.execute()); assert.commandWorked(coll.createIndex({x: 1})); } diff --git a/jstests/core/getmore_invalidated_documents.js b/jstests/core/getmore_invalidated_documents.js index 378fde3b02a..72acb4a7cc8 100644 --- a/jstests/core/getmore_invalidated_documents.js +++ b/jstests/core/getmore_invalidated_documents.js @@ -19,15 +19,15 @@ var y; // Case #1: Text search with deletion invalidation. t.drop(); assert.commandWorked(t.ensureIndex({a: "text"})); -assert.writeOK(t.insert({_id: 1, a: "bar"})); -assert.writeOK(t.insert({_id: 2, a: "bar"})); -assert.writeOK(t.insert({_id: 3, a: "bar"})); +assert.commandWorked(t.insert({_id: 1, a: "bar"})); +assert.commandWorked(t.insert({_id: 2, a: "bar"})); +assert.commandWorked(t.insert({_id: 3, a: "bar"})); cursor = t.find({$text: {$search: "bar"}}).batchSize(2); cursor.next(); cursor.next(); -assert.writeOK(t.remove({_id: 3})); +assert.commandWorked(t.remove({_id: 3})); // We should get back the document or not (depending on the storage engine / concurrency model). // Either is fine as long as we don't crash. @@ -37,16 +37,16 @@ assert(count === 0 || count === 1); // Case #2: Text search with mutation invalidation. t.drop(); assert.commandWorked(t.ensureIndex({a: "text"})); -assert.writeOK(t.insert({_id: 1, a: "bar"})); -assert.writeOK(t.insert({_id: 2, a: "bar"})); -assert.writeOK(t.insert({_id: 3, a: "bar"})); +assert.commandWorked(t.insert({_id: 1, a: "bar"})); +assert.commandWorked(t.insert({_id: 2, a: "bar"})); +assert.commandWorked(t.insert({_id: 3, a: "bar"})); cursor = t.find({$text: {$search: "bar"}}).batchSize(2); cursor.next(); cursor.next(); // Update the next matching doc so that it no longer matches. -assert.writeOK(t.update({_id: 3}, {$set: {a: "nomatch"}})); +assert.commandWorked(t.update({_id: 3}, {$set: {a: "nomatch"}})); // Either the cursor should skip the result that no longer matches, or we should get back the // old @@ -56,16 +56,16 @@ assert(!cursor.hasNext() || cursor.next()["a"] === "bar"); // Case #3: Merge sort with deletion invalidation. t.drop(); assert.commandWorked(t.ensureIndex({a: 1, b: 1})); -assert.writeOK(t.insert({a: 1, b: 1})); -assert.writeOK(t.insert({a: 1, b: 2})); -assert.writeOK(t.insert({a: 2, b: 3})); -assert.writeOK(t.insert({a: 2, b: 4})); +assert.commandWorked(t.insert({a: 1, b: 1})); +assert.commandWorked(t.insert({a: 1, b: 2})); +assert.commandWorked(t.insert({a: 2, b: 3})); +assert.commandWorked(t.insert({a: 2, b: 4})); cursor = t.find({a: {$in: [1, 2]}}).sort({b: 1}).batchSize(2); cursor.next(); cursor.next(); -assert.writeOK(t.remove({a: 2, b: 3})); +assert.commandWorked(t.remove({a: 2, b: 3})); count = cursor.itcount(); assert(count === 1 || count === 2); @@ -73,16 +73,16 @@ assert(count === 1 || count === 2); // Case #4: Merge sort with mutation invalidation. t.drop(); assert.commandWorked(t.ensureIndex({a: 1, b: 1})); -assert.writeOK(t.insert({a: 1, b: 1})); -assert.writeOK(t.insert({a: 1, b: 2})); -assert.writeOK(t.insert({a: 2, b: 3})); -assert.writeOK(t.insert({a: 2, b: 4})); +assert.commandWorked(t.insert({a: 1, b: 1})); +assert.commandWorked(t.insert({a: 1, b: 2})); +assert.commandWorked(t.insert({a: 2, b: 3})); +assert.commandWorked(t.insert({a: 2, b: 4})); cursor = t.find({a: {$in: [1, 2]}}).sort({b: 1}).batchSize(2); cursor.next(); cursor.next(); -assert.writeOK(t.update({a: 2, b: 3}, {$set: {a: 6}})); +assert.commandWorked(t.update({a: 2, b: 3}, {$set: {a: 6}})); // Either the cursor should skip the result that no longer matches, or we should get back the // old @@ -99,7 +99,7 @@ t.drop(); t.ensureIndex({geo: "2d"}); for (x = -1; x < 1; x++) { for (y = -1; y < 1; y++) { - assert.writeOK(t.insert({geo: [x, y]})); + assert.commandWorked(t.insert({geo: [x, y]})); } } @@ -108,7 +108,7 @@ cursor.next(); cursor.next(); // Drop all documents in the collection. -assert.writeOK(t.remove({})); +assert.commandWorked(t.remove({})); // Both MMAP v1 and doc-locking storage engines should force fetch the doc (it will be buffered // because it is the same distance from the center point as a doc already returned). @@ -119,7 +119,7 @@ t.drop(); t.ensureIndex({geo: "2dsphere"}); for (x = -1; x < 1; x++) { for (y = -1; y < 1; y++) { - assert.writeOK(t.insert({geo: [x, y]})); + assert.commandWorked(t.insert({geo: [x, y]})); } } @@ -128,7 +128,7 @@ cursor.next(); cursor.next(); // Drop all documents in the collection. -assert.writeOK(t.remove({})); +assert.commandWorked(t.remove({})); // Both MMAP v1 and doc-locking storage engines should force fetch the doc (it will be buffered // because it is the same distance from the center point as a doc already returned). @@ -138,7 +138,7 @@ assert(cursor.hasNext()); t.drop(); t.ensureIndex({geo: "2dsphere"}); for (x = 0; x < 6; x++) { - assert.writeOK(t.insert({geo: [x, x]})); + assert.commandWorked(t.insert({geo: [x, x]})); } cursor = t.find({geo: {$nearSphere: [0, 0], $maxDistance: 10}}).batchSize(2); @@ -146,7 +146,7 @@ cursor.next(); cursor.next(); // Drop all documents in the collection. -assert.writeOK(t.remove({})); +assert.commandWorked(t.remove({})); // We might force-fetch or we might skip over the deleted documents, depending on the internals // of the geo near search. Just make sure that we can exhaust the cursor without crashing. @@ -157,7 +157,7 @@ t.drop(); t.ensureIndex({geo: "2d"}); for (x = -1; x < 1; x++) { for (y = -1; y < 1; y++) { - assert.writeOK(t.insert({geo: [x, y]})); + assert.commandWorked(t.insert({geo: [x, y]})); } } @@ -166,7 +166,7 @@ cursor.next(); cursor.next(); // Update all documents in the collection to have position [15, 15]. -assert.writeOK(t.update({}, {$set: {geo: [15, 15]}}, false, true)); +assert.commandWorked(t.update({}, {$set: {geo: [15, 15]}}, false, true)); // The old version of the document should be returned (the update should not be reflected in the // results of the near search). @@ -180,7 +180,7 @@ t.drop(); t.ensureIndex({geo: "2dsphere"}); for (x = -1; x < 1; x++) { for (y = -1; y < 1; y++) { - assert.writeOK(t.insert({geo: [x, y]})); + assert.commandWorked(t.insert({geo: [x, y]})); } } @@ -189,7 +189,7 @@ cursor.next(); cursor.next(); // Update all documents in the collection to have position [15, 15]. -assert.writeOK(t.update({}, {$set: {geo: [15, 15]}}, false, true)); +assert.commandWorked(t.update({}, {$set: {geo: [15, 15]}}, false, true)); // The old version of the document should be returned (the update should not be reflected in the // results of the near search). @@ -209,7 +209,7 @@ cursor = t.find({a: {$in: [1, 2, 3]}}).sort({b: 1}).batchSize(2); cursor.next(); cursor.next(); -assert.writeOK(t.remove({a: 2})); +assert.commandWorked(t.remove({a: 2})); if (cursor.hasNext()) { assert.eq(cursor.next().b, 3); @@ -226,7 +226,7 @@ cursor = t.find({a: {$in: [1, 2, 3]}}).sort({b: 1}).batchSize(2); cursor.next(); cursor.next(); -assert.writeOK(t.update({a: 2}, {$set: {a: 4}})); +assert.commandWorked(t.update({a: 2}, {$set: {a: 4}})); count = cursor.itcount(); if (cursor.hasNext()) { diff --git a/jstests/core/grow_hash_table.js b/jstests/core/grow_hash_table.js index da6fdcc004c..783616b93fb 100644 --- a/jstests/core/grow_hash_table.js +++ b/jstests/core/grow_hash_table.js @@ -25,7 +25,7 @@ var doTest = function(count) { } // Store the document - assert.writeOK(testDB.collection.insert(doc)); + assert.commandWorked(testDB.collection.insert(doc)); // Try to read the document using a large projection try { diff --git a/jstests/core/idhack.js b/jstests/core/idhack.js index 880716ed206..a9e1cc68aa9 100644 --- a/jstests/core/idhack.js +++ b/jstests/core/idhack.js @@ -8,12 +8,12 @@ t.drop(); // Include helpers for analyzing explain output. load("jstests/libs/analyze_plan.js"); -assert.writeOK(t.insert({_id: {x: 1}, z: 1})); -assert.writeOK(t.insert({_id: {x: 2}, z: 2})); -assert.writeOK(t.insert({_id: {x: 3}, z: 3})); -assert.writeOK(t.insert({_id: 1, z: 4})); -assert.writeOK(t.insert({_id: 2, z: 5})); -assert.writeOK(t.insert({_id: 3, z: 6})); +assert.commandWorked(t.insert({_id: {x: 1}, z: 1})); +assert.commandWorked(t.insert({_id: {x: 2}, z: 2})); +assert.commandWorked(t.insert({_id: {x: 3}, z: 3})); +assert.commandWorked(t.insert({_id: 1, z: 4})); +assert.commandWorked(t.insert({_id: 2, z: 5})); +assert.commandWorked(t.insert({_id: 3, z: 6})); assert.eq(2, t.findOne({_id: {x: 2}}).z); assert.eq(2, t.find({_id: {$gte: 2}}).count()); @@ -46,7 +46,7 @@ explain = t.find(query).skip(1).explain(); assert(!isIdhack(db, explain.queryPlanner.winningPlan)); // ID hack cannot be used with a regex predicate. -assert.writeOK(t.insert({_id: "abc"})); +assert.commandWorked(t.insert({_id: "abc"})); explain = t.find({_id: /abc/}).explain(); assert.eq({_id: "abc"}, t.findOne({_id: /abc/})); assert(!isIdhack(db, explain.queryPlanner.winningPlan)); @@ -62,8 +62,8 @@ assert.eq({_id: {x: 2}}, t.findOne(query, {_id: 1})); // t.drop(); -assert.writeOK(t.insert({_id: 0, a: 0, b: [{c: 1}, {c: 2}]})); -assert.writeOK(t.insert({_id: 1, a: 1, b: [{c: 3}, {c: 4}]})); +assert.commandWorked(t.insert({_id: 0, a: 0, b: [{c: 1}, {c: 2}]})); +assert.commandWorked(t.insert({_id: 1, a: 1, b: [{c: 3}, {c: 4}]})); // Simple inclusion. assert.eq({_id: 1, a: 1}, t.find({_id: 1}, {a: 1}).next()); diff --git a/jstests/core/index_bounds_code.js b/jstests/core/index_bounds_code.js index cd1fa58b306..52eec12c26b 100644 --- a/jstests/core/index_bounds_code.js +++ b/jstests/core/index_bounds_code.js @@ -12,7 +12,7 @@ assert.commandWorked(coll.createIndex({a: 1})); const insertedFunc = function() { return 1; }; -assert.writeOK(coll.insert({a: insertedFunc})); +assert.commandWorked(coll.insert({a: insertedFunc})); // Test that queries involving comparison operators with values of type Code are covered. const proj = { @@ -39,9 +39,9 @@ assertCoveredQueryAndCount( // Test that documents that lie outside of the generated index bounds are not returned. coll.remove({}); -assert.writeOK(coll.insert({a: "string"})); -assert.writeOK(coll.insert({a: {b: 1}})); -assert.writeOK(coll.insert({a: MaxKey})); +assert.commandWorked(coll.insert({a: "string"})); +assert.commandWorked(coll.insert({a: {b: 1}})); +assert.commandWorked(coll.insert({a: MaxKey})); assertCoveredQueryAndCount({collection: coll, query: {a: {$gt: func}}, project: proj, count: 0}); assertCoveredQueryAndCount({collection: coll, query: {a: {$gte: func}}, project: proj, count: 0}); diff --git a/jstests/core/index_bounds_maxkey.js b/jstests/core/index_bounds_maxkey.js index c581375e616..e632e52810f 100644 --- a/jstests/core/index_bounds_maxkey.js +++ b/jstests/core/index_bounds_maxkey.js @@ -9,7 +9,7 @@ const coll = db.index_bounds_maxkey; coll.drop(); assert.commandWorked(coll.createIndex({a: 1})); -assert.writeOK(coll.insert({a: MaxKey})); +assert.commandWorked(coll.insert({a: MaxKey})); // Test that queries involving comparison operators with MaxKey are covered. const proj = { @@ -24,9 +24,9 @@ assertCoveredQueryAndCount({collection: coll, query: {a: {$lte: MaxKey}}, projec // Test that all documents are considered less than MaxKey, regardless of the presence of // the queried field 'a'. coll.remove({}); -assert.writeOK(coll.insert({a: "string"})); -assert.writeOK(coll.insert({a: {b: 1}})); -assert.writeOK(coll.insert({})); +assert.commandWorked(coll.insert({a: "string"})); +assert.commandWorked(coll.insert({a: {b: 1}})); +assert.commandWorked(coll.insert({})); assertCoveredQueryAndCount({collection: coll, query: {a: {$gt: MaxKey}}, project: proj, count: 0}); assertCoveredQueryAndCount({collection: coll, query: {a: {$gte: MaxKey}}, project: proj, count: 0}); assertCoveredQueryAndCount({collection: coll, query: {a: {$lt: MaxKey}}, project: proj, count: 3}); diff --git a/jstests/core/index_bounds_minkey.js b/jstests/core/index_bounds_minkey.js index b1d244db0b7..5d2ea8b36fd 100644 --- a/jstests/core/index_bounds_minkey.js +++ b/jstests/core/index_bounds_minkey.js @@ -9,7 +9,7 @@ const coll = db.index_bounds_minkey; coll.drop(); assert.commandWorked(coll.createIndex({a: 1})); -assert.writeOK(coll.insert({a: MinKey})); +assert.commandWorked(coll.insert({a: MinKey})); // Test that queries involving comparison operators with MinKey are covered. const proj = { @@ -24,9 +24,9 @@ assertCoveredQueryAndCount({collection: coll, query: {a: {$lte: MinKey}}, projec // Test that all documents are considered greater than MinKey, regardless of the presence of // the queried field 'a'. coll.remove({}); -assert.writeOK(coll.insert({a: "string"})); -assert.writeOK(coll.insert({a: {b: 1}})); -assert.writeOK(coll.insert({})); +assert.commandWorked(coll.insert({a: "string"})); +assert.commandWorked(coll.insert({a: {b: 1}})); +assert.commandWorked(coll.insert({})); assertCoveredQueryAndCount({collection: coll, query: {a: {$gt: MinKey}}, project: proj, count: 3}); assertCoveredQueryAndCount({collection: coll, query: {a: {$gte: MinKey}}, project: proj, count: 3}); assertCoveredQueryAndCount({collection: coll, query: {a: {$lt: MinKey}}, project: proj, count: 0}); diff --git a/jstests/core/index_bounds_object.js b/jstests/core/index_bounds_object.js index b1bdb2e9591..1b7e12fbd62 100644 --- a/jstests/core/index_bounds_object.js +++ b/jstests/core/index_bounds_object.js @@ -9,7 +9,7 @@ const coll = db.index_bounds_object; coll.drop(); assert.commandWorked(coll.createIndex({a: 1})); -assert.writeOK(coll.insert({a: {b: 1}})); +assert.commandWorked(coll.insert({a: {b: 1}})); // Test that queries involving comparison operators with objects are covered. const proj = { @@ -25,7 +25,7 @@ assertCoveredQueryAndCount({collection: coll, query: {a: {$lt: {b: 2}}}, project assertCoveredQueryAndCount({collection: coll, query: {a: {$lte: {b: 1}}}, project: proj, count: 1}); // Test that queries involving comparisons with an empty object are covered. -assert.writeOK(coll.insert({a: {}})); +assert.commandWorked(coll.insert({a: {}})); assertCoveredQueryAndCount({collection: coll, query: {a: {$gt: {}}}, project: proj, count: 1}); assertCoveredQueryAndCount({collection: coll, query: {a: {$gte: {}}}, project: proj, count: 2}); assertCoveredQueryAndCount({collection: coll, query: {a: {$lt: {}}}, project: proj, count: 0}); @@ -42,8 +42,8 @@ assertCoveredQueryAndCount( // Test that documents that lie outside of the generated index bounds are not returned. Cannot // test empty array upper bounds since that would force the index to be multi-key. coll.remove({}); -assert.writeOK(coll.insert({a: "string"})); -assert.writeOK(coll.insert({a: true})); +assert.commandWorked(coll.insert({a: "string"})); +assert.commandWorked(coll.insert({a: true})); assertCoveredQueryAndCount({collection: coll, query: {a: {$gt: {}}}, project: proj, count: 0}); assertCoveredQueryAndCount({collection: coll, query: {a: {$gte: {}}}, project: proj, count: 0}); assertCoveredQueryAndCount({collection: coll, query: {a: {$lt: {}}}, project: proj, count: 0}); @@ -51,7 +51,7 @@ assertCoveredQueryAndCount({collection: coll, query: {a: {$lte: {}}}, project: p // Adding a document containing an array makes the index multi-key which can never be used for a // covered query. -assert.writeOK(coll.insert({a: []})); +assert.commandWorked(coll.insert({a: []})); assert(!isIndexOnly(db, coll.find({a: {$gt: {}}}, proj).explain().queryPlanner.winningPlan)); assert(!isIndexOnly(db, coll.find({a: {$gte: {}}}, proj).explain().queryPlanner.winningPlan)); assert(!isIndexOnly(db, coll.find({a: {$lt: {}}}, proj).explain().queryPlanner.winningPlan)); diff --git a/jstests/core/index_bounds_pipe.js b/jstests/core/index_bounds_pipe.js index e0ef8cf915a..35e33e27276 100644 --- a/jstests/core/index_bounds_pipe.js +++ b/jstests/core/index_bounds_pipe.js @@ -11,12 +11,12 @@ const collName = 'index_bounds_pipe'; const coll = db.getCollection(collName); coll.drop(); -assert.writeOK(coll.insert({_id: ''})); -assert.writeOK(coll.insert({_id: '\\|'})); -assert.writeOK(coll.insert({_id: 'a'})); -assert.writeOK(coll.insert({_id: 'a|b'})); -assert.writeOK(coll.insert({_id: 'b'})); -assert.writeOK(coll.insert({_id: '|'})); +assert.commandWorked(coll.insert({_id: ''})); +assert.commandWorked(coll.insert({_id: '\\|'})); +assert.commandWorked(coll.insert({_id: 'a'})); +assert.commandWorked(coll.insert({_id: 'a|b'})); +assert.commandWorked(coll.insert({_id: 'b'})); +assert.commandWorked(coll.insert({_id: '|'})); /** * Asserts that a query on a field using 'params.regex' uses index bounds 'params.bounds' and @@ -56,7 +56,7 @@ function assertIndexBoundsAndResult(params) { assert.commandWorked(collRegexValue.createIndex({x: 1})); const doc = {_id: 0, x: params.regex}; - assert.writeOK(collRegexValue.insert(doc)); + assert.commandWorked(collRegexValue.insert(doc)); const regexQuery = {x: params.regex}; assert.eq( diff --git a/jstests/core/index_bounds_timestamp.js b/jstests/core/index_bounds_timestamp.js index fe0acf12936..c500f12202b 100644 --- a/jstests/core/index_bounds_timestamp.js +++ b/jstests/core/index_bounds_timestamp.js @@ -24,7 +24,7 @@ const documents = [ {_id: 3, ts: new Timestamp(1, 0)}, {_id: 4, ts: new Timestamp(Math.pow(2, 32) - 1, Math.pow(2, 32) - 1)} ]; -assert.writeOK(coll.insert(documents)); +assert.commandWorked(coll.insert(documents)); // Sanity check the timestamp bounds generation plan. let plan; diff --git a/jstests/core/index_decimal.js b/jstests/core/index_decimal.js index 9736d8f0903..73f74eda0f7 100644 --- a/jstests/core/index_decimal.js +++ b/jstests/core/index_decimal.js @@ -15,17 +15,17 @@ t.drop(); // Create doubles and NumberDecimals. The double 0.1 is actually 0.10000000000000000555 // and the double 0.3 is actually 0.2999999999999999888, so we can check ordering. -assert.writeOK(t.insert({x: 0.1, y: NumberDecimal('0.3000')})); -assert.writeOK(t.insert({x: 0.1})); -assert.writeOK(t.insert({y: 0.3})); +assert.commandWorked(t.insert({x: 0.1, y: NumberDecimal('0.3000')})); +assert.commandWorked(t.insert({x: 0.1})); +assert.commandWorked(t.insert({y: 0.3})); // Create an index on existing numbers. assert.commandWorked(t.createIndex({x: 1})); assert.commandWorked(t.createIndex({y: -1})); // Insert some more items after index creation. Use _id for decimal. -assert.writeOK(t.insert({x: NumberDecimal('0.10')})); -assert.writeOK(t.insert({_id: NumberDecimal('0E3')})); +assert.commandWorked(t.insert({x: NumberDecimal('0.10')})); +assert.commandWorked(t.insert({_id: NumberDecimal('0E3')})); assert.writeError(t.insert({_id: -0.0})); // Check that we return exactly the right document, use an index to do so, and that the diff --git a/jstests/core/index_elemmatch2.js b/jstests/core/index_elemmatch2.js index d2ff872dc49..19d744ce41d 100644 --- a/jstests/core/index_elemmatch2.js +++ b/jstests/core/index_elemmatch2.js @@ -10,10 +10,10 @@ load("jstests/libs/analyze_plan.js"); const coll = db.elemMatch_index; coll.drop(); -assert.writeOK(coll.insert({a: 1})); -assert.writeOK(coll.insert({a: [{}]})); -assert.writeOK(coll.insert({a: [1, null]})); -assert.writeOK(coll.insert({a: [{type: "Point", coordinates: [0, 0]}]})); +assert.commandWorked(coll.insert({a: 1})); +assert.commandWorked(coll.insert({a: [{}]})); +assert.commandWorked(coll.insert({a: [1, null]})); +assert.commandWorked(coll.insert({a: [{type: "Point", coordinates: [0, 0]}]})); assert.commandWorked(coll.createIndex({a: 1}, {sparse: true})); diff --git a/jstests/core/index_filter_commands.js b/jstests/core/index_filter_commands.js index 45acbb10a49..de110e5abb9 100644 --- a/jstests/core/index_filter_commands.js +++ b/jstests/core/index_filter_commands.js @@ -215,7 +215,7 @@ var collationEN = {locale: "en_US"}; assert.commandWorked(t.createIndex(indexA1, {collation: collationEN, name: "a_1:en_US"})); assert.commandWorked(t.createIndex(indexA1, {name: "a_1"})); -assert.writeOK(t.insert({a: "a"})); +assert.commandWorked(t.insert({a: "a"})); assert.commandWorked(t.runCommand('planCacheSetFilter', {query: queryAA, indexes: [indexA1]})); @@ -244,7 +244,7 @@ assert(isCollscan(db, explain.queryPlanner.winningPlan), "Expected collscan: " + // t.drop(); -assert.writeOK(t.insert({a: "a"})); +assert.commandWorked(t.insert({a: "a"})); assert.commandWorked(t.createIndex(indexA1, {name: "a_1"})); assert.commandWorked(t.runCommand( @@ -264,7 +264,7 @@ assert.eq(0, filters.length, tojson(filters)); // t.drop(); -assert.writeOK(t.insert({a: "a"})); +assert.commandWorked(t.insert({a: "a"})); assert.commandWorked(t.createIndex(indexA1, {name: "a_1"})); assert.commandFailed( diff --git a/jstests/core/index_multiple_compatibility.js b/jstests/core/index_multiple_compatibility.js index 8c203a49941..5a2a599f536 100644 --- a/jstests/core/index_multiple_compatibility.js +++ b/jstests/core/index_multiple_compatibility.js @@ -58,40 +58,40 @@ function testIndexCompat(coll, index1, index2, both) { // Check index 1 document. if (index1.hasOwnProperty('doc')) { - assert.writeOK(coll.insert(index1.doc)); + assert.commandWorked(coll.insert(index1.doc)); assert.eq(coll.find(index1.doc).hint(index1.index.name).itcount(), 1); assert.eq(coll.find(index1.doc).hint(index2.index.name).itcount(), 0); } // Check index 2 document. if (index2.hasOwnProperty('doc')) { - assert.writeOK(coll.insert(index2.doc)); + assert.commandWorked(coll.insert(index2.doc)); assert.eq(coll.find(index2.doc).hint(index2.index.name).itcount(), 1); assert.eq(coll.find(index2.doc).hint(index1.index.name).itcount(), 0); } // Check for present of both in both index1 and index2. if (typeof both !== "undefined") { - assert.writeOK(coll.insert(both)); + assert.commandWorked(coll.insert(both)); assert.eq(coll.find(both).hint(index1.index.name).itcount(), 1); assert.eq(coll.find(both).hint(index2.index.name).itcount(), 1); } // Remove index 1 document. if (index1.hasOwnProperty('doc')) { - assert.writeOK(coll.remove(index1.doc)); + assert.commandWorked(coll.remove(index1.doc)); assert.eq(coll.find(index1.doc).hint(index1.index.name).itcount(), 0); } // Remove index 2 document. if (index2.hasOwnProperty('doc')) { - assert.writeOK(coll.remove(index2.doc)); + assert.commandWorked(coll.remove(index2.doc)); assert.eq(coll.find(index2.doc).hint(index2.index.name).itcount(), 0); } // Remove both. if (typeof both !== "undefined") { - assert.writeOK(coll.remove(both)); + assert.commandWorked(coll.remove(both)); assert.eq(coll.find(both).hint(index1.index.name).itcount(), 0); assert.eq(coll.find(both).hint(index2.index.name).itcount(), 0); } @@ -188,7 +188,7 @@ testIndexCompat(coll, {a: "foo"}); // Test that unique constraints are still enforced. -assert.writeOK(coll.insert({a: "f"})); +assert.commandWorked(coll.insert({a: "f"})); assert.writeError(coll.insert({a: "F"})); // A unique partial index and non-unique index. @@ -206,10 +206,10 @@ testIndexCompat( {index: {key: {a: 1}, name: "a", collation: enUSStrength2, unique: false}, doc: {a: "foo"}}, {a: 5}); -assert.writeOK(coll.insert({a: 5})); +assert.commandWorked(coll.insert({a: 5})); // Test that uniqueness is only enforced by the partial index. -assert.writeOK(coll.insert({a: "foo"})); -assert.writeOK(coll.insert({a: "foo"})); +assert.commandWorked(coll.insert({a: "foo"})); +assert.commandWorked(coll.insert({a: "foo"})); assert.writeError(coll.insert({a: 5})); // Two unique indexes with different collations. @@ -219,7 +219,7 @@ testIndexCompat(coll, {a: "a"}); // Unique enforced on both indexes. -assert.writeOK(coll.insert({a: "a"})); +assert.commandWorked(coll.insert({a: "a"})); assert.writeError(coll.insert({a: "a"})); assert.writeError(coll.insert({a: "A"})); @@ -232,8 +232,8 @@ testIndexCompat( {index: {key: {a: 1}, name: "a2", collation: enUSStrength2, unique: false}, doc: {b: 0}}, {a: "a"}); -assert.writeOK(coll.insert({a: "a"})); -assert.writeOK(coll.insert({})); -assert.writeOK(coll.insert({})); +assert.commandWorked(coll.insert({a: "a"})); +assert.commandWorked(coll.insert({})); +assert.commandWorked(coll.insert({})); assert.writeError(coll.insert({a: "a"})); })(); diff --git a/jstests/core/index_partial_2dsphere.js b/jstests/core/index_partial_2dsphere.js index 15e6427667a..a194cf30d84 100644 --- a/jstests/core/index_partial_2dsphere.js +++ b/jstests/core/index_partial_2dsphere.js @@ -28,8 +28,8 @@ let indexedDoc = { "geoJson": {"type": "Polygon", "coordinates": [[[0, 0], [0, 1], [1, 1], [1, 0], [0, 0]]]} }; -assert.writeOK(coll.insert(unindexedDoc)); -assert.writeOK(coll.insert(indexedDoc)); +assert.commandWorked(coll.insert(unindexedDoc)); +assert.commandWorked(coll.insert(indexedDoc)); // Return the one indexed document. assert.eq( @@ -42,7 +42,7 @@ assert.eq( assert.writeError(coll.update({_id: 0}, {$set: {isIndexed: 1}})); // Update the indexed document to remove it from the index. -assert.writeOK(coll.update({_id: 1}, {$set: {isIndexed: -1}})); +assert.commandWorked(coll.update({_id: 1}, {$set: {isIndexed: -1}})); // This query should now return zero documents. assert.eq( @@ -52,11 +52,11 @@ assert.eq( .itcount()); // Re-index the document. -assert.writeOK(coll.update({_id: 1}, {$set: {isIndexed: 1}})); +assert.commandWorked(coll.update({_id: 1}, {$set: {isIndexed: 1}})); // Remove both should succeed without error. -assert.writeOK(coll.remove({_id: 0})); -assert.writeOK(coll.remove({_id: 1})); +assert.commandWorked(coll.remove({_id: 0})); +assert.commandWorked(coll.remove({_id: 1})); assert.eq( 0, diff --git a/jstests/core/index_partial_create_drop.js b/jstests/core/index_partial_create_drop.js index 0233f3fb8a0..1ad9d8178ed 100644 --- a/jstests/core/index_partial_create_drop.js +++ b/jstests/core/index_partial_create_drop.js @@ -43,7 +43,7 @@ assert.commandFailed(coll.createIndex( {x: 1}, {partialFilterExpression: {$expr: {$eq: [{$trim: {input: "$x"}}, "hi"]}}})); for (var i = 0; i < 10; i++) { - assert.writeOK(coll.insert({x: i, a: i})); + assert.commandWorked(coll.insert({x: i, a: i})); } // Create partial index. diff --git a/jstests/core/index_partial_read_ops.js b/jstests/core/index_partial_read_ops.js index eba93a7ee23..62ba040b3fb 100644 --- a/jstests/core/index_partial_read_ops.js +++ b/jstests/core/index_partial_read_ops.js @@ -14,8 +14,8 @@ var coll = db.index_partial_read_ops; coll.drop(); assert.commandWorked(coll.ensureIndex({x: 1}, {partialFilterExpression: {a: {$lte: 1.5}}})); -assert.writeOK(coll.insert({x: 5, a: 2})); // Not in index. -assert.writeOK(coll.insert({x: 6, a: 1})); // In index. +assert.commandWorked(coll.insert({x: 5, a: 2})); // Not in index. +assert.commandWorked(coll.insert({x: 6, a: 1})); // In index. // // Verify basic functionality with find(). diff --git a/jstests/core/index_partial_validate.js b/jstests/core/index_partial_validate.js index 321fede5c19..e3dedfd87db 100644 --- a/jstests/core/index_partial_validate.js +++ b/jstests/core/index_partial_validate.js @@ -13,7 +13,7 @@ res = t.ensureIndex({b: 1}); assert.commandWorked(res); res = t.insert({non_indexed_field: 'x'}); -assert.writeOK(res); +assert.commandWorked(res); res = t.validate(true); assert.commandWorked(res); diff --git a/jstests/core/index_partial_write_ops.js b/jstests/core/index_partial_write_ops.js index d79ce93155f..8d96d094a33 100644 --- a/jstests/core/index_partial_write_ops.js +++ b/jstests/core/index_partial_write_ops.js @@ -23,23 +23,23 @@ coll.drop(); // Create partial index. assert.commandWorked(coll.ensureIndex({x: 1}, {unique: true, partialFilterExpression: {a: 1}})); -assert.writeOK(coll.insert({_id: 1, x: 5, a: 2, b: 1})); // Not in index. -assert.writeOK(coll.insert({_id: 2, x: 6, a: 1, b: 1})); // In index. +assert.commandWorked(coll.insert({_id: 1, x: 5, a: 2, b: 1})); // Not in index. +assert.commandWorked(coll.insert({_id: 2, x: 6, a: 1, b: 1})); // In index. assert.eq(1, getNumKeys("x_1")); // Move into partial index, then back out. -assert.writeOK(coll.update({_id: 1}, {$set: {a: 1}})); +assert.commandWorked(coll.update({_id: 1}, {$set: {a: 1}})); assert.eq(2, getNumKeys("x_1")); -assert.writeOK(coll.update({_id: 1}, {$set: {a: 2}})); +assert.commandWorked(coll.update({_id: 1}, {$set: {a: 2}})); assert.eq(1, getNumKeys("x_1")); // Bit blip doc in partial index, and out of partial index. -assert.writeOK(coll.update({_id: 2}, {$set: {b: 2}})); +assert.commandWorked(coll.update({_id: 2}, {$set: {b: 2}})); assert.eq(1, getNumKeys("x_1")); -assert.writeOK(coll.update({_id: 1}, {$set: {b: 2}})); +assert.commandWorked(coll.update({_id: 1}, {$set: {b: 2}})); assert.eq(1, getNumKeys("x_1")); var array = []; @@ -48,23 +48,23 @@ for (var i = 0; i < 2048; i++) { } // Update that causes record relocation. -assert.writeOK(coll.update({_id: 2}, {$set: {b: array}})); +assert.commandWorked(coll.update({_id: 2}, {$set: {b: array}})); assert.eq(1, getNumKeys("x_1")); -assert.writeOK(coll.update({_id: 1}, {$set: {b: array}})); +assert.commandWorked(coll.update({_id: 1}, {$set: {b: array}})); assert.eq(1, getNumKeys("x_1")); // Delete that doesn't affect partial index. -assert.writeOK(coll.remove({x: 5})); +assert.commandWorked(coll.remove({x: 5})); assert.eq(1, getNumKeys("x_1")); // Delete that does affect partial index. -assert.writeOK(coll.remove({x: 6})); +assert.commandWorked(coll.remove({x: 6})); assert.eq(0, getNumKeys("x_1")); // Documents with duplicate keys that straddle the index. -assert.writeOK(coll.insert({_id: 3, x: 1, a: 1})); // In index. -assert.writeOK(coll.insert({_id: 4, x: 1, a: 0})); // Not in index. +assert.commandWorked(coll.insert({_id: 3, x: 1, a: 1})); // In index. +assert.commandWorked(coll.insert({_id: 4, x: 1, a: 0})); // Not in index. assert.writeErrorWithCode(coll.insert({_id: 5, x: 1, a: 1}), ErrorCodes.DuplicateKey); // Duplicate key constraint prevents insertion. @@ -72,7 +72,7 @@ assert.writeErrorWithCode(coll.insert({_id: 5, x: 1, a: 1}), assert.eq(1, getNumKeys("x_1")); // Remove _id 4, _id 3 should remain in index. -assert.writeOK(coll.remove({_id: 4})); +assert.commandWorked(coll.remove({_id: 4})); // _id 3 is still in the index. assert.eq(1, getNumKeys("x_1")); diff --git a/jstests/core/index_stats.js b/jstests/core/index_stats.js index ee99fdc4831..9d1ee063812 100644 --- a/jstests/core/index_stats.js +++ b/jstests/core/index_stats.js @@ -57,9 +57,9 @@ var getIndexNamesForWinningPlan = function(explain) { return indexNameList; }; -assert.writeOK(col.insert({a: 1, b: 1, c: 1})); -assert.writeOK(col.insert({a: 2, b: 2, c: 2})); -assert.writeOK(col.insert({a: 3, b: 3, c: 3})); +assert.commandWorked(col.insert({a: 1, b: 1, c: 1})); +assert.commandWorked(col.insert({a: 2, b: 2, c: 2})); +assert.commandWorked(col.insert({a: 3, b: 3, c: 3})); // // Confirm no index stats object exists prior to index creation. @@ -105,7 +105,7 @@ res = db.runCommand({findAndModify: colName, query: {a: 2}, remove: true}); assert.commandWorked(res); countA++; assert.eq(countA, getUsageCount("a_1")); -assert.writeOK(col.insert(res.value)); +assert.commandWorked(col.insert(res.value)); // // Confirm $and operation ticks indexes for winning plan, but not rejected plans. @@ -167,14 +167,14 @@ assert.eq(countB, getUsageCount("b_1_c_1")); // // Confirm index stats tick on update(). // -assert.writeOK(col.update({a: 2}, {$set: {d: 2}})); +assert.commandWorked(col.update({a: 2}, {$set: {d: 2}})); countA++; assert.eq(countA, getUsageCount("a_1")); // // Confirm index stats tick on remove(). // -assert.writeOK(col.remove({a: 2})); +assert.commandWorked(col.remove({a: 2})); countA++; assert.eq(countA, getUsageCount("a_1")); @@ -212,9 +212,9 @@ assert.throws(function() { // const foreignCollection = db[colName + "_foreign"]; foreignCollection.drop(); -assert.writeOK(foreignCollection.insert([{_id: 0}, {_id: 1}, {_id: 2}])); +assert.commandWorked(foreignCollection.insert([{_id: 0}, {_id: 1}, {_id: 2}])); col.drop(); -assert.writeOK(col.insert([{_id: 0, foreignId: 1}, {_id: 1, foreignId: 2}])); +assert.commandWorked(col.insert([{_id: 0, foreignId: 1}, {_id: 1, foreignId: 2}])); assert.eq(0, getUsageCount("_id_")); assert.eq(2, col.aggregate([ @@ -238,7 +238,7 @@ assert.eq(2, // Confirm index use is recorded for $graphLookup. // foreignCollection.drop(); -assert.writeOK(foreignCollection.insert([ +assert.commandWorked(foreignCollection.insert([ {_id: 0, connectedTo: 1}, {_id: 1, connectedTo: "X"}, {_id: 2, connectedTo: 3}, @@ -246,7 +246,7 @@ assert.writeOK(foreignCollection.insert([ // $graphLookup doesn't cache the query. ])); col.drop(); -assert.writeOK(col.insert([{_id: 0, foreignId: 0}, {_id: 1, foreignId: 2}])); +assert.commandWorked(col.insert([{_id: 0, foreignId: 0}, {_id: 1, foreignId: 2}])); assert.eq(0, getUsageCount("_id_")); assert.eq(2, col.aggregate([ diff --git a/jstests/core/index_type_change.js b/jstests/core/index_type_change.js index af2671338a2..96f020c9ec8 100644 --- a/jstests/core/index_type_change.js +++ b/jstests/core/index_type_change.js @@ -17,12 +17,12 @@ var coll = db.index_type_change; coll.drop(); assert.commandWorked(coll.ensureIndex({a: 1})); -assert.writeOK(coll.insert({a: 2})); +assert.commandWorked(coll.insert({a: 2})); assert.eq(1, coll.find({a: {$type: "double"}}).itcount()); var newVal = new NumberLong(2); var res = coll.update({}, {a: newVal}); // Replacement update. -assert.writeOK(res); +assert.commandWorked(res); assert.eq(res.nMatched, 1); if (coll.getMongo().writeMode() == "commands") assert.eq(res.nModified, 1); diff --git a/jstests/core/indexes_multiple_commands.js b/jstests/core/indexes_multiple_commands.js index 7058fd32019..f2b97f0e4f5 100644 --- a/jstests/core/indexes_multiple_commands.js +++ b/jstests/core/indexes_multiple_commands.js @@ -136,7 +136,7 @@ assertIndexesCreated( () => coll.createIndex({a: 1}, {name: "caseInsensitive", collation: {locale: "en_US", strength: 2}})); -assert.writeOK(coll.insert([{a: "a"}, {a: "A"}, {a: 20}])); +assert.commandWorked(coll.insert([{a: "a"}, {a: "A"}, {a: 20}])); // An ambiguous hint pattern fails. assert.throws(() => coll.find({a: 1}).hint({a: 1}).itcount()); diff --git a/jstests/core/indexu.js b/jstests/core/indexu.js index 953d178fff5..f8b6af7f15d 100644 --- a/jstests/core/indexu.js +++ b/jstests/core/indexu.js @@ -11,7 +11,7 @@ var dupDoc2 = {a: [{'1': 1}, 'c']}; var noDupDoc = {a: [{'1': 1}]}; // Test that we can't index dupDoc. -assert.writeOK(t.save(dupDoc)); +assert.commandWorked(t.save(dupDoc)); assert.commandFailed(t.ensureIndex({'a.0': 1})); t.remove({}); @@ -20,7 +20,7 @@ assert.writeError(t.save(dupDoc)); // Test that we can't index dupDoc2. t.drop(); -assert.writeOK(t.save(dupDoc2)); +assert.commandWorked(t.save(dupDoc2)); assert.commandFailed(t.ensureIndex({'a.1': 1})); t.remove({}); @@ -30,22 +30,22 @@ assert.writeError(t.save(dupDoc2)); // Test that we can index dupDoc with a different index. t.drop(); t.ensureIndex({'a.b': 1}); -assert.writeOK(t.save(dupDoc)); +assert.commandWorked(t.save(dupDoc)); // Test number field starting with hyphen. t.drop(); t.ensureIndex({'a.-1': 1}); -assert.writeOK(t.save({a: [{'-1': 1}]})); +assert.commandWorked(t.save({a: [{'-1': 1}]})); // Test number field starting with zero. t.drop(); t.ensureIndex({'a.00': 1}); -assert.writeOK(t.save({a: [{'00': 1}]})); +assert.commandWorked(t.save({a: [{'00': 1}]})); // Test multiple array indexes t.drop(); t.ensureIndex({'a.0': 1, 'a.1': 1}); -assert.writeOK(t.save({a: [{'1': 1}]})); +assert.commandWorked(t.save({a: [{'1': 1}]})); assert.writeError(t.save({a: [{'1': 1}, 4]})); // Test that we can index noDupDoc. @@ -57,7 +57,7 @@ assert.commandWorked(t.ensureIndex({'a.1': 1})); t.drop(); t.ensureIndex({'a.0': 1}); t.ensureIndex({'a.1': 1}); -assert.writeOK(t.save(noDupDoc)); +assert.commandWorked(t.save(noDupDoc)); // Test that we can query noDupDoc. assert.eq(1, t.find({'a.1': 1}).hint({'a.1': 1}).itcount()); @@ -80,7 +80,7 @@ assert.commandFailed(t.ensureIndex({'a.0.0': 1})); // Check where there is a duplicate for a fully addressed field. t.drop(); -assert.writeOK(t.save({a: [[1], {'0': [1]}]})); +assert.commandWorked(t.save({a: [[1], {'0': [1]}]})); assert.commandFailed(t.ensureIndex({'a.0.0': 1})); // Two ways of addressing parse to an array. diff --git a/jstests/core/insert1.js b/jstests/core/insert1.js index f3cb243dad1..0365e439707 100644 --- a/jstests/core/insert1.js +++ b/jstests/core/insert1.js @@ -47,7 +47,7 @@ var count = 100 * 1000; for (i = 0; i < count; ++i) { toInsert.push({_id: i, a: 5}); } -assert.writeOK(t.insert(toInsert)); +assert.commandWorked(t.insert(toInsert)); doc = t.findOne({_id: 1}); assert.eq(5, doc.a); assert.eq(count, t.count(), "bad count"); diff --git a/jstests/core/insert_illegal_doc.js b/jstests/core/insert_illegal_doc.js index d91866e8766..64ecb0ae7ad 100644 --- a/jstests/core/insert_illegal_doc.js +++ b/jstests/core/insert_illegal_doc.js @@ -19,7 +19,7 @@ assert.eq(0, coll.find().itcount(), "should not be a doc"); // test update res = coll.insert({_id: 1}); -assert.writeOK(res, "insert failed"); +assert.commandWorked(res, "insert failed"); res = coll.update({_id: 1}, {$set: {a: [1, 2, 3], b: [4, 5, 6]}}); assert.writeError(res); assert.eq(res.getWriteError().code, ErrorCodes.CannotIndexParallelArrays); diff --git a/jstests/core/json_schema/json_schema.js b/jstests/core/json_schema/json_schema.js index 13a10fde323..7611cefaa3a 100644 --- a/jstests/core/json_schema/json_schema.js +++ b/jstests/core/json_schema/json_schema.js @@ -12,16 +12,16 @@ load("jstests/libs/assert_schema_match.js"); let coll = db.jstests_json_schema; coll.drop(); -assert.writeOK(coll.insert({_id: 0, num: 3})); -assert.writeOK(coll.insert({_id: 1, num: -3})); -assert.writeOK(coll.insert({_id: 2, num: NumberInt(2)})); -assert.writeOK(coll.insert({_id: 3, num: NumberInt(-2)})); -assert.writeOK(coll.insert({_id: 4, num: NumberLong(1)})); -assert.writeOK(coll.insert({_id: 5, num: NumberLong(-1)})); -assert.writeOK(coll.insert({_id: 6, num: {}})); -assert.writeOK(coll.insert({_id: 7, num: "str"})); -assert.writeOK(coll.insert({_id: 8, num: "string"})); -assert.writeOK(coll.insert({_id: 9})); +assert.commandWorked(coll.insert({_id: 0, num: 3})); +assert.commandWorked(coll.insert({_id: 1, num: -3})); +assert.commandWorked(coll.insert({_id: 2, num: NumberInt(2)})); +assert.commandWorked(coll.insert({_id: 3, num: NumberInt(-2)})); +assert.commandWorked(coll.insert({_id: 4, num: NumberLong(1)})); +assert.commandWorked(coll.insert({_id: 5, num: NumberLong(-1)})); +assert.commandWorked(coll.insert({_id: 6, num: {}})); +assert.commandWorked(coll.insert({_id: 7, num: "str"})); +assert.commandWorked(coll.insert({_id: 8, num: "string"})); +assert.commandWorked(coll.insert({_id: 9})); // Test that $jsonSchema fails to parse if its argument is not an object. assert.throws(function() { @@ -176,10 +176,10 @@ assert.eq([{_id: 8}, {_id: 9}], .toArray()); coll.drop(); -assert.writeOK(coll.insert({_id: 0, obj: 3})); -assert.writeOK(coll.insert({_id: 1, obj: {f1: {f3: "str"}, f2: "str"}})); -assert.writeOK(coll.insert({_id: 2, obj: {f1: "str", f2: "str"}})); -assert.writeOK(coll.insert({_id: 3, obj: {f1: 1, f2: "str"}})); +assert.commandWorked(coll.insert({_id: 0, obj: 3})); +assert.commandWorked(coll.insert({_id: 1, obj: {f1: {f3: "str"}, f2: "str"}})); +assert.commandWorked(coll.insert({_id: 2, obj: {f1: "str", f2: "str"}})); +assert.commandWorked(coll.insert({_id: 3, obj: {f1: 1, f2: "str"}})); // Test that properties keyword can be used recursively, and that it does not apply when the // field does not contain on object. @@ -224,11 +224,11 @@ assert.eq([{_id: 0}, {_id: 1}, {_id: 2}], .toArray()); coll.drop(); -assert.writeOK(coll.insert({_id: 0, arr: 3})); -assert.writeOK(coll.insert({_id: 1, arr: [1, "foo"]})); -assert.writeOK(coll.insert({_id: 2, arr: [{a: 1}, {b: 2}]})); -assert.writeOK(coll.insert({_id: 3, arr: []})); -assert.writeOK(coll.insert({_id: 4, arr: {a: []}})); +assert.commandWorked(coll.insert({_id: 0, arr: 3})); +assert.commandWorked(coll.insert({_id: 1, arr: [1, "foo"]})); +assert.commandWorked(coll.insert({_id: 2, arr: [{a: 1}, {b: 2}]})); +assert.commandWorked(coll.insert({_id: 3, arr: []})); +assert.commandWorked(coll.insert({_id: 4, arr: {a: []}})); // Test that the type:"array" restriction works as expected. assert.eq([{_id: 1}, {_id: 2}, {_id: 3}], @@ -323,8 +323,8 @@ assert.eq(listCollectionsOutput.cursor.firstBatch[0].options.validator, {$jsonSc // Test that $jsonSchema and various internal match expressions work correctly with sibling // predicates. coll.drop(); -assert.writeOK(coll.insert({_id: 1, a: 1, b: 1})); -assert.writeOK(coll.insert({_id: 2, a: 2, b: 2})); +assert.commandWorked(coll.insert({_id: 1, a: 1, b: 1})); +assert.commandWorked(coll.insert({_id: 2, a: 2, b: 2})); assert.eq( 1, diff --git a/jstests/core/json_schema/misc_validation.js b/jstests/core/json_schema/misc_validation.js index fbd15e7b31a..045a7c74878 100644 --- a/jstests/core/json_schema/misc_validation.js +++ b/jstests/core/json_schema/misc_validation.js @@ -84,8 +84,8 @@ assert.commandFailedWithCode(res, ErrorCodes.FailedToParse); // Test that a valid $jsonSchema is legal in a count command. coll.drop(); -assert.writeOK(coll.insert({a: 1, b: "str"})); -assert.writeOK(coll.insert({a: 1, b: 1})); +assert.commandWorked(coll.insert({a: 1, b: "str"})); +assert.commandWorked(coll.insert({a: 1, b: 1})); assert.eq(1, coll.count({$jsonSchema: {properties: {a: {type: "number"}, b: {type: "string"}}}})); // Test that a valid $jsonSchema is legal in a $geoNear stage. @@ -93,8 +93,8 @@ const point = { type: "Point", coordinates: [31.0, 41.0] }; -assert.writeOK(coll.insert({geo: point, a: 1})); -assert.writeOK(coll.insert({geo: point, a: 0})); +assert.commandWorked(coll.insert({geo: point, a: 1})); +assert.commandWorked(coll.insert({geo: point, a: 0})); assert.commandWorked(coll.createIndex({geo: "2dsphere"})); res = coll.aggregate({ $geoNear: { @@ -111,10 +111,10 @@ assert.eq(res[0].loc, point, tojson(res)); // Test that a valid $jsonSchema is legal in a distinct command. coll.drop(); -assert.writeOK(coll.insert({a: 1})); -assert.writeOK(coll.insert({a: 2})); -assert.writeOK(coll.insert({a: "str"})); -assert.writeOK(coll.insert({a: ["STR", "str"]})); +assert.commandWorked(coll.insert({a: 1})); +assert.commandWorked(coll.insert({a: 2})); +assert.commandWorked(coll.insert({a: "str"})); +assert.commandWorked(coll.insert({a: ["STR", "str"]})); assert(arrayEq([1, 2], coll.distinct("a", {$jsonSchema: {properties: {a: {type: "number"}}}}))); @@ -127,16 +127,16 @@ const caseInsensitiveCollation = { coll.drop(); assert.commandWorked( testDB.createCollection(coll.getName(), {collation: caseInsensitiveCollation})); -assert.writeOK(coll.insert({a: "str"})); -assert.writeOK(coll.insert({a: ["STR", "sTr"]})); +assert.commandWorked(coll.insert({a: "str"})); +assert.commandWorked(coll.insert({a: ["STR", "sTr"]})); assert.eq(0, coll.find({$jsonSchema: schema}).itcount()); assert.eq(2, coll.find({$jsonSchema: {properties: {a: {uniqueItems: true}}}}).itcount()); assert.eq(2, coll.find({a: "STR"}).itcount()); // Test that $jsonSchema does not respect the collation set explicitly on a query. coll.drop(); -assert.writeOK(coll.insert({a: "str"})); -assert.writeOK(coll.insert({a: ["STR", "sTr"]})); +assert.commandWorked(coll.insert({a: "str"})); +assert.commandWorked(coll.insert({a: ["STR", "sTr"]})); if (testDB.getMongo().useReadCommands()) { assert.eq(0, coll.find({$jsonSchema: schema}).collation(caseInsensitiveCollation).itcount()); @@ -155,7 +155,7 @@ if (testDB.getMongo().useReadCommands()) { bulk.insert({name: "John", age: "unknown"}); bulk.insert({name: "Mark"}); bulk.insert({}); - assert.writeOK(bulk.execute()); + assert.commandWorked(bulk.execute()); assert.commandWorked(testDB.createView( "seniorCitizens", coll.getName(), [{ @@ -186,9 +186,9 @@ const foreign = testDB.json_schema_foreign; foreign.drop(); coll.drop(); for (let i = 0; i < 10; i++) { - assert.writeOK(foreign.insert({_id: i, n: [i - 1, i + 1]})); + assert.commandWorked(foreign.insert({_id: i, n: [i - 1, i + 1]})); } -assert.writeOK(coll.insert({starting: 0})); +assert.commandWorked(coll.insert({starting: 0})); res = coll.aggregate({ $graphLookup: { @@ -206,10 +206,10 @@ assert.eq(res[0].integers.length, 5); // Test that $jsonSchema is legal in a delete command. coll.drop(); -assert.writeOK(coll.insert({a: 1})); -assert.writeOK(coll.insert({a: 2})); -assert.writeOK(coll.insert({a: "str"})); -assert.writeOK(coll.insert({a: [3]})); +assert.commandWorked(coll.insert({a: 1})); +assert.commandWorked(coll.insert({a: 2})); +assert.commandWorked(coll.insert({a: "str"})); +assert.commandWorked(coll.insert({a: [3]})); schema = { properties: {a: {type: "number", maximum: 2}} @@ -235,18 +235,18 @@ if (db.getMongo().writeMode() === "commands") { // Test that $jsonSchema is legal in an update command. coll.drop(); -assert.writeOK(coll.insert({a: 1})); -assert.writeOK(coll.insert({a: 2})); +assert.commandWorked(coll.insert({a: 1})); +assert.commandWorked(coll.insert({a: 2})); res = coll.update({$jsonSchema: schema}, {$inc: {a: 1}}, {multi: true}); -assert.writeOK(res); +assert.commandWorked(res); assert.eq(2, res.nMatched); assert.eq(1, coll.find({$jsonSchema: schema}).itcount()); // Test that $jsonSchema is legal in a findAndModify command. coll.drop(); -assert.writeOK(coll.insert({a: "long_string"})); -assert.writeOK(coll.insert({a: "short"})); +assert.commandWorked(coll.insert({a: "long_string"})); +assert.commandWorked(coll.insert({a: "short"})); schema = { properties: {a: {type: "string", minLength: 6}} @@ -257,9 +257,9 @@ assert.eq(1, coll.find({$jsonSchema: schema}).itcount()); // Test that $jsonSchema works correctly in the presence of a basic b-tree index. coll.drop(); -assert.writeOK(coll.insert({_id: 1, a: 1, b: 1})); -assert.writeOK(coll.insert({_id: 2, a: 2, b: 2, point: [5, 5]})); -assert.writeOK(coll.insert({_id: 3, a: "temp text test"})); +assert.commandWorked(coll.insert({_id: 1, a: 1, b: 1})); +assert.commandWorked(coll.insert({_id: 2, a: 2, b: 2, point: [5, 5]})); +assert.commandWorked(coll.insert({_id: 3, a: "temp text test"})); assert.commandWorked(coll.createIndex({a: 1})); assert.eq(3, coll.find({$jsonSchema: {}}).itcount()); @@ -312,7 +312,7 @@ assert.eq(1, coll.find({$and: [{$jsonSchema: {}}, {$text: {$search: "TEST"}}]}). if (!isMongos) { coll.drop(); - assert.writeOK(coll.insert({_id: 0, a: true})); + assert.commandWorked(coll.insert({_id: 0, a: true})); // Test $jsonSchema in the precondition checking for applyOps. res = testDB.adminCommand({ @@ -331,6 +331,6 @@ if (!isMongos) { // Use majority write concern to clear the drop-pending that can cause lock conflicts with // transactions. coll.drop({writeConcern: {w: "majority"}}); - assert.writeOK(coll.insert({_id: 1, a: true})); + assert.commandWorked(coll.insert({_id: 1, a: true})); } }()); diff --git a/jstests/core/kill_cursors.js b/jstests/core/kill_cursors.js index a65078028ed..b839a3bf8c8 100644 --- a/jstests/core/kill_cursors.js +++ b/jstests/core/kill_cursors.js @@ -20,7 +20,7 @@ var coll = db.jstest_killcursors; coll.drop(); for (var i = 0; i < 10; i++) { - assert.writeOK(coll.insert({_id: i})); + assert.commandWorked(coll.insert({_id: i})); } // killCursors command should fail if the collection name is not a string. diff --git a/jstests/core/killop_drop_collection.js b/jstests/core/killop_drop_collection.js index b4efd13733b..a25bce9b2d6 100644 --- a/jstests/core/killop_drop_collection.js +++ b/jstests/core/killop_drop_collection.js @@ -17,9 +17,9 @@ var collectionName = "killop_drop"; let collection = db.getCollection(collectionName); collection.drop(); for (let i = 0; i < 1000; i++) { - assert.writeOK(collection.insert({x: i})); + assert.commandWorked(collection.insert({x: i})); } -assert.writeOK(collection.createIndex({x: 1}, {background: true})); +assert.commandWorked(collection.createIndex({x: 1}, {background: true})); // Attempt to fsyncLock the database, aborting early if the storage engine doesn't support it. const storageEngine = jsTest.options().storageEngine; diff --git a/jstests/core/min_max_bounds.js b/jstests/core/min_max_bounds.js index c2171df23fb..8419e3c0eca 100644 --- a/jstests/core/min_max_bounds.js +++ b/jstests/core/min_max_bounds.js @@ -10,9 +10,9 @@ load('jstests/aggregation/extras/utils.js'); // For resultsEq. var coll = db.query_bound_inclusion; coll.drop(); -assert.writeOK(coll.insert({a: 1, b: 1})); -assert.writeOK(coll.insert({a: 2, b: 2})); -assert.writeOK(coll.insert({a: 3, b: 3})); +assert.commandWorked(coll.insert({a: 1, b: 1})); +assert.commandWorked(coll.insert({a: 2, b: 2})); +assert.commandWorked(coll.insert({a: 3, b: 3})); assert.commandWorked(coll.createIndex({a: 1})); diff --git a/jstests/core/min_max_key.js b/jstests/core/min_max_key.js index 5314e8d3436..b9e9c3d6b89 100644 --- a/jstests/core/min_max_key.js +++ b/jstests/core/min_max_key.js @@ -18,7 +18,7 @@ const allElements = [ {_id: "a_string", a: "hello"} ]; -assert.writeOK(coll.insert(allElements)); +assert.commandWorked(coll.insert(allElements)); function testQueriesWithMinOrMaxKey() { const eqMinRes = coll.find({a: {$eq: MinKey}}).toArray(); diff --git a/jstests/core/minmax_edge.js b/jstests/core/minmax_edge.js index 081af7a347e..135d83337c3 100644 --- a/jstests/core/minmax_edge.js +++ b/jstests/core/minmax_edge.js @@ -35,17 +35,17 @@ function verifyResultIds(results, expectedIds) { */ function reset(t) { t.drop(); - assert.writeOK(t.insert({_id: 0, a: 1, b: 1})); - assert.writeOK(t.insert({_id: 1, a: 1, b: 2})); - assert.writeOK(t.insert({_id: 2, a: 1, b: 3})); + assert.commandWorked(t.insert({_id: 0, a: 1, b: 1})); + assert.commandWorked(t.insert({_id: 1, a: 1, b: 2})); + assert.commandWorked(t.insert({_id: 2, a: 1, b: 3})); - assert.writeOK(t.insert({_id: 3, a: 2, b: 1})); - assert.writeOK(t.insert({_id: 4, a: 2, b: 2})); - assert.writeOK(t.insert({_id: 5, a: 2, b: 3})); + assert.commandWorked(t.insert({_id: 3, a: 2, b: 1})); + assert.commandWorked(t.insert({_id: 4, a: 2, b: 2})); + assert.commandWorked(t.insert({_id: 5, a: 2, b: 3})); - assert.writeOK(t.insert({_id: 6, a: 3, b: 1})); - assert.writeOK(t.insert({_id: 7, a: 3, b: 2})); - assert.writeOK(t.insert({_id: 8, a: 3, b: 3})); + assert.commandWorked(t.insert({_id: 6, a: 3, b: 1})); + assert.commandWorked(t.insert({_id: 7, a: 3, b: 2})); + assert.commandWorked(t.insert({_id: 8, a: 3, b: 3})); } // Two helpers to save typing diff --git a/jstests/core/mr1.js b/jstests/core/mr1.js index 245059de523..fa7add00b89 100644 --- a/jstests/core/mr1.js +++ b/jstests/core/mr1.js @@ -167,7 +167,7 @@ if (true) { correct[k] = 1; bulk.insert({x: i, tags: [k]}); } - assert.writeOK(bulk.execute()); + assert.commandWorked(bulk.execute()); res = db.runCommand({mapreduce: "mr1", out: "mr1_foo", map: m, reduce: r}); d(res); diff --git a/jstests/core/mr5.js b/jstests/core/mr5.js index 1858eaa57a5..074002b5bc6 100644 --- a/jstests/core/mr5.js +++ b/jstests/core/mr5.js @@ -12,12 +12,12 @@ load("jstests/aggregation/extras/utils.js"); // For resultsEq. const t = db.mr5; t.drop(); -assert.writeOK(t.insert({"partner": 1, "visits": 9})); -assert.writeOK(t.insert({"partner": 2, "visits": 9})); -assert.writeOK(t.insert({"partner": 1, "visits": 11})); -assert.writeOK(t.insert({"partner": 1, "visits": 30})); -assert.writeOK(t.insert({"partner": 2, "visits": 41})); -assert.writeOK(t.insert({"partner": 2, "visits": 41})); +assert.commandWorked(t.insert({"partner": 1, "visits": 9})); +assert.commandWorked(t.insert({"partner": 2, "visits": 9})); +assert.commandWorked(t.insert({"partner": 1, "visits": 11})); +assert.commandWorked(t.insert({"partner": 1, "visits": 30})); +assert.commandWorked(t.insert({"partner": 2, "visits": 41})); +assert.commandWorked(t.insert({"partner": 2, "visits": 41})); let mapper = function() { emit(this.partner, {stats: [this.visits]}); diff --git a/jstests/core/mr_bigobject_replace.js b/jstests/core/mr_bigobject_replace.js index c02ee7f1fac..843afd3757e 100644 --- a/jstests/core/mr_bigobject_replace.js +++ b/jstests/core/mr_bigobject_replace.js @@ -45,7 +45,7 @@ function runTest(testOptions) { db.mr_bigobject_replace.drop(); // Insert a document so the mapper gets run. - assert.writeOK(db.input.insert({})); + assert.commandWorked(db.input.insert({})); var res = db.runCommand(Object.extend({ mapReduce: "input", diff --git a/jstests/core/mr_optim.js b/jstests/core/mr_optim.js index d4d088f93e5..1fbcaabbea1 100644 --- a/jstests/core/mr_optim.js +++ b/jstests/core/mr_optim.js @@ -18,7 +18,7 @@ if (res.ok !== 1) { } for (var i = 0; i < 1000; ++i) { - assert.writeOK(t.save({a: Math.random(1000), b: Math.random(10000)})); + assert.commandWorked(t.save({a: Math.random(1000), b: Math.random(10000)})); } function m() { diff --git a/jstests/core/mr_tolerates_js_exception.js b/jstests/core/mr_tolerates_js_exception.js index 2689bce8433..e291639cb92 100644 --- a/jstests/core/mr_tolerates_js_exception.js +++ b/jstests/core/mr_tolerates_js_exception.js @@ -15,7 +15,7 @@ let coll = db.mr_tolerates_js_exception; coll.drop(); for (let i = 0; i < 100; i++) { - assert.writeOK(coll.insert({_id: i, a: 1})); + assert.commandWorked(coll.insert({_id: i, a: 1})); } // Test that the command fails with a JS interpreter failure error when the reduce function diff --git a/jstests/core/nan.js b/jstests/core/nan.js index 4cca00c4b66..fbdba566d7b 100644 --- a/jstests/core/nan.js +++ b/jstests/core/nan.js @@ -7,18 +7,18 @@ const coll = db.jstests_nan; coll.drop(); -assert.writeOK(coll.insert({_id: 0, a: -Infinity})); -assert.writeOK(coll.insert({_id: 1, a: -3})); -assert.writeOK(coll.insert({_id: 2, a: 0})); -assert.writeOK(coll.insert({_id: 3, a: 3})); -assert.writeOK(coll.insert({_id: 4, a: Infinity})); -assert.writeOK(coll.insert({_id: 5, a: NaN})); -assert.writeOK(coll.insert({_id: 6, a: -NaN})); -assert.writeOK(coll.insert({_id: 7, a: undefined})); -assert.writeOK(coll.insert({_id: 8, a: null})); -assert.writeOK(coll.insert({_id: 9, a: []})); -assert.writeOK(coll.insert({_id: 10, a: {b: 1}})); -assert.writeOK(coll.insert({_id: 11, a: {b: 1}})); +assert.commandWorked(coll.insert({_id: 0, a: -Infinity})); +assert.commandWorked(coll.insert({_id: 1, a: -3})); +assert.commandWorked(coll.insert({_id: 2, a: 0})); +assert.commandWorked(coll.insert({_id: 3, a: 3})); +assert.commandWorked(coll.insert({_id: 4, a: Infinity})); +assert.commandWorked(coll.insert({_id: 5, a: NaN})); +assert.commandWorked(coll.insert({_id: 6, a: -NaN})); +assert.commandWorked(coll.insert({_id: 7, a: undefined})); +assert.commandWorked(coll.insert({_id: 8, a: null})); +assert.commandWorked(coll.insert({_id: 9, a: []})); +assert.commandWorked(coll.insert({_id: 10, a: {b: 1}})); +assert.commandWorked(coll.insert({_id: 11, a: {b: 1}})); /** * Ensures correct results for EQ, LT, LTE, GT, and GTE cases. diff --git a/jstests/core/natural.js b/jstests/core/natural.js index 2471e2be495..fa7a511eda1 100644 --- a/jstests/core/natural.js +++ b/jstests/core/natural.js @@ -8,9 +8,9 @@ var coll = db.jstests_natural; coll.drop(); assert.commandWorked(coll.ensureIndex({a: 1})); -assert.writeOK(coll.insert({_id: 1, a: 3})); -assert.writeOK(coll.insert({_id: 2, a: 2})); -assert.writeOK(coll.insert({_id: 3, a: 1})); +assert.commandWorked(coll.insert({_id: 1, a: 3})); +assert.commandWorked(coll.insert({_id: 2, a: 2})); +assert.commandWorked(coll.insert({_id: 3, a: 1})); // Regression test for SERVER-20660. Ensures that documents returned with $natural don't have // any extraneous fields. diff --git a/jstests/core/no_db_created.js b/jstests/core/no_db_created.js index e563a7cd468..bb0d998a3fe 100644 --- a/jstests/core/no_db_created.js +++ b/jstests/core/no_db_created.js @@ -22,16 +22,16 @@ var coll = mydb.fake; // force:true is for replset passthroughs assert.commandFailed(coll.runCommand("compact", {force: true})); noDB(mydb); -assert.writeOK(coll.insert({})); +assert.commandWorked(coll.insert({})); mydb.dropDatabase(); assert.commandFailed(coll.runCommand("dropIndexes")); noDB(mydb); -assert.writeOK(coll.insert({})); +assert.commandWorked(coll.insert({})); mydb.dropDatabase(); assert.commandFailed(coll.runCommand("collMod", {expireAfterSeconds: 1})); noDB(mydb); -assert.writeOK(coll.insert({})); +assert.commandWorked(coll.insert({})); mydb.dropDatabase(); }());
\ No newline at end of file diff --git a/jstests/core/not2.js b/jstests/core/not2.js index 8f0f91da1d5..0692c297762 100644 --- a/jstests/core/not2.js +++ b/jstests/core/not2.js @@ -20,10 +20,10 @@ function fail(query) { } function doTest() { - assert.writeOK(coll.remove({})); + assert.commandWorked(coll.remove({})); - assert.writeOK(coll.insert({i: "a"})); - assert.writeOK(coll.insert({i: "b"})); + assert.commandWorked(coll.insert({i: "a"})); + assert.commandWorked(coll.insert({i: "b"})); // TODO SERVER-12735: We currently do not handle double negatives during query // canonicalization. @@ -58,14 +58,14 @@ function doTest() { check({i: {$not: {$type: 1}}}, ["a", "b"]); check({i: {$not: {$type: 2}}}, []); - assert.writeOK(coll.remove({})); - assert.writeOK(coll.insert({i: 1})); + assert.commandWorked(coll.remove({})); + assert.commandWorked(coll.insert({i: 1})); check({i: {$not: {$mod: [5, 1]}}}, []); check({i: {$mod: [5, 2]}}, []); check({i: {$not: {$mod: [5, 2]}}}, [1]); - assert.writeOK(coll.remove({})); - assert.writeOK(coll.insert({i: ["a", "b"]})); + assert.commandWorked(coll.remove({})); + assert.commandWorked(coll.insert({i: ["a", "b"]})); check({i: {$not: {$size: 2}}}, []); check({i: {$not: {$size: 3}}}, [["a", "b"]]); check({i: {$not: {$gt: "a"}}}, []); @@ -73,9 +73,9 @@ function doTest() { check({i: {$not: {$all: ["a", "b"]}}}, []); check({i: {$not: {$all: ["c"]}}}, [["a", "b"]]); - assert.writeOK(coll.remove({})); - assert.writeOK(coll.insert({i: [{j: "a"}]})); - assert.writeOK(coll.insert({i: [{j: "b"}]})); + assert.commandWorked(coll.remove({})); + assert.commandWorked(coll.insert({i: [{j: "a"}]})); + assert.commandWorked(coll.insert({i: [{j: "b"}]})); check({i: {$not: {$elemMatch: {j: "a"}}}}, [[{j: "b"}]]); check({i: {$not: {$elemMatch: {j: "f"}}}}, [[{j: "a"}], [{j: "b"}]]); } diff --git a/jstests/core/null_query_semantics.js b/jstests/core/null_query_semantics.js index 8f664a6d80b..00aaacd6ed0 100644 --- a/jstests/core/null_query_semantics.js +++ b/jstests/core/null_query_semantics.js @@ -19,7 +19,7 @@ function extractAValues(results) { function testNotEqualsNullSemantics() { // For the first portion of the test, only insert documents without arrays. This will avoid // making the indexes multi-key, which may allow an index to be used to answer the queries. - assert.writeOK(coll.insert([ + assert.commandWorked(coll.insert([ {_id: "a_empty_subobject", a: {}}, {_id: "a_null", a: null}, {_id: "a_number", a: 4}, @@ -214,7 +214,7 @@ function testNotEqualsNullSemantics() { assert.eq(writeResult.getWriteErrors()[0].code, 16766, tojson(writeResult)); return; } - assert.writeOK(writeResult); + assert.commandWorked(writeResult); // Test the semantics of the query {a: {$eq: null}}. (function testBasicNullQuery() { diff --git a/jstests/core/opcounters_write_cmd.js b/jstests/core/opcounters_write_cmd.js index 2aef8fe72c5..3ffdac0b0b5 100644 --- a/jstests/core/opcounters_write_cmd.js +++ b/jstests/core/opcounters_write_cmd.js @@ -31,13 +31,13 @@ t.drop(); // Single insert, no error. opCounters = newdb.serverStatus().opcounters; res = t.insert({_id: 0}); -assert.writeOK(res); +assert.commandWorked(res); assert.eq(opCounters.insert + 1, newdb.serverStatus().opcounters.insert); // Bulk insert, no error. opCounters = newdb.serverStatus().opcounters; res = t.insert([{_id: 1}, {_id: 2}]); -assert.writeOK(res); +assert.commandWorked(res); assert.eq(opCounters.insert + 2, newdb.serverStatus().opcounters.insert); // Test is not run when in compatibility mode as errors are not counted @@ -71,7 +71,7 @@ t.insert({_id: 0}); // Update, no error. opCounters = newdb.serverStatus().opcounters; res = t.update({_id: 0}, {$set: {a: 1}}); -assert.writeOK(res); +assert.commandWorked(res); assert.eq(opCounters.update + 1, newdb.serverStatus().opcounters.update); // Update, with error. @@ -90,7 +90,7 @@ t.insert([{_id: 0}, {_id: 1}]); // Delete, no error. opCounters = newdb.serverStatus().opcounters; res = t.remove({_id: 0}); -assert.writeOK(res); +assert.commandWorked(res); assert.eq(opCounters.delete + 1, newdb.serverStatus().opcounters.delete); // Delete, with error. diff --git a/jstests/core/operation_latency_histogram.js b/jstests/core/operation_latency_histogram.js index d81308192ac..5e2b6a49ef7 100644 --- a/jstests/core/operation_latency_histogram.js +++ b/jstests/core/operation_latency_histogram.js @@ -48,13 +48,13 @@ var lastHistogram = getHistogramStats(testColl); // Insert var numRecords = 100; for (var i = 0; i < numRecords; i++) { - assert.writeOK(testColl.insert({_id: i})); + assert.commandWorked(testColl.insert({_id: i})); } lastHistogram = assertHistogramDiffEq(testColl, lastHistogram, 0, numRecords, 0); // Update for (var i = 0; i < numRecords; i++) { - assert.writeOK(testColl.update({_id: i}, {x: i})); + assert.commandWorked(testColl.update({_id: i}, {x: i})); } lastHistogram = assertHistogramDiffEq(testColl, lastHistogram, 0, numRecords, 0); @@ -85,13 +85,13 @@ lastHistogram = assertHistogramDiffEq(testColl, lastHistogram, 0, 0, numRecords // Remove for (var i = 0; i < numRecords; i++) { - assert.writeOK(testColl.remove({_id: i})); + assert.commandWorked(testColl.remove({_id: i})); } lastHistogram = assertHistogramDiffEq(testColl, lastHistogram, 0, numRecords, 0); // Upsert for (var i = 0; i < numRecords; i++) { - assert.writeOK(testColl.update({_id: i}, {x: i}, {upsert: 1})); + assert.commandWorked(testColl.update({_id: i}, {x: i}, {upsert: 1})); } lastHistogram = assertHistogramDiffEq(testColl, lastHistogram, 0, numRecords, 0); diff --git a/jstests/core/optimized_match_explain.js b/jstests/core/optimized_match_explain.js index 5575b8498bb..f62474124b4 100644 --- a/jstests/core/optimized_match_explain.js +++ b/jstests/core/optimized_match_explain.js @@ -10,10 +10,10 @@ load("jstests/libs/analyze_plan.js"); const coll = db.match_explain; coll.drop(); -assert.writeOK(coll.insert({a: 1, b: 1})); -assert.writeOK(coll.insert({a: 2, b: 3})); -assert.writeOK(coll.insert({a: 1, b: 2})); -assert.writeOK(coll.insert({a: 1, b: 4})); +assert.commandWorked(coll.insert({a: 1, b: 1})); +assert.commandWorked(coll.insert({a: 2, b: 3})); +assert.commandWorked(coll.insert({a: 1, b: 2})); +assert.commandWorked(coll.insert({a: 1, b: 4})); // Explain output should reflect optimizations. // $and should not be in the explain output because it is optimized out. diff --git a/jstests/core/or4.js b/jstests/core/or4.js index 8e07a42efa7..73a5ddb825d 100644 --- a/jstests/core/or4.js +++ b/jstests/core/or4.js @@ -14,10 +14,10 @@ coll.drop(); coll.ensureIndex({a: 1}); coll.ensureIndex({b: 1}); -assert.writeOK(coll.insert({a: 2})); -assert.writeOK(coll.insert({b: 3})); -assert.writeOK(coll.insert({b: 3})); -assert.writeOK(coll.insert({a: 2, b: 3})); +assert.commandWorked(coll.insert({a: 2})); +assert.commandWorked(coll.insert({b: 3})); +assert.commandWorked(coll.insert({b: 3})); +assert.commandWorked(coll.insert({a: 2, b: 3})); assert.eq(4, coll.count({$or: [{a: 2}, {b: 3}]})); assert.eq(2, coll.count({$or: [{a: 2}, {a: 2}]})); @@ -35,13 +35,13 @@ assert.eq(4, coll.find({$or: [{a: 2}, {b: 3}]}).limit(4).count(true)); coll.remove({$or: [{a: 2}, {b: 3}]}); assert.eq(0, coll.count()); -assert.writeOK(coll.insert({b: 3})); +assert.commandWorked(coll.insert({b: 3})); coll.remove({$or: [{a: 2}, {b: 3}]}); assert.eq(0, coll.count()); -assert.writeOK(coll.insert({a: 2})); -assert.writeOK(coll.insert({b: 3})); -assert.writeOK(coll.insert({a: 2, b: 3})); +assert.commandWorked(coll.insert({a: 2})); +assert.commandWorked(coll.insert({b: 3})); +assert.commandWorked(coll.insert({a: 2, b: 3})); coll.update({$or: [{a: 2}, {b: 3}]}, {$set: {z: 1}}, false, true); assert.eq(3, coll.count({z: 1})); @@ -53,13 +53,13 @@ assert.eq(2, coll.find({$or: [{a: 2}, {b: 3}]}).skip(1).toArray().length); assert.eq(3, coll.find({$or: [{a: 2}, {b: 3}]}).batchSize(2).toArray().length); -assert.writeOK(coll.insert({a: 1})); -assert.writeOK(coll.insert({b: 4})); -assert.writeOK(coll.insert({a: 2})); +assert.commandWorked(coll.insert({a: 1})); +assert.commandWorked(coll.insert({b: 4})); +assert.commandWorked(coll.insert({a: 2})); assert.eq(4, coll.find({$or: [{a: 2}, {b: 3}]}).batchSize(2).toArray().length); -assert.writeOK(coll.insert({a: 1, b: 3})); +assert.commandWorked(coll.insert({a: 1, b: 3})); assert.eq(4, coll.find({$or: [{a: 2}, {b: 3}]}).limit(4).toArray().length); assert.eq([1, 2], Array.sort(coll.distinct('a', {$or: [{a: 2}, {b: 3}]}))); @@ -77,7 +77,7 @@ assert.eq(5, coll.remove({}); -assert.writeOK(coll.insert({a: [1, 2]})); +assert.commandWorked(coll.insert({a: [1, 2]})); assert.eq(1, coll.find({$or: [{a: 1}, {a: 2}]}).toArray().length); assert.eq(1, coll.count({$or: [{a: 1}, {a: 2}]})); assert.eq(1, coll.find({$or: [{a: 2}, {a: 1}]}).toArray().length); diff --git a/jstests/core/or_always_false.js b/jstests/core/or_always_false.js index 6760ee37775..0766806a223 100644 --- a/jstests/core/or_always_false.js +++ b/jstests/core/or_always_false.js @@ -5,7 +5,7 @@ const coll = db.or_always_false; coll.drop(); -assert.writeOK(coll.insert([{}, {}, {}])); +assert.commandWorked(coll.insert([{}, {}, {}])); const emptyOrError = assert.throws(() => coll.find({$or: []}).itcount()); assert.eq(emptyOrError.code, ErrorCodes.BadValue); diff --git a/jstests/core/profile2.js b/jstests/core/profile2.js index d71471b2e5f..f8f0040683e 100644 --- a/jstests/core/profile2.js +++ b/jstests/core/profile2.js @@ -33,7 +33,7 @@ coll.getDB().system.profile.drop(); assert.commandWorked(coll.getDB().runCommand({profile: 2})); // Test update with large string element in query portion. -assert.writeOK(coll.update({a: hugeStr}, {})); +assert.commandWorked(coll.update({a: hugeStr}, {})); var results = coll.getDB().system.profile.find().toArray(); assert.eq(1, results.length); var result = results[0]; @@ -50,7 +50,7 @@ coll.getDB().system.profile.drop(); assert.commandWorked(coll.getDB().runCommand({profile: 2})); // Test update with large string element in update portion. -assert.writeOK(coll.update({}, {a: hugeStr})); +assert.commandWorked(coll.update({}, {a: hugeStr})); var results = coll.getDB().system.profile.find().toArray(); assert.eq(1, results.length); var result = results[0]; diff --git a/jstests/core/profile_agg.js b/jstests/core/profile_agg.js index 02a29500cf6..0b67296d9c0 100644 --- a/jstests/core/profile_agg.js +++ b/jstests/core/profile_agg.js @@ -19,7 +19,7 @@ testDB.setProfilingLevel(2); // var i; for (i = 0; i < 10; ++i) { - assert.writeOK(coll.insert({a: i})); + assert.commandWorked(coll.insert({a: i})); } assert.commandWorked(coll.createIndex({a: 1})); @@ -59,7 +59,7 @@ coll.drop(); assert.commandWorked(coll.createIndex({a: 1})); assert.commandWorked(coll.createIndex({b: 1})); for (i = 0; i < 5; ++i) { - assert.writeOK(coll.insert({a: i, b: i})); + assert.commandWorked(coll.insert({a: i, b: i})); } assert.eq(1, coll.aggregate([{$match: {a: 3, b: 3}}]).itcount()); @@ -73,7 +73,7 @@ assert.eq(profileObj.fromMultiPlanner, true, tojson(profileObj)); coll.drop(); assert.commandWorked(coll.createIndex({a: 1})); for (i = 0; i < 5; ++i) { - assert.writeOK(coll.insert({a: i, b: i})); + assert.commandWorked(coll.insert({a: i, b: i})); } assert.eq(1, coll.aggregate([{$match: {a: 3, b: 3}}], {hint: {_id: 1}}).itcount()); diff --git a/jstests/core/profile_count.js b/jstests/core/profile_count.js index 103a08cb728..d2b998df850 100644 --- a/jstests/core/profile_count.js +++ b/jstests/core/profile_count.js @@ -20,7 +20,7 @@ testDB.setProfilingLevel(2); // var i; for (i = 0; i < 10; ++i) { - assert.writeOK(coll.insert({a: i})); + assert.commandWorked(coll.insert({a: i})); } assert.eq(10, coll.count({}, {collation: {locale: "fr"}})); @@ -45,7 +45,7 @@ assert.eq(profileObj.appName, "MongoDB Shell", tojson(profileObj)); // coll.drop(); for (i = 0; i < 10; ++i) { - assert.writeOK(coll.insert({a: i})); + assert.commandWorked(coll.insert({a: i})); } var query = {a: {$gte: 5}}; @@ -60,7 +60,7 @@ assert.eq(profileObj.docsExamined, 10, tojson(profileObj)); // coll.drop(); for (i = 0; i < 10; ++i) { - assert.writeOK(coll.insert({a: i})); + assert.commandWorked(coll.insert({a: i})); } assert.commandWorked(coll.createIndex({a: 1})); @@ -83,7 +83,7 @@ coll.drop(); assert.commandWorked(coll.createIndex({a: 1})); assert.commandWorked(coll.createIndex({b: 1})); for (i = 0; i < 5; ++i) { - assert.writeOK(coll.insert({a: i, b: i})); + assert.commandWorked(coll.insert({a: i, b: i})); } assert.eq(1, coll.count({a: 3, b: 3})); diff --git a/jstests/core/profile_delete.js b/jstests/core/profile_delete.js index 29f3b3ff5e7..500320afe6c 100644 --- a/jstests/core/profile_delete.js +++ b/jstests/core/profile_delete.js @@ -19,14 +19,14 @@ testDB.setProfilingLevel(2); // var i; for (i = 0; i < 10; ++i) { - assert.writeOK(coll.insert({a: i, b: i})); + assert.commandWorked(coll.insert({a: i, b: i})); } assert.commandWorked(coll.createIndex({a: 1})); -assert.writeOK(coll.remove({a: {$gte: 2}, b: {$gte: 2}}, - db.getMongo().writeMode() === "commands" - ? {justOne: true, collation: {locale: "fr"}} - : {justOne: true})); +assert.commandWorked(coll.remove({a: {$gte: 2}, b: {$gte: 2}}, + db.getMongo().writeMode() === "commands" + ? {justOne: true, collation: {locale: "fr"}} + : {justOne: true})); var profileObj = getLatestProfilerEntry(testDB); @@ -51,10 +51,10 @@ assert.eq(profileObj.appName, "MongoDB Shell", tojson(profileObj)); // coll.drop(); for (i = 0; i < 10; ++i) { - assert.writeOK(coll.insert({a: i})); + assert.commandWorked(coll.insert({a: i})); } -assert.writeOK(coll.remove({a: {$gte: 2}})); +assert.commandWorked(coll.remove({a: {$gte: 2}})); profileObj = getLatestProfilerEntry(testDB); assert.eq(profileObj.ndeleted, 8, tojson(profileObj)); @@ -68,10 +68,10 @@ coll.drop(); assert.commandWorked(coll.createIndex({a: 1})); assert.commandWorked(coll.createIndex({b: 1})); for (i = 0; i < 5; ++i) { - assert.writeOK(coll.insert({a: i, b: i})); + assert.commandWorked(coll.insert({a: i, b: i})); } -assert.writeOK(coll.remove({a: 3, b: 3})); +assert.commandWorked(coll.remove({a: 3, b: 3})); profileObj = getLatestProfilerEntry(testDB); assert.eq(profileObj.fromMultiPlanner, true, tojson(profileObj)); diff --git a/jstests/core/profile_distinct.js b/jstests/core/profile_distinct.js index 6a2272e0f8a..4bfc8895f88 100644 --- a/jstests/core/profile_distinct.js +++ b/jstests/core/profile_distinct.js @@ -20,7 +20,7 @@ testDB.setProfilingLevel(2); // var i; for (i = 0; i < 10; ++i) { - assert.writeOK(coll.insert({a: i % 5, b: i})); + assert.commandWorked(coll.insert({a: i % 5, b: i})); } assert.commandWorked(coll.createIndex({b: 1})); @@ -49,7 +49,7 @@ coll.drop(); assert.commandWorked(coll.createIndex({a: 1})); assert.commandWorked(coll.createIndex({b: 1})); for (i = 0; i < 5; ++i) { - assert.writeOK(coll.insert({a: i, b: i})); + assert.commandWorked(coll.insert({a: i, b: i})); } coll.distinct("a", {a: 3, b: 3}); diff --git a/jstests/core/profile_find.js b/jstests/core/profile_find.js index 23bcf96e2ad..848405c8cd9 100644 --- a/jstests/core/profile_find.js +++ b/jstests/core/profile_find.js @@ -23,7 +23,7 @@ const profileEntryFilter = { // var i; for (i = 0; i < 3; ++i) { - assert.writeOK(coll.insert({a: i, b: i})); + assert.commandWorked(coll.insert({a: i, b: i})); } assert.commandWorked(coll.createIndex({a: 1}, {collation: {locale: "fr"}})); @@ -70,7 +70,7 @@ assert.eq(profileObj.appName, "MongoDB Shell", tojson(profileObj)); // coll.drop(); for (i = 0; i < 3; ++i) { - assert.writeOK(coll.insert({a: i, b: i})); + assert.commandWorked(coll.insert({a: i, b: i})); } assert.commandWorked(coll.createIndex({a: 1})); @@ -91,7 +91,7 @@ coll.drop(); assert.commandWorked(coll.createIndex({a: 1})); assert.commandWorked(coll.createIndex({b: 1})); for (i = 0; i < 5; ++i) { - assert.writeOK(coll.insert({a: i, b: i})); + assert.commandWorked(coll.insert({a: i, b: i})); } assert.neq(coll.findOne({a: 3, b: 3}), null); @@ -110,8 +110,8 @@ coll.drop(); assert.commandWorked(coll.createIndex({a: 1})); assert.commandWorked(coll.createIndex({b: 1})); for (i = 0; i < 20; ++i) { - assert.writeOK(coll.insert({a: 5, b: i})); - assert.writeOK(coll.insert({a: i, b: 10})); + assert.commandWorked(coll.insert({a: 5, b: i})); + assert.commandWorked(coll.insert({a: i, b: 10})); } // Until we get the failpoint described in the above comment (regarding SERVER-23620), we must @@ -133,7 +133,7 @@ assert.eq(profileObj.appName, "MongoDB Shell", tojson(profileObj)); // Confirm that query modifiers such as "hint" are in the profiler document. // coll.drop(); -assert.writeOK(coll.insert({_id: 2})); +assert.commandWorked(coll.insert({_id: 2})); assert.eq(coll.find().hint({_id: 1}).itcount(), 1); profileObj = getLatestProfilerEntry(testDB, profileEntryFilter); diff --git a/jstests/core/profile_findandmodify.js b/jstests/core/profile_findandmodify.js index 3c646d6468c..53ff28e7bad 100644 --- a/jstests/core/profile_findandmodify.js +++ b/jstests/core/profile_findandmodify.js @@ -17,7 +17,7 @@ testDB.setProfilingLevel(2); // coll.drop(); for (var i = 0; i < 3; i++) { - assert.writeOK(coll.insert({_id: i, a: i, b: [0]})); + assert.commandWorked(coll.insert({_id: i, a: i, b: [0]})); } assert.commandWorked(coll.createIndex({b: 1})); @@ -53,7 +53,7 @@ assert.eq(profileObj.appName, "MongoDB Shell", tojson(profileObj)); // coll.drop(); for (var i = 0; i < 3; i++) { - assert.writeOK(coll.insert({_id: i, a: i})); + assert.commandWorked(coll.insert({_id: i, a: i})); } assert.eq({_id: 2, a: 2}, coll.findAndModify({query: {a: 2}, remove: true})); @@ -75,7 +75,7 @@ assert.eq(profileObj.appName, "MongoDB Shell", tojson(profileObj)); // coll.drop(); for (var i = 0; i < 3; i++) { - assert.writeOK(coll.insert({_id: i, a: i})); + assert.commandWorked(coll.insert({_id: i, a: i})); } assert.eq({_id: 4, a: 1}, @@ -100,7 +100,7 @@ assert.eq(profileObj.appName, "MongoDB Shell", tojson(profileObj)); // coll.drop(); for (var i = 0; i < 3; i++) { - assert.writeOK(coll.insert({_id: i, a: i})); + assert.commandWorked(coll.insert({_id: i, a: i})); } assert.eq({_id: 2, a: 2}, coll.findAndModify({query: {_id: 2}, update: {$inc: {b: 1}}})); @@ -117,7 +117,7 @@ assert.eq(profileObj.appName, "MongoDB Shell", tojson(profileObj)); // coll.drop(); for (var i = 0; i < 3; i++) { - assert.writeOK(coll.insert({_id: i, a: i})); + assert.commandWorked(coll.insert({_id: i, a: i})); } assert.eq({a: 2}, @@ -139,7 +139,7 @@ assert.eq(profileObj.appName, "MongoDB Shell", tojson(profileObj)); // coll.drop(); for (var i = 0; i < 3; i++) { - assert.writeOK(coll.insert({_id: i, a: i})); + assert.commandWorked(coll.insert({_id: i, a: i})); } assert.eq({a: 2}, coll.findAndModify({query: {a: 2}, remove: true, fields: {_id: 0, a: 1}})); @@ -157,7 +157,7 @@ assert.eq(profileObj.appName, "MongoDB Shell", tojson(profileObj)); // coll.drop(); for (var i = 0; i < 3; i++) { - assert.writeOK(coll.insert({_id: i, a: i})); + assert.commandWorked(coll.insert({_id: i, a: i})); } assert.eq({_id: 0, a: 0}, @@ -174,7 +174,7 @@ coll.drop(); assert.commandWorked(coll.createIndex({a: 1})); assert.commandWorked(coll.createIndex({b: 1})); for (i = 0; i < 5; ++i) { - assert.writeOK(coll.insert({a: i, b: i})); + assert.commandWorked(coll.insert({a: i, b: i})); } coll.findAndModify({query: {a: 3, b: 3}, update: {$set: {c: 1}}}); diff --git a/jstests/core/profile_getmore.js b/jstests/core/profile_getmore.js index 5cdc3a51ffe..5cbccb95881 100644 --- a/jstests/core/profile_getmore.js +++ b/jstests/core/profile_getmore.js @@ -18,7 +18,7 @@ testDB.setProfilingLevel(2); // var i; for (i = 0; i < 10; ++i) { - assert.writeOK(coll.insert({a: i})); + assert.commandWorked(coll.insert({a: i})); } assert.commandWorked(coll.createIndex({a: 1})); @@ -61,7 +61,7 @@ assert.eq(profileObj.appName, "MongoDB Shell", tojson(profileObj)); // coll.drop(); for (i = 0; i < 10; ++i) { - assert.writeOK(coll.insert({a: i})); + assert.commandWorked(coll.insert({a: i})); } cursor = coll.find({a: {$gt: 0}}).sort({a: 1}).batchSize(2); @@ -78,7 +78,7 @@ assert.eq(profileObj.hasSortStage, true, tojson(profileObj)); // coll.drop(); for (i = 0; i < 3; ++i) { - assert.writeOK(coll.insert({a: i})); + assert.commandWorked(coll.insert({a: i})); } cursor = coll.find().batchSize(2); @@ -98,7 +98,7 @@ assert.eq(profileObj.appName, "MongoDB Shell", tojson(profileObj)); // coll.drop(); for (i = 0; i < 20; ++i) { - assert.writeOK(coll.insert({a: i})); + assert.commandWorked(coll.insert({a: i})); } assert.commandWorked(coll.createIndex({a: 1})); @@ -136,7 +136,7 @@ for (i = 0; i < 501; i++) { coll.drop(); for (i = 0; i < 4; i++) { - assert.writeOK(coll.insert(docToInsert)); + assert.commandWorked(coll.insert(docToInsert)); } cursor = coll.find(docToInsert).comment("profile_getmore").batchSize(2); diff --git a/jstests/core/profile_insert.js b/jstests/core/profile_insert.js index fa53801521d..e45b1011c89 100644 --- a/jstests/core/profile_insert.js +++ b/jstests/core/profile_insert.js @@ -25,7 +25,7 @@ testDB.setProfilingLevel(2); var doc = {_id: 1}; var result = coll.insert(doc); if (isWriteCommand) { - assert.writeOK(result); + assert.commandWorked(result); } var profileObj = getLatestProfilerEntry(testDB); @@ -60,7 +60,7 @@ bulk.insert(docArray[0]); bulk.insert(docArray[1]); result = bulk.execute(); if (isWriteCommand) { - assert.writeOK(result); + assert.commandWorked(result); } profileObj = getLatestProfilerEntry(testDB); @@ -84,7 +84,7 @@ doc = { _id: 1 }; var wtimeout = 60000; -assert.writeOK(coll.insert(doc, {writeConcern: {w: 1, wtimeout: wtimeout}, ordered: false})); +assert.commandWorked(coll.insert(doc, {writeConcern: {w: 1, wtimeout: wtimeout}, ordered: false})); profileObj = getLatestProfilerEntry(testDB); diff --git a/jstests/core/profile_mapreduce.js b/jstests/core/profile_mapreduce.js index 0dc3c81a0c2..1516fe67d45 100644 --- a/jstests/core/profile_mapreduce.js +++ b/jstests/core/profile_mapreduce.js @@ -33,7 +33,7 @@ var reduceFunction = function(a, b) { // coll.drop(); for (var i = 0; i < 3; i++) { - assert.writeOK(coll.insert({a: i, b: i})); + assert.commandWorked(coll.insert({a: i, b: i})); } assert.commandWorked(coll.createIndex({a: 1})); @@ -63,7 +63,7 @@ assert.eq(profileObj.appName, "MongoDB Shell", tojson(profileObj)); // coll.drop(); for (var i = 0; i < 5; i++) { - assert.writeOK(coll.insert({a: i, b: i})); + assert.commandWorked(coll.insert({a: i, b: i})); } coll.mapReduce(mapFunction, reduceFunction, {sort: {b: 1}, out: {inline: 1}}); @@ -77,7 +77,7 @@ assert.eq(profileObj.appName, "MongoDB Shell", tojson(profileObj)); // coll.drop(); for (var i = 0; i < 3; i++) { - assert.writeOK(coll.insert({a: i, b: i})); + assert.commandWorked(coll.insert({a: i, b: i})); } var outputCollectionName = "output_col"; @@ -93,7 +93,7 @@ coll.drop(); assert.commandWorked(coll.createIndex({a: 1})); assert.commandWorked(coll.createIndex({b: 1})); for (i = 0; i < 5; ++i) { - assert.writeOK(coll.insert({a: i, b: i})); + assert.commandWorked(coll.insert({a: i, b: i})); } coll.mapReduce(mapFunction, reduceFunction, {query: {a: 3, b: 3}, out: {inline: 1}}); diff --git a/jstests/core/profile_query_hash.js b/jstests/core/profile_query_hash.js index e635c7b6b56..d08f0de236a 100644 --- a/jstests/core/profile_query_hash.js +++ b/jstests/core/profile_query_hash.js @@ -20,10 +20,10 @@ function getShapes(collection) { return res.shapes; } -assert.writeOK(coll.insert({a: 1, b: 1})); -assert.writeOK(coll.insert({a: 1, b: 2})); -assert.writeOK(coll.insert({a: 1, b: 2})); -assert.writeOK(coll.insert({a: 2, b: 2})); +assert.commandWorked(coll.insert({a: 1, b: 1})); +assert.commandWorked(coll.insert({a: 1, b: 2})); +assert.commandWorked(coll.insert({a: 1, b: 2})); +assert.commandWorked(coll.insert({a: 2, b: 2})); // We need two indices since we do not currently create cache entries for queries with a single // candidate plan. diff --git a/jstests/core/profile_repair_cursor.js b/jstests/core/profile_repair_cursor.js index c0b3a34a929..492d59d29e8 100644 --- a/jstests/core/profile_repair_cursor.js +++ b/jstests/core/profile_repair_cursor.js @@ -14,7 +14,7 @@ var testColl = testDB.testColl; assert.commandWorked(testDB.dropDatabase()); // Insert some data to scan over. -assert.writeOK(testColl.insert([{}, {}, {}, {}])); +assert.commandWorked(testColl.insert([{}, {}, {}, {}])); testDB.setProfilingLevel(2); diff --git a/jstests/core/profile_sampling.js b/jstests/core/profile_sampling.js index 2bd2261031e..802b04ad5e5 100644 --- a/jstests/core/profile_sampling.js +++ b/jstests/core/profile_sampling.js @@ -16,13 +16,13 @@ try { assert.eq(0, profileDB.system.profile.count()); profileDB.createCollection(coll.getName()); - assert.writeOK(coll.insert({x: 1})); + assert.commandWorked(coll.insert({x: 1})); assert.commandWorked(profileDB.setProfilingLevel(1, {sampleRate: 0, slowms: -1})); assert.neq(null, coll.findOne({x: 1})); assert.eq(1, coll.find({x: 1}).count()); - assert.writeOK(coll.update({x: 1}, {$inc: {a: 1}})); + assert.commandWorked(coll.update({x: 1}, {$inc: {a: 1}})); assert.commandWorked(profileDB.setProfilingLevel(0)); @@ -34,7 +34,7 @@ try { // This should generate about 500 profile log entries. for (let i = 0; i < 500; i++) { assert.neq(null, coll.findOne({x: 1})); - assert.writeOK(coll.update({x: 1}, {$inc: {a: 1}})); + assert.commandWorked(coll.update({x: 1}, {$inc: {a: 1}})); } assert.commandWorked(profileDB.setProfilingLevel(0)); @@ -47,7 +47,7 @@ try { // This should generate exactly 1000 profile log entries. for (let i = 0; i < 5; i++) { assert.neq(null, coll.findOne({x: 1})); - assert.writeOK(coll.update({x: 1}, {$inc: {a: 1}})); + assert.commandWorked(coll.update({x: 1}, {$inc: {a: 1}})); } assert.commandWorked(profileDB.setProfilingLevel(0)); assert.eq(10, profileDB.system.profile.count()); diff --git a/jstests/core/profile_update.js b/jstests/core/profile_update.js index 8cde2ea6784..63ec6e96d76 100644 --- a/jstests/core/profile_update.js +++ b/jstests/core/profile_update.js @@ -19,11 +19,11 @@ testDB.setProfilingLevel(2); // var i; for (i = 0; i < 10; ++i) { - assert.writeOK(coll.insert({a: i})); + assert.commandWorked(coll.insert({a: i})); } assert.commandWorked(coll.createIndex({a: 1})); -assert.writeOK(coll.update({a: {$gte: 2}}, {$set: {c: 1}, $inc: {a: -10}})); +assert.commandWorked(coll.update({a: {$gte: 2}}, {$set: {c: 1}, $inc: {a: -10}})); var profileObj = getLatestProfilerEntry(testDB); @@ -48,9 +48,9 @@ assert.eq(profileObj.appName, "MongoDB Shell", tojson(profileObj)); if (db.getMongo().writeMode() === "commands") { coll.drop(); - assert.writeOK(coll.insert({_id: 0, a: [0]})); + assert.commandWorked(coll.insert({_id: 0, a: [0]})); - assert.writeOK(coll.update( + assert.commandWorked(coll.update( {_id: 0}, {$set: {"a.$[i]": 1}}, {collation: {locale: "fr"}, arrayFilters: [{i: 0}]})); profileObj = getLatestProfilerEntry(testDB); @@ -66,11 +66,11 @@ if (db.getMongo().writeMode() === "commands") { // coll.drop(); for (i = 0; i < 10; ++i) { - assert.writeOK(coll.insert({a: i})); + assert.commandWorked(coll.insert({a: i})); } assert.commandWorked(coll.createIndex({a: 1})); -assert.writeOK(coll.update({a: {$gte: 5}}, {$set: {c: 1}, $inc: {a: -10}}, {multi: true})); +assert.commandWorked(coll.update({a: {$gte: 5}}, {$set: {c: 1}, $inc: {a: -10}}, {multi: true})); profileObj = getLatestProfilerEntry(testDB); assert.eq(profileObj.keysExamined, 5, tojson(profileObj)); @@ -88,11 +88,11 @@ assert.eq(profileObj.appName, "MongoDB Shell", tojson(profileObj)); // coll.drop(); for (i = 0; i < 10; ++i) { - assert.writeOK(coll.insert({a: i})); + assert.commandWorked(coll.insert({a: i})); } assert.commandWorked(coll.createIndex({a: 1})); -assert.writeOK(coll.update({_id: "new value", a: 4}, {$inc: {b: 1}}, {upsert: true})); +assert.commandWorked(coll.update({_id: "new value", a: 4}, {$inc: {b: 1}}, {upsert: true})); profileObj = getLatestProfilerEntry(testDB); assert.eq(profileObj.command, @@ -115,10 +115,10 @@ coll.drop(); assert.commandWorked(coll.createIndex({a: 1})); assert.commandWorked(coll.createIndex({b: 1})); for (i = 0; i < 5; ++i) { - assert.writeOK(coll.insert({a: i, b: i})); + assert.commandWorked(coll.insert({a: i, b: i})); } -assert.writeOK(coll.update({a: 3, b: 3}, {$set: {c: 1}})); +assert.commandWorked(coll.update({a: 3, b: 3}, {$set: {c: 1}})); profileObj = getLatestProfilerEntry(testDB); assert.eq(profileObj.fromMultiPlanner, true, tojson(profileObj)); diff --git a/jstests/core/projection_dotted_paths.js b/jstests/core/projection_dotted_paths.js index 5af357bde02..48c2f1ae89f 100644 --- a/jstests/core/projection_dotted_paths.js +++ b/jstests/core/projection_dotted_paths.js @@ -14,7 +14,7 @@ load("jstests/libs/analyze_plan.js"); let coll = db["projection_dotted_paths"]; coll.drop(); assert.commandWorked(coll.createIndex({a: 1, "b.c": 1, "b.d": 1, c: 1})); -assert.writeOK(coll.insert({_id: 1, a: 1, b: {c: 1, d: 1, e: 1}, c: 1, e: 1})); +assert.commandWorked(coll.insert({_id: 1, a: 1, b: {c: 1, d: 1, e: 1}, c: 1, e: 1})); // Project exactly the set of fields in the index. Verify that the projection is computed // correctly and that the plan is covered. @@ -64,7 +64,7 @@ assert(isIdhack(db, explain.queryPlanner.winningPlan)); // If we make a dotted path multikey, projections using that path cannot be covered. But // projections which do not include the multikey path can still be covered. -assert.writeOK(coll.insert({a: 2, b: {c: 1, d: [1, 2, 3]}})); +assert.commandWorked(coll.insert({a: 2, b: {c: 1, d: [1, 2, 3]}})); resultDoc = coll.findOne({a: 2}, {_id: 0, "b.c": 1, "b.d": 1}); assert.eq(resultDoc, {b: {c: 1, d: [1, 2, 3]}}); @@ -81,7 +81,7 @@ assert(isIndexOnly(db, explain.queryPlanner.winningPlan)); // Verify that dotted projections work for multiple levels of nesting. assert.commandWorked(coll.createIndex({a: 1, "x.y.y": 1, "x.y.z": 1, "x.z": 1})); -assert.writeOK(coll.insert({a: 3, x: {y: {y: 1, f: 1, z: 1}, f: 1, z: 1}})); +assert.commandWorked(coll.insert({a: 3, x: {y: {y: 1, f: 1, z: 1}, f: 1, z: 1}})); resultDoc = coll.findOne({a: 3}, {_id: 0, "x.y.y": 1, "x.y.z": 1, "x.z": 1}); assert.eq(resultDoc, {x: {y: {y: 1, z: 1}, z: 1}}); explain = coll.find({a: 3}, {_id: 0, "x.y.y": 1, "x.y.z": 1, "x.z": 1}).explain("queryPlanner"); diff --git a/jstests/core/push.js b/jstests/core/push.js index 50ff92cc2cd..2e2827945e7 100644 --- a/jstests/core/push.js +++ b/jstests/core/push.js @@ -26,27 +26,27 @@ t.update({_id: 2}, {$pop: {a: -1}}); assert.eq("4,5", t.findOne().a.toString(), "E3"); res = t.update({_id: 2}, {$pop: {a: -1}}); -assert.writeOK(res); +assert.commandWorked(res); assert.eq("5", t.findOne().a.toString(), "E4"); res = t.update({_id: 2}, {$pop: {a: -1}}); -assert.writeOK(res); +assert.commandWorked(res); assert.eq("", t.findOne().a.toString(), "E5"); res = t.update({_id: 2}, {$pop: {a: -1}}); -assert.writeOK(res); +assert.commandWorked(res); assert.eq("", t.findOne().a.toString(), "E6"); res = t.update({_id: 2}, {$pop: {a: -1}}); -assert.writeOK(res); +assert.commandWorked(res); assert.eq("", t.findOne().a.toString(), "E7"); res = t.update({_id: 2}, {$pop: {a: 1}}); -assert.writeOK(res); +assert.commandWorked(res); assert.eq("", t.findOne().a.toString(), "E8"); res = t.update({_id: 2}, {$pop: {b: -1}}); -assert.writeOK(res); +assert.commandWorked(res); res = t.update({_id: 2}, {$pop: {b: 1}}); -assert.writeOK(res); +assert.commandWorked(res); diff --git a/jstests/core/push_sort.js b/jstests/core/push_sort.js index 815a88f0b7d..347f230a93d 100644 --- a/jstests/core/push_sort.js +++ b/jstests/core/push_sort.js @@ -64,10 +64,11 @@ assert.docEq(t.findOne({_id: 8}), doc8); // ensure doc was not changed t.save({_id: 100, x: [{a: 1}]}); // Elements of the $each vector can be integers. In here, '2' is a valid $each. -assert.writeOK(t.update({_id: 100}, {$push: {x: {$each: [2], $slice: -2, $sort: {a: 1}}}})); +assert.commandWorked(t.update({_id: 100}, {$push: {x: {$each: [2], $slice: -2, $sort: {a: 1}}}})); // For the same reason as above, '1' is an valid $each element. -assert.writeOK(t.update({_id: 100}, {$push: {x: {$each: [{a: 2}, 1], $slice: -2, $sort: {a: 1}}}})); +assert.commandWorked( + t.update({_id: 100}, {$push: {x: {$each: [{a: 2}, 1], $slice: -2, $sort: {a: 1}}}})); // The sort key pattern cannot be empty. assert.writeErrorWithCode( @@ -75,7 +76,8 @@ assert.writeErrorWithCode( ErrorCodes.BadValue); // Support positive $slice's (ie, trimming from the array's front). -assert.writeOK(t.update({_id: 100}, {$push: {x: {$each: [{a: 2}], $slice: 2, $sort: {a: 1}}}})); +assert.commandWorked( + t.update({_id: 100}, {$push: {x: {$each: [{a: 2}], $slice: 2, $sort: {a: 1}}}})); // A $slice cannot be a fractional value. assert.writeErrorWithCode( @@ -88,7 +90,7 @@ assert.writeErrorWithCode( ErrorCodes.BadValue); // Support sorting array alements that are not documents. -assert.writeOK(t.update({_id: 100}, {$push: {x: {$each: [{a: 2}], $slice: -2, $sort: 1}}})); +assert.commandWorked(t.update({_id: 100}, {$push: {x: {$each: [{a: 2}], $slice: -2, $sort: 1}}})); // The key pattern 'a.' is an invalid value for $sort. assert.writeErrorWithCode( @@ -110,4 +112,5 @@ t.remove({}); // Existing values are validated in the array do not have to be objects during a $sort with $each. t.save({_id: 100, x: [1, "foo"]}); -assert.writeOK(t.update({_id: 100}, {$push: {x: {$each: [{a: 2}], $slice: -2, $sort: {a: 1}}}})); +assert.commandWorked( + t.update({_id: 100}, {$push: {x: {$each: [{a: 2}], $slice: -2, $sort: {a: 1}}}})); diff --git a/jstests/core/record_store_count.js b/jstests/core/record_store_count.js index 61a1680fa94..89dcf8d4cdc 100644 --- a/jstests/core/record_store_count.js +++ b/jstests/core/record_store_count.js @@ -12,8 +12,8 @@ load("jstests/libs/fixture_helpers.js"); // For isMongos and isSharded. var coll = db.record_store_count; coll.drop(); -assert.writeOK(coll.insert({x: 0})); -assert.writeOK(coll.insert({x: 1})); +assert.commandWorked(coll.insert({x: 0})); +assert.commandWorked(coll.insert({x: 1})); assert.commandWorked(coll.ensureIndex({x: 1})); diff --git a/jstests/core/regex.js b/jstests/core/regex.js index 488d41f41d0..f74817e618c 100644 --- a/jstests/core/regex.js +++ b/jstests/core/regex.js @@ -8,33 +8,33 @@ assert.commandWorked(isMaster); const isMongos = (isMaster.msg === "isdbgrid"); t.drop(); -assert.writeOK(t.save({a: "bcd"})); +assert.commandWorked(t.save({a: "bcd"})); assert.eq(1, t.count({a: /b/}), "A"); assert.eq(1, t.count({a: /bc/}), "B"); assert.eq(1, t.count({a: /bcd/}), "C"); assert.eq(0, t.count({a: /bcde/}), "D"); t.drop(); -assert.writeOK(t.save({a: {b: "cde"}})); +assert.commandWorked(t.save({a: {b: "cde"}})); assert.eq(1, t.count({'a.b': /de/}), "E"); t.drop(); -assert.writeOK(t.save({a: {b: ["cde"]}})); +assert.commandWorked(t.save({a: {b: ["cde"]}})); assert.eq(1, t.count({'a.b': /de/}), "F"); t.drop(); -assert.writeOK(t.save({a: [{b: "cde"}]})); +assert.commandWorked(t.save({a: [{b: "cde"}]})); assert.eq(1, t.count({'a.b': /de/}), "G"); t.drop(); -assert.writeOK(t.save({a: [{b: ["cde"]}]})); +assert.commandWorked(t.save({a: [{b: ["cde"]}]})); assert.eq(1, t.count({'a.b': /de/}), "H"); // // Confirm match and explain serialization for $elemMatch with $regex. // t.drop(); -assert.writeOK(t.insert({x: ["abc"]})); +assert.commandWorked(t.insert({x: ["abc"]})); const query = { x: {$elemMatch: {$regex: 'ABC', $options: 'i'}} diff --git a/jstests/core/regex_not_id.js b/jstests/core/regex_not_id.js index 35b2c858867..a38b452d423 100644 --- a/jstests/core/regex_not_id.js +++ b/jstests/core/regex_not_id.js @@ -3,7 +3,7 @@ var testColl = db.regex_not_id; testColl.drop(); -assert.writeOK(testColl.insert({_id: "ABCDEF1"})); +assert.commandWorked(testColl.insert({_id: "ABCDEF1"})); // Should be an error. assert.writeError(testColl.insert({_id: /^A/})); diff --git a/jstests/core/remove2.js b/jstests/core/remove2.js index 50fe507c134..d01c1e2e58c 100644 --- a/jstests/core/remove2.js +++ b/jstests/core/remove2.js @@ -27,7 +27,7 @@ function g() { const res = t.remove({x: {$gte: 3}}); - assert.writeOK(res); + assert.commandWorked(res); assert(t.findOne({x: 3}) == null); assert(t.findOne({x: 8}) == null); assert(t.validate().valid); diff --git a/jstests/core/remove7.js b/jstests/core/remove7.js index 2cda8945089..4a1548fbce2 100644 --- a/jstests/core/remove7.js +++ b/jstests/core/remove7.js @@ -25,8 +25,8 @@ for (i = 0; i < 200; i++) { t.save({tags: getTags(100)}); var q = {tags: {$in: getTags(10)}}; var before = t.find(q).count(); - var res = assert.writeOK(t.remove(q)); + var res = assert.commandWorked(t.remove(q)); var after = t.find(q).count(); assert.eq(0, after, "not zero after!"); - assert.writeOK(res); + assert.commandWorked(res); } diff --git a/jstests/core/remove9.js b/jstests/core/remove9.js index 888625764ec..8756991e25e 100644 --- a/jstests/core/remove9.js +++ b/jstests/core/remove9.js @@ -17,7 +17,7 @@ const bulk = t.initializeUnorderedBulkOp(); for (let i = 0; i < 1000; ++i) { bulk.insert({i: i}); } -assert.writeOK(bulk.execute()); +assert.commandWorked(bulk.execute()); const s = startParallelShell(function() { const t = db.jstests_remove9; diff --git a/jstests/core/remove_undefined.js b/jstests/core/remove_undefined.js index 6b97cc5d053..11463c107c5 100644 --- a/jstests/core/remove_undefined.js +++ b/jstests/core/remove_undefined.js @@ -6,9 +6,9 @@ const coll = db.remove_undefined; coll.drop(); -assert.writeOK(coll.insert({_id: 1})); -assert.writeOK(coll.insert({_id: 2})); -assert.writeOK(coll.insert({_id: null})); +assert.commandWorked(coll.insert({_id: 1})); +assert.commandWorked(coll.insert({_id: 2})); +assert.commandWorked(coll.insert({_id: null})); const obj = { foo: 1, @@ -27,7 +27,7 @@ assert.writeErrorWithCode(coll.remove({_id: undefined}), ErrorCodes.BadValue); coll.remove({_id: obj.nullElem}); assert.eq(2, coll.count()); -assert.writeOK(coll.insert({_id: null})); +assert.commandWorked(coll.insert({_id: null})); assert.eq(3, coll.count()); assert.writeErrorWithCode(coll.remove({_id: undefined}), ErrorCodes.BadValue); diff --git a/jstests/core/removea.js b/jstests/core/removea.js index ee914662d92..2c45ee665f4 100644 --- a/jstests/core/removea.js +++ b/jstests/core/removea.js @@ -19,7 +19,7 @@ for (let v = 0; v < 2; ++v) { // Try each index version. let i = y + (B * x); batch.push({a: i}); } - assert.writeOK(t.insert(batch)); + assert.commandWorked(t.insert(batch)); } assert.eq(t.count(), S * B); @@ -27,6 +27,6 @@ for (let v = 0; v < 2; ++v) { // Try each index version. for (let i = 0; i < S * B; ++i) { toDrop.push(Random.randInt(10000)); // Dups in the query will be ignored. } - assert.writeOK(t.remove({a: {$in: toDrop}})); + assert.commandWorked(t.remove({a: {$in: toDrop}})); } })(); diff --git a/jstests/core/removeb.js b/jstests/core/removeb.js index eeed0fc30bc..eb8aafd65f9 100644 --- a/jstests/core/removeb.js +++ b/jstests/core/removeb.js @@ -26,7 +26,7 @@ const insertDocs = function(collection, nDocs) { bulk.insert({a: i}); } - assert.writeOK(bulk.execute()); + assert.commandWorked(bulk.execute()); print("Bulk insert " + nDocs + " documents completed"); }; @@ -46,7 +46,7 @@ const p = startParallelShell(function() { for (let j = 0; j < 100; ++j) { bulk.insert({a: i + j}); } - assert.writeOK(bulk.execute()); + assert.commandWorked(bulk.execute()); if (i % 1000 === 0) { print(i - 20000 + " of second set of 20000 documents inserted"); } diff --git a/jstests/core/rename4.js b/jstests/core/rename4.js index 32f48f9cd0f..6b42bc8373e 100644 --- a/jstests/core/rename4.js +++ b/jstests/core/rename4.js @@ -64,7 +64,7 @@ function good(start, mod, expected) { t.remove({}); t.save(start); var res = t.update({}, mod); - assert.writeOK(res); + assert.commandWorked(res); var got = t.findOne(); delete got._id; assert.docEq(expected, got); @@ -129,7 +129,7 @@ function l(start, mod, query, expected) { t.remove({}); t.save(start); var res = t.update({}, mod); - assert.writeOK(res); + assert.commandWorked(res); var got = t.find(query).hint({a: 1}).next(); delete got._id; assert.docEq(expected, got); diff --git a/jstests/core/rename_change_target_type.js b/jstests/core/rename_change_target_type.js index 859e1add0b2..a88759b0b65 100644 --- a/jstests/core/rename_change_target_type.js +++ b/jstests/core/rename_change_target_type.js @@ -6,8 +6,8 @@ let coll = db.rename_change_target_type; coll.drop(); -assert.writeOK(coll.insert({to: NumberLong(100), from: 100})); -assert.writeOK(coll.update({}, {$rename: {from: "to"}})); +assert.commandWorked(coll.insert({to: NumberLong(100), from: 100})); +assert.commandWorked(coll.update({}, {$rename: {from: "to"}})); let aggResult = coll.aggregate([{$project: {toType: {$type: "$to"}}}]).toArray(); assert.eq(aggResult.length, 1); diff --git a/jstests/core/return_key.js b/jstests/core/return_key.js index 26dd01082b6..684b1952310 100644 --- a/jstests/core/return_key.js +++ b/jstests/core/return_key.js @@ -17,9 +17,9 @@ var explain; var coll = db.jstests_returnkey; coll.drop(); -assert.writeOK(coll.insert({a: 1, b: 3})); -assert.writeOK(coll.insert({a: 2, b: 2})); -assert.writeOK(coll.insert({a: 3, b: 1})); +assert.commandWorked(coll.insert({a: 1, b: 3})); +assert.commandWorked(coll.insert({a: 2, b: 2})); +assert.commandWorked(coll.insert({a: 3, b: 1})); assert.commandWorked(coll.ensureIndex({a: 1})); assert.commandWorked(coll.ensureIndex({b: 1})); diff --git a/jstests/core/set7.js b/jstests/core/set7.js index 64784a7216c..e1cdd0f3bf2 100644 --- a/jstests/core/set7.js +++ b/jstests/core/set7.js @@ -57,8 +57,8 @@ assert.eq([0, 1, -2, 3, 4, 5, 6, 7, 8, 9, 10, 11], t.findOne().a); // Test multiple updates to a non-existent array element. t.drop(); -assert.writeOK(t.insert({a: []})); -assert.writeOK(t.update({}, {$set: {"a.2.b": 1, "a.2.c": 1}})); +assert.commandWorked(t.insert({a: []})); +assert.commandWorked(t.update({}, {$set: {"a.2.b": 1, "a.2.c": 1}})); assert.docEq({a: [null, null, {b: 1, c: 1}]}, t.findOne({}, {_id: 0})); // Test upsert case @@ -70,7 +70,7 @@ assert.eq([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11], t.findOne().a); t.drop(); t.save({a: []}); res = t.update({}, {$set: {"a.1500000": 1}}); // current limit -assert.writeOK(res); +assert.commandWorked(res); t.drop(); t.save({a: []}); diff --git a/jstests/core/set_type_change.js b/jstests/core/set_type_change.js index 5b06449dce4..12035cc39a9 100644 --- a/jstests/core/set_type_change.js +++ b/jstests/core/set_type_change.js @@ -14,7 +14,7 @@ var coll = db.set_type_change; coll.drop(); assert.commandWorked(coll.ensureIndex({a: 1})); -assert.writeOK(coll.insert({a: 2})); +assert.commandWorked(coll.insert({a: 2})); var newVal = new NumberLong(2); var res = coll.update({}, {$set: {a: newVal}}); diff --git a/jstests/core/shell_writeconcern.js b/jstests/core/shell_writeconcern.js index 26d68304c63..ae431dab94b 100644 --- a/jstests/core/shell_writeconcern.js +++ b/jstests/core/shell_writeconcern.js @@ -33,7 +33,7 @@ assert.eq(undefined, collB.getWriteConcern()); assert.eq(undefined, db.getWriteConcern()); // test methods, by generating an error -var res = assert.writeOK(collA.save({_id: 1}, {writeConcern: {w: 1}})); +var res = assert.commandWorked(collA.save({_id: 1}, {writeConcern: {w: 1}})); if (!db.getMongo().useWriteCommands()) { assert.eq(1, res.n, tojson(res)); assert.eq(1, res.upserted, tojson(res)); @@ -41,34 +41,34 @@ if (!db.getMongo().useWriteCommands()) { assert.eq(1, res.nUpserted, tojson(res)); } -var res = assert.writeOK(collA.update({_id: 1}, {_id: 1}, {writeConcern: {w: 1}})); +var res = assert.commandWorked(collA.update({_id: 1}, {_id: 1}, {writeConcern: {w: 1}})); if (!db.getMongo().useWriteCommands()) { assert.eq(1, res.n, tojson(res)); } else { assert.eq(1, res.nMatched, tojson(res)); } -var res = assert.writeOK(collA.update({_id: 1}, {_id: 1}, {writeConcern: {w: 1}})); +var res = assert.commandWorked(collA.update({_id: 1}, {_id: 1}, {writeConcern: {w: 1}})); if (!db.getMongo().useWriteCommands()) { assert.eq(1, res.n, tojson(res)); } else { assert.eq(1, res.nMatched, tojson(res)); } -var res = assert.writeOK(collA.insert({_id: 2}, {writeConcern: {w: 1}})); +var res = assert.commandWorked(collA.insert({_id: 2}, {writeConcern: {w: 1}})); if (!db.getMongo().useWriteCommands()) { assert.eq(0, res.n, tojson(res)); } else { assert.eq(1, res.nInserted, tojson(res)); } -var res = assert.writeOK(collA.remove({_id: 3}, {writeConcern: {w: 1}})); +var res = assert.commandWorked(collA.remove({_id: 3}, {writeConcern: {w: 1}})); if (!db.getMongo().useWriteCommands()) { assert.eq(0, res.n, tojson(res)); } else { assert.eq(0, res.nRemoved, tojson(res)); } -var res = assert.writeOK(collA.remove({}, {justOne: true, writeConcern: {w: 1}})); +var res = assert.commandWorked(collA.remove({}, {justOne: true, writeConcern: {w: 1}})); if (!db.getMongo().useWriteCommands()) { assert.eq(1, res.n, tojson(res)); } else { @@ -76,7 +76,7 @@ if (!db.getMongo().useWriteCommands()) { } // Test ordered write concern, and that the write concern isn't run/error. -assert.writeOK(collA.insert({_id: 1})); +assert.commandWorked(collA.insert({_id: 1})); var res = assert.writeError(collA.insert([{_id: 1}, {_id: 1}], {ordered: true, writeConcern: {w: 1}})); diff --git a/jstests/core/single_batch.js b/jstests/core/single_batch.js index b06e5ce7aa5..d9ff6769157 100644 --- a/jstests/core/single_batch.js +++ b/jstests/core/single_batch.js @@ -10,7 +10,7 @@ var padding = new Array(1024 * 1024).join("x"); // Insert ~20 MB of data. for (var i = 0; i < 20; i++) { - assert.writeOK(coll.insert({_id: i, padding: padding})); + assert.commandWorked(coll.insert({_id: i, padding: padding})); } // The limit is 18, but we should end up with fewer documents since 18 docs won't fit in a diff --git a/jstests/core/sort1.js b/jstests/core/sort1.js index edd787306b0..7d5c227d8b4 100644 --- a/jstests/core/sort1.js +++ b/jstests/core/sort1.js @@ -42,9 +42,9 @@ assert(coll.validate().valid); // 'numericOrdering' option which orders number-like strings by their numerical values. if (db.getMongo().useReadCommands()) { coll.drop(); - assert.writeOK(coll.insert({_id: 0, str: '1000'})); - assert.writeOK(coll.insert({_id: 1, str: '5'})); - assert.writeOK(coll.insert({_id: 2, str: '200'})); + assert.commandWorked(coll.insert({_id: 0, str: '1000'})); + assert.commandWorked(coll.insert({_id: 1, str: '5'})); + assert.commandWorked(coll.insert({_id: 2, str: '200'})); var cursor = coll.find().sort({str: -1}).collation({locale: 'en_US', numericOrdering: true}); assert.eq(cursor.next(), {_id: 0, str: '1000'}); @@ -56,8 +56,8 @@ if (db.getMongo().useReadCommands()) { // Ensure that sorting of arrays correctly respects a collation with numeric ordering. if (db.getMongo().useReadCommands()) { coll.drop(); - assert.writeOK(coll.insert({_id: 0, strs: ['1000', '500']})); - assert.writeOK(coll.insert({_id: 1, strs: ['2000', '60']})); + assert.commandWorked(coll.insert({_id: 0, strs: ['1000', '500']})); + assert.commandWorked(coll.insert({_id: 1, strs: ['2000', '60']})); cursor = coll.find({strs: {$lt: '1000'}}).sort({strs: 1}).collation({ locale: 'en_US', numericOrdering: true diff --git a/jstests/core/sort3.js b/jstests/core/sort3.js index 5e5f3313f51..211c3d1e1c2 100644 --- a/jstests/core/sort3.js +++ b/jstests/core/sort3.js @@ -4,9 +4,9 @@ const coll = db.sort3; coll.drop(); -assert.writeOK(coll.insert({a: 1})); -assert.writeOK(coll.insert({a: 5})); -assert.writeOK(coll.insert({a: 3})); +assert.commandWorked(coll.insert({a: 1})); +assert.commandWorked(coll.insert({a: 5})); +assert.commandWorked(coll.insert({a: 3})); assert.eq([1, 3, 5], coll.find().sort({a: 1}).toArray().map(doc => doc.a)); assert.eq([5, 3, 1], coll.find().sort({a: -1}).toArray().map(doc => doc.a)); diff --git a/jstests/core/sort4.js b/jstests/core/sort4.js index 63d7f3810bd..0afe2cebe80 100644 --- a/jstests/core/sort4.js +++ b/jstests/core/sort4.js @@ -22,18 +22,18 @@ function nice(sort, correct, extra) { return s; } -assert.writeOK(coll.insert({name: 'A', prename: 'B'})); -assert.writeOK(coll.insert({name: 'A', prename: 'C'})); -assert.writeOK(coll.insert({name: 'B', prename: 'B'})); -assert.writeOK(coll.insert({name: 'B', prename: 'D'})); +assert.commandWorked(coll.insert({name: 'A', prename: 'B'})); +assert.commandWorked(coll.insert({name: 'A', prename: 'C'})); +assert.commandWorked(coll.insert({name: 'B', prename: 'B'})); +assert.commandWorked(coll.insert({name: 'B', prename: 'D'})); nice({name: 1, prename: 1}, "AB,AC,BB,BD", "s3"); nice({prename: 1, name: 1}, "AB,BB,AC,BD", "s3"); -assert.writeOK(coll.insert({name: 'A'})); +assert.commandWorked(coll.insert({name: 'A'})); nice({name: 1, prename: 1}, "A,AB,AC,BB,BD", "e1"); -assert.writeOK(coll.insert({name: 'C'})); +assert.commandWorked(coll.insert({name: 'C'})); nice({name: 1, prename: 1}, "A,AB,AC,BB,BD,C", "e2"); // SERVER-282 assert.commandWorked(coll.ensureIndex({name: 1, prename: 1})); diff --git a/jstests/core/sort_array.js b/jstests/core/sort_array.js index 20ae0187693..bd30bcb169f 100644 --- a/jstests/core/sort_array.js +++ b/jstests/core/sort_array.js @@ -39,8 +39,8 @@ function testAggAndFindSort({filter, sort, project, hint, expected}) { } coll.drop(); -assert.writeOK(coll.insert({_id: 0, a: [3, 0, 1]})); -assert.writeOK(coll.insert({_id: 1, a: [8, 4, -1]})); +assert.commandWorked(coll.insert({_id: 0, a: [3, 0, 1]})); +assert.commandWorked(coll.insert({_id: 1, a: [8, 4, -1]})); // Sanity check that a sort on "_id" is usually pushed down into the query layer, but that // $_internalInhibitOptimization prevents this from happening. This makes sure that this test is @@ -58,9 +58,9 @@ testAggAndFindSort({ expected: [{_id: 1, a: [8, 4, -1]}, {_id: 0, a: [3, 0, 1]}] }); -assert.writeOK(coll.remove({})); -assert.writeOK(coll.insert({_id: 0, a: [3, 0, 1]})); -assert.writeOK(coll.insert({_id: 1, a: [0, 4, -1]})); +assert.commandWorked(coll.remove({})); +assert.commandWorked(coll.insert({_id: 0, a: [3, 0, 1]})); +assert.commandWorked(coll.insert({_id: 1, a: [0, 4, -1]})); // Descending sort, without an index. testAggAndFindSort({ @@ -70,9 +70,9 @@ testAggAndFindSort({ expected: [{_id: 1, a: [0, 4, -1]}, {_id: 0, a: [3, 0, 1]}] }); -assert.writeOK(coll.remove({})); -assert.writeOK(coll.insert({_id: 0, a: [3, 0, 1]})); -assert.writeOK(coll.insert({_id: 1, a: [8, 4, -1]})); +assert.commandWorked(coll.remove({})); +assert.commandWorked(coll.insert({_id: 0, a: [3, 0, 1]})); +assert.commandWorked(coll.insert({_id: 1, a: [8, 4, -1]})); assert.commandWorked(coll.createIndex({a: 1})); // Ascending sort, in the presence of an index. The multikey index should not be used to provide @@ -84,9 +84,9 @@ testAggAndFindSort({ expected: [{_id: 1, a: [8, 4, -1]}, {_id: 0, a: [3, 0, 1]}] }); -assert.writeOK(coll.remove({})); -assert.writeOK(coll.insert({_id: 0, a: [3, 0, 1]})); -assert.writeOK(coll.insert({_id: 1, a: [0, 4, -1]})); +assert.commandWorked(coll.remove({})); +assert.commandWorked(coll.insert({_id: 0, a: [3, 0, 1]})); +assert.commandWorked(coll.insert({_id: 1, a: [0, 4, -1]})); // Descending sort, in the presence of an index. testAggAndFindSort({ @@ -96,9 +96,9 @@ testAggAndFindSort({ expected: [{_id: 1, a: [0, 4, -1]}, {_id: 0, a: [3, 0, 1]}] }); -assert.writeOK(coll.remove({})); -assert.writeOK(coll.insert({_id: 0, x: [{y: [4, 0, 1], z: 7}, {y: 0, z: 9}]})); -assert.writeOK(coll.insert({_id: 1, x: [{y: 1, z: 7}, {y: 0, z: [8, 6]}]})); +assert.commandWorked(coll.remove({})); +assert.commandWorked(coll.insert({_id: 0, x: [{y: [4, 0, 1], z: 7}, {y: 0, z: 9}]})); +assert.commandWorked(coll.insert({_id: 1, x: [{y: 1, z: 7}, {y: 0, z: [8, 6]}]})); // Compound mixed ascending/descending sorts, without an index. Sort key for doc with _id: 0 is // {'': 0, '': 9}. Sort key for doc with _id: 1 is {'': 0, '': 8}. @@ -121,7 +121,7 @@ testAggAndFindSort( // Test that a multikey index can provide a sort over a non-multikey field. coll.drop(); assert.commandWorked(coll.createIndex({a: 1, "b.c": 1})); -assert.writeOK(coll.insert({a: [1, 2, 3], b: {c: 9}})); +assert.commandWorked(coll.insert({a: [1, 2, 3], b: {c: 9}})); explain = coll.find({a: 2}).sort({"b.c": -1}).explain(); assert(planHasStage(db, explain, "IXSCAN")); assert(!planHasStage(db, explain, "SORT")); @@ -135,9 +135,9 @@ assert(!planHasStage(db, explain, "SORT")); // Test that we can correctly sort by an array field in agg when there are additional fields not // involved in the sort pattern. coll.drop(); -assert.writeOK( +assert.commandWorked( coll.insert({_id: 0, a: 1, b: {c: 1}, d: [{e: {f: 1, g: [6, 5, 4]}}, {e: {g: [3, 2, 1]}}]})); -assert.writeOK( +assert.commandWorked( coll.insert({_id: 1, a: 2, b: {c: 2}, d: [{e: {f: 2, g: [5, 4, 3]}}, {e: {g: [2, 1, 0]}}]})); testAggAndFindSort( @@ -146,9 +146,9 @@ testAggAndFindSort( // Test a sort over the trailing field of a compound index, where the two fields of the index // share a path prefix. This is designed as a regression test for SERVER-31858. coll.drop(); -assert.writeOK(coll.insert({_id: 2, a: [{b: 1, c: 2}, {b: 2, c: 3}]})); -assert.writeOK(coll.insert({_id: 0, a: [{b: 2, c: 0}, {b: 1, c: 4}]})); -assert.writeOK(coll.insert({_id: 1, a: [{b: 1, c: 5}, {b: 2, c: 1}]})); +assert.commandWorked(coll.insert({_id: 2, a: [{b: 1, c: 2}, {b: 2, c: 3}]})); +assert.commandWorked(coll.insert({_id: 0, a: [{b: 2, c: 0}, {b: 1, c: 4}]})); +assert.commandWorked(coll.insert({_id: 1, a: [{b: 1, c: 5}, {b: 2, c: 1}]})); assert.commandWorked(coll.createIndex({"a.b": 1, "a.c": 1})); testAggAndFindSort({ filter: {"a.b": 1}, diff --git a/jstests/core/sorta.js b/jstests/core/sorta.js index f030cc6a673..fd7f8422187 100644 --- a/jstests/core/sorta.js +++ b/jstests/core/sorta.js @@ -21,7 +21,7 @@ const bulk = coll.initializeUnorderedBulkOp(); for (let doc of docs) { bulk.insert(doc); } -assert.writeOK(bulk.execute()); +assert.commandWorked(bulk.execute()); assert.eq(coll.find().sort({a: 1, _id: 1}).toArray(), docs); diff --git a/jstests/core/sortc.js b/jstests/core/sortc.js index 3b6213a11c7..975b3acf764 100644 --- a/jstests/core/sortc.js +++ b/jstests/core/sortc.js @@ -5,8 +5,8 @@ const coll = db.jstests_sortc; coll.drop(); -assert.writeOK(coll.insert({a: 1})); -assert.writeOK(coll.insert({a: 2})); +assert.commandWorked(coll.insert({a: 1})); +assert.commandWorked(coll.insert({a: 2})); function checkA(a, sort, skip, query) { query = query || {}; diff --git a/jstests/core/sortl.js b/jstests/core/sortl.js index d0d94473460..3d1a4adcd12 100644 --- a/jstests/core/sortl.js +++ b/jstests/core/sortl.js @@ -5,7 +5,7 @@ var coll = db.sortl; coll.drop(); -assert.writeOK(coll.insert({_id: 1, a: 2})); +assert.commandWorked(coll.insert({_id: 1, a: 2})); var res = coll.find({_id: 1}).sort({a: 1}); assert.eq(res.next(), {_id: 1, a: 2}); assert.eq(res.hasNext(), false); diff --git a/jstests/core/splitvector.js b/jstests/core/splitvector.js index f30d2fdc386..62a89f3027f 100644 --- a/jstests/core/splitvector.js +++ b/jstests/core/splitvector.js @@ -73,7 +73,7 @@ let bulkInsertDocs = function(coll, numDocs, filler) { for (let i = 1; i <= numDocs; i++) { bulk.insert({x: i, y: filler}); } - assert.writeOK(bulk.execute()); + assert.commandWorked(bulk.execute()); }; // Inserts numDocs into the given collection using a bulk operation. Each document's x value is set @@ -83,7 +83,7 @@ let bulkInsertDocsFixedX = function(coll, numDocs, filler, xVal) { for (let i = 1; i <= numDocs; i++) { bulk.insert({x: xVal, y: filler}); } - assert.writeOK(bulk.execute()); + assert.commandWorked(bulk.execute()); }; // ------------------------- diff --git a/jstests/core/stages_delete.js b/jstests/core/stages_delete.js index 88d70a39ec3..29145d961bb 100644 --- a/jstests/core/stages_delete.js +++ b/jstests/core/stages_delete.js @@ -14,9 +14,9 @@ var deleteStage; // Test delete stage with isMulti: true. coll.drop(); -assert.writeOK(coll.insert({deleteMe: true})); -assert.writeOK(coll.insert({deleteMe: true})); -assert.writeOK(coll.insert({deleteMe: false})); +assert.commandWorked(coll.insert({deleteMe: true})); +assert.commandWorked(coll.insert({deleteMe: true})); +assert.commandWorked(coll.insert({deleteMe: false})); deleteStage = { delete: {args: {node: collScanStage, isMulti: true}} }; @@ -27,9 +27,9 @@ assert.eq(coll.count({deleteMe: false}), 1); // Test delete stage with isMulti: false. coll.drop(); -assert.writeOK(coll.insert({deleteMe: true})); -assert.writeOK(coll.insert({deleteMe: true})); -assert.writeOK(coll.insert({deleteMe: false})); +assert.commandWorked(coll.insert({deleteMe: true})); +assert.commandWorked(coll.insert({deleteMe: true})); +assert.commandWorked(coll.insert({deleteMe: false})); deleteStage = { delete: {args: {node: collScanStage, isMulti: false}} }; diff --git a/jstests/core/stages_ixscan.js b/jstests/core/stages_ixscan.js index 7bfa4c5b4c4..78e22e997c4 100644 --- a/jstests/core/stages_ixscan.js +++ b/jstests/core/stages_ixscan.js @@ -182,7 +182,7 @@ var ixscanName = { } }; -assert.writeOK(t.insert([{a: "1234"}, {a: "124"}])); +assert.commandWorked(t.insert([{a: "1234"}, {a: "124"}])); var res = db.runCommand({stageDebug: {collection: collname, plan: ixscanName}}); assert.commandWorked(res); assert.eq(res.results.map((doc) => doc.a), ["124", "1234"]); diff --git a/jstests/core/system_profile.js b/jstests/core/system_profile.js index 73e6e2587c5..06c8e48f99b 100644 --- a/jstests/core/system_profile.js +++ b/jstests/core/system_profile.js @@ -43,7 +43,7 @@ assert.commandFailed(testDB.system.profile.runCommand("findAndModify", {query: { // Using mapReduce to write to "system.profile" should fail. assert.commandWorked(testDB.dropDatabase()); -assert.writeOK(testDB.foo.insert({val: 1})); +assert.commandWorked(testDB.foo.insert({val: 1})); assert.commandFailed(testDB.foo.runCommand("mapReduce", { map: function() { emit(0, this.val); @@ -56,7 +56,7 @@ assert.commandFailed(testDB.foo.runCommand("mapReduce", { // Using aggregate to write to "system.profile" should fail. assert.commandWorked(testDB.dropDatabase()); -assert.writeOK(testDB.foo.insert({val: 1})); +assert.commandWorked(testDB.foo.insert({val: 1})); assert.commandFailed(testDB.foo.runCommand("aggregate", {pipeline: [{$out: "system.profile"}]})); // Renaming to/from "system.profile" should fail. diff --git a/jstests/core/tailable_cursor_invalidation.js b/jstests/core/tailable_cursor_invalidation.js index 2424bce64f7..08ff40b0bba 100644 --- a/jstests/core/tailable_cursor_invalidation.js +++ b/jstests/core/tailable_cursor_invalidation.js @@ -43,7 +43,7 @@ function dropAndRecreateColl() { for (let i = 0; i < numDocs; ++i) { bulk.insert({_id: i}); } - assert.writeOK(bulk.execute()); + assert.commandWorked(bulk.execute()); } dropAndRecreateColl(); diff --git a/jstests/core/tailable_getmore_batch_size.js b/jstests/core/tailable_getmore_batch_size.js index 466fa25a686..05bab0ba341 100644 --- a/jstests/core/tailable_getmore_batch_size.js +++ b/jstests/core/tailable_getmore_batch_size.js @@ -16,7 +16,7 @@ function dropAndRecreateColl({numDocs}) { for (let i = 0; i < numDocs; ++i) { bulk.insert({_id: i}); } - assert.writeOK(bulk.execute()); + assert.commandWorked(bulk.execute()); } // Test that running a find with the 'tailable' option will return results immediately, even if diff --git a/jstests/core/tailable_skip_limit.js b/jstests/core/tailable_skip_limit.js index 672a52aeb3d..8d489ba9298 100644 --- a/jstests/core/tailable_skip_limit.js +++ b/jstests/core/tailable_skip_limit.js @@ -10,14 +10,14 @@ var t = db[collname]; t.drop(); assert.commandWorked(db.createCollection(collname, {capped: true, size: 1024})); -assert.writeOK(t.insert({_id: 1})); -assert.writeOK(t.insert({_id: 2})); +assert.commandWorked(t.insert({_id: 1})); +assert.commandWorked(t.insert({_id: 2})); // Non-tailable with skip var cursor = t.find().skip(1); assert.eq(2, cursor.next()["_id"]); assert(!cursor.hasNext()); -assert.writeOK(t.insert({_id: 3})); +assert.commandWorked(t.insert({_id: 3})); assert(!cursor.hasNext()); // Non-tailable with limit @@ -26,7 +26,7 @@ for (var i = 1; i <= 3; i++) { assert.eq(i, cursor.next()["_id"]); } assert(!cursor.hasNext()); -assert.writeOK(t.insert({_id: 4})); +assert.commandWorked(t.insert({_id: 4})); assert(!cursor.hasNext()); // Non-tailable with negative limit @@ -35,14 +35,14 @@ for (var i = 1; i <= 4; i++) { assert.eq(i, cursor.next()["_id"]); } assert(!cursor.hasNext()); -assert.writeOK(t.insert({_id: 5})); +assert.commandWorked(t.insert({_id: 5})); assert(!cursor.hasNext()); // Tailable with skip cursor = t.find().addOption(2).skip(4); assert.eq(5, cursor.next()["_id"]); assert(!cursor.hasNext()); -assert.writeOK(t.insert({_id: 6})); +assert.commandWorked(t.insert({_id: 6})); assert(cursor.hasNext()); assert.eq(6, cursor.next()["_id"]); @@ -52,7 +52,7 @@ for (var i = 1; i <= 6; i++) { assert.eq(i, cursor.next()["_id"]); } assert(!cursor.hasNext()); -assert.writeOK(t.insert({_id: 7})); +assert.commandWorked(t.insert({_id: 7})); assert(cursor.hasNext()); assert.eq(7, cursor.next()["_id"]); @@ -88,6 +88,6 @@ assert.eq(cmdRes.cursor.firstBatch.length, 0); // Test that the cursor works in the shell. assert.eq(t.find().addOption(2).itcount(), 0); -assert.writeOK(t.insert({a: 1})); +assert.commandWorked(t.insert({a: 1})); assert.eq(t.find().addOption(2).itcount(), 1); })(); diff --git a/jstests/core/text_covered_matching.js b/jstests/core/text_covered_matching.js index a81dfd84e09..75814f04cce 100644 --- a/jstests/core/text_covered_matching.js +++ b/jstests/core/text_covered_matching.js @@ -17,9 +17,9 @@ const coll = db.text_covered_matching; coll.drop(); assert.commandWorked(coll.createIndex({a: "text", b: 1})); -assert.writeOK(coll.insert({a: "hello", b: 1, c: 1})); -assert.writeOK(coll.insert({a: "world", b: 2, c: 2})); -assert.writeOK(coll.insert({a: "hello world", b: 3, c: 3})); +assert.commandWorked(coll.insert({a: "hello", b: 1, c: 1})); +assert.commandWorked(coll.insert({a: "world", b: 2, c: 2})); +assert.commandWorked(coll.insert({a: "hello world", b: 3, c: 3})); // // Test the query {$text: {$search: "hello"}, b: 1} with and without the 'textScore' in the @@ -107,9 +107,9 @@ assert.eq(explainResult.executionStats.nReturned, // coll.drop(); assert.commandWorked(coll.createIndex({a: "text", "b.d": 1})); -assert.writeOK(coll.insert({a: "hello", b: {d: 1}, c: {e: 1}})); -assert.writeOK(coll.insert({a: "world", b: {d: 2}, c: {e: 2}})); -assert.writeOK(coll.insert({a: "hello world", b: {d: 3}, c: {e: 3}})); +assert.commandWorked(coll.insert({a: "hello", b: {d: 1}, c: {e: 1}})); +assert.commandWorked(coll.insert({a: "world", b: {d: 2}, c: {e: 2}})); +assert.commandWorked(coll.insert({a: "hello world", b: {d: 3}, c: {e: 3}})); // Expected result: // - We examine two keys, for the two documents with "hello" in their text; diff --git a/jstests/core/top.js b/jstests/core/top.js index 21b196a850d..7219192516f 100644 --- a/jstests/core/top.js +++ b/jstests/core/top.js @@ -35,14 +35,14 @@ var numRecords = 100; // Insert for (var i = 0; i < numRecords; i++) { - assert.writeOK(testColl.insert({_id: i})); + assert.commandWorked(testColl.insert({_id: i})); } assertTopDiffEq(testColl, lastTop, "insert", numRecords); lastTop = assertTopDiffEq(testColl, lastTop, "writeLock", numRecords); // Update for (i = 0; i < numRecords; i++) { - assert.writeOK(testColl.update({_id: i}, {x: i})); + assert.commandWorked(testColl.update({_id: i}, {x: i})); } lastTop = assertTopDiffEq(testColl, lastTop, "update", numRecords); @@ -65,13 +65,13 @@ lastTop = assertTopDiffEq(testColl, lastTop, "getmore", numRecords); // Remove for (i = 0; i < numRecords; i++) { - assert.writeOK(testColl.remove({_id: 1})); + assert.commandWorked(testColl.remove({_id: 1})); } lastTop = assertTopDiffEq(testColl, lastTop, "remove", numRecords); // Upsert, note that these are counted as updates, not inserts for (i = 0; i < numRecords; i++) { - assert.writeOK(testColl.update({_id: i}, {x: i}, {upsert: 1})); + assert.commandWorked(testColl.update({_id: i}, {x: i}, {upsert: 1})); } lastTop = assertTopDiffEq(testColl, lastTop, "update", numRecords); diff --git a/jstests/core/ts1.js b/jstests/core/ts1.js index a52995dd4c8..e1d937ee6c5 100644 --- a/jstests/core/ts1.js +++ b/jstests/core/ts1.js @@ -10,7 +10,7 @@ t.drop(); const N = 20; for (let i = 0; i < N; i++) { - assert.writeOK(t.insert({_id: i, x: new Timestamp()})); + assert.commandWorked(t.insert({_id: i, x: new Timestamp()})); sleep(100); } @@ -37,7 +37,7 @@ for (let i = 0; i < N - 1; i++) { assert.eq(N, t.find({x: {$type: 17}}).itcount()); assert.eq(0, t.find({x: {$type: 3}}).itcount()); -assert.writeOK(t.insert({_id: 100, x: new Timestamp(123456, 50)})); +assert.commandWorked(t.insert({_id: 100, x: new Timestamp(123456, 50)})); const x = t.findOne({_id: 100}).x; assert.eq(123456, x.t); assert.eq(50, x.i); diff --git a/jstests/core/txns/abort_expired_transaction.js b/jstests/core/txns/abort_expired_transaction.js index c64ed7407e5..b211ef7b132 100644 --- a/jstests/core/txns/abort_expired_transaction.js +++ b/jstests/core/txns/abort_expired_transaction.js @@ -26,7 +26,7 @@ try { assert.commandWorked(db.adminCommand({setParameter: 1, transactionLifetimeLimitSeconds: 1})); jsTest.log("Create a collection '" + ns + "' outside of the transaction."); - assert.writeOK(testColl.insert({foo: "bar"}, {writeConcern: {w: "majority"}})); + assert.commandWorked(testColl.insert({foo: "bar"}, {writeConcern: {w: "majority"}})); jsTest.log("Set up the session."); const sessionOptions = {causalConsistency: false}; diff --git a/jstests/core/txns/find_and_modify_in_transaction.js b/jstests/core/txns/find_and_modify_in_transaction.js index 02c5a1639e1..835d94fbd61 100644 --- a/jstests/core/txns/find_and_modify_in_transaction.js +++ b/jstests/core/txns/find_and_modify_in_transaction.js @@ -20,8 +20,8 @@ const sessionDb = session.getDatabase(dbName); const sessionColl = sessionDb[collName]; jsTest.log("Prepopulate the collection."); -assert.writeOK(testColl.insert([{_id: 0, a: 0}, {_id: 1, a: 1}, {_id: 2, a: 2}], - {writeConcern: {w: "majority"}})); +assert.commandWorked(testColl.insert([{_id: 0, a: 0}, {_id: 1, a: 1}, {_id: 2, a: 2}], + {writeConcern: {w: "majority"}})); /*********************************************************************************************** * Do a non-matching find-and-modify with remove. diff --git a/jstests/core/txns/multi_delete_in_transaction.js b/jstests/core/txns/multi_delete_in_transaction.js index c8aad0c5c79..7567a1b95df 100644 --- a/jstests/core/txns/multi_delete_in_transaction.js +++ b/jstests/core/txns/multi_delete_in_transaction.js @@ -20,8 +20,8 @@ const sessionDb = session.getDatabase(dbName); const sessionColl = sessionDb[collName]; jsTest.log("Prepopulate the collection."); -assert.writeOK(testColl.insert([{_id: 0, a: 0}, {_id: 1, a: 0}, {_id: 2, a: 1}], - {writeConcern: {w: "majority"}})); +assert.commandWorked(testColl.insert([{_id: 0, a: 0}, {_id: 1, a: 0}, {_id: 2, a: 1}], + {writeConcern: {w: "majority"}})); jsTest.log("Do an empty multi-delete."); session.startTransaction({writeConcern: {w: "majority"}}); diff --git a/jstests/core/txns/multi_update_in_transaction.js b/jstests/core/txns/multi_update_in_transaction.js index c6d9f3e994c..d9754f586d8 100644 --- a/jstests/core/txns/multi_update_in_transaction.js +++ b/jstests/core/txns/multi_update_in_transaction.js @@ -20,8 +20,8 @@ const sessionDb = session.getDatabase(dbName); const sessionColl = sessionDb[collName]; jsTest.log("Prepopulate the collection."); -assert.writeOK(testColl.insert([{_id: 0, a: 0}, {_id: 1, a: 0}, {_id: 2, a: 1}], - {writeConcern: {w: "majority"}})); +assert.commandWorked(testColl.insert([{_id: 0, a: 0}, {_id: 1, a: 0}, {_id: 2, a: 1}], + {writeConcern: {w: "majority"}})); jsTest.log("Do an empty multi-update."); session.startTransaction({writeConcern: {w: "majority"}}); diff --git a/jstests/core/txns/read_concerns.js b/jstests/core/txns/read_concerns.js index 409236a5ffd..fb7aa201131 100644 --- a/jstests/core/txns/read_concerns.js +++ b/jstests/core/txns/read_concerns.js @@ -18,7 +18,7 @@ function runTest(level, sessionOptions, supported) { const sessionColl = sessionDB[collName]; // Set up the collection. - assert.writeOK(sessionColl.insert({_id: 0}, {writeConcern: {w: "majority"}})); + assert.commandWorked(sessionColl.insert({_id: 0}, {writeConcern: {w: "majority"}})); if (level) { session.startTransaction({readConcern: {level: level}}); diff --git a/jstests/core/txns/read_own_multikey_writes.js b/jstests/core/txns/read_own_multikey_writes.js index 9af97dc4baa..1c3dc450280 100644 --- a/jstests/core/txns/read_own_multikey_writes.js +++ b/jstests/core/txns/read_own_multikey_writes.js @@ -15,11 +15,11 @@ const sessionColl = sessionDb.getCollection(collName); assert.commandWorked(sessionDb.runCommand({create: collName})); -assert.writeOK(sessionColl.insert({a: 1})); +assert.commandWorked(sessionColl.insert({a: 1})); assert.commandWorked(sessionColl.createIndex({a: 1})); session.startTransaction(); -assert.writeOK(sessionColl.update({}, {$set: {a: [1, 2, 3]}})); +assert.commandWorked(sessionColl.update({}, {$set: {a: [1, 2, 3]}})); assert.eq(1, sessionColl.find({}, {_id: 0, a: 1}).sort({a: 1}).itcount()); assert.commandWorked(session.commitTransaction_forTesting()); diff --git a/jstests/core/txns/repeatable_reads_in_transaction.js b/jstests/core/txns/repeatable_reads_in_transaction.js index 3286b6e72cb..870a1d58e6f 100644 --- a/jstests/core/txns/repeatable_reads_in_transaction.js +++ b/jstests/core/txns/repeatable_reads_in_transaction.js @@ -26,7 +26,8 @@ const session2Db = session2.getDatabase(dbName); const session2Coll = session2Db.getCollection(collName); jsTest.log("Prepopulate the collection."); -assert.writeOK(testColl.insert([{_id: 0}, {_id: 1}, {_id: 2}], {writeConcern: {w: "majority"}})); +assert.commandWorked( + testColl.insert([{_id: 0}, {_id: 1}, {_id: 2}], {writeConcern: {w: "majority"}})); // Create a constant array of documents we expect to be returned during a read-only transaction. // The value should not change since external changes should not be visible within this @@ -61,7 +62,7 @@ assert.sameMembers(expectedDocs, sessionColl.find().toArray()); jsTestLog( "Writes that occur outside of a transaction should not be visible to a read only transaction."); -assert.writeOK(testColl.insert({_id: 4}, {writeConcern: {w: "majority"}})); +assert.commandWorked(testColl.insert({_id: 4}, {writeConcern: {w: "majority"}})); assert.sameMembers(expectedDocs, sessionColl.find().toArray()); diff --git a/jstests/core/txns/start_transaction_with_read.js b/jstests/core/txns/start_transaction_with_read.js index 045b9af1083..e6af5ebe31b 100644 --- a/jstests/core/txns/start_transaction_with_read.js +++ b/jstests/core/txns/start_transaction_with_read.js @@ -25,7 +25,7 @@ const initialDoc = { _id: "pretransaction1", x: 0 }; -assert.writeOK(sessionColl.insert(initialDoc, {writeConcern: {w: "majority"}})); +assert.commandWorked(sessionColl.insert(initialDoc, {writeConcern: {w: "majority"}})); jsTest.log("Start a transaction with a read"); diff --git a/jstests/core/txns/statement_ids_accepted.js b/jstests/core/txns/statement_ids_accepted.js index d93c0e818be..bf73cbff55b 100644 --- a/jstests/core/txns/statement_ids_accepted.js +++ b/jstests/core/txns/statement_ids_accepted.js @@ -92,7 +92,7 @@ assert.commandWorked(sessionDb.runCommand({ jsTestLog("Check that find and getmore accept a statement ID"); // Put in some data to find so getMore has a cursor to use. -assert.writeOK(testColl.insert([{_id: 0}, {_id: 1}], {writeConcern: {w: "majority"}})); +assert.commandWorked(testColl.insert([{_id: 0}, {_id: 1}], {writeConcern: {w: "majority"}})); let res = assert.commandWorked(sessionDb.runCommand({ find: collName, batchSize: 1, @@ -169,10 +169,10 @@ if (!isMongos) { // Skip commands that do not exist on mongos. jsTestLog("Check that geoSearch accepts a statement ID"); - assert.writeOK(testColl.insert({geo: {type: "Point", coordinates: [0, 0]}, a: 0}), - {writeConcern: {w: "majority"}}); - assert.writeOK(testColl.insert({geoh: {lat: 0, long: 0}, b: 0}), - {writeConcern: {w: "majority"}}); + assert.commandWorked(testColl.insert({geo: {type: "Point", coordinates: [0, 0]}, a: 0}), + {writeConcern: {w: "majority"}}); + assert.commandWorked(testColl.insert({geoh: {lat: 0, long: 0}, b: 0}), + {writeConcern: {w: "majority"}}); assert.commandWorked(sessionDb.runCommand({ createIndexes: collName, indexes: [ diff --git a/jstests/core/type_array.js b/jstests/core/type_array.js index 0bc3dc0f6f3..cec6ff71748 100644 --- a/jstests/core/type_array.js +++ b/jstests/core/type_array.js @@ -21,14 +21,14 @@ function extractSortedIdsFromCursor(cursor) { } function runTests() { - assert.writeOK(coll.remove({})); - assert.writeOK(coll.insert({_id: 1, a: [1, 2, 3]})); - assert.writeOK(coll.insert({_id: 2, a: [1, "foo", 3]})); - assert.writeOK(coll.insert({_id: 3, a: []})); - assert.writeOK(coll.insert({_id: 4, a: [[]]})); - assert.writeOK(coll.insert({_id: 5, a: [[[]]]})); - assert.writeOK(coll.insert({_id: 6, a: 1})); - assert.writeOK(coll.insert({_id: 7, a: "foo"})); + assert.commandWorked(coll.remove({})); + assert.commandWorked(coll.insert({_id: 1, a: [1, 2, 3]})); + assert.commandWorked(coll.insert({_id: 2, a: [1, "foo", 3]})); + assert.commandWorked(coll.insert({_id: 3, a: []})); + assert.commandWorked(coll.insert({_id: 4, a: [[]]})); + assert.commandWorked(coll.insert({_id: 5, a: [[[]]]})); + assert.commandWorked(coll.insert({_id: 6, a: 1})); + assert.commandWorked(coll.insert({_id: 7, a: "foo"})); assert.eq([1, 2, 6], extractSortedIdsFromCursor(coll.find({a: {$type: "number"}}))); assert.eq([2, 7], extractSortedIdsFromCursor(coll.find({a: {$type: "string"}}))); @@ -36,14 +36,14 @@ function runTests() { assert.eq([4, 5], extractSortedIdsFromCursor(coll.find({"a.0": {$type: "array"}}))); assert.eq([5], extractSortedIdsFromCursor(coll.find({"a.0.0": {$type: "array"}}))); - assert.writeOK(coll.remove({})); - assert.writeOK(coll.insert({_id: 0, a: 1})); - assert.writeOK(coll.insert({_id: 1, a: NumberInt(1)})); - assert.writeOK(coll.insert({_id: 2, a: NumberLong(1)})); - assert.writeOK(coll.insert({_id: 3, a: "str"})); - assert.writeOK(coll.insert({_id: 4, a: []})); - assert.writeOK(coll.insert({_id: 5, a: [NumberInt(1), "str"]})); - assert.writeOK(coll.insert({_id: 6})); + assert.commandWorked(coll.remove({})); + assert.commandWorked(coll.insert({_id: 0, a: 1})); + assert.commandWorked(coll.insert({_id: 1, a: NumberInt(1)})); + assert.commandWorked(coll.insert({_id: 2, a: NumberLong(1)})); + assert.commandWorked(coll.insert({_id: 3, a: "str"})); + assert.commandWorked(coll.insert({_id: 4, a: []})); + assert.commandWorked(coll.insert({_id: 5, a: [NumberInt(1), "str"]})); + assert.commandWorked(coll.insert({_id: 6})); // Test that $type fails when given array that contains an element that is neither a string // nor a number. @@ -67,6 +67,6 @@ function runTests() { // Verify $type queries both with and without an index. runTests(); -assert.writeOK(coll.createIndex({a: 1})); +assert.commandWorked(coll.createIndex({a: 1})); runTests(); }()); diff --git a/jstests/core/uniqueness.js b/jstests/core/uniqueness.js index 54a5a71c276..d138f59d0ae 100644 --- a/jstests/core/uniqueness.js +++ b/jstests/core/uniqueness.js @@ -20,7 +20,7 @@ t.drop(); // test uniqueness of _id res = t.save({_id: 3}); -assert.writeOK(res); +assert.commandWorked(res); // this should yield an error res = t.insert({_id: 3}); @@ -28,7 +28,7 @@ assert.writeError(res); assert.eq(1, t.count()); res = t.insert({_id: 4, x: 99}); -assert.writeOK(res); +assert.commandWorked(res); // this should yield an error res = t.update({_id: 4}, {_id: 3, x: 99}); diff --git a/jstests/core/update_addToSet.js b/jstests/core/update_addToSet.js index bcf5b752846..5927dd882f8 100644 --- a/jstests/core/update_addToSet.js +++ b/jstests/core/update_addToSet.js @@ -77,18 +77,18 @@ o = { _id: 1, a: [1, 2] }; -assert.writeOK(t.insert(o)); +assert.commandWorked(t.insert(o)); -assert.writeOK(t.update({}, {$addToSet: {a: {'x.$.y': 'bad'}}})); -assert.writeOK(t.update({}, {$addToSet: {a: {b: {'x.$.y': 'bad'}}}})); +assert.commandWorked(t.update({}, {$addToSet: {a: {'x.$.y': 'bad'}}})); +assert.commandWorked(t.update({}, {$addToSet: {a: {b: {'x.$.y': 'bad'}}}})); assert.writeError(t.update({}, {$addToSet: {a: {"$bad": "bad"}}})); assert.writeError(t.update({}, {$addToSet: {a: {b: {"$bad": "bad"}}}})); -assert.writeOK(t.update({}, {$addToSet: {a: {_id: {"x.y": 2}}}})); +assert.commandWorked(t.update({}, {$addToSet: {a: {_id: {"x.y": 2}}}})); -assert.writeOK(t.update({}, {$addToSet: {a: {$each: [{'x.$.y': 'bad'}]}}})); -assert.writeOK(t.update({}, {$addToSet: {a: {$each: [{b: {'x.$.y': 'bad'}}]}}})); +assert.commandWorked(t.update({}, {$addToSet: {a: {$each: [{'x.$.y': 'bad'}]}}})); +assert.commandWorked(t.update({}, {$addToSet: {a: {$each: [{b: {'x.$.y': 'bad'}}]}}})); assert.writeError(t.update({}, {$addToSet: {a: {$each: [{'$bad': 'bad'}]}}})); assert.writeError(t.update({}, {$addToSet: {a: {$each: [{b: {'$bad': 'bad'}}]}}})); @@ -99,10 +99,10 @@ o = { _id: 1, a: [1, 2] }; -assert.writeOK(t.insert(o)); +assert.commandWorked(t.insert(o)); -assert.writeOK(t.update({}, {$addToSet: {a: {_id: ["foo", "bar", "baz"]}}})); -assert.writeOK(t.update({}, {$addToSet: {a: {_id: /acme.*corp/}}})); +assert.commandWorked(t.update({}, {$addToSet: {a: {_id: ["foo", "bar", "baz"]}}})); +assert.commandWorked(t.update({}, {$addToSet: {a: {_id: /acme.*corp/}}})); // Test that DBRefs are allowed. t.drop(); @@ -110,19 +110,19 @@ o = { _id: 1, a: [1, 2] }; -assert.writeOK(t.insert(o)); +assert.commandWorked(t.insert(o)); foo = { "foo": "bar" }; -assert.writeOK(t.insert(foo)); +assert.commandWorked(t.insert(foo)); let fooDoc = t.findOne(foo); assert.eq(fooDoc.foo, foo.foo); let fooDocRef = {reference: new DBRef(t.getName(), fooDoc._id, t.getDB().getName())}; -assert.writeOK(t.update({_id: o._id}, {$addToSet: {a: fooDocRef}})); +assert.commandWorked(t.update({_id: o._id}, {$addToSet: {a: fooDocRef}})); assert.eq(t.findOne({_id: o._id}).a[2], fooDocRef); -assert.writeOK(t.update({_id: o._id}, {$addToSet: {a: {b: fooDocRef}}})); +assert.commandWorked(t.update({_id: o._id}, {$addToSet: {a: {b: fooDocRef}}})); assert.eq(t.findOne({_id: o._id}).a[3].b, fooDocRef); diff --git a/jstests/core/update_affects_indexes.js b/jstests/core/update_affects_indexes.js index 956efadbf0e..41b0cb4a016 100644 --- a/jstests/core/update_affects_indexes.js +++ b/jstests/core/update_affects_indexes.js @@ -27,68 +27,68 @@ function assertExpectedIndexKeys(docId, expectedKeys, unexpectedKeys) { } // $set implicitly creates array element at end of array. -assert.writeOK(coll.insert({_id: 0, a: [{b: 0}]})); +assert.commandWorked(coll.insert({_id: 0, a: [{b: 0}]})); assertExpectedIndexKeys({_id: 0}, [{"a.b": 0}], [{"a.b": null}]); -assert.writeOK(coll.update({_id: 0}, {$set: {"a.1.c": 0}})); +assert.commandWorked(coll.update({_id: 0}, {$set: {"a.1.c": 0}})); assertExpectedIndexKeys({_id: 0}, [{"a.b": 0}, {"a.b": null}], []); // $set implicitly creates array element beyond end of array. -assert.writeOK(coll.insert({_id: 1, a: [{b: 0}]})); +assert.commandWorked(coll.insert({_id: 1, a: [{b: 0}]})); assertExpectedIndexKeys({_id: 1}, [{"a.b": 0}], [{"a.b": null}]); -assert.writeOK(coll.update({_id: 1}, {$set: {"a.3.c": 0}})); +assert.commandWorked(coll.update({_id: 1}, {$set: {"a.3.c": 0}})); assertExpectedIndexKeys({_id: 1}, [{"a.b": 0}, {"a.b": null}], []); // $set implicitly creates array element in empty array (no index key changes needed). -assert.writeOK(coll.insert({_id: 2, a: []})); +assert.commandWorked(coll.insert({_id: 2, a: []})); assertExpectedIndexKeys({_id: 2}, [{"a.b": null}], []); -assert.writeOK(coll.update({_id: 2}, {$set: {"a.0.c": 0}})); +assert.commandWorked(coll.update({_id: 2}, {$set: {"a.0.c": 0}})); assertExpectedIndexKeys({_id: 2}, [{"a.b": null}], []); // $inc implicitly creates array element at end of array. -assert.writeOK(coll.insert({_id: 3, a: [{b: 0}]})); +assert.commandWorked(coll.insert({_id: 3, a: [{b: 0}]})); assertExpectedIndexKeys({_id: 3}, [{"a.b": 0}], [{"a.b": null}]); -assert.writeOK(coll.update({_id: 3}, {$inc: {"a.1.c": 0}})); +assert.commandWorked(coll.update({_id: 3}, {$inc: {"a.1.c": 0}})); assertExpectedIndexKeys({_id: 3}, [{"a.b": 0}, {"a.b": null}], []); // $mul implicitly creates array element at end of array. -assert.writeOK(coll.insert({_id: 4, a: [{b: 0}]})); +assert.commandWorked(coll.insert({_id: 4, a: [{b: 0}]})); assertExpectedIndexKeys({_id: 4}, [{"a.b": 0}], [{"a.b": null}]); -assert.writeOK(coll.update({_id: 4}, {$mul: {"a.1.c": 0}})); +assert.commandWorked(coll.update({_id: 4}, {$mul: {"a.1.c": 0}})); assertExpectedIndexKeys({_id: 4}, [{"a.b": 0}, {"a.b": null}], []); // $addToSet implicitly creates array element at end of array. -assert.writeOK(coll.insert({_id: 5, a: [{b: 0}]})); +assert.commandWorked(coll.insert({_id: 5, a: [{b: 0}]})); assertExpectedIndexKeys({_id: 5}, [{"a.b": 0}], [{"a.b": null}]); -assert.writeOK(coll.update({_id: 5}, {$addToSet: {"a.1.c": 0}})); +assert.commandWorked(coll.update({_id: 5}, {$addToSet: {"a.1.c": 0}})); assertExpectedIndexKeys({_id: 5}, [{"a.b": 0}, {"a.b": null}], []); // $bit implicitly creates array element at end of array. -assert.writeOK(coll.insert({_id: 6, a: [{b: 0}]})); +assert.commandWorked(coll.insert({_id: 6, a: [{b: 0}]})); assertExpectedIndexKeys({_id: 6}, [{"a.b": 0}], [{"a.b": null}]); -assert.writeOK(coll.update({_id: 6}, {$bit: {"a.1.c": {and: NumberInt(1)}}})); +assert.commandWorked(coll.update({_id: 6}, {$bit: {"a.1.c": {and: NumberInt(1)}}})); assertExpectedIndexKeys({_id: 6}, [{"a.b": 0}, {"a.b": null}], []); // $min implicitly creates array element at end of array. -assert.writeOK(coll.insert({_id: 7, a: [{b: 0}]})); +assert.commandWorked(coll.insert({_id: 7, a: [{b: 0}]})); assertExpectedIndexKeys({_id: 7}, [{"a.b": 0}], [{"a.b": null}]); -assert.writeOK(coll.update({_id: 7}, {$min: {"a.1.c": 0}})); +assert.commandWorked(coll.update({_id: 7}, {$min: {"a.1.c": 0}})); assertExpectedIndexKeys({_id: 7}, [{"a.b": 0}, {"a.b": null}], []); // $max implicitly creates array element at end of array. -assert.writeOK(coll.insert({_id: 8, a: [{b: 0}]})); +assert.commandWorked(coll.insert({_id: 8, a: [{b: 0}]})); assertExpectedIndexKeys({_id: 8}, [{"a.b": 0}], [{"a.b": null}]); -assert.writeOK(coll.update({_id: 8}, {$max: {"a.1.c": 0}})); +assert.commandWorked(coll.update({_id: 8}, {$max: {"a.1.c": 0}})); assertExpectedIndexKeys({_id: 8}, [{"a.b": 0}, {"a.b": null}], []); // $currentDate implicitly creates array element at end of array. -assert.writeOK(coll.insert({_id: 9, a: [{b: 0}]})); +assert.commandWorked(coll.insert({_id: 9, a: [{b: 0}]})); assertExpectedIndexKeys({_id: 9}, [{"a.b": 0}], [{"a.b": null}]); -assert.writeOK(coll.update({_id: 9}, {$currentDate: {"a.1.c": true}})); +assert.commandWorked(coll.update({_id: 9}, {$currentDate: {"a.1.c": true}})); assertExpectedIndexKeys({_id: 9}, [{"a.b": 0}, {"a.b": null}], []); // $push implicitly creates array element at end of array. -assert.writeOK(coll.insert({_id: 10, a: [{b: 0}]})); +assert.commandWorked(coll.insert({_id: 10, a: [{b: 0}]})); assertExpectedIndexKeys({_id: 10}, [{"a.b": 0}], [{"a.b": null}]); -assert.writeOK(coll.update({_id: 10}, {$push: {"a.1.c": 0}})); +assert.commandWorked(coll.update({_id: 10}, {$push: {"a.1.c": 0}})); assertExpectedIndexKeys({_id: 10}, [{"a.b": 0}, {"a.b": null}], []); }()); diff --git a/jstests/core/update_arrayFilters.js b/jstests/core/update_arrayFilters.js index 55d7614495d..a7e517a3fe4 100644 --- a/jstests/core/update_arrayFilters.js +++ b/jstests/core/update_arrayFilters.js @@ -83,9 +83,9 @@ if (db.getMongo().writeMode() !== "commands") { assert.writeErrorWithCode(res, ErrorCodes.QueryFeatureNotAllowed); // Good value for arrayFilters succeeds. - assert.writeOK(coll.update( + assert.commandWorked(coll.update( {_id: 0}, {$set: {"a.$[i]": 5, "a.$[j]": 6}}, {arrayFilters: [{i: 0}, {j: 0}]})); - assert.writeOK(coll.update( + assert.commandWorked(coll.update( {_id: 0}, {$set: {"a.$[i]": 5}}, {arrayFilters: [{$or: [{i: 0}, {$and: [{}]}]}]})); } @@ -160,7 +160,7 @@ if (db.getMongo().writeMode() !== "commands") { }); bulk = coll.initializeUnorderedBulkOp(); bulk.find({}).arrayFilters([{i: 0}]).update({$set: {"a.$[i]": 5}}); - assert.writeOK(bulk.execute()); + assert.commandWorked(bulk.execute()); // updateOne(). bulk = coll.initializeUnorderedBulkOp(); @@ -170,7 +170,7 @@ if (db.getMongo().writeMode() !== "commands") { }); bulk = coll.initializeUnorderedBulkOp(); bulk.find({_id: 0}).arrayFilters([{i: 0}]).updateOne({$set: {"a.$[i]": 5}}); - assert.writeOK(bulk.execute()); + assert.commandWorked(bulk.execute()); } // @@ -273,51 +273,52 @@ assert.commandWorked(coll.explain().findAndModify( // $set. coll.drop(); -assert.writeOK(coll.insert({_id: 0, a: [0, 1, 0, 1]})); +assert.commandWorked(coll.insert({_id: 0, a: [0, 1, 0, 1]})); if (db.getMongo().writeMode() === "commands") { - assert.writeOK(coll.update({_id: 0}, {$set: {"a.$[i]": 2}}, {arrayFilters: [{i: 0}]})); + assert.commandWorked(coll.update({_id: 0}, {$set: {"a.$[i]": 2}}, {arrayFilters: [{i: 0}]})); assert.eq(coll.findOne({_id: 0}), {_id: 0, a: [2, 1, 2, 1]}); } -assert.writeOK(coll.update({_id: 0}, {$set: {"a.$[]": 3}})); +assert.commandWorked(coll.update({_id: 0}, {$set: {"a.$[]": 3}})); assert.eq(coll.findOne({_id: 0}), {_id: 0, a: [3, 3, 3, 3]}); // $unset. coll.drop(); -assert.writeOK(coll.insert({_id: 0, a: [0, 1, 0, 1]})); +assert.commandWorked(coll.insert({_id: 0, a: [0, 1, 0, 1]})); if (db.getMongo().writeMode() === "commands") { - assert.writeOK(coll.update({_id: 0}, {$unset: {"a.$[i]": true}}, {arrayFilters: [{i: 0}]})); + assert.commandWorked( + coll.update({_id: 0}, {$unset: {"a.$[i]": true}}, {arrayFilters: [{i: 0}]})); assert.eq(coll.findOne({_id: 0}), {_id: 0, a: [null, 1, null, 1]}); } -assert.writeOK(coll.update({_id: 0}, {$unset: {"a.$[]": true}})); +assert.commandWorked(coll.update({_id: 0}, {$unset: {"a.$[]": true}})); assert.eq(coll.findOne({_id: 0}), {_id: 0, a: [null, null, null, null]}); // $inc. coll.drop(); -assert.writeOK(coll.insert({_id: 0, a: [0, 1, 0, 1]})); +assert.commandWorked(coll.insert({_id: 0, a: [0, 1, 0, 1]})); if (db.getMongo().writeMode() === "commands") { - assert.writeOK(coll.update({_id: 0}, {$inc: {"a.$[i]": 1}}, {arrayFilters: [{i: 1}]})); + assert.commandWorked(coll.update({_id: 0}, {$inc: {"a.$[i]": 1}}, {arrayFilters: [{i: 1}]})); assert.eq(coll.findOne({_id: 0}), {_id: 0, a: [0, 2, 0, 2]}); } coll.drop(); -assert.writeOK(coll.insert({_id: 0, a: [0, 1, 0, 1]})); -assert.writeOK(coll.update({_id: 0}, {$inc: {"a.$[]": 1}})); +assert.commandWorked(coll.insert({_id: 0, a: [0, 1, 0, 1]})); +assert.commandWorked(coll.update({_id: 0}, {$inc: {"a.$[]": 1}})); assert.eq(coll.findOne({_id: 0}), {_id: 0, a: [1, 2, 1, 2]}); // $mul. coll.drop(); -assert.writeOK(coll.insert({_id: 0, a: [0, 2, 0, 2]})); +assert.commandWorked(coll.insert({_id: 0, a: [0, 2, 0, 2]})); if (db.getMongo().writeMode() === "commands") { - assert.writeOK(coll.update({_id: 0}, {$mul: {"a.$[i]": 3}}, {arrayFilters: [{i: 2}]})); + assert.commandWorked(coll.update({_id: 0}, {$mul: {"a.$[i]": 3}}, {arrayFilters: [{i: 2}]})); assert.eq(coll.findOne({_id: 0}), {_id: 0, a: [0, 6, 0, 6]}); } coll.drop(); -assert.writeOK(coll.insert({_id: 0, a: [1, 2, 1, 2]})); -assert.writeOK(coll.update({_id: 0}, {$mul: {"a.$[]": 3}})); +assert.commandWorked(coll.insert({_id: 0, a: [1, 2, 1, 2]})); +assert.commandWorked(coll.update({_id: 0}, {$mul: {"a.$[]": 3}})); assert.eq(coll.findOne({_id: 0}), {_id: 0, a: [3, 6, 3, 6]}); // $rename. coll.drop(); -assert.writeOK(coll.insert({_id: 0, a: [1, 2, 3, 4]})); +assert.commandWorked(coll.insert({_id: 0, a: [1, 2, 3, 4]})); if (db.getMongo().writeMode() === "commands") { res = coll.update({_id: 0}, {$rename: {"a.$[i]": "b"}}, {arrayFilters: [{i: 0}]}); assert.writeErrorWithCode(res, ErrorCodes.BadValue); @@ -334,7 +335,7 @@ if (db.getMongo().writeMode() === "commands") { "updated failed for reason other than unused array filter"); } coll.drop(); -assert.writeOK(coll.insert({_id: 0, a: [0], b: [1]})); +assert.commandWorked(coll.insert({_id: 0, a: [0], b: [1]})); res = coll.update({_id: 0}, {$rename: {"a.$[]": "b"}}); assert.writeErrorWithCode(res, ErrorCodes.BadValue); assert.neq( @@ -347,51 +348,53 @@ assert.neq(-1, res.getWriteError().errmsg.indexOf( "The destination field for $rename may not be dynamic: b.$[]"), "update failed for a reason other than using array updates with $rename"); -assert.writeOK(coll.update({_id: 0}, {$rename: {"a": "b"}})); +assert.commandWorked(coll.update({_id: 0}, {$rename: {"a": "b"}})); assert.eq(coll.findOne({_id: 0}), {_id: 0, b: [0]}); // $setOnInsert. coll.drop(); if (db.getMongo().writeMode() === "commands") { - assert.writeOK(coll.update( + assert.commandWorked(coll.update( {_id: 0, a: [0]}, {$setOnInsert: {"a.$[i]": 1}}, {arrayFilters: [{i: 0}], upsert: true})); assert.eq(coll.findOne({_id: 0}), {_id: 0, a: [1]}); } coll.drop(); -assert.writeOK(coll.update({_id: 0, a: [0]}, {$setOnInsert: {"a.$[]": 1}}, {upsert: true})); +assert.commandWorked(coll.update({_id: 0, a: [0]}, {$setOnInsert: {"a.$[]": 1}}, {upsert: true})); assert.eq(coll.findOne({_id: 0}), {_id: 0, a: [1]}); // $min. coll.drop(); -assert.writeOK(coll.insert({_id: 0, a: [{b: 0, c: 1}, {b: 0, c: -1}, {b: 1, c: 1}]})); +assert.commandWorked(coll.insert({_id: 0, a: [{b: 0, c: 1}, {b: 0, c: -1}, {b: 1, c: 1}]})); if (db.getMongo().writeMode() === "commands") { - assert.writeOK(coll.update({_id: 0}, {$min: {"a.$[i].c": 0}}, {arrayFilters: [{"i.b": 0}]})); + assert.commandWorked( + coll.update({_id: 0}, {$min: {"a.$[i].c": 0}}, {arrayFilters: [{"i.b": 0}]})); assert.eq(coll.findOne({_id: 0}), {_id: 0, a: [{b: 0, c: 0}, {b: 0, c: -1}, {b: 1, c: 1}]}); } -assert.writeOK(coll.update({_id: 0}, {$min: {"a.$[].c": 0}})); +assert.commandWorked(coll.update({_id: 0}, {$min: {"a.$[].c": 0}})); assert.eq(coll.findOne({_id: 0}), {_id: 0, a: [{b: 0, c: 0}, {b: 0, c: -1}, {b: 1, c: 0}]}); // $max. coll.drop(); -assert.writeOK(coll.insert({_id: 0, a: [{b: 0, c: 1}, {b: 0, c: -1}, {b: 1, c: -1}]})); +assert.commandWorked(coll.insert({_id: 0, a: [{b: 0, c: 1}, {b: 0, c: -1}, {b: 1, c: -1}]})); if (db.getMongo().writeMode() === "commands") { - assert.writeOK(coll.update({_id: 0}, {$max: {"a.$[i].c": 0}}, {arrayFilters: [{"i.b": 0}]})); + assert.commandWorked( + coll.update({_id: 0}, {$max: {"a.$[i].c": 0}}, {arrayFilters: [{"i.b": 0}]})); assert.eq(coll.findOne({_id: 0}), {_id: 0, a: [{b: 0, c: 1}, {b: 0, c: 0}, {b: 1, c: -1}]}); } -assert.writeOK(coll.update({_id: 0}, {$max: {"a.$[].c": 0}})); +assert.commandWorked(coll.update({_id: 0}, {$max: {"a.$[].c": 0}})); assert.eq(coll.findOne({_id: 0}), {_id: 0, a: [{b: 0, c: 1}, {b: 0, c: 0}, {b: 1, c: 0}]}); // $currentDate. coll.drop(); -assert.writeOK(coll.insert({_id: 0, a: [0, 1]})); +assert.commandWorked(coll.insert({_id: 0, a: [0, 1]})); if (db.getMongo().writeMode() === "commands") { - assert.writeOK( + assert.commandWorked( coll.update({_id: 0}, {$currentDate: {"a.$[i]": true}}, {arrayFilters: [{i: 0}]})); let doc = coll.findOne({_id: 0}); assert(doc.a[0].constructor == Date, tojson(doc)); assert.eq(doc.a[1], 1, printjson(doc)); } -assert.writeOK(coll.update({_id: 0}, {$currentDate: {"a.$[]": true}})); +assert.commandWorked(coll.update({_id: 0}, {$currentDate: {"a.$[]": true}})); let doc = coll.findOne({_id: 0}); assert(doc.a[0].constructor == Date, tojson(doc)); assert(doc.a[1].constructor == Date, tojson(doc)); @@ -399,74 +402,76 @@ assert(doc.a[1].constructor == Date, tojson(doc)); // $addToSet. coll.drop(); if (db.getMongo().writeMode() === "commands") { - assert.writeOK(coll.insert({_id: 0, a: [[0], [1]]})); - assert.writeOK(coll.update({_id: 0}, {$addToSet: {"a.$[i]": 2}}, {arrayFilters: [{i: 0}]})); + assert.commandWorked(coll.insert({_id: 0, a: [[0], [1]]})); + assert.commandWorked( + coll.update({_id: 0}, {$addToSet: {"a.$[i]": 2}}, {arrayFilters: [{i: 0}]})); assert.eq(coll.findOne({_id: 0}), {_id: 0, a: [[0, 2], [1]]}); } coll.drop(); -assert.writeOK(coll.insert({_id: 0, a: [[0], [1]]})); -assert.writeOK(coll.update({_id: 0}, {$addToSet: {"a.$[]": 2}})); +assert.commandWorked(coll.insert({_id: 0, a: [[0], [1]]})); +assert.commandWorked(coll.update({_id: 0}, {$addToSet: {"a.$[]": 2}})); assert.eq(coll.findOne({_id: 0}), {_id: 0, a: [[0, 2], [1, 2]]}); // $pop. coll.drop(); -assert.writeOK(coll.insert({_id: 0, a: [[0, 1], [1, 2]]})); +assert.commandWorked(coll.insert({_id: 0, a: [[0, 1], [1, 2]]})); if (db.getMongo().writeMode() === "commands") { - assert.writeOK(coll.update({_id: 0}, {$pop: {"a.$[i]": 1}}, {arrayFilters: [{i: 0}]})); + assert.commandWorked(coll.update({_id: 0}, {$pop: {"a.$[i]": 1}}, {arrayFilters: [{i: 0}]})); assert.eq({_id: 0, a: [[0], [1, 2]]}, coll.findOne()); } -assert.writeOK(coll.remove({})); -assert.writeOK(coll.insert({_id: 0, a: [[0]]})); -assert.writeOK(coll.update({_id: 0}, {$pop: {"a.$[]": 1}})); +assert.commandWorked(coll.remove({})); +assert.commandWorked(coll.insert({_id: 0, a: [[0]]})); +assert.commandWorked(coll.update({_id: 0}, {$pop: {"a.$[]": 1}})); assert.eq({_id: 0, a: [[]]}, coll.findOne()); // $pullAll. coll.drop(); -assert.writeOK(coll.insert({_id: 0, a: [[0, 1, 2, 3], [1, 2, 3, 4]]})); +assert.commandWorked(coll.insert({_id: 0, a: [[0, 1, 2, 3], [1, 2, 3, 4]]})); if (db.getMongo().writeMode() === "commands") { - assert.writeOK(coll.update({_id: 0}, {$pullAll: {"a.$[i]": [0, 2]}}, {arrayFilters: [{i: 0}]})); + assert.commandWorked( + coll.update({_id: 0}, {$pullAll: {"a.$[i]": [0, 2]}}, {arrayFilters: [{i: 0}]})); assert.eq({_id: 0, a: [[1, 3], [1, 2, 3, 4]]}, coll.findOne()); } coll.drop(); -assert.writeOK(coll.insert({_id: 0, a: [[0, 1, 2, 3], [1, 2, 3, 4]]})); +assert.commandWorked(coll.insert({_id: 0, a: [[0, 1, 2, 3], [1, 2, 3, 4]]})); res = coll.update({_id: 0}, {$pullAll: {"a.$[]": [0, 2]}}); assert.eq({_id: 0, a: [[1, 3], [1, 3, 4]]}, coll.findOne()); // $pull. coll.drop(); -assert.writeOK(coll.insert({_id: 0, a: [[0, 1], [1, 2]]})); +assert.commandWorked(coll.insert({_id: 0, a: [[0, 1], [1, 2]]})); if (db.getMongo().writeMode() === "commands") { - assert.writeOK(coll.update({_id: 0}, {$pull: {"a.$[i]": 1}}, {arrayFilters: [{i: 2}]})); + assert.commandWorked(coll.update({_id: 0}, {$pull: {"a.$[i]": 1}}, {arrayFilters: [{i: 2}]})); assert.eq({_id: 0, a: [[0, 1], [2]]}, coll.findOne()); } -assert.writeOK(coll.remove({})); -assert.writeOK(coll.insert({_id: 0, a: [[0, 1], [1, 2]]})); -assert.writeOK(coll.update({_id: 0}, {$pull: {"a.$[]": 1}})); +assert.commandWorked(coll.remove({})); +assert.commandWorked(coll.insert({_id: 0, a: [[0, 1], [1, 2]]})); +assert.commandWorked(coll.update({_id: 0}, {$pull: {"a.$[]": 1}})); assert.eq({_id: 0, a: [[0], [2]]}, coll.findOne()); // $push. coll.drop(); -assert.writeOK(coll.insert({_id: 0, a: [[0, 1], [2, 3]]})); +assert.commandWorked(coll.insert({_id: 0, a: [[0, 1], [2, 3]]})); if (db.getMongo().writeMode() === "commands") { - assert.writeOK(coll.update({_id: 0}, {$push: {"a.$[i]": 4}}, {arrayFilters: [{i: 0}]})); + assert.commandWorked(coll.update({_id: 0}, {$push: {"a.$[i]": 4}}, {arrayFilters: [{i: 0}]})); assert.eq({_id: 0, a: [[0, 1, 4], [2, 3]]}, coll.findOne()); } coll.drop(); -assert.writeOK(coll.insert({_id: 0, a: [[0, 1], [2, 3]]})); -assert.writeOK(coll.update({_id: 0}, {$push: {"a.$[]": 4}})); +assert.commandWorked(coll.insert({_id: 0, a: [[0, 1], [2, 3]]})); +assert.commandWorked(coll.update({_id: 0}, {$push: {"a.$[]": 4}})); assert.eq({_id: 0, a: [[0, 1, 4], [2, 3, 4]]}, coll.findOne()); // $bit. coll.drop(); -assert.writeOK(coll.insert({_id: 0, a: [NumberInt(0), NumberInt(2)]})); +assert.commandWorked(coll.insert({_id: 0, a: [NumberInt(0), NumberInt(2)]})); if (db.getMongo().writeMode() === "commands") { - assert.writeOK( + assert.commandWorked( coll.update({_id: 0}, {$bit: {"a.$[i]": {or: NumberInt(10)}}}, {arrayFilters: [{i: 0}]})); assert.eq({_id: 0, a: [NumberInt(10), NumberInt(2)]}, coll.findOne()); } -assert.writeOK(coll.remove({})); -assert.writeOK(coll.insert({_id: 0, a: [NumberInt(0), NumberInt(2)]})); -assert.writeOK(coll.update({_id: 0}, {$bit: {"a.$[]": {or: NumberInt(10)}}})); +assert.commandWorked(coll.remove({})); +assert.commandWorked(coll.insert({_id: 0, a: [NumberInt(0), NumberInt(2)]})); +assert.commandWorked(coll.update({_id: 0}, {$bit: {"a.$[]": {or: NumberInt(10)}}})); assert.eq({_id: 0, a: [NumberInt(10), NumberInt(10)]}, coll.findOne()); // @@ -474,14 +479,15 @@ assert.eq({_id: 0, a: [NumberInt(10), NumberInt(10)]}, coll.findOne()); // coll.drop(); -assert.writeOK(coll.insert({_id: 0, a: [0, 1, 0, 1]})); -assert.writeOK(coll.insert({_id: 1, a: [0, 2, 0, 2]})); +assert.commandWorked(coll.insert({_id: 0, a: [0, 1, 0, 1]})); +assert.commandWorked(coll.insert({_id: 1, a: [0, 2, 0, 2]})); if (db.getMongo().writeMode() === "commands") { - assert.writeOK(coll.update({}, {$set: {"a.$[i]": 3}}, {multi: true, arrayFilters: [{i: 0}]})); + assert.commandWorked( + coll.update({}, {$set: {"a.$[i]": 3}}, {multi: true, arrayFilters: [{i: 0}]})); assert.eq(coll.findOne({_id: 0}), {_id: 0, a: [3, 1, 3, 1]}); assert.eq(coll.findOne({_id: 1}), {_id: 1, a: [3, 2, 3, 2]}); } -assert.writeOK(coll.update({}, {$set: {"a.$[]": 3}}, {multi: true})); +assert.commandWorked(coll.update({}, {$set: {"a.$[]": 3}}, {multi: true})); assert.eq(coll.findOne({_id: 0}), {_id: 0, a: [3, 3, 3, 3]}); assert.eq(coll.findOne({_id: 1}), {_id: 1, a: [3, 3, 3, 3]}); @@ -492,8 +498,8 @@ assert.eq(coll.findOne({_id: 1}), {_id: 1, a: [3, 3, 3, 3]}); if (db.getMongo().writeMode() === "commands") { // arrayFilters respect operation collation. coll.drop(); - assert.writeOK(coll.insert({_id: 0, a: ["foo", "FOO"]})); - assert.writeOK( + assert.commandWorked(coll.insert({_id: 0, a: ["foo", "FOO"]})); + assert.commandWorked( coll.update({_id: 0}, {$set: {"a.$[i]": "bar"}}, {arrayFilters: [{i: "foo"}], collation: {locale: "en_US", strength: 2}})); @@ -504,8 +510,9 @@ if (db.getMongo().writeMode() === "commands") { assert.commandWorked( db.createCollection(collName, {collation: {locale: "en_US", strength: 2}})); coll = db[collName]; - assert.writeOK(coll.insert({_id: 0, a: ["foo", "FOO"]})); - assert.writeOK(coll.update({_id: 0}, {$set: {"a.$[i]": "bar"}}, {arrayFilters: [{i: "foo"}]})); + assert.commandWorked(coll.insert({_id: 0, a: ["foo", "FOO"]})); + assert.commandWorked( + coll.update({_id: 0}, {$set: {"a.$[i]": "bar"}}, {arrayFilters: [{i: "foo"}]})); assert.eq(coll.findOne({_id: 0}), {_id: 0, a: ["bar", "bar"]}); } @@ -515,40 +522,42 @@ if (db.getMongo().writeMode() === "commands") { // Update all documents in array. coll.drop(); -assert.writeOK(coll.insert({_id: 0, a: [{b: 0}, {b: 1}]})); -assert.writeOK(coll.update({_id: 0}, {$set: {"a.$[].b": 2}})); +assert.commandWorked(coll.insert({_id: 0, a: [{b: 0}, {b: 1}]})); +assert.commandWorked(coll.update({_id: 0}, {$set: {"a.$[].b": 2}})); assert.eq(coll.findOne({_id: 0}), {_id: 0, a: [{b: 2}, {b: 2}]}); // Update all matching documents in array. if (db.getMongo().writeMode() === "commands") { coll.drop(); - assert.writeOK(coll.insert({_id: 0, a: [{b: 0}, {b: 1}]})); - assert.writeOK(coll.update({_id: 0}, {$set: {"a.$[i].b": 2}}, {arrayFilters: [{"i.b": 0}]})); + assert.commandWorked(coll.insert({_id: 0, a: [{b: 0}, {b: 1}]})); + assert.commandWorked( + coll.update({_id: 0}, {$set: {"a.$[i].b": 2}}, {arrayFilters: [{"i.b": 0}]})); assert.eq(coll.findOne({_id: 0}), {_id: 0, a: [{b: 2}, {b: 1}]}); } // Update all matching scalars in array. if (db.getMongo().writeMode() === "commands") { coll.drop(); - assert.writeOK(coll.insert({_id: 0, a: [0, 1]})); - assert.writeOK(coll.update({_id: 0}, {$set: {"a.$[i]": 2}}, {arrayFilters: [{i: 0}]})); + assert.commandWorked(coll.insert({_id: 0, a: [0, 1]})); + assert.commandWorked(coll.update({_id: 0}, {$set: {"a.$[i]": 2}}, {arrayFilters: [{i: 0}]})); assert.eq(coll.findOne({_id: 0}), {_id: 0, a: [2, 1]}); } // Update all matching scalars in array of arrays. if (db.getMongo().writeMode() === "commands") { coll.drop(); - assert.writeOK(coll.insert({_id: 0, a: [[0, 1], [0, 1]]})); - assert.writeOK(coll.update({_id: 0}, {$set: {"a.$[].$[j]": 2}}, {arrayFilters: [{j: 0}]})); + assert.commandWorked(coll.insert({_id: 0, a: [[0, 1], [0, 1]]})); + assert.commandWorked( + coll.update({_id: 0}, {$set: {"a.$[].$[j]": 2}}, {arrayFilters: [{j: 0}]})); assert.eq(coll.findOne({_id: 0}), {_id: 0, a: [[2, 1], [2, 1]]}); } // Update all matching documents in nested array. if (db.getMongo().writeMode() === "commands") { coll.drop(); - assert.writeOK( + assert.commandWorked( coll.insert({_id: 0, a: [{b: 0, c: [{d: 0}, {d: 1}]}, {b: 1, c: [{d: 0}, {d: 1}]}]})); - assert.writeOK(coll.update( + assert.commandWorked(coll.update( {_id: 0}, {$set: {"a.$[i].c.$[j].d": 2}}, {arrayFilters: [{"i.b": 0}, {"j.d": 0}]})); assert.eq(coll.findOne({_id: 0}), {_id: 0, a: [{b: 0, c: [{d: 2}, {d: 1}]}, {b: 1, c: [{d: 0}, {d: 1}]}]}); @@ -557,8 +566,8 @@ if (db.getMongo().writeMode() === "commands") { // Update all scalars in array matching a logical predicate. if (db.getMongo().writeMode() === "commands") { coll.drop(); - assert.writeOK(coll.insert({_id: 0, a: [0, 1, 3]})); - assert.writeOK( + assert.commandWorked(coll.insert({_id: 0, a: [0, 1, 3]})); + assert.commandWorked( coll.update({_id: 0}, {$set: {"a.$[i]": 2}}, {arrayFilters: [{$or: [{i: 0}, {i: 3}]}]})); assert.eq(coll.findOne({_id: 0}), {_id: 0, a: [2, 1, 2]}); } @@ -606,7 +615,7 @@ if (db.getMongo().writeMode() === "commands") { // Include an implicit array traversal in a path in an update modifier. coll.drop(); -assert.writeOK(coll.insert({_id: 0, a: [{b: 0}]})); +assert.commandWorked(coll.insert({_id: 0, a: [{b: 0}]})); res = coll.update({_id: 0}, {$set: {"a.b": 1}}); assert.writeErrorWithCode(res, ErrorCodes.PathNotViable); assert.neq( @@ -633,7 +642,7 @@ if (db.getMongo().writeMode() === "commands") { "update failed for a reason other than bad array filter identifier: " + tojson(res.getWriteError())); - assert.writeOK(coll.insert({_id: 0, a: [0], b: [{j: 0}]})); + assert.commandWorked(coll.insert({_id: 0, a: [0], b: [{j: 0}]})); res = coll.update({_id: 0}, {$set: {"a.$[i.j]": 1, "b.$[i]": 1}}, {arrayFilters: [{"i.j": 0}]}); assert.writeErrorWithCode(res, ErrorCodes.PathNotViable); assert.neq( @@ -650,15 +659,15 @@ if (db.getMongo().writeMode() === "commands") { // "a.$[i].b.$[k].c" and "a.$[j].b.$[k].d" are not a conflict, even if i and j are not // disjoint. coll.drop(); - assert.writeOK(coll.insert({_id: 0, a: [{x: 0, b: [{y: 0, c: 0, d: 0}]}]})); - assert.writeOK(coll.update({_id: 0}, - {$set: {"a.$[i].b.$[k].c": 1, "a.$[j].b.$[k].d": 1}}, - {arrayFilters: [{"i.x": 0}, {"j.x": 0}, {"k.y": 0}]})); + assert.commandWorked(coll.insert({_id: 0, a: [{x: 0, b: [{y: 0, c: 0, d: 0}]}]})); + assert.commandWorked(coll.update({_id: 0}, + {$set: {"a.$[i].b.$[k].c": 1, "a.$[j].b.$[k].d": 1}}, + {arrayFilters: [{"i.x": 0}, {"j.x": 0}, {"k.y": 0}]})); assert.eq(coll.findOne({_id: 0}), {_id: 0, a: [{x: 0, b: [{y: 0, c: 1, d: 1}]}]}); // "a.$[i].b.$[k].c" and "a.$[j].b.$[k].c" are a conflict iff i and j are not disjoint. coll.drop(); - assert.writeOK( + assert.commandWorked( coll.insert({_id: 0, a: [{x: 0, b: [{y: 0, c: 0}]}, {x: 1, b: [{y: 0, c: 0}]}]})); res = coll.update({_id: 0}, @@ -669,16 +678,16 @@ if (db.getMongo().writeMode() === "commands") { res.getWriteError().errmsg.indexOf("Update created a conflict at 'a.0.b.$[k].c'"), "update failed for a reason other than conflicting array updates"); - assert.writeOK(coll.update({_id: 0}, - {$set: {"a.$[i].b.$[k].c": 1, "a.$[j].b.$[k].c": 2}}, - {arrayFilters: [{"i.x": 0}, {"j.x": 1}, {"k.y": 0}]})); + assert.commandWorked(coll.update({_id: 0}, + {$set: {"a.$[i].b.$[k].c": 1, "a.$[j].b.$[k].c": 2}}, + {arrayFilters: [{"i.x": 0}, {"j.x": 1}, {"k.y": 0}]})); assert.eq(coll.findOne({_id: 0}), {_id: 0, a: [{x: 0, b: [{y: 0, c: 1}]}, {x: 1, b: [{y: 0, c: 2}]}]}); // "a.$[i].b.$[k].c" and "a.$[j].b.$[m].c" are a conflict iff k and m intersect for some // element of a matching i and j. coll.drop(); - assert.writeOK(coll.insert( + assert.commandWorked(coll.insert( {_id: 0, a: [{x: 0, b: [{y: 0, c: 0}]}, {x: 1, b: [{y: 0, c: 0}, {y: 1, c: 0}]}]})); res = coll.update({_id: 0}, @@ -689,9 +698,10 @@ if (db.getMongo().writeMode() === "commands") { res.getWriteError().errmsg.indexOf("Update created a conflict at 'a.0.b.0.c'"), "update failed for a reason other than conflicting array updates"); - assert.writeOK(coll.update({_id: 0}, - {$set: {"a.$[i].b.$[k].c": 1, "a.$[j].b.$[m].c": 2}}, - {arrayFilters: [{"i.x": 1}, {"j.x": 1}, {"k.y": 0}, {"m.y": 1}]})); + assert.commandWorked( + coll.update({_id: 0}, + {$set: {"a.$[i].b.$[k].c": 1, "a.$[j].b.$[m].c": 2}}, + {arrayFilters: [{"i.x": 1}, {"j.x": 1}, {"k.y": 0}, {"m.y": 1}]})); assert.eq(coll.findOne({_id: 0}), {_id: 0, a: [{x: 0, b: [{y: 0, c: 0}]}, {x: 1, b: [{y: 0, c: 1}, {y: 1, c: 2}]}]}); } diff --git a/jstests/core/update_array_offset_positional.js b/jstests/core/update_array_offset_positional.js index 8e433831c01..210e4d65bb7 100644 --- a/jstests/core/update_array_offset_positional.js +++ b/jstests/core/update_array_offset_positional.js @@ -12,19 +12,19 @@ coll.drop(); // coll.drop(); -assert.writeOK(coll.insert({_id: 0, a: [0]})); +assert.commandWorked(coll.insert({_id: 0, a: [0]})); assert.writeError(coll.update({_id: 0, "a.0": 0}, {$set: {"a.$": 1}})); coll.drop(); -assert.writeOK(coll.insert({_id: 0, a: [{b: 0}]})); +assert.commandWorked(coll.insert({_id: 0, a: [{b: 0}]})); assert.writeError(coll.update({_id: 0, "a.0.b": 0}, {$set: {"a.$.b": 1}})); coll.drop(); -assert.writeOK(coll.insert({_id: 0, a: [[0]]})); +assert.commandWorked(coll.insert({_id: 0, a: [[0]]})); assert.writeError(coll.update({_id: 0, "a.0.0": 0}, {$set: {"a.$.0": 1}})); coll.drop(); -assert.writeOK(coll.insert({_id: 0, a: [{b: [0]}]})); +assert.commandWorked(coll.insert({_id: 0, a: [{b: [0]}]})); assert.writeError(coll.update({_id: 0, "a.0.b.0": 0}, {$set: {"a.$.b.0": 1}})); // @@ -33,13 +33,13 @@ assert.writeError(coll.update({_id: 0, "a.0.b.0": 0}, {$set: {"a.$.b.0": 1}})); // coll.drop(); -assert.writeOK(coll.insert({_id: 0, a: [{b: [0, 1]}]})); -assert.writeOK(coll.update({_id: 0, "a.0.b": 1}, {$set: {"a.0.b.$": 2}})); +assert.commandWorked(coll.insert({_id: 0, a: [{b: [0, 1]}]})); +assert.commandWorked(coll.update({_id: 0, "a.0.b": 1}, {$set: {"a.0.b.$": 2}})); assert.eq(coll.findOne({_id: 0}), {_id: 0, a: [{b: [0, 2]}]}); coll.drop(); -assert.writeOK(coll.insert({_id: 0, a: [{b: [0, 1]}]})); -assert.writeOK(coll.update({_id: 0, "a.b.1": 1}, {$set: {"a.$.b.1": 2}})); +assert.commandWorked(coll.insert({_id: 0, a: [{b: [0, 1]}]})); +assert.commandWorked(coll.update({_id: 0, "a.b.1": 1}, {$set: {"a.$.b.1": 2}})); assert.eq(coll.findOne({_id: 0}), {_id: 0, a: [{b: [0, 2]}]}); // @@ -48,22 +48,22 @@ assert.eq(coll.findOne({_id: 0}), {_id: 0, a: [{b: [0, 2]}]}); // coll.drop(); -assert.writeOK(coll.insert({_id: 0, a: [0, 1], b: [0]})); -assert.writeOK(coll.update({_id: 0, a: 1, "b.0": 0}, {$set: {"a.$": 2}})); +assert.commandWorked(coll.insert({_id: 0, a: [0, 1], b: [0]})); +assert.commandWorked(coll.update({_id: 0, a: 1, "b.0": 0}, {$set: {"a.$": 2}})); assert.eq(coll.findOne({_id: 0}), {_id: 0, a: [0, 2], b: [0]}); coll.drop(); -assert.writeOK(coll.insert({_id: 0, a: [0, 1], b: [{c: 0}]})); -assert.writeOK(coll.update({_id: 0, a: 1, "b.0.c": 0}, {$set: {"a.$": 2}})); +assert.commandWorked(coll.insert({_id: 0, a: [0, 1], b: [{c: 0}]})); +assert.commandWorked(coll.update({_id: 0, a: 1, "b.0.c": 0}, {$set: {"a.$": 2}})); assert.eq(coll.findOne({_id: 0}), {_id: 0, a: [0, 2], b: [{c: 0}]}); coll.drop(); -assert.writeOK(coll.insert({_id: 0, a: [0, 1], b: [[0]]})); -assert.writeOK(coll.update({_id: 0, a: 1, "b.0.0": 0}, {$set: {"a.$": 2}})); +assert.commandWorked(coll.insert({_id: 0, a: [0, 1], b: [[0]]})); +assert.commandWorked(coll.update({_id: 0, a: 1, "b.0.0": 0}, {$set: {"a.$": 2}})); assert.eq(coll.findOne({_id: 0}), {_id: 0, a: [0, 2], b: [[0]]}); coll.drop(); -assert.writeOK(coll.insert({_id: 0, a: [0, 1], b: [{c: [0]}]})); -assert.writeOK(coll.update({_id: 0, a: 1, "b.0.c.0": 0}, {$set: {"a.$": 2}})); +assert.commandWorked(coll.insert({_id: 0, a: [0, 1], b: [{c: [0]}]})); +assert.commandWorked(coll.update({_id: 0, a: 1, "b.0.c.0": 0}, {$set: {"a.$": 2}})); assert.eq(coll.findOne({_id: 0}), {_id: 0, a: [0, 2], b: [{c: [0]}]}); }()); diff --git a/jstests/core/update_arraymatch6.js b/jstests/core/update_arraymatch6.js index a32bbf3c7d7..ec318370561 100644 --- a/jstests/core/update_arraymatch6.js +++ b/jstests/core/update_arraymatch6.js @@ -10,7 +10,7 @@ t.drop(); function doTest() { t.save({a: [{id: 1, x: [5, 6, 7]}, {id: 2, x: [8, 9, 10]}]}); res = t.update({'a.id': 1}, {$set: {'a.$.x': [1, 1, 1]}}); - assert.writeOK(res); + assert.commandWorked(res); assert.eq.automsg("1", "t.findOne().a[ 0 ].x[ 0 ]"); } diff --git a/jstests/core/update_bit_examples.js b/jstests/core/update_bit_examples.js index 6545751aacd..0b8f868ea17 100644 --- a/jstests/core/update_bit_examples.js +++ b/jstests/core/update_bit_examples.js @@ -12,21 +12,21 @@ coll.drop(); coll.remove({}); coll.save({_id: 1, a: NumberInt(2)}); res = coll.update({}, {$bit: {a: {and: NumberInt(4)}}}); -assert.writeOK(res); +assert.commandWorked(res); assert.eq(coll.findOne().a, 0); // $bit or coll.remove({}); coll.save({_id: 1, a: NumberInt(2)}); res = coll.update({}, {$bit: {a: {or: NumberInt(4)}}}); -assert.writeOK(res); +assert.commandWorked(res); assert.eq(coll.findOne().a, 6); // $bit xor coll.remove({}); coll.save({_id: 1, a: NumberInt(0)}); res = coll.update({}, {$bit: {a: {xor: NumberInt(4)}}}); -assert.writeOK(res); +assert.commandWorked(res); assert.eq(coll.findOne().a, 4); // SERVER-19706 Empty bit operation. diff --git a/jstests/core/update_currentdate_examples.js b/jstests/core/update_currentdate_examples.js index 9cde5cad16e..e8a3da2ea09 100644 --- a/jstests/core/update_currentdate_examples.js +++ b/jstests/core/update_currentdate_examples.js @@ -12,19 +12,19 @@ coll.drop(); coll.remove({}); coll.save({_id: 1, a: 2}); res = coll.update({}, {$currentDate: {a: true}}); -assert.writeOK(res); +assert.commandWorked(res); assert(coll.findOne().a.constructor == Date); // $currentDate type = date coll.remove({}); coll.save({_id: 1, a: 2}); res = coll.update({}, {$currentDate: {a: {$type: "date"}}}); -assert.writeOK(res); +assert.commandWorked(res); assert(coll.findOne().a.constructor == Date); // $currentDate type = timestamp coll.remove({}); coll.save({_id: 1, a: 2}); res = coll.update({}, {$currentDate: {a: {$type: "timestamp"}}}); -assert.writeOK(res); +assert.commandWorked(res); assert(coll.findOne().a.constructor == Timestamp); diff --git a/jstests/core/update_min_max_examples.js b/jstests/core/update_min_max_examples.js index 3ec86705a1f..e8fa949811b 100644 --- a/jstests/core/update_min_max_examples.js +++ b/jstests/core/update_min_max_examples.js @@ -9,13 +9,13 @@ coll.drop(); // $min for number coll.insert({_id: 1, a: 2}); res = coll.update({_id: 1}, {$min: {a: 1}}); -assert.writeOK(res); +assert.commandWorked(res); assert.eq(coll.findOne({_id: 1}).a, 1); // $max for number coll.insert({_id: 2, a: 2}); res = coll.update({_id: 2}, {$max: {a: 1}}); -assert.writeOK(res); +assert.commandWorked(res); assert.eq(coll.findOne({_id: 2}).a, 2); // $min for Date @@ -36,7 +36,7 @@ date.setMilliseconds(date.getMilliseconds() + 2); // Test that we have advanced the date and it's no longer the same as the one we inserted. assert.eq(null, coll.findOne({_id: 4, a: date})); res = coll.update({_id: 4}, {$max: {a: date}}); -assert.writeOK(res); +assert.commandWorked(res); assert.eq(coll.findOne({_id: 4}).a, date); // $max for small number @@ -44,20 +44,20 @@ coll.insert({_id: 5, a: 1e-15}); // Slightly bigger than 1e-15. const biggerval = 0.000000000000001000000000000001; res = coll.update({_id: 5}, {$max: {a: biggerval}}); -assert.writeOK(res); +assert.commandWorked(res); assert.eq(coll.findOne({_id: 5}).a, biggerval); // $min for a small number coll.insert({_id: 6, a: biggerval}); res = coll.update({_id: 6}, {$min: {a: 1e-15}}); -assert.writeOK(res); +assert.commandWorked(res); assert.eq(coll.findOne({_id: 6}).a, 1e-15); // $max with positional operator let insertdoc = {_id: 7, y: [{a: 2}, {a: 6}, {a: [9, 1, 1]}]}; coll.insert(insertdoc); res = coll.update({_id: 7, "y.a": 6}, {$max: {"y.$.a": 7}}); -assert.writeOK(res); +assert.commandWorked(res); insertdoc.y[1].a = 7; assert.docEq(coll.findOne({_id: 7}), insertdoc); @@ -68,7 +68,7 @@ insertdoc = { }; coll.insert(insertdoc); res = coll.update({_id: 8, "y.a": 6}, {$min: {"y.$.a": 5}}); -assert.writeOK(res); +assert.commandWorked(res); insertdoc.y[1].a = 5; assert.docEq(coll.findOne({_id: 8}), insertdoc); }()); diff --git a/jstests/core/update_modifier_pop.js b/jstests/core/update_modifier_pop.js index 77c6bae702c..75d43fc5967 100644 --- a/jstests/core/update_modifier_pop.js +++ b/jstests/core/update_modifier_pop.js @@ -6,7 +6,7 @@ let coll = db.update_modifier_pop; coll.drop(); -assert.writeOK(coll.insert({_id: 0})); +assert.commandWorked(coll.insert({_id: 0})); // $pop with value of 0 fails to parse. assert.writeErrorWithCode(coll.update({_id: 0}, {$pop: {"a.b": 0}}), ErrorCodes.FailedToParse); @@ -24,49 +24,49 @@ assert.writeErrorWithCode(coll.update({_id: 0}, {$pop: {"a.b": 1.1}}), ErrorCode assert.writeErrorWithCode(coll.update({_id: 0}, {$pop: {a: {b: 1}}}), ErrorCodes.FailedToParse); // $pop is a no-op when the path does not exist. -let writeRes = assert.writeOK(coll.update({_id: 0}, {$pop: {"a.b": 1}})); +let writeRes = assert.commandWorked(coll.update({_id: 0}, {$pop: {"a.b": 1}})); assert.eq(writeRes.nMatched, 1); if (db.getMongo().writeMode() === "commands") { assert.eq(writeRes.nModified, 0); } // $pop is a no-op when the path partially exists. -assert.writeOK(coll.remove({})); -assert.writeOK(coll.insert({_id: 0, a: {c: 1}})); -writeRes = assert.writeOK(coll.update({_id: 0}, {$pop: {"a.b": 1}})); +assert.commandWorked(coll.remove({})); +assert.commandWorked(coll.insert({_id: 0, a: {c: 1}})); +writeRes = assert.commandWorked(coll.update({_id: 0}, {$pop: {"a.b": 1}})); assert.eq(writeRes.nMatched, 1); if (db.getMongo().writeMode() === "commands") { assert.eq(writeRes.nModified, 0); } // $pop fails when the path is blocked by a scalar element. -assert.writeOK(coll.remove({})); -assert.writeOK(coll.insert({_id: 0, a: {b: 1}})); +assert.commandWorked(coll.remove({})); +assert.commandWorked(coll.insert({_id: 0, a: {b: 1}})); assert.writeError(coll.update({_id: 0}, {$pop: {"a.b.c": 1}})); // $pop fails when the path is blocked by an array element. -assert.writeOK(coll.remove({})); -assert.writeOK(coll.insert({_id: 0, a: {b: [1, 2]}})); +assert.commandWorked(coll.remove({})); +assert.commandWorked(coll.insert({_id: 0, a: {b: [1, 2]}})); assert.writeError(coll.update({_id: 0}, {$pop: {"a.b.c": 1}})); // $pop fails when the path exists but is not an array. -assert.writeOK(coll.remove({})); -assert.writeOK(coll.insert({_id: 0, a: {b: {c: 1}}})); +assert.commandWorked(coll.remove({})); +assert.commandWorked(coll.insert({_id: 0, a: {b: {c: 1}}})); assert.writeError(coll.update({_id: 0}, {$pop: {"a.b": 1}})); // $pop is a no-op when the path contains an empty array. -assert.writeOK(coll.remove({})); -assert.writeOK(coll.insert({_id: 0, a: {b: []}})); -writeRes = assert.writeOK(coll.update({_id: 0}, {$pop: {"a.b": 1}})); +assert.commandWorked(coll.remove({})); +assert.commandWorked(coll.insert({_id: 0, a: {b: []}})); +writeRes = assert.commandWorked(coll.update({_id: 0}, {$pop: {"a.b": 1}})); assert.eq(writeRes.nMatched, 1); if (db.getMongo().writeMode() === "commands") { assert.eq(writeRes.nModified, 0); } // Successfully pop from the end of an array. -assert.writeOK(coll.remove({})); -assert.writeOK(coll.insert({_id: 0, a: {b: [1, 2, 3]}})); -writeRes = assert.writeOK(coll.update({_id: 0}, {$pop: {"a.b": 1}})); +assert.commandWorked(coll.remove({})); +assert.commandWorked(coll.insert({_id: 0, a: {b: [1, 2, 3]}})); +writeRes = assert.commandWorked(coll.update({_id: 0}, {$pop: {"a.b": 1}})); assert.eq(writeRes.nMatched, 1); if (db.getMongo().writeMode() === "commands") { assert.eq(writeRes.nModified, 1); @@ -74,7 +74,7 @@ if (db.getMongo().writeMode() === "commands") { assert.eq({_id: 0, a: {b: [1, 2]}}, coll.findOne()); // Successfully pop from the beginning of an array. -writeRes = assert.writeOK(coll.update({_id: 0}, {$pop: {"a.b": -1}})); +writeRes = assert.commandWorked(coll.update({_id: 0}, {$pop: {"a.b": -1}})); assert.eq(writeRes.nMatched, 1); if (db.getMongo().writeMode() === "commands") { assert.eq(writeRes.nModified, 1); @@ -82,29 +82,30 @@ if (db.getMongo().writeMode() === "commands") { assert.eq({_id: 0, a: {b: [2]}}, coll.findOne()); // $pop with the positional ($) operator. -assert.writeOK(coll.remove({})); -assert.writeOK(coll.insert({_id: 0, a: [{b: [1, 2, 3]}, {b: [4, 5, 6]}]})); -assert.writeOK(coll.update({_id: 0, "a.b": 5}, {$pop: {"a.$.b": 1}})); +assert.commandWorked(coll.remove({})); +assert.commandWorked(coll.insert({_id: 0, a: [{b: [1, 2, 3]}, {b: [4, 5, 6]}]})); +assert.commandWorked(coll.update({_id: 0, "a.b": 5}, {$pop: {"a.$.b": 1}})); assert.eq({_id: 0, a: [{b: [1, 2, 3]}, {b: [4, 5]}]}, coll.findOne()); // $pop with arrayFilters. if (db.getMongo().writeMode() === "commands") { - assert.writeOK(coll.remove({})); - assert.writeOK(coll.insert({_id: 0, a: [{b: [1, 2]}, {b: [4, 5]}, {b: [2, 3]}]})); - assert.writeOK(coll.update({_id: 0}, {$pop: {"a.$[i].b": -1}}, {arrayFilters: [{"i.b": 2}]})); + assert.commandWorked(coll.remove({})); + assert.commandWorked(coll.insert({_id: 0, a: [{b: [1, 2]}, {b: [4, 5]}, {b: [2, 3]}]})); + assert.commandWorked( + coll.update({_id: 0}, {$pop: {"a.$[i].b": -1}}, {arrayFilters: [{"i.b": 2}]})); assert.eq({_id: 0, a: [{b: [2]}, {b: [4, 5]}, {b: [3]}]}, coll.findOne()); } // $pop from a nested array. -assert.writeOK(coll.remove({})); -assert.writeOK(coll.insert({_id: 0, a: [1, [2, 3, 4]]})); -assert.writeOK(coll.update({_id: 0}, {$pop: {"a.1": 1}})); +assert.commandWorked(coll.remove({})); +assert.commandWorked(coll.insert({_id: 0, a: [1, [2, 3, 4]]})); +assert.commandWorked(coll.update({_id: 0}, {$pop: {"a.1": 1}})); assert.eq({_id: 0, a: [1, [2, 3]]}, coll.findOne()); // $pop is a no-op when array element in path does not exist. -assert.writeOK(coll.remove({})); -assert.writeOK(coll.insert({_id: 0, a: [{b: 0}, {b: 1}]})); -writeRes = assert.writeOK(coll.update({_id: 0}, {$pop: {"a.2.b": 1}})); +assert.commandWorked(coll.remove({})); +assert.commandWorked(coll.insert({_id: 0, a: [{b: 0}, {b: 1}]})); +writeRes = assert.commandWorked(coll.update({_id: 0}, {$pop: {"a.2.b": 1}})); assert.eq(writeRes.nMatched, 1); if (db.getMongo().writeMode() === "commands") { assert.eq(writeRes.nModified, 0); diff --git a/jstests/core/update_mul_examples.js b/jstests/core/update_mul_examples.js index 831bd257380..89a0ac70532 100644 --- a/jstests/core/update_mul_examples.js +++ b/jstests/core/update_mul_examples.js @@ -12,33 +12,33 @@ coll.drop(); coll.remove({}); coll.save({_id: 1, a: 2}); res = coll.update({}, {$mul: {a: 10}}); -assert.writeOK(res); +assert.commandWorked(res); assert.eq(coll.findOne().a, 20); // $mul negative coll.remove({}); coll.save({_id: 1, a: 2}); res = coll.update({}, {$mul: {a: -10}}); -assert.writeOK(res); +assert.commandWorked(res); assert.eq(coll.findOne().a, -20); // $mul zero coll.remove({}); coll.save({_id: 1, a: 2}); res = coll.update({}, {$mul: {a: 0}}); -assert.writeOK(res); +assert.commandWorked(res); assert.eq(coll.findOne().a, 0); // $mul decimal coll.remove({}); coll.save({_id: 1, a: 2}); res = coll.update({}, {$mul: {a: 1.1}}); -assert.writeOK(res); +assert.commandWorked(res); assert.eq(coll.findOne().a, 2.2); // $mul negative decimal coll.remove({}); coll.save({_id: 1, a: 2}); res = coll.update({}, {$mul: {a: -0.1}}); -assert.writeOK(res); +assert.commandWorked(res); assert.eq(coll.findOne().a, -0.2); diff --git a/jstests/core/update_multi5.js b/jstests/core/update_multi5.js index 8f797d8de2f..c8823ef1904 100644 --- a/jstests/core/update_multi5.js +++ b/jstests/core/update_multi5.js @@ -6,10 +6,11 @@ var t = db.update_multi5; t.drop(); -assert.writeOK(t.insert({path: 'r1', subscribers: [1, 2]})); -assert.writeOK(t.insert({path: 'r2', subscribers: [3, 4]})); +assert.commandWorked(t.insert({path: 'r1', subscribers: [1, 2]})); +assert.commandWorked(t.insert({path: 'r2', subscribers: [3, 4]})); -var res = assert.writeOK(t.update({}, {$addToSet: {subscribers: 5}}, {upsert: false, multi: true})); +var res = + assert.commandWorked(t.update({}, {$addToSet: {subscribers: 5}}, {upsert: false, multi: true})); assert.eq(res.nMatched, 2, tojson(res)); diff --git a/jstests/core/update_server-12848.js b/jstests/core/update_server-12848.js index 0f86e0135b3..9f14feb09cd 100644 --- a/jstests/core/update_server-12848.js +++ b/jstests/core/update_server-12848.js @@ -10,11 +10,11 @@ t.drop(); var orig = {"_id": 1, "a": [1, []]}; res = t.insert(orig); -assert.writeOK(res, "insert"); +assert.commandWorked(res, "insert"); assert.eq(orig, t.findOne()); res = t.update({"_id": 1}, {$addToSet: {"a.1": 1}}); -assert.writeOK(res, "update"); +assert.commandWorked(res, "update"); var updated = {"_id": 1, "a": [1, [1]]}; assert.eq(updated, t.findOne()); diff --git a/jstests/core/updatea.js b/jstests/core/updatea.js index dd54ed04b59..99938c433fa 100644 --- a/jstests/core/updatea.js +++ b/jstests/core/updatea.js @@ -13,22 +13,22 @@ orig = { }; res = t.save(orig); -assert.writeOK(res); +assert.commandWorked(res); // SERVER-181 res = t.update({}, {$set: {"a.0.x": 3}}); -assert.writeOK(res); +assert.commandWorked(res); orig.a[0].x = 3; assert.eq(orig, t.findOne(), "A1"); res = t.update({}, {$set: {"a.1.z": 17}}); -assert.writeOK(res); +assert.commandWorked(res); orig.a[1].z = 17; assert.eq(orig, t.findOne(), "A2"); // SERVER-273 res = t.update({}, {$unset: {"a.1.y": 1}}); -assert.writeOK(res); +assert.commandWorked(res); delete orig.a[1].y; assert.eq(orig, t.findOne(), "A3"); @@ -39,10 +39,10 @@ orig = { comments: [{name: "blah", rate_up: 0, rate_ups: []}] }; res = t.save(orig); -assert.writeOK(res); +assert.commandWorked(res); res = t.update({}, {$inc: {"comments.0.rate_up": 1}, $push: {"comments.0.rate_ups": 99}}); -assert.writeOK(res); +assert.commandWorked(res); orig.comments[0].rate_up++; orig.comments[0].rate_ups.push(99); assert.eq(orig, t.findOne(), "B1"); @@ -56,22 +56,22 @@ for (i = 0; i < 12; i++) orig.a.push(i); res = t.save(orig); -assert.writeOK(res); +assert.commandWorked(res); assert.eq(orig, t.findOne(), "C1"); res = t.update({}, {$inc: {"a.0": 1}}); -assert.writeOK(res); +assert.commandWorked(res); orig.a[0]++; assert.eq(orig, t.findOne(), "C2"); res = t.update({}, {$inc: {"a.10": 1}}); -assert.writeOK(res); +assert.commandWorked(res); orig.a[10]++; // SERVER-3218 t.drop(); t.insert({"a": {"c00": 1}, 'c': 2}); res = t.update({"c": 2}, {'$inc': {'a.c000': 1}}); -assert.writeOK(res); +assert.commandWorked(res); assert.eq({"c00": 1, "c000": 1}, t.findOne().a, "D1"); diff --git a/jstests/core/updateh.js b/jstests/core/updateh.js index 706f329d0e0..1fd3d62750d 100644 --- a/jstests/core/updateh.js +++ b/jstests/core/updateh.js @@ -12,7 +12,7 @@ t.drop(); t.insert({x: 1}); res = t.update({x: 1}, {$set: {y: 1}}); // ok -assert.writeOK(res); +assert.commandWorked(res); res = t.update({x: 1}, {$set: {$z: 1}}); // not ok assert.writeError(res); @@ -46,7 +46,7 @@ res = t.update({n: 0}, {$set: {"$secret.agent.x": 1}}); assert.writeError(res); res = t.update({n: 0}, {$set: {"secret.agent$": 1}}); -assert.writeOK(res); +assert.commandWorked(res); t.save({_id: 0, n: 0}); // Test that you cannot update database references into top level fields @@ -73,15 +73,15 @@ assert.writeError(res); // the correct case ( subdoc) // SERVER-3231 res = t.update({n: 0}, {$set: {x: {$ref: '1', $id: 1, $db: '1'}}}); -assert.writeOK(res); +assert.commandWorked(res); t.save({_id: 0, n: 0}); // Test that '$' can occur elsewhere in a field name. // SERVER-7557 res = t.update({n: 0}, {$set: {ke$sha: 1}}); -assert.writeOK(res); +assert.commandWorked(res); t.save({_id: 0, n: 0}); res = t.update({n: 0}, {$set: {more$$moreproblem$: 1}}); -assert.writeOK(res); +assert.commandWorked(res); t.save({_id: 0, n: 0}); diff --git a/jstests/core/updatel.js b/jstests/core/updatel.js index ce5bd4d5dc7..9990aa6c6f2 100644 --- a/jstests/core/updatel.js +++ b/jstests/core/updatel.js @@ -47,11 +47,11 @@ assert.eq([{_id: 0, a: [{b: {c: 1}}]}], t.find().toArray(), "No update occurred. t.drop(); t.insert({_id: 1, arr: [{a: "z", b: 1}]}); res = t.update({"arr.a": /^z$/}, {$set: {"arr.$.b": 2}}, false, true); -assert.writeOK(res); +assert.commandWorked(res); assert.eq(t.findOne().arr[0], {a: "z", b: 2}); t.drop(); t.insert({_id: 1, arr: [{a: "z", b: 1}, {a: "abc", b: 2}, {a: "lmn", b: 3}]}); res = t.update({"arr.a": /l/}, {$inc: {"arr.$.b": 2}}, false, true); -assert.writeOK(res); +assert.commandWorked(res); assert.eq(t.findOne().arr[2], {a: "lmn", b: 5}); diff --git a/jstests/core/upsert_and.js b/jstests/core/upsert_and.js index 111dc140b8f..8c13f9b63d4 100644 --- a/jstests/core/upsert_and.js +++ b/jstests/core/upsert_and.js @@ -9,34 +9,34 @@ coll = db.upsert4; coll.drop(); res = coll.update({_id: 1, $and: [{c: 1}, {d: 1}], a: 12}, {$inc: {y: 1}}, true); -assert.writeOK(res); +assert.commandWorked(res); assert.docEq(coll.findOne(), {_id: 1, c: 1, d: 1, a: 12, y: 1}); coll.remove({}); res = coll.update({$and: [{c: 1}, {d: 1}]}, {$setOnInsert: {_id: 1}}, true); -assert.writeOK(res); +assert.commandWorked(res); assert.docEq(coll.findOne(), {_id: 1, c: 1, d: 1}); coll.remove({}); res = coll.update({$and: [{c: 1}, {d: 1}, {$or: [{x: 1}]}]}, {$setOnInsert: {_id: 1}}, true); -assert.writeOK(res); +assert.commandWorked(res); assert.docEq(coll.findOne(), {_id: 1, c: 1, d: 1, x: 1}); coll.remove({}); res = coll.update({$and: [{c: 1}, {d: 1}], $or: [{x: 1}, {x: 2}]}, {$setOnInsert: {_id: 1}}, true); -assert.writeOK(res); +assert.commandWorked(res); assert.docEq(coll.findOne(), {_id: 1, c: 1, d: 1}); coll.remove({}); res = coll.update( {r: {$gt: 3}, $and: [{c: 1}, {d: 1}], $or: [{x: 1}, {x: 2}]}, {$setOnInsert: {_id: 1}}, true); -assert.writeOK(res); +assert.commandWorked(res); assert.docEq(coll.findOne(), {_id: 1, c: 1, d: 1}); coll.remove({}); res = coll.update( {r: /s/, $and: [{c: 1}, {d: 1}], $or: [{x: 1}, {x: 2}]}, {$setOnInsert: {_id: 1}}, true); -assert.writeOK(res); +assert.commandWorked(res); assert.docEq(coll.findOne(), {_id: 1, c: 1, d: 1}); coll.remove({}); diff --git a/jstests/core/upsert_fields.js b/jstests/core/upsert_fields.js index 3a76ac93cb1..c8944424bf8 100644 --- a/jstests/core/upsert_fields.js +++ b/jstests/core/upsert_fields.js @@ -17,7 +17,7 @@ var upsertedResult = function(query, expr) { }; var upsertedField = function(query, expr, fieldName) { - var res = assert.writeOK(upsertedResult(query, expr)); + var res = assert.commandWorked(upsertedResult(query, expr)); var doc = coll.findOne(); assert.neq(doc, null, "findOne query returned no results! UpdateRes: " + tojson(res)); return doc[fieldName]; diff --git a/jstests/core/verify_update_mods.js b/jstests/core/verify_update_mods.js index 134668e62bd..1bd9ccdc465 100644 --- a/jstests/core/verify_update_mods.js +++ b/jstests/core/verify_update_mods.js @@ -10,36 +10,36 @@ t.drop(); t.save({_id: 1}); res = t.update({}, {$set: {a: 1}}); -assert.writeOK(res); +assert.commandWorked(res); t.remove({}); t.save({_id: 1}); res = t.update({}, {$unset: {a: 1}}); -assert.writeOK(res); +assert.commandWorked(res); t.remove({}); t.save({_id: 1}); res = t.update({}, {$inc: {a: 1}}); -assert.writeOK(res); +assert.commandWorked(res); t.remove({}); t.save({_id: 1}); res = t.update({}, {$mul: {a: 1}}); -assert.writeOK(res); +assert.commandWorked(res); t.remove({}); t.save({_id: 1}); res = t.update({}, {$push: {a: 1}}); -assert.writeOK(res); +assert.commandWorked(res); t.remove({}); res = t.update({}, {$addToSet: {a: 1}}); -assert.writeOK(res); +assert.commandWorked(res); t.remove({}); t.save({_id: 1}); res = t.update({}, {$pull: {a: 1}}); -assert.writeOK(res); +assert.commandWorked(res); t.remove({}); t.save({_id: 1}); @@ -49,12 +49,12 @@ t.remove({}); t.save({_id: 1}); res = t.update({}, {$rename: {a: "b"}}); -assert.writeOK(res); +assert.commandWorked(res); t.remove({}); t.save({_id: 1}); res = t.update({}, {$bit: {a: {and: NumberLong(1)}}}); -assert.writeOK(res); +assert.commandWorked(res); t.remove({}); // SERVER-3223 test $bit can do an upsert @@ -68,15 +68,15 @@ t.remove({}); t.save({_id: 1}); res = t.update({}, {$currentDate: {a: true}}); -assert.writeOK(res); +assert.commandWorked(res); t.remove({}); t.save({_id: 1}); res = t.update({}, {$max: {a: 1}}); -assert.writeOK(res); +assert.commandWorked(res); t.remove({}); t.save({_id: 1}); res = t.update({}, {$min: {a: 1}}); -assert.writeOK(res); +assert.commandWorked(res); t.remove({}); diff --git a/jstests/core/views/duplicate_ns.js b/jstests/core/views/duplicate_ns.js index f7693549164..8b22e6769a4 100644 --- a/jstests/core/views/duplicate_ns.js +++ b/jstests/core/views/duplicate_ns.js @@ -14,9 +14,9 @@ const collName = "myns"; const viewId = dbName + "." + collName; assert.commandWorked(viewsDb.dropDatabase()); -assert.writeOK(viewsDb.system.views.remove({_id: viewId})); +assert.commandWorked(viewsDb.system.views.remove({_id: viewId})); assert.commandWorked(viewsDb.runCommand({create: collName})); -assert.writeOK(viewsDb.system.views.insert({ +assert.commandWorked(viewsDb.system.views.insert({ _id: viewId, viewOn: "coll", pipeline: [], diff --git a/jstests/core/views/invalid_system_views.js b/jstests/core/views/invalid_system_views.js index cdfd8240589..c4358a26dd2 100644 --- a/jstests/core/views/invalid_system_views.js +++ b/jstests/core/views/invalid_system_views.js @@ -20,12 +20,12 @@ function runTest(badViewDefinition) { assert.commandWorked(viewsDB.dropDatabase()); // Create a regular collection, then insert an invalid view into system.views. - assert.writeOK(viewsDB.collection.insert({x: 1})); + assert.commandWorked(viewsDB.collection.insert({x: 1})); assert.commandWorked(viewsDB.runCommand({create: "collection2"})); assert.commandWorked(viewsDB.runCommand({create: "collection3"})); assert.commandWorked(viewsDB.collection.createIndex({x: 1})); - assert.writeOK(viewsDB.system.views.insert(badViewDefinition), - "failed to insert " + tojson(badViewDefinition)); + assert.commandWorked(viewsDB.system.views.insert(badViewDefinition), + "failed to insert " + tojson(badViewDefinition)); // Test that a command involving views properly fails with a views-specific error code. assert.commandFailedWithCode( @@ -49,12 +49,12 @@ function runTest(badViewDefinition) { makeErrorMessage("applyOps")); } - assert.writeOK(viewsDB.collection.insert({y: "baz"}), makeErrorMessage("insert")); + assert.commandWorked(viewsDB.collection.insert({y: "baz"}), makeErrorMessage("insert")); - assert.writeOK(viewsDB.collection.update({y: "baz"}, {$set: {y: "qux"}}), - makeErrorMessage("update")); + assert.commandWorked(viewsDB.collection.update({y: "baz"}, {$set: {y: "qux"}}), + makeErrorMessage("update")); - assert.writeOK(viewsDB.collection.remove({y: "baz"}), makeErrorMessage("remove")); + assert.commandWorked(viewsDB.collection.remove({y: "baz"}), makeErrorMessage("remove")); assert.commandWorked( viewsDB.runCommand({findAndModify: "collection", query: {x: 1}, update: {x: 2}}), @@ -116,7 +116,7 @@ function runTest(badViewDefinition) { assert.commandWorked(viewsDB.runCommand({drop: "collection2"}), makeErrorMessage("drop")); // Drop the offending view so that the validate hook succeeds. - assert.writeOK(viewsDB.system.views.remove(badViewDefinition)); + assert.commandWorked(viewsDB.system.views.remove(badViewDefinition)); } runTest({_id: "invalid_system_views.badViewStringPipeline", viewOn: "collection", pipeline: "bad"}); diff --git a/jstests/core/views/views_aggregation.js b/jstests/core/views/views_aggregation.js index fb78211307f..db833937dda 100644 --- a/jstests/core/views/views_aggregation.js +++ b/jstests/core/views/views_aggregation.js @@ -44,7 +44,7 @@ let bulk = coll.initializeUnorderedBulkOp(); allDocuments.forEach(function(doc) { bulk.insert(doc); }); -assert.writeOK(bulk.execute()); +assert.commandWorked(bulk.execute()); // Create views on the data. assert.commandWorked(viewsDB.runCommand({create: "emptyPipelineView", viewOn: "coll"})); @@ -104,7 +104,7 @@ assert.commandWorked( viewsDB.invalidDocs.drop(); viewsDB.invalidDocsView.drop(); -assert.writeOK(viewsDB.invalidDocs.insert({illegalField: "present"})); +assert.commandWorked(viewsDB.invalidDocs.insert({illegalField: "present"})); assert.commandWorked(viewsDB.createView("invalidDocsView", "invalidDocs", [])); assert.commandWorked( @@ -122,7 +122,7 @@ const largeStrSize = 10 * 1024 * 1024; const largeStr = new Array(largeStrSize).join('x'); viewsDB.largeColl.drop(); for (let i = 0; i <= extSortLimit / largeStrSize; ++i) { - assert.writeOK(viewsDB.largeColl.insert({x: i, largeStr: largeStr})); + assert.commandWorked(viewsDB.largeColl.insert({x: i, largeStr: largeStr})); } assertErrorCode(viewsDB.largeColl, [{$sort: {x: -1}}], diff --git a/jstests/core/views/views_all_commands.js b/jstests/core/views/views_all_commands.js index 6fba75008b3..ca92980eba8 100644 --- a/jstests/core/views/views_all_commands.js +++ b/jstests/core/views/views_all_commands.js @@ -254,8 +254,8 @@ let viewsCommandTests = { getLog: {skip: isUnrelated}, getMore: { setup: function(conn) { - assert.writeOK(conn.collection.remove({})); - assert.writeOK(conn.collection.insert([{_id: 1}, {_id: 2}, {_id: 3}])); + assert.commandWorked(conn.collection.remove({})); + assert.commandWorked(conn.collection.insert([{_id: 1}, {_id: 2}, {_id: 3}])); }, command: function(conn) { function testGetMoreForCommand(cmd) { @@ -308,8 +308,8 @@ let viewsCommandTests = { isMaster: {skip: isUnrelated}, killCursors: { setup: function(conn) { - assert.writeOK(conn.collection.remove({})); - assert.writeOK(conn.collection.insert([{_id: 1}, {_id: 2}, {_id: 3}])); + assert.commandWorked(conn.collection.remove({})); + assert.commandWorked(conn.collection.insert([{_id: 1}, {_id: 2}, {_id: 3}])); }, command: function(conn) { // First get and check a partial result for an aggregate command. @@ -592,7 +592,7 @@ for (let command of commands) { // 'collection'. assert.commandWorked(dbHandle.dropDatabase()); assert.commandWorked(dbHandle.runCommand({create: "view", viewOn: "collection"})); - assert.writeOK(dbHandle.collection.insert({x: 1})); + assert.commandWorked(dbHandle.collection.insert({x: 1})); if (subtest.setup !== undefined) subtest.setup(dbHandle); diff --git a/jstests/core/views/views_basic.js b/jstests/core/views/views_basic.js index 1186dbcd779..0b4dcda6001 100644 --- a/jstests/core/views/views_basic.js +++ b/jstests/core/views/views_basic.js @@ -27,7 +27,7 @@ bulk.insert({_id: "Oakland", state: "CA", pop: 3}); bulk.insert({_id: "Palo Alto", state: "CA", pop: 10}); bulk.insert({_id: "San Francisco", state: "CA", pop: 4}); bulk.insert({_id: "Trenton", state: "NJ", pop: 5}); -assert.writeOK(bulk.execute()); +assert.commandWorked(bulk.execute()); // Test creating views on both collections and other views, using the database command and the // shell helper. diff --git a/jstests/core/views/views_change.js b/jstests/core/views/views_change.js index 94521013136..acb8253b963 100644 --- a/jstests/core/views/views_change.js +++ b/jstests/core/views/views_change.js @@ -42,7 +42,7 @@ resetCollectionAndViews(); // A view is updated when its viewOn is modified. When auth is enabled, we expect collMod to // fail when specifying "viewOn" but not "pipeline". -assert.writeOK(collection.insert(doc)); +assert.commandWorked(collection.insert(doc)); assertFindResultEq("view", [doc]); let res = viewDB.runCommand({collMod: "view", viewOn: "nonexistent"}); if (jsTest.options().auth) { @@ -56,8 +56,8 @@ resetCollectionAndViews(); // A view is updated when its pipeline is modified. When auth is enabled, we expect collMod to // fail when specifying "pipeline" but not "viewOn". -assert.writeOK(collection.insert(doc)); -assert.writeOK(collection.insert({a: 7})); +assert.commandWorked(collection.insert(doc)); +assert.commandWorked(collection.insert({a: 7})); assertFindResultEq("view", [doc]); res = viewDB.runCommand({collMod: "view", pipeline: [{$match: {a: {$gt: 4}}}]}); if (jsTest.options().auth) { @@ -70,15 +70,15 @@ if (jsTest.options().auth) { resetCollectionAndViews(); // A view is updated when the backing collection is updated. -assert.writeOK(collection.insert(doc)); +assert.commandWorked(collection.insert(doc)); assertFindResultEq("view", [doc]); -assert.writeOK(collection.update({a: 1}, {$set: {a: 2}})); +assert.commandWorked(collection.update({a: 1}, {$set: {a: 2}})); assertFindResultEq("view", []); resetCollectionAndViews(); // A view is updated when a backing view is updated. -assert.writeOK(collection.insert(doc)); +assert.commandWorked(collection.insert(doc)); assertFindResultEq("viewOnView", [doc]); assert.commandWorked(viewDB.runCommand( {collMod: "view", viewOn: "collection", pipeline: [{$match: {nonexistent: 1}}]})); @@ -87,7 +87,7 @@ assertFindResultEq("viewOnView", []); resetCollectionAndViews(); // A view appears empty if the backing collection is dropped. -assert.writeOK(collection.insert(doc)); +assert.commandWorked(collection.insert(doc)); assertFindResultEq("view", [doc]); assert.commandWorked(viewDB.runCommand({drop: "collection"})); assertFindResultEq("view", []); @@ -95,7 +95,7 @@ assertFindResultEq("view", []); resetCollectionAndViews(); // A view appears empty if a backing view is dropped. -assert.writeOK(collection.insert(doc)); +assert.commandWorked(collection.insert(doc)); assertFindResultEq("viewOnView", [doc]); assert.commandWorked(viewDB.runCommand({drop: "view"})); assertFindResultEq("viewOnView", []); diff --git a/jstests/core/views/views_collation.js b/jstests/core/views/views_collation.js index 9c18c27a41b..13eb65c3db7 100644 --- a/jstests/core/views/views_collation.js +++ b/jstests/core/views/views_collation.js @@ -468,9 +468,9 @@ assert.commandWorked(viewsDB.runCommand({ collation: {locale: "en", strength: 1} })); -assert.writeOK(viewsDB.case_sensitive_coll.insert({f: "case"})); -assert.writeOK(viewsDB.case_sensitive_coll.insert({f: "Case"})); -assert.writeOK(viewsDB.case_sensitive_coll.insert({f: "CASE"})); +assert.commandWorked(viewsDB.case_sensitive_coll.insert({f: "case"})); +assert.commandWorked(viewsDB.case_sensitive_coll.insert({f: "Case"})); +assert.commandWorked(viewsDB.case_sensitive_coll.insert({f: "CASE"})); let explain, cursorStage; diff --git a/jstests/core/views/views_count.js b/jstests/core/views/views_count.js index 8fa24191959..fa676fe6f02 100644 --- a/jstests/core/views/views_count.js +++ b/jstests/core/views/views_count.js @@ -14,7 +14,7 @@ let bulk = coll.initializeUnorderedBulkOp(); for (let i = 0; i < 10; i++) { bulk.insert({x: i}); } -assert.writeOK(bulk.execute()); +assert.commandWorked(bulk.execute()); // Create views on the data. assert.commandWorked(viewsDB.runCommand({create: "identityView", viewOn: "coll"})); diff --git a/jstests/core/views/views_distinct.js b/jstests/core/views/views_distinct.js index 8ef9e208a81..0f25ac3beb1 100644 --- a/jstests/core/views/views_distinct.js +++ b/jstests/core/views/views_distinct.js @@ -22,7 +22,7 @@ let bulk = coll.initializeUnorderedBulkOp(); allDocuments.forEach(function(doc) { bulk.insert(doc); }); -assert.writeOK(bulk.execute()); +assert.commandWorked(bulk.execute()); // Create views on the data. assert.commandWorked(viewsDB.runCommand({create: "identityView", viewOn: "coll"})); @@ -106,7 +106,7 @@ bulk = coll.initializeUnorderedBulkOp(); allDocuments.forEach(function(doc) { bulk.insert(doc); }); -assert.writeOK(bulk.execute()); +assert.commandWorked(bulk.execute()); assertIdentityViewDistinctMatchesCollection("a"); assertIdentityViewDistinctMatchesCollection("b"); diff --git a/jstests/core/views/views_drop.js b/jstests/core/views/views_drop.js index 2f0b9b7e62e..c1e6b20cf30 100644 --- a/jstests/core/views/views_drop.js +++ b/jstests/core/views/views_drop.js @@ -14,7 +14,7 @@ let viewsDB = db.getSiblingDB(viewsDBName); viewsDB.dropDatabase(); // Create collection and a view on it. -assert.writeOK(viewsDB.coll.insert({x: 1})); +assert.commandWorked(viewsDB.coll.insert({x: 1})); assert.commandWorked(viewsDB.createView("view", "coll", [])); assert.eq( viewsDB.view.find({}, {_id: 0}).toArray(), [{x: 1}], "couldn't find expected doc in view"); diff --git a/jstests/core/views/views_find.js b/jstests/core/views/views_find.js index 3a7f5f80ce6..1468870d40e 100644 --- a/jstests/core/views/views_find.js +++ b/jstests/core/views/views_find.js @@ -37,7 +37,7 @@ let bulk = coll.initializeUnorderedBulkOp(); allDocuments.forEach(function(doc) { bulk.insert(doc); }); -assert.writeOK(bulk.execute()); +assert.commandWorked(bulk.execute()); // Create views on the data. assert.commandWorked( @@ -93,7 +93,7 @@ assert.eq(explainPlan.executionStats.nReturned, 5); assert(explainPlan.executionStats.hasOwnProperty("allPlansExecution")); // Only simple 0 or 1 projections are allowed on views. -assert.writeOK(viewsDB.coll.insert({arr: [{x: 1}]})); +assert.commandWorked(viewsDB.coll.insert({arr: [{x: 1}]})); assert.commandFailedWithCode( viewsDB.runCommand({find: "identityView", projection: {arr: {$elemMatch: {x: 1}}}}), ErrorCodes.InvalidPipelineOperator); diff --git a/jstests/core/views/views_rename.js b/jstests/core/views/views_rename.js index 9d4f1238810..ee0d2bfbd11 100644 --- a/jstests/core/views/views_rename.js +++ b/jstests/core/views/views_rename.js @@ -14,7 +14,7 @@ let coll = db.getCollection(collName); db.view.drop(); coll.drop(); assert.commandWorked(db.createView("view", collName, [])); -assert.writeOK(coll.insert({_id: 1})); +assert.commandWorked(coll.insert({_id: 1})); assert.eq(db.view.find().count(), 1, "couldn't find document in view"); assert.commandWorked(db.system.views.renameCollection("views", /*dropTarget*/ true)); assert.eq(db.view.find().count(), diff --git a/jstests/core/views/views_stats.js b/jstests/core/views/views_stats.js index 28c5fa0b9a2..6f098955a00 100644 --- a/jstests/core/views/views_stats.js +++ b/jstests/core/views/views_stats.js @@ -69,10 +69,10 @@ if (lastTop === undefined) { } lastHistogram = getHistogramStats(view); -assert.writeOK(coll.insert({})); -assert.writeOK(coll.update({}, {$set: {x: 1}})); +assert.commandWorked(coll.insert({})); +assert.commandWorked(coll.update({}, {$set: {x: 1}})); coll.aggregate([{$match: {}}]); -assert.writeOK(coll.remove({})); +assert.commandWorked(coll.remove({})); assertTopDiffEq(view, lastTop, "insert", 0); assertTopDiffEq(view, lastTop, "update", 0); diff --git a/jstests/core/where4.js b/jstests/core/where4.js index a4997d07561..123afb2baaf 100644 --- a/jstests/core/where4.js +++ b/jstests/core/where4.js @@ -12,30 +12,30 @@ var myDB = db.getSiblingDB("where4"); myDB.dropDatabase(); -assert.writeOK(myDB.where4.insert({x: 1, y: 1})); -assert.writeOK(myDB.where4.insert({x: 2, y: 1})); +assert.commandWorked(myDB.where4.insert({x: 1, y: 1})); +assert.commandWorked(myDB.where4.insert({x: 2, y: 1})); -assert.writeOK(myDB.where4.update({ +assert.commandWorked(myDB.where4.update({ $where: function() { return this.x == 1; } }, - {$inc: {y: 1}}, - false, - true)); + {$inc: {y: 1}}, + false, + true)); assert.eq(2, myDB.where4.findOne({x: 1}).y); assert.eq(1, myDB.where4.findOne({x: 2}).y); // Test that where queries work with stored javascript -assert.writeOK(myDB.system.js.save({ +assert.commandWorked(myDB.system.js.save({ _id: "where4_addOne", value: function(x) { return x + 1; } })); -assert.writeOK( +assert.commandWorked( myDB.where4.update({$where: "where4_addOne(this.x) == 2"}, {$inc: {y: 1}}, false, true)); assert.eq(3, myDB.where4.findOne({x: 1}).y); |