mirror of
https://github.com/mongodb/mongo.git
synced 2024-11-30 00:56:44 +01:00
SERVER-46997 Test $out, $merge, non-inline mapReduce fail when sent to a secondary with primary read pref
This commit is contained in:
parent
526e5bcf9e
commit
ee48bf3b43
@ -49,5 +49,26 @@ for (let readMode of ["commands", "legacy"]) {
|
||||
}
|
||||
}
|
||||
|
||||
function assertNotMasterNoSlaveOk(func) {
|
||||
secDB.getMongo().forceReadMode("commands");
|
||||
secDB.getMongo().setSlaveOk(false);
|
||||
secDB.getMongo().setReadPref("primary");
|
||||
const res = assert.throws(func);
|
||||
assert.commandFailedWithCode(res, ErrorCodes.NotMasterNoSlaveOk);
|
||||
}
|
||||
|
||||
// Test that agg with $out/$merge and non-inline mapReduce fail with 'NotMasterNoSlaveOk' when
|
||||
// directed at a secondary with "primary" read preference.
|
||||
const secondaryColl = secDB.slaveok_read_pref;
|
||||
assertNotMasterNoSlaveOk(() => secondaryColl.aggregate([{$out: "target"}]).itcount());
|
||||
assertNotMasterNoSlaveOk(
|
||||
() =>
|
||||
secondaryColl
|
||||
.aggregate([{$merge: {into: "target", whenMatched: "fail", whenNotMatched: "insert"}}])
|
||||
.itcount());
|
||||
assertNotMasterNoSlaveOk(() => secondaryColl.mapReduce(() => emit(this.a),
|
||||
(k, v) => Array.sum(b),
|
||||
{out: {replace: "target"}}));
|
||||
|
||||
rst.stopSet();
|
||||
})();
|
||||
})();
|
||||
|
Loading…
Reference in New Issue
Block a user