Skip to content

Commit 904dbfd

Browse files
committed
test(transactions): ensure test runner properly excludes sharded
Test runner was attempting to run sharded transaction tests against 4.0.x servers. Modified the way tests are created so that different topologies have different version requirements Fixes NODE-1890
1 parent 8ebf8a9 commit 904dbfd

File tree

1 file changed

+33
-30
lines changed

1 file changed

+33
-30
lines changed

test/functional/transactions_tests.js

Lines changed: 33 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -239,39 +239,42 @@ function generateTopologyTests(testSuites, testContext) {
239239
testSuites.forEach(testSuite => {
240240
const suiteName = testSuite.name;
241241
const topologies = parseTopologies(testSuite.topology);
242-
const minServerVersion = testSuite.minServerVersion
243-
? `>=${testSuite.minServerVersion}`
244-
: '>=3.7.x';
245242

246243
const tests = testSuite.tests;
247-
describe(suiteName, {
248-
metadata: { requires: { topology: topologies, mongodb: minServerVersion } },
249-
test: function() {
250-
beforeEach(() => prepareDatabaseForSuite(testSuite, testContext));
251-
afterEach(() => testContext.cleanupAfterSuite());
252-
253-
tests.forEach(spec => {
254-
const maybeSkipIt = shouldSkipTest(spec);
255-
maybeSkipIt(spec.description, function() {
256-
let testPromise = Promise.resolve();
257-
258-
if (spec.failPoint) {
259-
testPromise = testPromise.then(() => testContext.enableFailPoint(spec.failPoint));
260-
}
261-
262-
// run the actual test
263-
testPromise = testPromise.then(() =>
264-
runTestSuiteTest(this.configuration, spec, testContext)
265-
);
266-
267-
if (spec.failPoint) {
268-
testPromise = testPromise.then(() => testContext.disableFailPoint(spec.failPoint));
269-
}
270-
271-
return testPromise.then(() => validateOutcome(spec, testContext));
244+
topologies.forEach(topology => {
245+
const DEFAULT_MIN_SERVER_VERSION = topology === 'sharded' ? '>=4.1.5' : '>=3.7.x';
246+
const minServerVersion = testSuite.minServerVersion
247+
? `>=${testSuite.minServerVersion}`
248+
: DEFAULT_MIN_SERVER_VERSION;
249+
describe(`${suiteName} - ${topology}`, {
250+
metadata: { requires: { topology: [topology], mongodb: minServerVersion } },
251+
test: function() {
252+
beforeEach(() => prepareDatabaseForSuite(testSuite, testContext));
253+
afterEach(() => testContext.cleanupAfterSuite());
254+
255+
tests.forEach(spec => {
256+
const maybeSkipIt = shouldSkipTest(spec);
257+
maybeSkipIt(spec.description, function() {
258+
let testPromise = Promise.resolve();
259+
260+
if (spec.failPoint) {
261+
testPromise = testPromise.then(() => testContext.enableFailPoint(spec.failPoint));
262+
}
263+
264+
// run the actual test
265+
testPromise = testPromise.then(() =>
266+
runTestSuiteTest(this.configuration, spec, testContext)
267+
);
268+
269+
if (spec.failPoint) {
270+
testPromise = testPromise.then(() => testContext.disableFailPoint(spec.failPoint));
271+
}
272+
273+
return testPromise.then(() => validateOutcome(spec, testContext));
274+
});
272275
});
273-
});
274-
}
276+
}
277+
});
275278
});
276279
});
277280
}

0 commit comments

Comments
 (0)