summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJudah Schvimer <judah@mongodb.com>2017-04-17 10:02:12 -0400
committerTess Avitabile <tess.avitabile@mongodb.com>2019-02-22 11:51:21 -0500
commit308c006003937ef496f24c7e12676c007a185cd2 (patch)
treed9f1fa4498281aad76e026d5bcb0f04ee78c9d8b
parentf69dc2d3637dd1fb8de8d11c2a03289a5c31fceb (diff)
downloadmongo-308c006003937ef496f24c7e12676c007a185cd2.tar.gz
SERVER-28053 allow network errors when turning off rollbackHangBeforeStart failpoint
(cherry picked from commit 148c0031f517117a39e0c260051169b2831d5e64)
-rw-r--r--jstests/replsets/double_rollback_early.js4
-rw-r--r--jstests/replsets/read_committed_stale_history.js4
-rw-r--r--jstests/replsets/rollback_too_new.js8
-rw-r--r--jstests/replsets/rollback_with_socket_error_then_steady_state.js4
-rw-r--r--jstests/replsets/stepdown.js10
-rw-r--r--src/mongo/shell/assert.js16
-rw-r--r--src/mongo/shell/replsettest.js8
7 files changed, 25 insertions, 29 deletions
diff --git a/jstests/replsets/double_rollback_early.js b/jstests/replsets/double_rollback_early.js
index 07757270593..11ceb4fefa2 100644
--- a/jstests/replsets/double_rollback_early.js
+++ b/jstests/replsets/double_rollback_early.js
@@ -130,8 +130,8 @@
// It should fail with a rbid error and get stuck.
jsTestLog("Repartition to: [0,3,4] and [1,2].");
nodes[1].reconnect(nodes[2]);
- assert.commandWorked(
- nodes[2].adminCommand({configureFailPoint: 'rollbackHangBeforeStart', mode: 'off'}));
+ assert.adminCommandWorkedAllowingNetworkError(
+ nodes[2], {configureFailPoint: 'rollbackHangBeforeStart', mode: 'off'});
jsTestLog("Wait for node 2 exit ROLLBACK state and go into RECOVERING");
waitForState(nodes[2], ReplSetTest.State.RECOVERING);
diff --git a/jstests/replsets/read_committed_stale_history.js b/jstests/replsets/read_committed_stale_history.js
index 1129e0118d9..424e0d838ce 100644
--- a/jstests/replsets/read_committed_stale_history.js
+++ b/jstests/replsets/read_committed_stale_history.js
@@ -127,8 +127,8 @@
checkDocNotCommitted(nodes[0], {a: 2});
jsTest.log("Allow the original primary to roll back its write and catch up to the new primary");
- assert.commandWorked(
- nodes[0].adminCommand({configureFailPoint: 'rollbackHangBeforeStart', mode: 'off'}));
+ assert.adminCommandWorkedAllowingNetworkError(
+ nodes[0], {configureFailPoint: 'rollbackHangBeforeStart', mode: 'off'});
assert.soonNoExcept(function() {
return null == nodes[0].getDB(dbName).getCollection(collName).findOne({a: 2});
diff --git a/jstests/replsets/rollback_too_new.js b/jstests/replsets/rollback_too_new.js
index 4e216a6028d..131d80a54fe 100644
--- a/jstests/replsets/rollback_too_new.js
+++ b/jstests/replsets/rollback_too_new.js
@@ -43,13 +43,7 @@
// We bump the term to make sure node 0's oplog is ahead of node 2's.
var term = getLatestOp(conns[0]).t;
- try {
- assert.commandWorked(conns[0].adminCommand({replSetStepDown: 1, force: true}));
- } catch (e) {
- if (!isNetworkError(e)) {
- throw e;
- }
- }
+ assert.adminCommandWorkedAllowingNetworkError(conns[0], {replSetStepDown: 1, force: true});
// After stepping down due to the higher term, it will eventually get reelected.
replTest.waitForState(conns[0], ReplSetTest.State.PRIMARY);
diff --git a/jstests/replsets/rollback_with_socket_error_then_steady_state.js b/jstests/replsets/rollback_with_socket_error_then_steady_state.js
index 8dcea725885..33f6fdf2684 100644
--- a/jstests/replsets/rollback_with_socket_error_then_steady_state.js
+++ b/jstests/replsets/rollback_with_socket_error_then_steady_state.js
@@ -106,8 +106,8 @@
nodes[4].reconnect(nodes[2]);
// Turn off failpoint on node 2 to allow rollback against node 1 to fail with a network error.
- assert.commandWorked(
- nodes[2].adminCommand({configureFailPoint: 'rollbackHangBeforeStart', mode: 'off'}));
+ assert.adminCommandWorkedAllowingNetworkError(
+ nodes[2], {configureFailPoint: 'rollbackHangBeforeStart', mode: 'off'});
// Make node 0 ahead of node 2 again so node 2 will pick it as a sync source.
diff --git a/jstests/replsets/stepdown.js b/jstests/replsets/stepdown.js
index 6213e47bede..5f222025f18 100644
--- a/jstests/replsets/stepdown.js
+++ b/jstests/replsets/stepdown.js
@@ -107,15 +107,7 @@ master = replTest.getPrimary();
var firstMaster = master;
print("\nmaster is now " + firstMaster);
-try {
- assert.commandWorked(master.getDB("admin").runCommand({replSetStepDown: 100, force: true}));
-} catch (e) {
- // ignore errors due to connection failures as we expect the master to close connections
- // on stepdown
- if (!isNetworkError(e)) {
- throw e;
- }
-}
+assert.adminCommandWorkedAllowingNetworkError(master, {replSetStepDown: 100, force: true});
print("\nget a master");
replTest.getPrimary();
diff --git a/src/mongo/shell/assert.js b/src/mongo/shell/assert.js
index 2ce8e1e3dce..07529431834 100644
--- a/src/mongo/shell/assert.js
+++ b/src/mongo/shell/assert.js
@@ -250,6 +250,22 @@ assert.retryNoExcept = function(func, msg, num_attempts, intervalMS) {
assert.retry(safeFunc, msg, num_attempts, intervalMS);
};
+/**
+ * Runs the given command on the 'admin' database of the provided node. Asserts that the command
+ * worked but allows network errors to occur.
+ */
+assert.adminCommandWorkedAllowingNetworkError = function(node, commandObj) {
+ try {
+ assert.commandWorked(node.adminCommand(commandObj));
+ } catch (e) {
+ // Ignore errors due to connection failures.
+ if (!isNetworkError(e)) {
+ throw e;
+ }
+ print("Caught network error: " + tojson(e));
+ }
+};
+
assert.time = function(f, msg, timeout /*ms*/) {
if (assert._debug && msg)
print("in assert for: " + msg);
diff --git a/src/mongo/shell/replsettest.js b/src/mongo/shell/replsettest.js
index 0e677ee79b1..3ad7d0e8a35 100644
--- a/src/mongo/shell/replsettest.js
+++ b/src/mongo/shell/replsettest.js
@@ -910,13 +910,7 @@ var ReplSetTest = function(opts) {
this._setDefaultConfigOptions(config);
- try {
- assert.commandWorked(this.getPrimary().adminCommand({replSetReconfig: config}));
- } catch (e) {
- if (!isNetworkError(e)) {
- throw e;
- }
- }
+ assert.adminCommandWorkedAllowingNetworkError(this.getPrimary(), {replSetReconfig: config});
};
/**