0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-11-24 16:46:00 +01:00
mongodb/jstests/replsets/replsettest_stop_with_default_rwc.js
Matt Broadstone 771dabd098 SERVER-81339 Convert ReplSetTest and ShardingTest to modules (#26332)
GitOrigin-RevId: 744aa110a53786b23c62ff53f87a1418b5991e8d
2024-08-20 22:00:49 +00:00

26 lines
983 B
JavaScript

/**
* Tests that none of the operations in the ReplSetTest consistency checks are affected by
* changing the default read or write concern during the test itself.
*/
import {ReplSetTest} from "jstests/libs/replsettest.js";
const name = jsTestName();
// We need to have at least 2 nodes to run the data consistency checks.
const rst = new ReplSetTest({name: name, nodes: 2});
rst.startSet();
rst.initiate();
// Deliberately set a write concern and read concern that are different from the default w:1 and
// local values.
// The write concern is unsatisfiable, so any operations run in the shutdown hooks will fail if
// they inherit it.
assert.commandWorked(rst.getPrimary().adminCommand({
setDefaultRWConcern: 1,
defaultWriteConcern: {w: 42},
defaultReadConcern: {level: "majority"}
}));
// It should always be possible to successfully stop the replset (including running consistency
// checks) even when the default write concern is unsatisfiable.
rst.stopSet();