Skip to content

Commit 3e9584b

Browse files
committed
test(txns): add support for running and cleaning up fail points
1 parent c3e127a commit 3e9584b

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

test/functional/transactions_tests.js

+25
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,22 @@ describe('Transactions (spec)', function() {
115115
const maybeSkipIt = testData.skipReason ? it.skip : it;
116116
maybeSkipIt(testData.description, function() {
117117
let testPromise = Promise.resolve();
118+
119+
if (testData.failPoint) {
120+
testPromise = testPromise.then(() =>
121+
enableFailPoint(testData.failPoint, testContext)
122+
);
123+
}
124+
125+
// run the actual test
118126
testPromise = testPromise.then(() => runTestSuiteTest(testData, testContext));
119127

128+
if (testData.failPoint) {
129+
testPromise = testPromise.then(() =>
130+
disableFailPoint(testData.failPoint, testContext)
131+
);
132+
}
133+
120134
return testPromise;
121135
});
122136
});
@@ -154,6 +168,17 @@ function cleanupAfterSuite(context) {
154168
}
155169
}
156170

171+
function enableFailPoint(failPoint, testContext) {
172+
return testContext.sharedClient.db(testContext.dbName).executeDbAdminCommand(failPoint);
173+
}
174+
175+
function disableFailPoint(failPoint, testContext) {
176+
return testContext.sharedClient.db(testContext.dbName).executeDbAdminCommand({
177+
configureFailPoint: failPoint.configureFailPoint,
178+
mode: 'off'
179+
});
180+
}
181+
157182
let displayCommands = false;
158183
function runTestSuiteTest(testData, context) {
159184
const commandEvents = [];

0 commit comments

Comments
 (0)