Files
mongo/jstests/core/aggregation_accepts_write_concern.js
2019-07-27 11:02:23 -04:00

32 lines
950 B
JavaScript

/**
* Confirms that the aggregate command accepts writeConcern regardless of whether the pipeline
* writes or is read-only.
* @tags: [assumes_write_concern_unchanged, does_not_support_stepdowns]
*/
(function() {
"use strict";
const testDB = db.getSiblingDB("aggregation_accepts_write_concern");
assert.commandWorked(testDB.dropDatabase());
const collName = "test";
assert.commandWorked(
testDB.runCommand({insert: collName, documents: [{_id: 1}], writeConcern: {w: "majority"}}));
// A read-only aggregation accepts writeConcern.
assert.commandWorked(testDB.runCommand({
aggregate: collName,
pipeline: [{$match: {_id: 1}}],
cursor: {},
writeConcern: {w: "majority"}
}));
// An aggregation pipeline that writes accepts writeConcern.
assert.commandWorked(testDB.runCommand({
aggregate: collName,
pipeline: [{$match: {_id: 1}}, {$out: collName + "_out"}],
cursor: {},
writeConcern: {w: "majority"}
}));
})();