diff options
author | Jamie Heppenstall <jamie.heppenstall@mongodb.com> | 2019-08-01 15:29:16 -0400 |
---|---|---|
committer | Jamie Heppenstall <jamie.heppenstall@mongodb.com> | 2019-08-13 16:30:10 -0400 |
commit | 4605de0e64aa4e57487e620f91e5de52615a1941 (patch) | |
tree | 717983da77f949e5b37f0a8fb61b48c38e9100c1 | |
parent | b81e081faab34d7deae06b4b837f2a1ba5b8360d (diff) | |
download | mongo-4605de0e64aa4e57487e620f91e5de52615a1941.tar.gz |
SERVER-40496 Include namespace in configureFailpoint commands in transactions_snapshot_errors_subsequent_statements.js and transactions_writes_not_retryable.js
(cherry picked from commit ed4709c4b0d3c34bd085fdfe4f1b54557956080f)
3 files changed, 32 insertions, 9 deletions
diff --git a/jstests/sharding/libs/sharded_transactions_helpers.js b/jstests/sharding/libs/sharded_transactions_helpers.js index dc49b839e30..a25eef6e7f8 100644 --- a/jstests/sharding/libs/sharded_transactions_helpers.js +++ b/jstests/sharding/libs/sharded_transactions_helpers.js @@ -42,16 +42,29 @@ function getCoordinatorFailpoints() { return coordinatorFailpointDataArr.map(failpoint => Object.assign({}, failpoint)); } -function setFailCommandOnShards(st, mode, commands, code, numShards) { +function setFailCommandOnShards(st, mode, commands, code, numShards, ns) { for (let i = 0; i < numShards; i++) { const shardConn = st["rs" + i].getPrimary(); // Sharding tests require failInternalCommands: true, since the mongos appears to mongod to // be an internal client. - assert.commandWorked(shardConn.adminCommand({ - configureFailPoint: "failCommand", - mode: mode, - data: {errorCode: code, failCommands: commands, failInternalCommands: true} - })); + if (ns) { + assert.commandWorked(shardConn.adminCommand({ + configureFailPoint: "failCommand", + mode: mode, + data: { + namespace: ns, + errorCode: code, + failCommands: commands, + failInternalCommands: true + } + })); + } else { + assert.commandWorked(shardConn.adminCommand({ + configureFailPoint: "failCommand", + mode: mode, + data: {errorCode: code, failCommands: commands, failInternalCommands: true} + })); + } } } diff --git a/jstests/sharding/transactions_snapshot_errors_subsequent_statements.js b/jstests/sharding/transactions_snapshot_errors_subsequent_statements.js index e83ef670708..d3ac5f6e15c 100644 --- a/jstests/sharding/transactions_snapshot_errors_subsequent_statements.js +++ b/jstests/sharding/transactions_snapshot_errors_subsequent_statements.js @@ -59,7 +59,7 @@ function runTest(st, collName, errorCode, isSharded) { assert.commandWorked(sessionDB.runCommand({find: collName, filter: {_id: 15}})); // Verify the command must fail on a snapshot error from a subsequent statement. - setFailCommandOnShards(st, {times: 1}, [commandName], errorCode, 1); + setFailCommandOnShards(st, {times: 1}, [commandName], errorCode, 1, ns); const res = assert.commandFailedWithCode(sessionDB.runCommand(commandBody), errorCode); assert.eq(res.errorLabels, ["TransientTransactionError"]); diff --git a/jstests/sharding/transactions_writes_not_retryable.js b/jstests/sharding/transactions_writes_not_retryable.js index e6782394ec7..99dc2155469 100644 --- a/jstests/sharding/transactions_writes_not_retryable.js +++ b/jstests/sharding/transactions_writes_not_retryable.js @@ -20,7 +20,12 @@ function runTest(st, session, sessionDB, writeCmdName, writeCmd, isSharded) { assert.commandWorked(st.rs0.getPrimary().adminCommand({ configureFailPoint: "failCommand", mode: {times: 1}, - data: {errorCode: retryableError, failCommands: [writeCmdName], failInternalCommands: true} + data: { + namespace: ns, + errorCode: retryableError, + failCommands: [writeCmdName], + failInternalCommands: true + } })); session.startTransaction(); @@ -36,7 +41,12 @@ function runTest(st, session, sessionDB, writeCmdName, writeCmd, isSharded) { assert.commandWorked(st.rs0.getPrimary().adminCommand({ configureFailPoint: "failCommand", mode: {times: 1}, - data: {closeConnection: true, failCommands: [writeCmdName], failInternalCommands: true} + data: { + namespace: ns, + closeConnection: true, + failCommands: [writeCmdName], + failInternalCommands: true + } })); session.startTransaction(); |