Skip to content

test: legacy spec runner improvements #2917

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 27 additions & 25 deletions test/functional/spec-runner/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,35 +129,15 @@ function generateTopologyTests(testSuites, testContext, filter) {
environmentRequirementList.forEach(requires => {
const suiteName = `${testSuite.name} - ${requires.topology.join()}`;
describe(suiteName, {
// FIXME: calling this.skip() inside tests triggers the leak checker, disable until fixed
metadata: { requires, sessions: { skipLeakTests: true } },
metadata: { requires },
test: function () {
beforeEach(() => prepareDatabaseForSuite(testSuite, testContext));
afterEach(() => testContext.cleanupAfterSuite());
testSuite.tests.forEach(spec => {
it(spec.description, function () {
if (requires.authEnabled && process.env.AUTH !== 'auth') {
// TODO: We do not have a way to determine if auth is enabled in our mocha metadata
// We need to do a admin.command({getCmdLineOpts: 1}) if it errors (code=13) auth is on
this.skip();
}

if (
spec.operations.some(
op => op.name === 'waitForEvent' && op.arguments.event === 'PoolReadyEvent'
)
) {
// TODO(NODE-2994): Connection storms work will add new events to connection pool
this.skip();
}

if (
spec.skipReason ||
(filter && typeof filter === 'function' && !filter(spec, this.configuration))
) {
return this.skip();
}

const maybeIt = shouldRunSpecTest(this.configuration, requires, spec, filter)
? it
: it.skip;
maybeIt(spec.description, function () {
let testPromise = Promise.resolve();
if (spec.failPoint) {
testPromise = testPromise.then(() => testContext.enableFailPoint(spec.failPoint));
Expand All @@ -180,6 +160,28 @@ function generateTopologyTests(testSuites, testContext, filter) {
});
}

function shouldRunSpecTest(configuration, requires, spec, filter) {
if (requires.authEnabled && process.env.AUTH !== 'auth') {
// TODO(NODE-3488): We do not have a way to determine if auth is enabled in our mocha metadata
// We need to do a admin.command({getCmdLineOpts: 1}) if it errors (code=13) auth is on
return false;
}

if (
spec.operations.some(
op => op.name === 'waitForEvent' && op.arguments.event === 'PoolReadyEvent'
)
) {
// TODO(NODE-2994): Connection storms work will add new events to connection pool
return false;
}

if (spec.skipReason || (filter && typeof filter === 'function' && !filter(spec, configuration))) {
return false;
}
return true;
}

// Test runner helpers
function prepareDatabaseForSuite(suite, context) {
context.dbName = suite.database_name || 'spec_db';
Expand Down
2 changes: 1 addition & 1 deletion test/functional/spec-runner/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function resolveConnectionString(configuration, spec, context) {
isShardedEnvironment && !useMultipleMongoses
? `mongodb://${configuration.host}:${configuration.port}/${
configuration.db
}?directConnection=false${authSource ? '&authSource=${authSource}' : ''}`
}?directConnection=false${authSource ? `&authSource=${authSource}` : ''}`
: configuration.url({ username, password, authSource });
return connectionString;
}
Expand Down