summaryrefslogtreecommitdiff
path: root/jstests/noPassthrough/currentop_transaction_metrics.js
diff options
context:
space:
mode:
Diffstat (limited to 'jstests/noPassthrough/currentop_transaction_metrics.js')
-rw-r--r--jstests/noPassthrough/currentop_transaction_metrics.js102
1 files changed, 51 insertions, 51 deletions
diff --git a/jstests/noPassthrough/currentop_transaction_metrics.js b/jstests/noPassthrough/currentop_transaction_metrics.js
index d676167c2c2..b65c39963f7 100644
--- a/jstests/noPassthrough/currentop_transaction_metrics.js
+++ b/jstests/noPassthrough/currentop_transaction_metrics.js
@@ -5,68 +5,68 @@
*/
(function() {
- 'use strict';
- load("jstests/core/txns/libs/prepare_helpers.js");
+'use strict';
+load("jstests/core/txns/libs/prepare_helpers.js");
- const rst = new ReplSetTest({nodes: 1});
- rst.startSet();
- rst.initiate();
+const rst = new ReplSetTest({nodes: 1});
+rst.startSet();
+rst.initiate();
- const collName = 'currentop_transaction_metrics';
- const testDB = rst.getPrimary().getDB('test');
- const adminDB = rst.getPrimary().getDB('admin');
- testDB.runCommand({drop: collName, writeConcern: {w: "majority"}});
- assert.commandWorked(testDB[collName].insert({x: 1}, {writeConcern: {w: "majority"}}));
+const collName = 'currentop_transaction_metrics';
+const testDB = rst.getPrimary().getDB('test');
+const adminDB = rst.getPrimary().getDB('admin');
+testDB.runCommand({drop: collName, writeConcern: {w: "majority"}});
+assert.commandWorked(testDB[collName].insert({x: 1}, {writeConcern: {w: "majority"}}));
- const session = adminDB.getMongo().startSession({causalConsistency: false});
- const sessionDB = session.getDatabase('test');
+const session = adminDB.getMongo().startSession({causalConsistency: false});
+const sessionDB = session.getDatabase('test');
- session.startTransaction();
- // Run a few operations so that the transaction goes through several active/inactive periods.
- assert.commandWorked(sessionDB[collName].update({}, {a: 1}));
- assert.commandWorked(sessionDB[collName].insert({_id: "insert-1"}));
- assert.commandWorked(sessionDB[collName].insert({_id: "insert-2"}));
- assert.commandWorked(sessionDB[collName].insert({_id: "insert-3"}));
+session.startTransaction();
+// Run a few operations so that the transaction goes through several active/inactive periods.
+assert.commandWorked(sessionDB[collName].update({}, {a: 1}));
+assert.commandWorked(sessionDB[collName].insert({_id: "insert-1"}));
+assert.commandWorked(sessionDB[collName].insert({_id: "insert-2"}));
+assert.commandWorked(sessionDB[collName].insert({_id: "insert-3"}));
- const transactionFilter = {
- active: false,
- 'lsid': {$exists: true},
- 'transaction.parameters.txnNumber': {$eq: 0},
- 'transaction.parameters.autocommit': {$eq: false},
- 'transaction.timePreparedMicros': {$exists: false}
- };
+const transactionFilter = {
+ active: false,
+ 'lsid': {$exists: true},
+ 'transaction.parameters.txnNumber': {$eq: 0},
+ 'transaction.parameters.autocommit': {$eq: false},
+ 'transaction.timePreparedMicros': {$exists: false}
+};
- let currentOp = adminDB.aggregate([{$currentOp: {}}, {$match: transactionFilter}]).toArray();
- assert.eq(currentOp.length, 1);
+let currentOp = adminDB.aggregate([{$currentOp: {}}, {$match: transactionFilter}]).toArray();
+assert.eq(currentOp.length, 1);
- // Check that the currentOp's transaction subdocument's fields align with our expectations.
- let transactionDocument = currentOp[0].transaction;
- assert.gte(transactionDocument.timeOpenMicros,
- transactionDocument.timeActiveMicros + transactionDocument.timeInactiveMicros);
+// Check that the currentOp's transaction subdocument's fields align with our expectations.
+let transactionDocument = currentOp[0].transaction;
+assert.gte(transactionDocument.timeOpenMicros,
+ transactionDocument.timeActiveMicros + transactionDocument.timeInactiveMicros);
- // Check that preparing the transaction enables the 'timePreparedMicros' field in currentOp.
- const prepareTimestamp = PrepareHelpers.prepareTransaction(session);
+// Check that preparing the transaction enables the 'timePreparedMicros' field in currentOp.
+const prepareTimestamp = PrepareHelpers.prepareTransaction(session);
- const prepareTransactionFilter = {
- active: false,
- 'lsid': {$exists: true},
- 'transaction.parameters.txnNumber': {$eq: 0},
- 'transaction.parameters.autocommit': {$eq: false},
- 'transaction.timePreparedMicros': {$exists: true}
- };
+const prepareTransactionFilter = {
+ active: false,
+ 'lsid': {$exists: true},
+ 'transaction.parameters.txnNumber': {$eq: 0},
+ 'transaction.parameters.autocommit': {$eq: false},
+ 'transaction.timePreparedMicros': {$exists: true}
+};
- currentOp = adminDB.aggregate([{$currentOp: {}}, {$match: prepareTransactionFilter}]).toArray();
- assert.eq(currentOp.length, 1);
+currentOp = adminDB.aggregate([{$currentOp: {}}, {$match: prepareTransactionFilter}]).toArray();
+assert.eq(currentOp.length, 1);
- // Check that the currentOp's transaction subdocument's fields align with our expectations.
- const prepareTransactionDocument = currentOp[0].transaction;
- assert.gte(prepareTransactionDocument.timeOpenMicros,
- prepareTransactionDocument.timeActiveMicros +
- prepareTransactionDocument.timeInactiveMicros);
- assert.gte(prepareTransactionDocument.timePreparedMicros, 0);
+// Check that the currentOp's transaction subdocument's fields align with our expectations.
+const prepareTransactionDocument = currentOp[0].transaction;
+assert.gte(
+ prepareTransactionDocument.timeOpenMicros,
+ prepareTransactionDocument.timeActiveMicros + prepareTransactionDocument.timeInactiveMicros);
+assert.gte(prepareTransactionDocument.timePreparedMicros, 0);
- PrepareHelpers.commitTransaction(session, prepareTimestamp);
- session.endSession();
+PrepareHelpers.commitTransaction(session, prepareTimestamp);
+session.endSession();
- rst.stopSet();
+rst.stopSet();
})();