diff options
author | Ted Tuckman <ted.tuckman@mongodb.com> | 2019-12-13 20:24:47 +0000 |
---|---|---|
committer | evergreen <evergreen@mongodb.com> | 2019-12-13 20:24:47 +0000 |
commit | 20f3aa60b55714839ad50be8cdb09f25d523fe29 (patch) | |
tree | cd9bb0ccbd3da57f1c5c24cb3edb135743a2e29c | |
parent | 299369cafdebe49a4222f481159dcf915eba71ba (diff) | |
download | mongo-20f3aa60b55714839ad50be8cdb09f25d523fe29.tar.gz |
SERVER-45076 Complete all TODOs left from agg map reduce knob removal
-rw-r--r-- | jstests/core/bypass_doc_validation.js | 28 | ||||
-rw-r--r-- | jstests/core/mr_agg_explain.js | 2 | ||||
-rw-r--r-- | jstests/core/mr_fail_invalid_js.js | 3 | ||||
-rw-r--r-- | jstests/core/mr_reduce_merge_other_db.js (renamed from jstests/core/mr_output_other_db.js) | 29 | ||||
-rw-r--r-- | jstests/core/mr_replace_into_other_db.js | 46 | ||||
-rw-r--r-- | jstests/sharding/commands_that_write_accept_wc_shards.js | 441 | ||||
-rw-r--r-- | jstests/sharding/mr_noscripting.js | 1 | ||||
-rw-r--r-- | jstests/sharding/safe_secondary_reads_drop_recreate.js | 47 |
8 files changed, 301 insertions, 296 deletions
diff --git a/jstests/core/bypass_doc_validation.js b/jstests/core/bypass_doc_validation.js index e5997fb3694..eb78df57754 100644 --- a/jstests/core/bypass_doc_validation.js +++ b/jstests/core/bypass_doc_validation.js @@ -108,9 +108,31 @@ function runBypassDocumentValidationTest(validator) { assert.commandWorked(res); assert.eq(1, outputColl.count({value: 'mapReduce'})); - // TODO SERVER-42511 Test the mapReduce command reading from a different database with output in - // this database which has the document validation. - + // Test the mapReduce command if it is reading from a different database and collection without + // validation. + const otherDb = myDb.getSisterDB("mr_second_input_db"); + const otherDbColl = otherDb.mr_second_input_coll; + assert.commandWorked(otherDbColl.insert({val: 1})); + outputColl.drop(); + assert.commandWorked(myDb.createCollection(outputCollName, {validator: validator})); + res = otherDb.runCommand({ + mapReduce: otherDbColl.getName(), + map: map, + reduce: reduce, + out: {replace: outputCollName, db: myDb.getName()}, + bypassDocumentValidation: false + }); + assertFailsValidation(res); + assert.eq(0, outputColl.count({value: 'mapReduce'})); + res = otherDb.runCommand({ + mapReduce: otherDbColl.getName(), + map: map, + reduce: reduce, + out: {replace: outputCollName, db: myDb.getName()}, + bypassDocumentValidation: true + }); + assert.commandWorked(res); + assert.eq(1, outputColl.count({value: 'mapReduce'})); // Test the insert command. Includes a test for a document with no _id (SERVER-20859). res = myDb.runCommand({insert: collName, documents: [{}], bypassDocumentValidation: false}); assertFailsValidation(BulkWriteResult(res)); diff --git a/jstests/core/mr_agg_explain.js b/jstests/core/mr_agg_explain.js index e2d4e92c955..17098f54ba8 100644 --- a/jstests/core/mr_agg_explain.js +++ b/jstests/core/mr_agg_explain.js @@ -1,6 +1,6 @@ /** * Tests that running mapReduce with explain behaves as expected. - * @tags: [incompatible_with_embedded] + * @tags: [incompatible_with_embedded, requires_fcv_44] */ (function() { "use strict"; diff --git a/jstests/core/mr_fail_invalid_js.js b/jstests/core/mr_fail_invalid_js.js index 01b422c1fe3..0bdef235bec 100644 --- a/jstests/core/mr_fail_invalid_js.js +++ b/jstests/core/mr_fail_invalid_js.js @@ -1,9 +1,12 @@ // Tests that mapReduce fails gracefully when given a map or reduce function which fails in some // way. +// MapReduce uses $merge to merge in 4.4 which errors on missing fields, so this test cannot be run +// in multiversion. // @tags: [ // # mapReduce does not support afterClusterTime. // does_not_support_causal_consistency, // does_not_support_stepdowns, +// requires_fcv_44, // uses_map_reduce_with_temp_collections, // ] (function() { diff --git a/jstests/core/mr_output_other_db.js b/jstests/core/mr_reduce_merge_other_db.js index 0ecd28ed0cb..9f5b2d7cf44 100644 --- a/jstests/core/mr_output_other_db.js +++ b/jstests/core/mr_reduce_merge_other_db.js @@ -25,28 +25,7 @@ const reduceFn = function(k, vs) { return Array.sum(vs); }; -// TODO SERVER-42511 we should fix up and call the functions in this file once we flip on the new -// implementation. -function testReplace() { - let res = assert.commandWorked( - coll.mapReduce(mapFn, reduceFn, {out: {replace: outCollStr, db: outDbStr}})); - const expected = - [{_id: 1, value: 1}, {_id: 2, value: 2}, {_id: 3, value: 2}, {_id: 4, value: 1}]; - let actual = outColl.find().sort({_id: 1}).toArray(); - assert.eq(expected, actual); - - assert.eq(res.result.collection, outCollStr, "Wrong collection " + res.result.collection); - assert.eq(res.result.db, outDbStr, "Wrong db " + res.result.db); - - // Run the whole thing again and make sure it does the same thing. - assert.commandWorked(outColl.insert({_id: 5, value: 1})); - assert.commandWorked( - coll.mapReduce(mapFn, reduceFn, {out: {replace: outCollStr, db: outDbStr}})); - actual = outColl.find().sort({_id: 1}).toArray(); - assert.eq(expected, actual); -} - -function testMerge() { +(function testMerge() { outColl.drop(); assert.commandWorked( outColl.insert([{_id: 1, value: "something else"}, {_id: 5, value: "existing"}])); @@ -61,9 +40,9 @@ function testMerge() { ]; let actual = outColl.find().sort({_id: 1}).toArray(); assert.eq(expected, actual); -} +})(); -function testReduce() { +(function testReduce() { outColl.drop(); assert.commandWorked(outColl.insert([{_id: 1, value: 100}, {_id: 5, value: 0}])); let res = assert.commandWorked( @@ -77,5 +56,5 @@ function testReduce() { ]; let actual = outColl.find().sort({_id: 1}).toArray(); assert.eq(expected, actual); -} +})(); }()); diff --git a/jstests/core/mr_replace_into_other_db.js b/jstests/core/mr_replace_into_other_db.js new file mode 100644 index 00000000000..274aeee3b3b --- /dev/null +++ b/jstests/core/mr_replace_into_other_db.js @@ -0,0 +1,46 @@ +// @tags: [ +// # mapReduce does not support afterClusterTime. +// does_not_support_causal_consistency, +// does_not_support_stepdowns, +// uses_map_reduce_with_temp_collections, +// assumes_unsharded_collection, +// ] +// +(function() { +"use strict"; + +const coll = db.mr_replace; +coll.drop(); + +assert.commandWorked(coll.insert([{a: [1, 2]}, {a: [2, 3]}, {a: [3, 4]}])); + +const outCollStr = "mr_replace_col"; +const outDbStr = "mr_db"; +const outDb = db.getMongo().getDB(outDbStr); +// insert into outDb so map reduce doesn't fail to find it. +assert.commandWorked(outDb.random_coll.insert({val: 1})); +const outColl = outDb[outCollStr]; + +const mapFn = function() { + for (i = 0; i < this.a.length; i++) + emit(this.a[i], 1); +}; +const reduceFn = function(k, vs) { + return Array.sum(vs); +}; + +let res = assert.commandWorked( + coll.mapReduce(mapFn, reduceFn, {out: {replace: outCollStr, db: outDbStr}})); +const expected = [{_id: 1, value: 1}, {_id: 2, value: 2}, {_id: 3, value: 2}, {_id: 4, value: 1}]; +let actual = outColl.find().sort({_id: 1}).toArray(); +assert.eq(expected, actual); + +assert.eq(res.result.collection, outCollStr, "Wrong collection " + res.result.collection); +assert.eq(res.result.db, outDbStr, "Wrong db " + res.result.db); + +// Run the whole thing again and make sure it does the same thing. +assert.commandWorked(outColl.insert({_id: 5, value: 1})); +assert.commandWorked(coll.mapReduce(mapFn, reduceFn, {out: {replace: outCollStr, db: outDbStr}})); +actual = outColl.find().sort({_id: 1}).toArray(); +assert.eq(expected, actual); +}()); diff --git a/jstests/sharding/commands_that_write_accept_wc_shards.js b/jstests/sharding/commands_that_write_accept_wc_shards.js index c9c0875499c..d5ef9c051c5 100644 --- a/jstests/sharding/commands_that_write_accept_wc_shards.js +++ b/jstests/sharding/commands_that_write_accept_wc_shards.js @@ -7,7 +7,7 @@ * * This test is labeled resource intensive because its total io_write is 58MB compared to a median * of 5MB across all sharding tests in wiredTiger. - * @tags: [resource_intensive] + * @tags: [resource_intensive, requires_fcv_44] */ load('jstests/libs/write_concern_util.js'); @@ -266,234 +266,231 @@ const reduce = function(key, values) { return count; }; -// TODO SERVER-42511: Remove with internalQueryUseAggMapReduce M/R feature flag. -if (TestData.setParameters.internalQueryUseAggMapReduce) { - // MapReduce on an unsharded collection. - commands.push({ - req: {mapReduce: collName, map: map, reduce: reduce, out: "foo"}, - setupFunc: function() { - coll.insert({x: -3, tags: ["a", "b"]}); - coll.insert({x: -7, tags: ["b", "c"]}); - coll.insert({x: 23, tags: ["c", "a"]}); - coll.insert({x: 27, tags: ["b", "c"]}); - }, - confirmFunc: function(writesExpected = true) { - if (writesExpected) { - assert.eq(db.foo.findOne({_id: 'a'}).value, 2); - assert.eq(db.foo.findOne({_id: 'b'}).value, 3); - assert.eq(db.foo.findOne({_id: 'c'}).value, 3); - db.foo.drop(); - } else { - assert.eq(0, db.foo.find().itcount()); - } - }, - admin: false, - // MapReduce with a replace output action is not expected to write on write concern error. - isExpectedToWriteOnWriteConcernFailure: false, - }); +// MapReduce on an unsharded collection. +commands.push({ + req: {mapReduce: collName, map: map, reduce: reduce, out: "foo"}, + setupFunc: function() { + coll.insert({x: -3, tags: ["a", "b"]}); + coll.insert({x: -7, tags: ["b", "c"]}); + coll.insert({x: 23, tags: ["c", "a"]}); + coll.insert({x: 27, tags: ["b", "c"]}); + }, + confirmFunc: function(writesExpected = true) { + if (writesExpected) { + assert.eq(db.foo.findOne({_id: 'a'}).value, 2); + assert.eq(db.foo.findOne({_id: 'b'}).value, 3); + assert.eq(db.foo.findOne({_id: 'c'}).value, 3); + db.foo.drop(); + } else { + assert.eq(0, db.foo.find().itcount()); + } + }, + admin: false, + // MapReduce with a replace output action is not expected to write on write concern error. + isExpectedToWriteOnWriteConcernFailure: false, +}); - // MapReduce on an unsharded collection with an output to a sharded collection. - commands.push({ - req: {mapReduce: collName, map: map, reduce: reduce, out: {merge: "foo", sharded: true}}, - setupFunc: function() { - db.adminCommand({enablesharding: db.toString()}); - assert.commandWorked(db.foo.createIndex({_id: "hashed"})); - st.shardColl(db.foo, {_id: "hashed"}, false); - coll.insert({x: -3, tags: ["a", "b"]}); - coll.insert({x: -7, tags: ["b", "c"]}); - coll.insert({x: 23, tags: ["c", "a"]}); - coll.insert({x: 27, tags: ["b", "c"]}); - }, - confirmFunc: function(writesExpected = true) { - if (writesExpected) { - assert.eq(db.foo.findOne({_id: 'a'}).value, 2); - assert.eq(db.foo.findOne({_id: 'b'}).value, 3); - assert.eq(db.foo.findOne({_id: 'c'}).value, 3); - db.foo.drop(); - } else { - assert.eq(0, db.foo.find().itcount()); - } - }, - admin: false, - isExpectedToWriteOnWriteConcernFailure: true, - }); +// MapReduce on an unsharded collection with an output to a sharded collection. +commands.push({ + req: {mapReduce: collName, map: map, reduce: reduce, out: {merge: "foo", sharded: true}}, + setupFunc: function() { + db.adminCommand({enablesharding: db.toString()}); + assert.commandWorked(db.foo.createIndex({_id: "hashed"})); + st.shardColl(db.foo, {_id: "hashed"}, false); + coll.insert({x: -3, tags: ["a", "b"]}); + coll.insert({x: -7, tags: ["b", "c"]}); + coll.insert({x: 23, tags: ["c", "a"]}); + coll.insert({x: 27, tags: ["b", "c"]}); + }, + confirmFunc: function(writesExpected = true) { + if (writesExpected) { + assert.eq(db.foo.findOne({_id: 'a'}).value, 2); + assert.eq(db.foo.findOne({_id: 'b'}).value, 3); + assert.eq(db.foo.findOne({_id: 'c'}).value, 3); + db.foo.drop(); + } else { + assert.eq(0, db.foo.find().itcount()); + } + }, + admin: false, + isExpectedToWriteOnWriteConcernFailure: true, +}); - // MapReduce on a sharded collection. - commands.push({ - req: {mapReduce: collName, map: map, reduce: reduce, out: "foo"}, - setupFunc: function() { - shardCollectionWithChunks(st, coll); - coll.insert({x: -3, tags: ["a", "b"]}); - coll.insert({x: -7, tags: ["b", "c"]}); - coll.insert({x: 23, tags: ["c", "a"]}); - coll.insert({x: 27, tags: ["b", "c"]}); - }, - confirmFunc: function(writesExpected = true) { - if (writesExpected) { - assert.eq(db.foo.findOne({_id: 'a'}).value, 2); - assert.eq(db.foo.findOne({_id: 'b'}).value, 3); - assert.eq(db.foo.findOne({_id: 'c'}).value, 3); - db.foo.drop(); - } else { - assert.eq(0, db.foo.find().itcount()); - } - }, - admin: false, - // MapReduce with a replace output action expected not to write on write concern error. - isExpectedToWriteOnWriteConcernFailure: false, - }); +// MapReduce on a sharded collection. +commands.push({ + req: {mapReduce: collName, map: map, reduce: reduce, out: "foo"}, + setupFunc: function() { + shardCollectionWithChunks(st, coll); + coll.insert({x: -3, tags: ["a", "b"]}); + coll.insert({x: -7, tags: ["b", "c"]}); + coll.insert({x: 23, tags: ["c", "a"]}); + coll.insert({x: 27, tags: ["b", "c"]}); + }, + confirmFunc: function(writesExpected = true) { + if (writesExpected) { + assert.eq(db.foo.findOne({_id: 'a'}).value, 2); + assert.eq(db.foo.findOne({_id: 'b'}).value, 3); + assert.eq(db.foo.findOne({_id: 'c'}).value, 3); + db.foo.drop(); + } else { + assert.eq(0, db.foo.find().itcount()); + } + }, + admin: false, + // MapReduce with a replace output action expected not to write on write concern error. + isExpectedToWriteOnWriteConcernFailure: false, +}); - // MapReduce from a sharded collection with merge to a sharded collection. - commands.push({ - req: {mapReduce: collName, map: map, reduce: reduce, out: {merge: "foo", sharded: true}}, - setupFunc: function() { - shardCollectionWithChunks(st, coll); - assert.commandWorked(db.foo.createIndex({_id: "hashed"})); - st.shardColl(db.foo, {_id: "hashed"}, false); - coll.insert({x: -3, tags: ["a", "b"]}); - coll.insert({x: -7, tags: ["b", "c"]}); - coll.insert({x: 23, tags: ["c", "a"]}); - coll.insert({x: 27, tags: ["b", "c"]}); - }, - confirmFunc: function(writesExpected = true) { - if (writesExpected) { - assert.eq(db.foo.findOne({_id: 'a'}).value, 2); - assert.eq(db.foo.findOne({_id: 'b'}).value, 3); - assert.eq(db.foo.findOne({_id: 'c'}).value, 3); - db.foo.drop(); - } else { - assert.eq(0, db.foo.find().itcount()); - } - }, - admin: false, - // When output action is "merge" writes to the output collection are expected to succeed, - // regardless of writeConcern error. - isExpectedToWriteOnWriteConcernFailure: true, - }); +// MapReduce from a sharded collection with merge to a sharded collection. +commands.push({ + req: {mapReduce: collName, map: map, reduce: reduce, out: {merge: "foo", sharded: true}}, + setupFunc: function() { + shardCollectionWithChunks(st, coll); + assert.commandWorked(db.foo.createIndex({_id: "hashed"})); + st.shardColl(db.foo, {_id: "hashed"}, false); + coll.insert({x: -3, tags: ["a", "b"]}); + coll.insert({x: -7, tags: ["b", "c"]}); + coll.insert({x: 23, tags: ["c", "a"]}); + coll.insert({x: 27, tags: ["b", "c"]}); + }, + confirmFunc: function(writesExpected = true) { + if (writesExpected) { + assert.eq(db.foo.findOne({_id: 'a'}).value, 2); + assert.eq(db.foo.findOne({_id: 'b'}).value, 3); + assert.eq(db.foo.findOne({_id: 'c'}).value, 3); + db.foo.drop(); + } else { + assert.eq(0, db.foo.find().itcount()); + } + }, + admin: false, + // When output action is "merge" writes to the output collection are expected to succeed, + // regardless of writeConcern error. + isExpectedToWriteOnWriteConcernFailure: true, +}); - // MapReduce on an unsharded collection, output to different database. - commands.push({ - req: {mapReduce: collName, map: map, reduce: reduce, out: {replace: "foo", db: "other"}}, - setupFunc: function() { - db.getSiblingDB("other").createCollection("foo"); - coll.insert({x: -3, tags: ["a", "b"]}); - coll.insert({x: -7, tags: ["b", "c"]}); - coll.insert({x: 23, tags: ["c", "a"]}); - coll.insert({x: 27, tags: ["b", "c"]}); - }, - confirmFunc: function(writesExpected = true) { - const otherDB = db.getSiblingDB("other"); - if (writesExpected) { - assert.eq(otherDB.foo.findOne({_id: 'a'}).value, 2); - assert.eq(otherDB.foo.findOne({_id: 'b'}).value, 3); - assert.eq(otherDB.foo.findOne({_id: 'c'}).value, 3); - otherDB.foo.drop(); - } else { - assert.eq(0, otherDB.foo.find().itcount()); - } - }, - admin: false, - // MapReduce with a replace output action is not expected to write on write concern error. - isExpectedToWriteOnWriteConcernFailure: false, - }); +// MapReduce on an unsharded collection, output to different database. +commands.push({ + req: {mapReduce: collName, map: map, reduce: reduce, out: {replace: "foo", db: "other"}}, + setupFunc: function() { + db.getSiblingDB("other").createCollection("foo"); + coll.insert({x: -3, tags: ["a", "b"]}); + coll.insert({x: -7, tags: ["b", "c"]}); + coll.insert({x: 23, tags: ["c", "a"]}); + coll.insert({x: 27, tags: ["b", "c"]}); + }, + confirmFunc: function(writesExpected = true) { + const otherDB = db.getSiblingDB("other"); + if (writesExpected) { + assert.eq(otherDB.foo.findOne({_id: 'a'}).value, 2); + assert.eq(otherDB.foo.findOne({_id: 'b'}).value, 3); + assert.eq(otherDB.foo.findOne({_id: 'c'}).value, 3); + otherDB.foo.drop(); + } else { + assert.eq(0, otherDB.foo.find().itcount()); + } + }, + admin: false, + // MapReduce with a replace output action is not expected to write on write concern error. + isExpectedToWriteOnWriteConcernFailure: false, +}); - // MapReduce on a sharded collection, output to a different database. - commands.push({ - req: {mapReduce: collName, map: map, reduce: reduce, out: {replace: "foo", db: "other"}}, - setupFunc: function() { - db.getSiblingDB("other").createCollection("foo"); - shardCollectionWithChunks(st, coll); - coll.insert({x: -3, tags: ["a", "b"]}); - coll.insert({x: -7, tags: ["b", "c"]}); - coll.insert({x: 23, tags: ["c", "a"]}); - coll.insert({x: 27, tags: ["b", "c"]}); - }, - confirmFunc: function(writesExpected = true) { - const otherDB = db.getSiblingDB("other"); - if (writesExpected) { - assert.eq(otherDB.foo.findOne({_id: 'a'}).value, 2); - assert.eq(otherDB.foo.findOne({_id: 'b'}).value, 3); - assert.eq(otherDB.foo.findOne({_id: 'c'}).value, 3); - otherDB.foo.drop(); - } else { - assert.eq(0, otherDB.foo.find().itcount()); - } - }, - admin: false, - // MapReduce with a replace output action expected not to write on write concern error. - isExpectedToWriteOnWriteConcernFailure: false, - }); +// MapReduce on a sharded collection, output to a different database. +commands.push({ + req: {mapReduce: collName, map: map, reduce: reduce, out: {replace: "foo", db: "other"}}, + setupFunc: function() { + db.getSiblingDB("other").createCollection("foo"); + shardCollectionWithChunks(st, coll); + coll.insert({x: -3, tags: ["a", "b"]}); + coll.insert({x: -7, tags: ["b", "c"]}); + coll.insert({x: 23, tags: ["c", "a"]}); + coll.insert({x: 27, tags: ["b", "c"]}); + }, + confirmFunc: function(writesExpected = true) { + const otherDB = db.getSiblingDB("other"); + if (writesExpected) { + assert.eq(otherDB.foo.findOne({_id: 'a'}).value, 2); + assert.eq(otherDB.foo.findOne({_id: 'b'}).value, 3); + assert.eq(otherDB.foo.findOne({_id: 'c'}).value, 3); + otherDB.foo.drop(); + } else { + assert.eq(0, otherDB.foo.find().itcount()); + } + }, + admin: false, + // MapReduce with a replace output action expected not to write on write concern error. + isExpectedToWriteOnWriteConcernFailure: false, +}); - // MapReduce on an unsharded collection with merge to a sharded collection in a different db. - commands.push({ - req: { - mapReduce: collName, - map: map, - reduce: reduce, - out: {merge: "foo", db: "other", sharded: true} - }, - setupFunc: function() { - const otherDB = db.getSiblingDB("other"); - otherDB.createCollection("foo"); - otherDB.adminCommand({enablesharding: otherDB.toString()}); - assert.commandWorked(otherDB.foo.createIndex({_id: "hashed"})); - st.shardColl(db.foo, {_id: "hashed"}, false); - coll.insert({x: -3, tags: ["a", "b"]}); - coll.insert({x: -7, tags: ["b", "c"]}); - coll.insert({x: 23, tags: ["c", "a"]}); - coll.insert({x: 27, tags: ["b", "c"]}); - }, - confirmFunc: function(writesExpected = true) { - const otherDB = db.getSiblingDB("other"); - if (writesExpected) { - assert.eq(otherDB.foo.findOne({_id: 'a'}).value, 2); - assert.eq(otherDB.foo.findOne({_id: 'b'}).value, 3); - assert.eq(otherDB.foo.findOne({_id: 'c'}).value, 3); - otherDB.foo.drop(); - } else { - assert.eq(0, otherDB.foo.find().itcount()); - } - }, - admin: false, - isExpectedToWriteOnWriteConcernFailure: true, - }); +// MapReduce on an unsharded collection with merge to a sharded collection in a different db. +commands.push({ + req: { + mapReduce: collName, + map: map, + reduce: reduce, + out: {merge: "foo", db: "other", sharded: true} + }, + setupFunc: function() { + const otherDB = db.getSiblingDB("other"); + otherDB.createCollection("foo"); + otherDB.adminCommand({enablesharding: otherDB.toString()}); + assert.commandWorked(otherDB.foo.createIndex({_id: "hashed"})); + st.shardColl(db.foo, {_id: "hashed"}, false); + coll.insert({x: -3, tags: ["a", "b"]}); + coll.insert({x: -7, tags: ["b", "c"]}); + coll.insert({x: 23, tags: ["c", "a"]}); + coll.insert({x: 27, tags: ["b", "c"]}); + }, + confirmFunc: function(writesExpected = true) { + const otherDB = db.getSiblingDB("other"); + if (writesExpected) { + assert.eq(otherDB.foo.findOne({_id: 'a'}).value, 2); + assert.eq(otherDB.foo.findOne({_id: 'b'}).value, 3); + assert.eq(otherDB.foo.findOne({_id: 'c'}).value, 3); + otherDB.foo.drop(); + } else { + assert.eq(0, otherDB.foo.find().itcount()); + } + }, + admin: false, + isExpectedToWriteOnWriteConcernFailure: true, +}); - // MapReduce from a sharded collection with merge to a sharded collection in different db. - commands.push({ - req: { - mapReduce: collName, - map: map, - reduce: reduce, - out: {merge: "foo", db: "other", sharded: true} - }, - setupFunc: function() { - shardCollectionWithChunks(st, coll); - const otherDB = db.getSiblingDB("other"); - otherDB.createCollection("foo"); - assert.commandWorked(otherDB.foo.createIndex({_id: "hashed"})); - st.shardColl(otherDB.foo, {_id: "hashed"}, false); - coll.insert({x: -3, tags: ["a", "b"]}); - coll.insert({x: -7, tags: ["b", "c"]}); - coll.insert({x: 23, tags: ["c", "a"]}); - coll.insert({x: 27, tags: ["b", "c"]}); - }, - confirmFunc: function(writesExpected = true) { - const otherDB = db.getSiblingDB("other"); - if (writesExpected) { - assert.eq(otherDB.foo.findOne({_id: 'a'}).value, 2); - assert.eq(otherDB.foo.findOne({_id: 'b'}).value, 3); - assert.eq(otherDB.foo.findOne({_id: 'c'}).value, 3); - otherDB.foo.drop(); - } else { - assert.eq(0, otherDB.foo.find().itcount()); - } - }, - admin: false, - // When output action is "merge" writes to the output collection are expected to succeed, - // regardless of writeConcern error. - isExpectedToWriteOnWriteConcernFailure: true, - }); -} +// MapReduce from a sharded collection with merge to a sharded collection in different db. +commands.push({ + req: { + mapReduce: collName, + map: map, + reduce: reduce, + out: {merge: "foo", db: "other", sharded: true} + }, + setupFunc: function() { + shardCollectionWithChunks(st, coll); + const otherDB = db.getSiblingDB("other"); + otherDB.createCollection("foo"); + assert.commandWorked(otherDB.foo.createIndex({_id: "hashed"})); + st.shardColl(otherDB.foo, {_id: "hashed"}, false); + coll.insert({x: -3, tags: ["a", "b"]}); + coll.insert({x: -7, tags: ["b", "c"]}); + coll.insert({x: 23, tags: ["c", "a"]}); + coll.insert({x: 27, tags: ["b", "c"]}); + }, + confirmFunc: function(writesExpected = true) { + const otherDB = db.getSiblingDB("other"); + if (writesExpected) { + assert.eq(otherDB.foo.findOne({_id: 'a'}).value, 2); + assert.eq(otherDB.foo.findOne({_id: 'b'}).value, 3); + assert.eq(otherDB.foo.findOne({_id: 'c'}).value, 3); + otherDB.foo.drop(); + } else { + assert.eq(0, otherDB.foo.find().itcount()); + } + }, + admin: false, + // When output action is "merge" writes to the output collection are expected to succeed, + // regardless of writeConcern error. + isExpectedToWriteOnWriteConcernFailure: true, +}); function testValidWriteConcern(cmd) { cmd.req.writeConcern = {w: 'majority', wtimeout: 5 * 60 * 1000}; diff --git a/jstests/sharding/mr_noscripting.js b/jstests/sharding/mr_noscripting.js index bfca188f0b0..dd4c2d83f9b 100644 --- a/jstests/sharding/mr_noscripting.js +++ b/jstests/sharding/mr_noscripting.js @@ -26,7 +26,6 @@ const reduceFn = function(key, values) { return 1; }; -// TODO SERVER-42511 Remove the usage of internalQueryUseAggMapReduce. assert.commandFailedWithCode( testDB.runCommand({mapreduce: 'bar', map: mapFn, reduce: reduceFn, out: {inline: 1}}), 31264); diff --git a/jstests/sharding/safe_secondary_reads_drop_recreate.js b/jstests/sharding/safe_secondary_reads_drop_recreate.js index dc7f395e6b9..036d70d302b 100644 --- a/jstests/sharding/safe_secondary_reads_drop_recreate.js +++ b/jstests/sharding/safe_secondary_reads_drop_recreate.js @@ -13,8 +13,8 @@ * - checkResults: A function that asserts whether the command should succeed or fail. If the * command is expected to succeed, the function should assert the expected results * *when the the collection has been dropped and recreated as empty.* - * - behavior: Must be one of "unshardedOnly", "targetsPrimaryUsesConnectionVersioning" or - * "versioned". Determines what system profiler checks are performed. + * - behavior: Must be "unshardedOnly", or "versioned". Determines what system profiler checks are + * performed. * * Tagged as 'requires_fcv_44', since this test cannot run against versions less then 4.4. This is * because 'planCacheListPlans' and 'planCacheListQueryShapes' were deleted in 4.4, and thus not @@ -40,9 +40,7 @@ let validateTestCase = function(test) { assert(test.setUp && typeof (test.setUp) === "function"); assert(test.command && typeof (test.command) === "object"); assert(test.checkResults && typeof (test.checkResults) === "function"); - assert(test.behavior === "unshardedOnly" || - test.behavior === "targetsPrimaryUsesConnectionVersioning" || - test.behavior === "versioned"); + assert(test.behavior === "unshardedOnly" || test.behavior === "versioned"); }; let testCases = { @@ -346,19 +344,6 @@ let scenarios = { if (test.behavior === "unshardedOnly") { profilerHasZeroMatchingEntriesOrThrow( {profileDB: primaryShardSecondary.getDB(db), filter: commandProfile}); - } else if (test.behavior === "targetsPrimaryUsesConnectionVersioning") { - // Check that the primary shard primary received the request without a shardVersion - // field and returned success. - profilerHasSingleMatchingEntryOrThrow({ - profileDB: primaryShardPrimary.getDB(db), - filter: Object.extend({ - "command.shardVersion": {"$exists": false}, - "command.$readPreference": {$exists: false}, - "command.readConcern": {"level": "local"}, - "errCode": {"$exists": false} - }, - commandProfile) - }); } else if (test.behavior == "versioned") { // Check that the primary shard secondary returned stale shardVersion. profilerHasSingleMatchingEntryOrThrow({ @@ -416,19 +401,6 @@ let scenarios = { if (test.behavior === "unshardedOnly") { profilerHasZeroMatchingEntriesOrThrow( {profileDB: primaryShardSecondary.getDB(db), filter: commandProfile}); - } else if (test.behavior === "targetsPrimaryUsesConnectionVersioning") { - // Check that the primary shard primary received the request without a shardVersion - // field and returned success. - profilerHasSingleMatchingEntryOrThrow({ - profileDB: primaryShardPrimary.getDB(db), - filter: Object.extend({ - "command.shardVersion": {"$exists": false}, - "command.$readPreference": {$exists: false}, - "command.readConcern": {"level": "local"}, - "errCode": {"$exists": false}, - }, - commandProfile) - }); } else if (test.behavior == "versioned") { // Check that the primary shard secondary returned stale shardVersion. profilerHasSingleMatchingEntryOrThrow({ @@ -500,19 +472,6 @@ let scenarios = { {profileDB: donorShardSecondary.getDB(db), filter: commandProfile}); profilerHasZeroMatchingEntriesOrThrow( {profileDB: recipientShardSecondary.getDB(db), filter: commandProfile}); - } else if (test.behavior === "targetsPrimaryUsesConnectionVersioning") { - // Check that the recipient shard primary received the request without a - // shardVersion field and returned success. - profilerHasSingleMatchingEntryOrThrow({ - profileDB: recipientShardPrimary.getDB(db), - filter: Object.extend({ - "command.shardVersion": {"$exists": false}, - "command.$readPreference": {$exists: false}, - "command.readConcern": {"level": "local"}, - "errCode": {"$exists": false}, - }, - commandProfile) - }); } else if (test.behavior == "versioned") { // Check that the donor shard secondary returned stale shardVersion. profilerHasSingleMatchingEntryOrThrow({ |