diff options
author | William Schultz <william.schultz@mongodb.com> | 2016-11-21 10:52:28 -0500 |
---|---|---|
committer | Judah Schvimer <judah@mongodb.com> | 2016-12-28 15:26:17 -0500 |
commit | d623f873409bba46b82454ee03140f67274363a7 (patch) | |
tree | a33718546a7e844ccc0067d39c41b518190946ad /jstests/libs | |
parent | 4075543b3ef659c26798e291615d5271438b7fc2 (diff) | |
download | mongo-d623f873409bba46b82454ee03140f67274363a7.tar.gz |
SERVER-27024 Added test for stepdown needs majority behavior
(cherry picked from commit 48741605f13b278f3c51bfc11660bd0a2dbb498b)
Diffstat (limited to 'jstests/libs')
-rw-r--r-- | jstests/libs/write_concern_util.js | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/jstests/libs/write_concern_util.js b/jstests/libs/write_concern_util.js new file mode 100644 index 00000000000..476a9c3e818 --- /dev/null +++ b/jstests/libs/write_concern_util.js @@ -0,0 +1,47 @@ +/** + * Utilities for testing writeConcern. + */ +// Stops replication at a server. +function stopServerReplication(conn) { + var errMsg = 'Failed to enable rsSyncApplyStop failpoint.'; + assert.commandWorked( + conn.getDB('admin').runCommand({configureFailPoint: 'rsSyncApplyStop', mode: 'alwaysOn'}), + errMsg); +} + +// Stops replication at all replicaset secondaries. +function stopReplicationOnSecondaries(rs) { + var secondaries = rs.getSecondaries(); + secondaries.forEach(stopServerReplication); +} + +// Stops replication at all shard secondaries. +function stopReplicationOnSecondariesOfAllShards(st) { + st._rsObjects.forEach(stopReplicationOnSecondaries); +} + +// Restarts replication at a server. +function restartServerReplication(conn) { + var errMsg = 'Failed to disable rsSyncApplyStop failpoint.'; + assert.commandWorked( + conn.getDB('admin').runCommand({configureFailPoint: 'rsSyncApplyStop', mode: 'off'}), + errMsg); +} + +// Restarts replication at all nodes in a replicaset. +function restartReplSetReplication(rs) { + rs.nodes.forEach(restartServerReplication); +} + +// Restarts replication at all nodes in a sharded cluster. +function restartReplicationOnAllShards(st) { + st._rsObjects.forEach(restartReplSetReplication); + restartReplSetReplication(st.configRS); +} + +// Asserts that a writeConcernError was received. +function assertWriteConcernError(res) { + assert(res.writeConcernError, "No writeConcernError received, got: " + tojson(res)); + assert(res.writeConcernError.code); + assert(res.writeConcernError.errmsg); +} |