diff options
author | Kyle Suarez <kyle.suarez@mongodb.com> | 2018-08-28 11:00:26 -0400 |
---|---|---|
committer | Kyle Suarez <kyle.suarez@mongodb.com> | 2018-08-28 11:00:26 -0400 |
commit | 15d627c3b7b9b1b2ca4d2f729102f730a0568c1c (patch) | |
tree | b1d9e72bcc62e982117e63e56f4283b7894162a3 /jstests/core/views | |
parent | 3ef3a0de876f16e8fcc6a49f8e0056849b10a24e (diff) | |
download | mongo-15d627c3b7b9b1b2ca4d2f729102f730a0568c1c.tar.gz |
SERVER-13201 support $out to foreign database
Allows $out to write to a database foreign to the aggregation namespace
when the mode is "insertDocuments" or "replaceDocuments"
Diffstat (limited to 'jstests/core/views')
-rw-r--r-- | jstests/core/views/views_aggregation.js | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/jstests/core/views/views_aggregation.js b/jstests/core/views/views_aggregation.js index 0ee368c4e24..112e8c963a9 100644 --- a/jstests/core/views/views_aggregation.js +++ b/jstests/core/views/views_aggregation.js @@ -73,8 +73,32 @@ assertAggResultEq("popSortedView", [], allDocuments.sort(byPopulation), doOrderedSort); assertAggResultEq("popSortedView", [{$limit: 1}, {$project: {_id: 1}}], [{_id: "Palo Alto"}]); - // Test that the $out stage errors when given a view namespace. + // Test that the $out stage errors when writing to a view namespace. assertErrorCode(coll, [{$out: "emptyPipelineView"}], ErrorCodes.CommandNotSupportedOnView); + assertErrorCode(coll, + [{$out: {to: "emptyPipelineView", mode: "replaceCollection"}}], + ErrorCodes.CommandNotSupportedOnView); + assertErrorCode(coll, + [{$out: {to: "emptyPipelineView", mode: "insertDocuments"}}], + ErrorCodes.CommandNotSupportedOnView); + assertErrorCode(coll, + [{$out: {to: "emptyPipelineView", mode: "replaceDocuments"}}], + ErrorCodes.CommandNotSupportedOnView); + + // Test that the $out stage errors when writing to a view namespace in a foreign database. + let foreignDB = db.getSiblingDB("views_aggregation_foreign"); + foreignDB.view.drop(); + assert.commandWorked(foreignDB.createView("view", "coll", [])); + assertErrorCode(coll, + [{$out: {db: foreignDB.getName(), to: "view", mode: "insertDocuments"}}], + ErrorCodes.CommandNotSupportedOnView); + assertErrorCode(coll, + [{$out: {db: foreignDB.getName(), to: "view", mode: "replaceDocuments"}}], + ErrorCodes.CommandNotSupportedOnView); + // TODO (SERVER-36832): When $out to foreign database is allowed with "replaceCollection", this + // should fail with ErrorCodes.CommandNotSupportedOnView. + assertErrorCode( + coll, [{$out: {db: foreignDB.getName(), to: "view", mode: "replaceCollection"}}], 50939); // Test that an aggregate on a view propagates the 'bypassDocumentValidation' option. const validatedCollName = "collectionWithValidator"; |