Skip to content

Commit

Permalink
lint changes
Browse files Browse the repository at this point in the history
  • Loading branch information
baileympearson committed Feb 13, 2025
1 parent 26a85b7 commit e1b4a9e
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import * as path from 'path';

// eslint-disable-next-line @typescript-eslint/no-restricted-imports
import { ClientEncryption } from '../../../src/client-side-encryption/client_encryption';
import { type CommandStartedEvent, MongoClient, type MongoClientOptions } from '../../mongodb';
import { type CommandStartedEvent, type MongoClient, type MongoClientOptions } from '../../mongodb';
import { type TestConfiguration } from '../../tools/runner/config';
import { dropCollection } from '../shared';
import { TestConfiguration } from '../../tools/runner/config';

/* REFERENCE: (note commit hash) */
/* https://github.com/mongodb/specifications/blob/b3beada 72ae1c992294ae6a8eea572003a274c35/source/client-side-encryption/tests/README.rst#deadlock-tests */
Expand All @@ -30,10 +30,12 @@ const $jsonSchema = BSON.EJSON.parse(
)
);

function makeClient(configuration: TestConfiguration, options: MongoClientOptions = {}): MongoClient &
{
commandStartedEvents: Array<CommandStartedEvent>,
clientsCreated: number
function makeClient(
configuration: TestConfiguration,
options: MongoClientOptions = {}
): MongoClient & {
commandStartedEvents: Array<CommandStartedEvent>;
clientsCreated: number;
} {
options = { ...options, monitorCommands: true, __skipPingOnConnect: true };
if (process.env.MONGODB_API_VERSION) {
Expand Down Expand Up @@ -104,12 +106,13 @@ const metadata: MongoDBMetadataUI = {
topology: '!load-balanced'
}
};
describe.only('Connection Pool Deadlock Prevention', function () {

describe('Connection Pool Deadlock Prevention', function () {
beforeEach(async function () {
this.clientTest = makeClient(this.configuration);
this.clientKeyVault = makeClient(this.configuration, {
monitorCommands: true,
maxPoolSize: 1,
maxPoolSize: 1
});

this.clientEncryption = undefined;
Expand All @@ -132,7 +135,7 @@ describe.only('Connection Pool Deadlock Prevention', function () {
this.clientEncryption = new ClientEncryption(this.clientTest, {
kmsProviders: { local: { key: LOCAL_KEY } },
keyVaultNamespace: 'keyvault.datakeys',
keyVaultClient: this.keyVaultClient,
keyVaultClient: this.keyVaultClient
});

this.ciphertext = await this.clientEncryption.encrypt('string0', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const getKmsProviders = (localKey, kmipEndpoint, azureEndpoint, gcpEndpoint) =>
return result;
};

const noop = () => { };
const noop = () => {};
const metadata = {
requires: {
clientSideEncryption: true,
Expand Down Expand Up @@ -1355,7 +1355,7 @@ describe('Client Side Encryption Prose Tests', metadata, function () {

// TODO(NODE-3151): Implement kms prose tests
describe('KMS TLS Tests', () => {
it.skip('TBD', () => { }).skipReason = 'TODO(NODE-3151): Implement "KMS TLS Tests"';
it.skip('TBD', () => {}).skipReason = 'TODO(NODE-3151): Implement "KMS TLS Tests"';
});

/**
Expand Down Expand Up @@ -1696,7 +1696,7 @@ describe('Client Side Encryption Prose Tests', metadata, function () {
context(
'Case 5: `tlsDisableOCSPEndpointCheck` is permitted',
metadata,
function () { }
function () {}
).skipReason = 'TODO(NODE-4840): Node does not support any OCSP options';

context('Case 6: named KMS providers apply TLS options', function () {
Expand Down
19 changes: 11 additions & 8 deletions test/tools/runner/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,11 @@ export class TestConfiguration {
replicaSet: url.searchParams.get('replicaSet'),
proxyURIParams: url.searchParams.get('proxyHost')
? {
proxyHost: url.searchParams.get('proxyHost'),
proxyPort: Number(url.searchParams.get('proxyPort')),
proxyUsername: url.searchParams.get('proxyUsername'),
proxyPassword: url.searchParams.get('proxyPassword')
}
proxyHost: url.searchParams.get('proxyHost'),
proxyPort: Number(url.searchParams.get('proxyPort')),
proxyUsername: url.searchParams.get('proxyUsername'),
proxyPassword: url.searchParams.get('proxyPassword')
}
: undefined
};
if (url.username) {
Expand Down Expand Up @@ -455,18 +455,21 @@ export class AstrolabeTestConfiguration extends TestConfiguration {
}

export class AlpineTestConfiguration extends TestConfiguration {
override newClient(urlOrQueryOptions?: string | Record<string, any>, serverOptions?: MongoClientOptions): MongoClient {
override newClient(
urlOrQueryOptions?: string | Record<string, any>,
serverOptions?: MongoClientOptions
): MongoClient {
const options = serverOptions ?? {};

if (options.autoEncryption) {
const extraOptions: MongoClientOptions['autoEncryption']['extraOptions'] = {
...options.autoEncryption.extraOptions,
mongocryptdBypassSpawn: true,
mongocryptdURI: process.env.MONGOCRYPTD_URI
}
};
options.autoEncryption.extraOptions = extraOptions;
}

return super.newClient(urlOrQueryOptions, options);
}
}
}
9 changes: 4 additions & 5 deletions test/tools/runner/hooks/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,11 +153,10 @@ const testConfigBeforeHook = async function () {
.command({ getParameter: '*' })
.catch(error => ({ noReply: error }));

const Config: typeof TestConfiguration = process.env.ALPINE ? AlpineTestConfiguration : TestConfiguration;
this.configuration = new Config(
loadBalanced ? SINGLE_MONGOS_LB_URI : MONGODB_URI,
context
);
const Config: typeof TestConfiguration = process.env.ALPINE
? AlpineTestConfiguration
: TestConfiguration;
this.configuration = new Config(loadBalanced ? SINGLE_MONGOS_LB_URI : MONGODB_URI, context);

await client.close();

Expand Down
7 changes: 4 additions & 3 deletions test/tools/spec-runner/context.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ class TestRunnerContext {
? `${extractAuthFromConnectionString(process.env.MONGODB_URI)}@`
: '';
return config.newClient(
`mongodb://${authString}${proxy.host}:${proxy.port}/${process.env.AUTH === 'auth' ? '?authSource=admin' : ''
`mongodb://${authString}${proxy.host}:${proxy.port}/${
process.env.AUTH === 'auth' ? '?authSource=admin' : ''
}`
);
});
Expand Down Expand Up @@ -247,8 +248,8 @@ function findMatchingEvents(context, eventName) {
const allEvents = context.sdamEvents.concat(context.cmapEvents);
return eventName === 'ServerMarkedUnknownEvent'
? context.sdamEvents
.filter(event => event.constructor.name === 'ServerDescriptionChangedEvent')
.filter(event => event.newDescription.type === 'Unknown')
.filter(event => event.constructor.name === 'ServerDescriptionChangedEvent')
.filter(event => event.newDescription.type === 'Unknown')
: allEvents.filter(event => event.constructor.name.match(new RegExp(eventName)));
}

Expand Down
28 changes: 14 additions & 14 deletions test/tools/spec-runner/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -263,19 +263,19 @@ function prepareDatabaseForSuite(suite, context) {
const setupPromise = context.serverless
? Promise.resolve()
: db
.admin()
.command({ killAllSessions: [] })
.catch(err => {
if (
err.message.match(/no such (cmd|command)/) ||
err.message.match(/Failed to kill on some hosts/) ||
err.code === 11601
) {
return;
}
.admin()
.command({ killAllSessions: [] })
.catch(err => {
if (
err.message.match(/no such (cmd|command)/) ||
err.message.match(/Failed to kill on some hosts/) ||
err.code === 11601
) {
return;
}

throw err;
});
throw err;
});

if (context.collectionName == null || context.dbName === 'admin') {
return setupPromise;
Expand Down Expand Up @@ -334,7 +334,7 @@ function prepareDatabaseForSuite(suite, context) {
.db(context.dbName)
.collection(context.collectionName)
.distinct('x')
.catch(() => { });
.catch(() => {});
});
});
}
Expand Down Expand Up @@ -914,7 +914,7 @@ function testOperation(operation, obj, context, options) {
() => {
throw new Error('expected an error!');
},
() => { }
() => {}
);
}

Expand Down

0 comments on commit e1b4a9e

Please sign in to comment.