Skip to content

Commit c67daea

Browse files
authored
test: legacy spec runner improvements (#2917)
1 parent 4a10389 commit c67daea

File tree

2 files changed

+28
-26
lines changed

2 files changed

+28
-26
lines changed

test/functional/spec-runner/index.js

+27-25
Original file line numberDiff line numberDiff line change
@@ -129,35 +129,15 @@ function generateTopologyTests(testSuites, testContext, filter) {
129129
environmentRequirementList.forEach(requires => {
130130
const suiteName = `${testSuite.name} - ${requires.topology.join()}`;
131131
describe(suiteName, {
132-
// FIXME: calling this.skip() inside tests triggers the leak checker, disable until fixed
133-
metadata: { requires, sessions: { skipLeakTests: true } },
132+
metadata: { requires },
134133
test: function () {
135134
beforeEach(() => prepareDatabaseForSuite(testSuite, testContext));
136135
afterEach(() => testContext.cleanupAfterSuite());
137136
testSuite.tests.forEach(spec => {
138-
it(spec.description, function () {
139-
if (requires.authEnabled && process.env.AUTH !== 'auth') {
140-
// TODO: We do not have a way to determine if auth is enabled in our mocha metadata
141-
// We need to do a admin.command({getCmdLineOpts: 1}) if it errors (code=13) auth is on
142-
this.skip();
143-
}
144-
145-
if (
146-
spec.operations.some(
147-
op => op.name === 'waitForEvent' && op.arguments.event === 'PoolReadyEvent'
148-
)
149-
) {
150-
// TODO(NODE-2994): Connection storms work will add new events to connection pool
151-
this.skip();
152-
}
153-
154-
if (
155-
spec.skipReason ||
156-
(filter && typeof filter === 'function' && !filter(spec, this.configuration))
157-
) {
158-
return this.skip();
159-
}
160-
137+
const maybeIt = shouldRunSpecTest(this.configuration, requires, spec, filter)
138+
? it
139+
: it.skip;
140+
maybeIt(spec.description, function () {
161141
let testPromise = Promise.resolve();
162142
if (spec.failPoint) {
163143
testPromise = testPromise.then(() => testContext.enableFailPoint(spec.failPoint));
@@ -180,6 +160,28 @@ function generateTopologyTests(testSuites, testContext, filter) {
180160
});
181161
}
182162

163+
function shouldRunSpecTest(configuration, requires, spec, filter) {
164+
if (requires.authEnabled && process.env.AUTH !== 'auth') {
165+
// TODO(NODE-3488): We do not have a way to determine if auth is enabled in our mocha metadata
166+
// We need to do a admin.command({getCmdLineOpts: 1}) if it errors (code=13) auth is on
167+
return false;
168+
}
169+
170+
if (
171+
spec.operations.some(
172+
op => op.name === 'waitForEvent' && op.arguments.event === 'PoolReadyEvent'
173+
)
174+
) {
175+
// TODO(NODE-2994): Connection storms work will add new events to connection pool
176+
return false;
177+
}
178+
179+
if (spec.skipReason || (filter && typeof filter === 'function' && !filter(spec, configuration))) {
180+
return false;
181+
}
182+
return true;
183+
}
184+
183185
// Test runner helpers
184186
function prepareDatabaseForSuite(suite, context) {
185187
context.dbName = suite.database_name || 'spec_db';

test/functional/spec-runner/utils.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ function resolveConnectionString(configuration, spec, context) {
1010
isShardedEnvironment && !useMultipleMongoses
1111
? `mongodb://${configuration.host}:${configuration.port}/${
1212
configuration.db
13-
}?directConnection=false${authSource ? '&authSource=${authSource}' : ''}`
13+
}?directConnection=false${authSource ? `&authSource=${authSource}` : ''}`
1414
: configuration.url({ username, password, authSource });
1515
return connectionString;
1616
}

0 commit comments

Comments
 (0)