0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-11-24 16:46:00 +01:00
mongodb/jstests/replsets/wtimeout_too_large.js
Moustafa Maher 2fd5f78d5a SERVER-95421 make initiateWithHighElectionTimeout the default in ReplSetTest (#28174)
GitOrigin-RevId: df168ee363c3f0e86526270437d3688ac4bb326d
2024-10-22 02:53:25 +00:00

30 lines
926 B
JavaScript

/**
* Test that the server rejects extremely large values for write concern wtimeout.
*/
import {ReplSetTest} from "jstests/libs/replsettest.js";
const rst = new ReplSetTest({name: jsTestName(), nodes: 2});
rst.startSet();
rst.initiate();
const dbName = "testdb";
const collName = "testcoll";
const primary = rst.getPrimary();
const primaryDB = primary.getDB(dbName);
const primaryColl = primaryDB.getCollection(collName);
jsTestLog("Issuing a write within accepted wtimeout bounds");
assert.commandWorked(
primaryColl.insert({a: 1}, {writeConcern: {w: 2, wtimeout: ReplSetTest.kDefaultTimeoutMS}}));
jsTestLog("Issuing a high wtimeout write and confirming that it gets rejected");
// Outside int32 bounds.
const oneTrillionMS = 1000 * 1000 * 1000 * 1000;
assert.commandFailedWithCode(
primaryColl.insert({b: 2}, {writeConcern: {w: 2, wtimeout: oneTrillionMS}}),
ErrorCodes.FailedToParse);
rst.stopSet();