summaryrefslogtreecommitdiff
path: root/jstests
diff options
context:
space:
mode:
authorEsha Maharishi <esha.maharishi@mongodb.com>2018-12-17 15:39:49 -0500
committerEsha Maharishi <esha.maharishi@mongodb.com>2018-12-18 10:25:57 -0500
commit679094ff6ea0bf8fab574f141f402601836fcd48 (patch)
tree5c469a5c10a88a423d5c8814abe80422bca144cf /jstests
parent9449da9e4d99d6a6140ee3eb1bc1261b00f9a905 (diff)
downloadmongo-679094ff6ea0bf8fab574f141f402601836fcd48.tar.gz
SERVER-38645 txn_basic_two_phase_commit.js and txn_failover_two_phase_commit.js should not check the RAMLog, since the RAMLog rotates the lines out after 1024 lines
Diffstat (limited to 'jstests')
-rw-r--r--jstests/sharding/libs/sharded_transactions_helpers.js7
-rw-r--r--jstests/sharding/txn_basic_two_phase_commit.js10
-rw-r--r--jstests/sharding/txn_failover_two_phase_commit.js24
3 files changed, 28 insertions, 13 deletions
diff --git a/jstests/sharding/libs/sharded_transactions_helpers.js b/jstests/sharding/libs/sharded_transactions_helpers.js
index 8b88ae98315..b0e24aaf71a 100644
--- a/jstests/sharding/libs/sharded_transactions_helpers.js
+++ b/jstests/sharding/libs/sharded_transactions_helpers.js
@@ -40,3 +40,10 @@ function assertNoSuchTransactionOnConn(conn, lsid, txnNumber) {
tojson(lsid) + ", txnNumber: " + tojson(txnNumber) +
", connection: " + tojson(conn));
}
+
+function waitForFailpoint(hitFailpointStr, numTimes) {
+ assert.soon(function() {
+ const re = new RegExp(hitFailpointStr, 'g' /* find all occurrences */);
+ return (rawMongoProgramOutput().match(re) || []).length == numTimes;
+ }, 'Failed to find "' + hitFailpointStr + '" logged ' + numTimes + ' times');
+}
diff --git a/jstests/sharding/txn_basic_two_phase_commit.js b/jstests/sharding/txn_basic_two_phase_commit.js
index 736d3ee7811..7fd70635e35 100644
--- a/jstests/sharding/txn_basic_two_phase_commit.js
+++ b/jstests/sharding/txn_basic_two_phase_commit.js
@@ -8,7 +8,7 @@
(function() {
'use strict';
- load("jstests/libs/check_log.js");
+ load('jstests/sharding/libs/sharded_transactions_helpers.js');
const dbName = "test";
const collName = "foo";
@@ -195,9 +195,8 @@
}
// Check that the coordinator wrote the participant list.
- checkLog.containsWithCount(coordinator,
- "Hit hangBeforeWaitingForParticipantListWriteConcern failpoint",
- txnNumber);
+ waitForFailpoint("Hit hangBeforeWaitingForParticipantListWriteConcern failpoint",
+ txnNumber);
checkParticipantListMatches(coordinator, lsid, txnNumber, expectedParticipantList);
assert.commandWorked(coordinator.adminCommand({
configureFailPoint: "hangBeforeWaitingForParticipantListWriteConcern",
@@ -205,8 +204,7 @@
}));
// Check that the coordinator wrote the decision.
- checkLog.containsWithCount(
- coordinator, "Hit hangBeforeWaitingForDecisionWriteConcern failpoint", txnNumber);
+ waitForFailpoint("Hit hangBeforeWaitingForDecisionWriteConcern failpoint", txnNumber);
checkParticipantListMatches(coordinator, lsid, txnNumber, expectedParticipantList);
checkDecisionIs(coordinator, lsid, txnNumber, (shouldCommit ? "commit" : "abort"));
assert.commandWorked(coordinator.adminCommand({
diff --git a/jstests/sharding/txn_failover_two_phase_commit.js b/jstests/sharding/txn_failover_two_phase_commit.js
index 64a39dbed28..f0881715ee7 100644
--- a/jstests/sharding/txn_failover_two_phase_commit.js
+++ b/jstests/sharding/txn_failover_two_phase_commit.js
@@ -9,7 +9,7 @@
(function() {
'use strict';
- load("jstests/libs/check_log.js");
+ load('jstests/sharding/libs/sharded_transactions_helpers.js');
const dbName = "test";
const collName = "foo";
@@ -21,6 +21,8 @@
// the transaction timeout.
TestData.transactionLifetimeLimitSeconds = 15;
+ let failpointCounter = 0;
+
const runTest = function(sameNodeStepsUpAfterFailover) {
jsTest.log("Testing all scenarios with sameNodeStepsUpAfterFailover: " +
@@ -152,7 +154,7 @@
}
// Wait for the desired failpoint to be hit.
- checkLog.contains(coordPrimary, "Hit " + failpoint + " failpoint");
+ waitForFailpoint("Hit " + failpoint + " failpoint", failpointCounter);
// Induce the coordinator primary to step down.
const stepDownResult = assert.throws(function() {
@@ -169,11 +171,6 @@
// The router should retry commitTransaction against the new primary.
awaitResult();
- // Clear RAMLog on this node so that we can use checkLog again. Otherwise, the next
- // checkLog against this node will see the log line from the previous test case and not
- // wait for a new log line.
- coordinatorReplSetTest.restart(coordPrimary);
-
// Check that the transaction committed or aborted as expected.
if (expectAbortResponse) {
jsTest.log("Verify that the transaction was aborted on all shards.");
@@ -193,6 +190,12 @@
st.s.getDB(dbName).getCollection(collName).drop();
};
+ //
+ // Run through all the failpoints when one participant responds to prepare with vote abort.
+ //
+
+ ++failpointCounter;
+
testCommitProtocol(true /* make a participant abort */,
"hangBeforeWritingParticipantList",
true /* expect abort decision */);
@@ -203,6 +206,12 @@
"hangBeforeDeletingCoordinatorDoc",
true /* expect abort decision */);
+ //
+ // Run through all the failpoints when all participants respond to prepare with vote commit.
+ //
+
+ ++failpointCounter;
+
// Note: If the coordinator fails over before making the participant list durable, the
// transaction will abort even if all participants could have committed. Further note that
// this is a property of the coordinator only - in general, the coordinator is co-located
@@ -214,6 +223,7 @@
testCommitProtocol(false /* all participants can commit */,
"hangBeforeWritingParticipantList",
true /* expect abort decision */);
+
testCommitProtocol(false /* all participants can commit */,
"hangBeforeWritingDecision",
false /* expect commit decision */);