summaryrefslogtreecommitdiff
path: root/jstests
diff options
context:
space:
mode:
authorDianna <dianna.hohensee@10gen.com>2019-04-17 11:44:14 -0400
committerDianna <dianna.hohensee@10gen.com>2019-04-22 13:38:12 -0400
commit96bf04156c9a78446f6b5dea988888427e032a2f (patch)
treeff2984d9f49b3df5cfee60e744831f703b794ed0 /jstests
parentb10765d357743ed050c886be582f63fc9d2d08d8 (diff)
downloadmongo-96bf04156c9a78446f6b5dea988888427e032a2f.tar.gz
SERVER-38165 Enable transactions testing with the inMemory storage engine
Diffstat (limited to 'jstests')
-rw-r--r--jstests/noPassthrough/readConcern_snapshot.js3
-rw-r--r--jstests/replsets/commit_transaction_recovery.js2
-rw-r--r--jstests/replsets/inmemory_preserves_active_txns.js23
-rw-r--r--jstests/replsets/recover_multiple_prepared_transactions_startup.js2
-rw-r--r--jstests/replsets/recovery_preserves_active_txns.js2
-rw-r--r--jstests/replsets/startup_recovery_commit_transaction_before_stable_timestamp.js4
-rw-r--r--jstests/replsets/startup_recovery_reconstructs_txn_prepared_before_stable_ts.js4
7 files changed, 26 insertions, 14 deletions
diff --git a/jstests/noPassthrough/readConcern_snapshot.js b/jstests/noPassthrough/readConcern_snapshot.js
index b208cf4d715..c649af2aa54 100644
--- a/jstests/noPassthrough/readConcern_snapshot.js
+++ b/jstests/noPassthrough/readConcern_snapshot.js
@@ -17,8 +17,7 @@
let session =
rst.getPrimary().getDB(dbName).getMongo().startSession({causalConsistency: false});
let sessionDb = session.getDatabase(dbName);
- if (!sessionDb.serverStatus().storageEngine.supportsSnapshotReadConcern ||
- !sessionDb.serverStatus().storageEngine.persistent) {
+ if (!sessionDb.serverStatus().storageEngine.supportsSnapshotReadConcern) {
// Transactions with readConcern snapshot fail.
session.startTransaction({readConcern: {level: "snapshot"}});
assert.commandFailedWithCode(sessionDb.runCommand({find: collName}),
diff --git a/jstests/replsets/commit_transaction_recovery.js b/jstests/replsets/commit_transaction_recovery.js
index dea4b96de37..a1a12e8c183 100644
--- a/jstests/replsets/commit_transaction_recovery.js
+++ b/jstests/replsets/commit_transaction_recovery.js
@@ -3,7 +3,7 @@
* replaying the commitTransaction oplog entry. We hold back the snapshot so that we make sure that
* the operations from the transaction are not reflected in the data when recovery starts.
*
- * @tags: [uses_transactions, uses_prepare_transaction]
+ * @tags: [requires_persistence, uses_transactions, uses_prepare_transaction]
*/
(function() {
diff --git a/jstests/replsets/inmemory_preserves_active_txns.js b/jstests/replsets/inmemory_preserves_active_txns.js
index cefc3431a3a..8dc006ae682 100644
--- a/jstests/replsets/inmemory_preserves_active_txns.js
+++ b/jstests/replsets/inmemory_preserves_active_txns.js
@@ -22,6 +22,14 @@
return;
}
+ function findPrepareEntry(oplogColl) {
+ if (TestData.setParameters.useMultipleOplogEntryFormatForTransactions) {
+ return oplogColl.findOne({op: "c", o: {"prepareTransaction": 1}});
+ } else {
+ return oplogColl.findOne({prepare: true});
+ }
+ }
+
// A new replica set for both the commit and abort tests to ensure the same clean state.
function doTest(commitOrAbort) {
const replSet = new ReplSetTest({
@@ -60,20 +68,25 @@
jsTestLog("Get transaction entry from config.transactions");
const txnEntry = primary.getDB("config").transactions.findOne();
- assert.eq(txnEntry.startOpTime.ts, prepareTimestamp, tojson(txnEntry));
+ if (TestData.setParameters.useMultipleOplogEntryFormatForTransactions) {
+ assert.lt(txnEntry.startOpTime.ts, prepareTimestamp, tojson(txnEntry));
+ } else {
+ assert.eq(txnEntry.startOpTime.ts, prepareTimestamp, tojson(txnEntry));
+ }
assert.soonNoExcept(() => {
const secondaryTxnEntry = secondary.getDB("config").transactions.findOne();
+ assert(secondaryTxnEntry);
assert.eq(secondaryTxnEntry, txnEntry, tojson(secondaryTxnEntry));
return true;
});
jsTestLog("Find prepare oplog entry");
- const oplogEntry = primaryOplog.findOne({prepare: true});
+ const oplogEntry = findPrepareEntry(primaryOplog);
assert.eq(oplogEntry.ts, prepareTimestamp, tojson(oplogEntry));
// Must already be written on secondary, since the config.transactions entry is.
- const secondaryOplogEntry = secondaryOplog.findOne({prepare: true});
+ const secondaryOplogEntry = findPrepareEntry(secondaryOplog);
assert.eq(secondaryOplogEntry.ts, prepareTimestamp, tojson(secondaryOplogEntry));
jsTestLog("Insert documents until oplog exceeds oplogSize");
@@ -84,11 +97,11 @@
jsTestLog(
`Oplog dataSize = ${primaryOplog.dataSize()}, check the prepare entry still exists`);
- assert.eq(oplogEntry, primaryOplog.findOne({prepare: true}));
+ assert.eq(oplogEntry, findPrepareEntry(primaryOplog));
assert.soon(() => {
return secondaryOplog.dataSize() > PrepareHelpers.oplogSizeBytes;
});
- assert.eq(oplogEntry, secondaryOplog.findOne({prepare: true}));
+ assert.eq(oplogEntry, findPrepareEntry(secondaryOplog));
if (commitOrAbort === "commit") {
jsTestLog("Commit prepared transaction and wait for oplog to shrink to max oplogSize");
diff --git a/jstests/replsets/recover_multiple_prepared_transactions_startup.js b/jstests/replsets/recover_multiple_prepared_transactions_startup.js
index ae90d4708f0..10d82bd5536 100644
--- a/jstests/replsets/recover_multiple_prepared_transactions_startup.js
+++ b/jstests/replsets/recover_multiple_prepared_transactions_startup.js
@@ -2,7 +2,7 @@
* Test that startup recovery successfully recovers multiple prepared transactions and that we can
* commit or abort the transaction afterwards.
*
- * @tags: [uses_transactions, uses_prepare_transaction]
+ * @tags: [requires_persistence, uses_transactions, uses_prepare_transaction]
*/
(function() {
diff --git a/jstests/replsets/recovery_preserves_active_txns.js b/jstests/replsets/recovery_preserves_active_txns.js
index 69a6dfe38be..bc8b2caddd7 100644
--- a/jstests/replsets/recovery_preserves_active_txns.js
+++ b/jstests/replsets/recovery_preserves_active_txns.js
@@ -7,7 +7,7 @@
* This tests the oldestActiveTransactionTimestamp, which is calculated from the "startOpTime"
* field of documents in the config.transactions collection.
*
- * @tags: [uses_transactions, uses_prepare_transaction]
+ * @tags: [requires_persistence, uses_transactions, uses_prepare_transaction]
*/
(function() {
diff --git a/jstests/replsets/startup_recovery_commit_transaction_before_stable_timestamp.js b/jstests/replsets/startup_recovery_commit_transaction_before_stable_timestamp.js
index 23d003d4aa9..340ff978b78 100644
--- a/jstests/replsets/startup_recovery_commit_transaction_before_stable_timestamp.js
+++ b/jstests/replsets/startup_recovery_commit_transaction_before_stable_timestamp.js
@@ -6,7 +6,7 @@
* reflects the transaction. If the operations are replayed, this will cause a BSONTooLarge
* exception.
*
- * @tags: [uses_transactions, uses_prepare_transaction]
+ * @tags: [requires_persistence, uses_transactions, uses_prepare_transaction]
*/
(function() {
@@ -90,4 +90,4 @@
assert.eq(testDB[collName].findOne({_id: 1}), {_id: 1, a: 1});
replTest.stopSet();
-}()); \ No newline at end of file
+}());
diff --git a/jstests/replsets/startup_recovery_reconstructs_txn_prepared_before_stable_ts.js b/jstests/replsets/startup_recovery_reconstructs_txn_prepared_before_stable_ts.js
index 6b91a5badef..1a8c46d5d3d 100644
--- a/jstests/replsets/startup_recovery_reconstructs_txn_prepared_before_stable_ts.js
+++ b/jstests/replsets/startup_recovery_reconstructs_txn_prepared_before_stable_ts.js
@@ -2,7 +2,7 @@
* Test that we can successfully reconstruct a prepared transaction that was prepared before the
* stable timestamp at the end of startup recovery.
*
- * @tags: [uses_transactions, uses_prepare_transaction]
+ * @tags: [requires_persistence, uses_transactions, uses_prepare_transaction]
*/
(function() {
@@ -112,4 +112,4 @@
assert.eq(testColl.count(), 3);
replTest.stopSet();
-}()); \ No newline at end of file
+}());