From 4dbd896a02fc99ff622601b8dadc7f18f8ca0cbc Mon Sep 17 00:00:00 2001 From: bailey Date: Wed, 28 Jan 2026 15:23:53 -0700 Subject: [PATCH 01/36] initial POC --- .eslintrc.json | 5 +- src/cmap/auth/gssapi.ts | 11 +-- src/cmap/connection.ts | 21 +++--- src/cmap/handshake/client_metadata.ts | 6 +- src/connection_string.ts | 11 +++ src/index.ts | 1 + src/mongo_client.ts | 72 ++++++++++--------- test/unit/assorted/optional_require.test.ts | 4 +- test/unit/cmap/connect.test.ts | 17 +++-- .../cmap/handshake/client_metadata.test.ts | 60 +++++++++------- test/unit/sdam/topology.test.ts | 8 ++- 11 files changed, 133 insertions(+), 83 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index d009780f37..95c6e99a81 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -276,7 +276,8 @@ "patterns": [ "**/../lib/**", "mongodb-mock-server", - "node:*" + "node:*", + "os" ], "paths": [ { @@ -327,4 +328,4 @@ } } ] -} +} \ No newline at end of file diff --git a/src/cmap/auth/gssapi.ts b/src/cmap/auth/gssapi.ts index d18cb6b360..0154057919 100644 --- a/src/cmap/auth/gssapi.ts +++ b/src/cmap/auth/gssapi.ts @@ -1,5 +1,4 @@ import * as dns from 'dns'; -import * as os from 'os'; import { getKerberos, type Kerberos, type KerberosClient } from '../../deps'; import { MongoInvalidArgumentError, MongoMissingCredentialsError } from '../../error'; @@ -69,9 +68,13 @@ export class GSSAPI extends AuthProvider { } } -async function makeKerberosClient(authContext: AuthContext): Promise { - const { hostAddress } = authContext.options; - const { credentials } = authContext; +async function makeKerberosClient({ + options: { + hostAddress, + runtime: { os } + }, + credentials +}: AuthContext): Promise { if (!hostAddress || typeof hostAddress.host !== 'string' || !credentials) { throw new MongoInvalidArgumentError( 'Connection must have host and port and credentials defined.' diff --git a/src/cmap/connection.ts b/src/cmap/connection.ts index 9652e3a5e4..c53c86d7ed 100644 --- a/src/cmap/connection.ts +++ b/src/cmap/connection.ts @@ -35,6 +35,7 @@ import { type MongoClientAuthProviders } from '../mongo_client_auth_providers'; import { MongoLoggableComponent, type MongoLogger, SeverityLevel } from '../mongo_logger'; import { type Abortable, type CancellationToken, TypedEventEmitter } from '../mongo_types'; import { ReadPreference, type ReadPreferenceLike } from '../read_preference'; +import { type Runtime } from '../runtime_adapters'; import { ServerType } from '../sdam/common'; import { applySession, type ClientSession, updateSessionFromResponse } from '../sessions'; import { type TimeoutContext, TimeoutError } from '../timeout'; @@ -118,8 +119,8 @@ export interface ProxyOptions { /** @public */ export interface ConnectionOptions extends SupportedNodeConnectionOptions, - StreamDescriptionOptions, - ProxyOptions { + StreamDescriptionOptions, + ProxyOptions { // Internal creation info id: number | ''; generation: number; @@ -143,6 +144,8 @@ export interface ConnectionOptions metadata: Promise; /** @internal */ mongoLogger?: MongoLogger | undefined; + /** @internal */ + runtime: Runtime; } /** @public */ @@ -526,10 +529,10 @@ export class Connection extends TypedEventEmitter { options.documentsReturnedIn == null || !options.raw ? options : { - ...options, - raw: false, - fieldsAsRaw: { [options.documentsReturnedIn]: true } - }; + ...options, + raw: false, + fieldsAsRaw: { [options.documentsReturnedIn]: true } + }; /** MongoDBResponse instance or subclass */ let document: MongoDBResponse | undefined = undefined; @@ -692,9 +695,9 @@ export class Connection extends TypedEventEmitter { options.agreedCompressor === 'none' || !OpCompressedRequest.canCompress(command) ? command : new OpCompressedRequest(command, { - agreedCompressor: options.agreedCompressor ?? 'none', - zlibCompressionLevel: options.zlibCompressionLevel ?? 0 - }); + agreedCompressor: options.agreedCompressor ?? 'none', + zlibCompressionLevel: options.zlibCompressionLevel ?? 0 + }); const buffer = Buffer.concat(await finalCommand.toBin()); diff --git a/src/cmap/handshake/client_metadata.ts b/src/cmap/handshake/client_metadata.ts index 48cb6a4735..3b79e1df48 100644 --- a/src/cmap/handshake/client_metadata.ts +++ b/src/cmap/handshake/client_metadata.ts @@ -1,4 +1,3 @@ -import * as os from 'os'; import * as process from 'process'; import { BSON, type Document, Int32, NumberUtils } from '../../bson'; @@ -96,7 +95,8 @@ export class LimitedSizeDocument { } } -type MakeClientMetadataOptions = Pick; +type MakeClientMetadataOptions = Pick; + /** * From the specs: * Implementors SHOULD cumulatively update fields in the following order until the document is under the size limit: @@ -107,7 +107,7 @@ type MakeClientMetadataOptions = Pick; */ export async function makeClientMetadata( driverInfoList: DriverInfo[], - { appName = '' }: MakeClientMetadataOptions + { appName = '', runtime: { os } }: MakeClientMetadataOptions ): Promise { const metadataDocument = new LimitedSizeDocument(512); diff --git a/src/connection_string.ts b/src/connection_string.ts index df6dfc607a..ce63e99ad9 100644 --- a/src/connection_string.ts +++ b/src/connection_string.ts @@ -20,6 +20,7 @@ import { import { MongoLoggableComponent, MongoLogger, SeverityLevel } from './mongo_logger'; import { ReadConcern, type ReadConcernLevel } from './read_concern'; import { ReadPreference, type ReadPreferenceMode } from './read_preference'; +import { type Runtime } from './runtime_adapters'; import { ServerMonitoringMode } from './sdam/monitor'; import type { TagSet } from './sdam/server_description'; import { @@ -538,6 +539,13 @@ export function parseOptions( } ); + const runtime: Runtime = { + // eslint-disable-next-line @typescript-eslint/no-require-imports + os: options.runtimeAdapters?.os ?? require('os') + }; + + mongoOptions.runtime = runtime; + return mongoOptions; } @@ -1061,6 +1069,9 @@ export const OPTIONS = { default: true, type: 'boolean' }, + runtimeAdapters: { + type: 'record' + }, serializeFunctions: { type: 'boolean' }, diff --git a/src/index.ts b/src/index.ts index 8f5c4cfa60..74803dfa2a 100644 --- a/src/index.ts +++ b/src/index.ts @@ -562,6 +562,7 @@ export type { ReadPreferenceLikeOptions, ReadPreferenceOptions } from './read_preference'; +export type { OsAdapter, Runtime, RuntimeAdapters } from './runtime_adapters'; export type { ClusterTime } from './sdam/common'; export type { Monitor, diff --git a/src/mongo_client.ts b/src/mongo_client.ts index 970f0f8806..1ac02e93c6 100644 --- a/src/mongo_client.ts +++ b/src/mongo_client.ts @@ -46,6 +46,7 @@ import { EndSessionsOperation } from './operations/end_sessions'; import { executeOperation } from './operations/execute_operation'; import type { ReadConcern, ReadConcernLevel, ReadConcernLike } from './read_concern'; import { ReadPreference, type ReadPreferenceMode } from './read_preference'; +import { type Runtime, type RuntimeAdapters } from './runtime_adapters'; import type { ServerMonitoringMode } from './sdam/monitor'; import type { TagSet } from './sdam/server_description'; import { DeprioritizedServers, readPreferenceServerSelector } from './sdam/server_selection'; @@ -318,6 +319,8 @@ export interface MongoClientOptions extends BSONSerializeOptions, SupportedNodeC connectionType?: typeof Connection; /** @internal */ __skipPingOnConnect?: boolean; + /** @experimental */ + runtimeAdapters?: RuntimeAdapters; } /** @public */ @@ -1032,39 +1035,39 @@ export class MongoClient extends TypedEventEmitter implements */ export interface MongoOptions extends Required< - Pick< - MongoClientOptions, - | 'autoEncryption' - | 'connectTimeoutMS' - | 'directConnection' - | 'driverInfo' - | 'forceServerObjectId' - | 'minHeartbeatFrequencyMS' - | 'heartbeatFrequencyMS' - | 'localThresholdMS' - | 'maxConnecting' - | 'maxIdleTimeMS' - | 'maxPoolSize' - | 'minPoolSize' - | 'monitorCommands' - | 'noDelay' - | 'pkFactory' - | 'raw' - | 'replicaSet' - | 'retryReads' - | 'retryWrites' - | 'serverSelectionTimeoutMS' - | 'socketTimeoutMS' - | 'srvMaxHosts' - | 'srvServiceName' - | 'tlsAllowInvalidCertificates' - | 'tlsAllowInvalidHostnames' - | 'tlsInsecure' - | 'waitQueueTimeoutMS' - | 'zlibCompressionLevel' - > - >, - SupportedNodeConnectionOptions { + Pick< + MongoClientOptions, + | 'autoEncryption' + | 'connectTimeoutMS' + | 'directConnection' + | 'driverInfo' + | 'forceServerObjectId' + | 'minHeartbeatFrequencyMS' + | 'heartbeatFrequencyMS' + | 'localThresholdMS' + | 'maxConnecting' + | 'maxIdleTimeMS' + | 'maxPoolSize' + | 'minPoolSize' + | 'monitorCommands' + | 'noDelay' + | 'pkFactory' + | 'raw' + | 'replicaSet' + | 'retryReads' + | 'retryWrites' + | 'serverSelectionTimeoutMS' + | 'socketTimeoutMS' + | 'srvMaxHosts' + | 'srvServiceName' + | 'tlsAllowInvalidCertificates' + | 'tlsAllowInvalidHostnames' + | 'tlsInsecure' + | 'waitQueueTimeoutMS' + | 'zlibCompressionLevel' + > + >, + SupportedNodeConnectionOptions { appName?: string; hosts: HostAddress[]; srvHost?: string; @@ -1152,4 +1155,7 @@ export interface MongoOptions timeoutMS?: number; /** @internal */ __skipPingOnConnect?: boolean; + + /** @internal */ + runtime: Runtime; } diff --git a/test/unit/assorted/optional_require.test.ts b/test/unit/assorted/optional_require.test.ts index 5dc579ee30..f6772baf2d 100644 --- a/test/unit/assorted/optional_require.test.ts +++ b/test/unit/assorted/optional_require.test.ts @@ -41,7 +41,9 @@ describe('optionalRequire', function () { const gssapi = new GSSAPI(); const error = await gssapi - .auth(new AuthContext(null, true, { hostAddress: new HostAddress('a'), credentials: true })) + .auth(new AuthContext(null, true, { + hostAddress: new HostAddress('a'), credentials: true, runtime: { os: require('os') } + })) .then( () => null, e => e diff --git a/test/unit/cmap/connect.test.ts b/test/unit/cmap/connect.test.ts index a97cb7194a..145d9f0ff3 100644 --- a/test/unit/cmap/connect.test.ts +++ b/test/unit/cmap/connect.test.ts @@ -210,7 +210,9 @@ describe('Connect Tests', function () { connection: {}, options: { ...CONNECT_DEFAULTS, - metadata: makeClientMetadata([], {}) + metadata: makeClientMetadata([], { + runtime: { os: require('os') } + }) } }; }); @@ -239,7 +241,9 @@ describe('Connect Tests', function () { name: 's'.repeat(128) } ], - { appName: longAppName } + { + appName: longAppName, runtime: { os: require('os') } + } ); const longAuthContext = { connection: {}, @@ -267,7 +271,9 @@ describe('Connect Tests', function () { connection: {}, options: { ...CONNECT_DEFAULTS, - metadata: makeClientMetadata([], {}) + metadata: makeClientMetadata([], { + runtime: { os: require('os') } + }) } }; }); @@ -296,7 +302,10 @@ describe('Connect Tests', function () { name: 's'.repeat(128) } ], - { appName: longAppName } + { + appName: longAppName, + runtime: { os: require('os') } + } ); const longAuthContext = { connection: {}, diff --git a/test/unit/cmap/handshake/client_metadata.test.ts b/test/unit/cmap/handshake/client_metadata.test.ts index 6128838448..b4b19b1720 100644 --- a/test/unit/cmap/handshake/client_metadata.test.ts +++ b/test/unit/cmap/handshake/client_metadata.test.ts @@ -12,6 +12,11 @@ import { makeClientMetadata } from '../../../../src/cmap/handshake/client_metadata'; import { MongoInvalidArgumentError } from '../../../../src/error'; +import { Runtime } from '../../../../src'; + +const runtime: Runtime = { + os: require('os') +}; describe('client metadata module', () => { afterEach(() => sinon.restore()); @@ -141,7 +146,7 @@ describe('client metadata module', () => { describe('makeClientMetadata()', () => { context('when no FAAS environment is detected', () => { it('does not append FAAS metadata', async () => { - const metadata = await makeClientMetadata([], {}); + const metadata = await makeClientMetadata([], { runtime }); expect(metadata).not.to.have.property( 'env', 'faas metadata applied in a non-faas environment' @@ -164,14 +169,14 @@ describe('client metadata module', () => { context('when driverInfo.platform is provided', () => { it('throws an error if driverInfo.platform is too large', async () => { - const error = await makeClientMetadata([{ platform: 'a'.repeat(512) }], {}).catch(e => e); + const error = await makeClientMetadata([{ platform: 'a'.repeat(512) }], { runtime }).catch(e => e); expect(error) .to.be.instanceOf(MongoInvalidArgumentError) .to.match(/platform/); }); it('appends driverInfo.platform to the platform field', async () => { - const metadata = await makeClientMetadata([{ platform: 'myPlatform' }], {}); + const metadata = await makeClientMetadata([{ platform: 'myPlatform' }], { runtime }); expect(metadata).to.deep.equal({ driver: { name: 'nodejs', @@ -190,12 +195,12 @@ describe('client metadata module', () => { context('when driverInfo.name is provided', () => { it('throws an error if driverInfo.name is too large', async () => { - const error = await makeClientMetadata([{ name: 'a'.repeat(512) }], {}).catch(e => e); + const error = await makeClientMetadata([{ name: 'a'.repeat(512) }], { runtime }).catch(e => e); expect(error).to.be.instanceOf(MongoInvalidArgumentError).to.match(/name/); }); it('appends driverInfo.name to the driver.name field', async () => { - const metadata = await makeClientMetadata([{ name: 'myName' }], {}); + const metadata = await makeClientMetadata([{ name: 'myName' }], { runtime }); expect(metadata).to.deep.equal({ driver: { name: 'nodejs|myName', @@ -214,14 +219,14 @@ describe('client metadata module', () => { context('when driverInfo.version is provided', () => { it('throws an error if driverInfo.version is too large', async () => { - const error = await makeClientMetadata([{ version: 'a'.repeat(512) }], {}).catch(e => e); + const error = await makeClientMetadata([{ version: 'a'.repeat(512) }], { runtime }).catch(e => e); expect(error) .to.be.instanceOf(MongoInvalidArgumentError) .to.match(/version/); }); it('appends driverInfo.version to the version field', async () => { - const metadata = await makeClientMetadata([{ version: 'myVersion' }], {}); + const metadata = await makeClientMetadata([{ version: 'myVersion' }], { runtime }); expect(metadata).to.deep.equal({ driver: { name: 'nodejs', @@ -240,7 +245,7 @@ describe('client metadata module', () => { context('when no custom driverInto is provided', () => { it('does not append the driver info to the metadata', async () => { - const metadata = await makeClientMetadata([], {}); + const metadata = await makeClientMetadata([], { runtime }); expect(metadata).to.deep.equal({ driver: { name: 'nodejs', @@ -257,7 +262,7 @@ describe('client metadata module', () => { }); it('does not set the application field', async () => { - const metadata = await makeClientMetadata([], {}); + const metadata = await makeClientMetadata([], { runtime }); expect(metadata).not.to.have.property('application'); }); }); @@ -267,6 +272,7 @@ describe('client metadata module', () => { it('truncates the application name to <=128 bytes', async () => { const longString = 'a'.repeat(300); const metadata = await makeClientMetadata([], { + runtime, appName: longString }); expect(metadata.application?.name).to.be.a('string'); @@ -283,6 +289,7 @@ describe('client metadata module', () => { it('truncates the application name to 129 bytes', async () => { const longString = '€'.repeat(300); const metadata = await makeClientMetadata([], { + runtime, appName: longString }); @@ -298,6 +305,7 @@ describe('client metadata module', () => { context('when the app name is under 128 bytes', () => { it('sets the application name to the value', async () => { const metadata = await makeClientMetadata([], { + runtime, appName: 'myApplication' }); expect(metadata.application?.name).to.equal('myApplication'); @@ -313,37 +321,37 @@ describe('client metadata module', () => { it('sets platform to Deno', async () => { globalThis.Deno = { version: { deno: '1.2.3' } }; - const metadata = await makeClientMetadata([], {}); + const metadata = await makeClientMetadata([], { runtime }); expect(metadata.platform).to.equal('Deno v1.2.3, LE'); }); it('sets platform to Deno with driverInfo.platform', async () => { globalThis.Deno = { version: { deno: '1.2.3' } }; - const metadata = await makeClientMetadata([{ platform: 'myPlatform' }], {}); + const metadata = await makeClientMetadata([{ platform: 'myPlatform' }], { runtime }); expect(metadata.platform).to.equal('Deno v1.2.3, LE|myPlatform'); }); it('ignores version if Deno.version.deno is not a string', async () => { globalThis.Deno = { version: { deno: 1 } }; - const metadata = await makeClientMetadata([], {}); + const metadata = await makeClientMetadata([], { runtime }); expect(metadata.platform).to.equal('Deno v0.0.0-unknown, LE'); }); it('ignores version if Deno.version does not have a deno property', async () => { globalThis.Deno = { version: { somethingElse: '1.2.3' } }; - const metadata = await makeClientMetadata([], {}); + const metadata = await makeClientMetadata([], { runtime }); expect(metadata.platform).to.equal('Deno v0.0.0-unknown, LE'); }); it('ignores version if Deno.version is null', async () => { globalThis.Deno = { version: null }; - const metadata = await makeClientMetadata([], {}); + const metadata = await makeClientMetadata([], { runtime }); expect(metadata.platform).to.equal('Deno v0.0.0-unknown, LE'); }); it('ignores version if Deno is nullish', async () => { globalThis.Deno = null; - const metadata = await makeClientMetadata([], {}); + const metadata = await makeClientMetadata([], { runtime }); expect(metadata.platform).to.equal('Deno v0.0.0-unknown, LE'); }); }); @@ -357,7 +365,7 @@ describe('client metadata module', () => { globalThis.Bun = class { static version = '1.2.3'; }; - const metadata = await makeClientMetadata([], {}); + const metadata = await makeClientMetadata([], { runtime }); expect(metadata.platform).to.equal('Bun v1.2.3, LE'); }); @@ -365,7 +373,7 @@ describe('client metadata module', () => { globalThis.Bun = class { static version = '1.2.3'; }; - const metadata = await makeClientMetadata([{ platform: 'myPlatform' }], {}); + const metadata = await makeClientMetadata([{ platform: 'myPlatform' }], { runtime }); expect(metadata.platform).to.equal('Bun v1.2.3, LE|myPlatform'); }); @@ -373,7 +381,7 @@ describe('client metadata module', () => { globalThis.Bun = class { static version = 1; }; - const metadata = await makeClientMetadata([], {}); + const metadata = await makeClientMetadata([], { runtime }); expect(metadata.platform).to.equal('Bun v0.0.0-unknown, LE'); }); @@ -381,13 +389,13 @@ describe('client metadata module', () => { globalThis.Bun = class { static version = 1; }; - const metadata = await makeClientMetadata([{ platform: 'myPlatform' }], {}); + const metadata = await makeClientMetadata([{ platform: 'myPlatform' }], { runtime }); expect(metadata.platform).to.equal('Bun v0.0.0-unknown, LE|myPlatform'); }); it('ignores version if Bun is nullish', async () => { globalThis.Bun = null; - const metadata = await makeClientMetadata([{ platform: 'myPlatform' }], {}); + const metadata = await makeClientMetadata([{ platform: 'myPlatform' }], { runtime }); expect(metadata.platform).to.equal('Bun v0.0.0-unknown, LE|myPlatform'); }); }); @@ -508,7 +516,7 @@ describe('client metadata module', () => { }); it(`returns ${inspect(outcome)} under env property`, async () => { - const { env } = await makeClientMetadata([], {}); + const { env } = await makeClientMetadata([], { runtime }); expect(env).to.deep.equal(outcome); }); @@ -532,7 +540,7 @@ describe('client metadata module', () => { }); it('does not attach it to the metadata', async () => { - expect(await makeClientMetadata([], {})).not.to.have.nested.property('aws.memory_mb'); + expect(await makeClientMetadata([], { runtime })).not.to.have.nested.property('aws.memory_mb'); }); }); }); @@ -547,7 +555,7 @@ describe('client metadata module', () => { }); it('only includes env.name', async () => { - const metadata = await makeClientMetadata([], {}); + const metadata = await makeClientMetadata([], { runtime }); expect(metadata).to.not.have.nested.property('env.region'); expect(metadata).to.have.nested.property('env.name', 'aws.lambda'); expect(metadata.env).to.have.all.keys('name'); @@ -565,7 +573,7 @@ describe('client metadata module', () => { }); it('only includes env.name', async () => { - const metadata = await makeClientMetadata([], {}); + const metadata = await makeClientMetadata([], { runtime }); expect(metadata).to.have.property('env'); expect(metadata).to.have.nested.property('env.region', 'abc'); expect(metadata.os).to.have.all.keys('type'); @@ -582,7 +590,7 @@ describe('client metadata module', () => { }); it('omits os information', async () => { - const metadata = await makeClientMetadata([], {}); + const metadata = await makeClientMetadata([], { runtime }); expect(metadata).to.not.have.property('os'); }); }); @@ -598,7 +606,7 @@ describe('client metadata module', () => { }); it('omits the faas env', async () => { - const metadata = await makeClientMetadata([{ name: 'a'.repeat(350) }], {}); + const metadata = await makeClientMetadata([{ name: 'a'.repeat(350) }], { runtime }); expect(metadata).to.not.have.property('env'); }); }); diff --git a/test/unit/sdam/topology.test.ts b/test/unit/sdam/topology.test.ts index 1444e1a40c..1dab4f6a93 100644 --- a/test/unit/sdam/topology.test.ts +++ b/test/unit/sdam/topology.test.ts @@ -29,6 +29,11 @@ import { TimeoutContext } from '../../../src/timeout'; import { isHello, ns } from '../../../src/utils'; import * as mock from '../../tools/mongodb-mock/index'; import { topologyWithPlaceholderClient } from '../../tools/utils'; +import { Runtime } from '../../../src'; + +const runtime: Runtime = { + os: require('os') +}; describe('Topology (unit)', function () { let client, topology; @@ -56,6 +61,7 @@ describe('Topology (unit)', function () { it('should correctly pass appname', async function () { const topology: Topology = topologyWithPlaceholderClient([`localhost:27017`], { metadata: makeClientMetadata([], { + runtime, appName: 'My application name' }) }); @@ -120,7 +126,7 @@ describe('Topology (unit)', function () { }); const server = await topology.selectServer('primary', { timeoutContext: ctx, - operationName: 'none' + operationName: 'none', }); const err = await server .command(new RunCursorCommandOperation(ns('admin.$cmd'), { ping: 1 }, {}), ctx) From b790827671322da3d67e0ae7c23841c93b8a32dd Mon Sep 17 00:00:00 2001 From: bailey Date: Wed, 28 Jan 2026 15:28:13 -0700 Subject: [PATCH 02/36] lint --- src/cmap/connection.ts | 18 ++--- src/mongo_client.ts | 66 +++++++++---------- src/runtime_adapters.ts | 25 +++++++ test/tools/utils.ts | 6 ++ test/unit/assorted/optional_require.test.ts | 11 +++- test/unit/cmap/connect.test.ts | 10 +-- .../cmap/handshake/client_metadata.test.ts | 21 +++--- test/unit/sdam/topology.test.ts | 9 +-- 8 files changed, 101 insertions(+), 65 deletions(-) create mode 100644 src/runtime_adapters.ts diff --git a/src/cmap/connection.ts b/src/cmap/connection.ts index c53c86d7ed..dfffb15dae 100644 --- a/src/cmap/connection.ts +++ b/src/cmap/connection.ts @@ -119,8 +119,8 @@ export interface ProxyOptions { /** @public */ export interface ConnectionOptions extends SupportedNodeConnectionOptions, - StreamDescriptionOptions, - ProxyOptions { + StreamDescriptionOptions, + ProxyOptions { // Internal creation info id: number | ''; generation: number; @@ -529,10 +529,10 @@ export class Connection extends TypedEventEmitter { options.documentsReturnedIn == null || !options.raw ? options : { - ...options, - raw: false, - fieldsAsRaw: { [options.documentsReturnedIn]: true } - }; + ...options, + raw: false, + fieldsAsRaw: { [options.documentsReturnedIn]: true } + }; /** MongoDBResponse instance or subclass */ let document: MongoDBResponse | undefined = undefined; @@ -695,9 +695,9 @@ export class Connection extends TypedEventEmitter { options.agreedCompressor === 'none' || !OpCompressedRequest.canCompress(command) ? command : new OpCompressedRequest(command, { - agreedCompressor: options.agreedCompressor ?? 'none', - zlibCompressionLevel: options.zlibCompressionLevel ?? 0 - }); + agreedCompressor: options.agreedCompressor ?? 'none', + zlibCompressionLevel: options.zlibCompressionLevel ?? 0 + }); const buffer = Buffer.concat(await finalCommand.toBin()); diff --git a/src/mongo_client.ts b/src/mongo_client.ts index 1ac02e93c6..75a2bc9fd2 100644 --- a/src/mongo_client.ts +++ b/src/mongo_client.ts @@ -1035,39 +1035,39 @@ export class MongoClient extends TypedEventEmitter implements */ export interface MongoOptions extends Required< - Pick< - MongoClientOptions, - | 'autoEncryption' - | 'connectTimeoutMS' - | 'directConnection' - | 'driverInfo' - | 'forceServerObjectId' - | 'minHeartbeatFrequencyMS' - | 'heartbeatFrequencyMS' - | 'localThresholdMS' - | 'maxConnecting' - | 'maxIdleTimeMS' - | 'maxPoolSize' - | 'minPoolSize' - | 'monitorCommands' - | 'noDelay' - | 'pkFactory' - | 'raw' - | 'replicaSet' - | 'retryReads' - | 'retryWrites' - | 'serverSelectionTimeoutMS' - | 'socketTimeoutMS' - | 'srvMaxHosts' - | 'srvServiceName' - | 'tlsAllowInvalidCertificates' - | 'tlsAllowInvalidHostnames' - | 'tlsInsecure' - | 'waitQueueTimeoutMS' - | 'zlibCompressionLevel' - > - >, - SupportedNodeConnectionOptions { + Pick< + MongoClientOptions, + | 'autoEncryption' + | 'connectTimeoutMS' + | 'directConnection' + | 'driverInfo' + | 'forceServerObjectId' + | 'minHeartbeatFrequencyMS' + | 'heartbeatFrequencyMS' + | 'localThresholdMS' + | 'maxConnecting' + | 'maxIdleTimeMS' + | 'maxPoolSize' + | 'minPoolSize' + | 'monitorCommands' + | 'noDelay' + | 'pkFactory' + | 'raw' + | 'replicaSet' + | 'retryReads' + | 'retryWrites' + | 'serverSelectionTimeoutMS' + | 'socketTimeoutMS' + | 'srvMaxHosts' + | 'srvServiceName' + | 'tlsAllowInvalidCertificates' + | 'tlsAllowInvalidHostnames' + | 'tlsInsecure' + | 'waitQueueTimeoutMS' + | 'zlibCompressionLevel' + > + >, + SupportedNodeConnectionOptions { appName?: string; hosts: HostAddress[]; srvHost?: string; diff --git a/src/runtime_adapters.ts b/src/runtime_adapters.ts new file mode 100644 index 0000000000..3ad5e8751c --- /dev/null +++ b/src/runtime_adapters.ts @@ -0,0 +1,25 @@ +/** + * @public + * @experimental + */ +export type OsAdapter = Pick; + +/** + * @public + * @experimental + * + * This type represents the interface that the driver needs from the runtime in order to function. + */ +export interface RuntimeAdapters { + os?: OsAdapter; +} + +/** + * @internal + * + * Represents a complete, parsed set of runtime adapters. After options parsing, all adapters + * are always present (either using the user's provided adapter, or defaulting to Nodejs' module). + */ +export interface Runtime { + os: OsAdapter; +} diff --git a/test/tools/utils.ts b/test/tools/utils.ts index 5a23fdd970..97def9d179 100644 --- a/test/tools/utils.ts +++ b/test/tools/utils.ts @@ -7,6 +7,7 @@ import * as path from 'node:path'; import { EJSON } from 'bson'; import * as BSON from 'bson'; import { expect } from 'chai'; +import * as os from 'os'; import * as process from 'process'; import { Readable } from 'stream'; import { setTimeout } from 'timers'; @@ -18,6 +19,7 @@ import { type HostAddress, MongoClient, type MongoClientOptions, + type Runtime, type ServerApiVersion, type TopologyOptions } from '../../src'; @@ -604,3 +606,7 @@ export function configureMongocryptdSpawnHooks( port }; } + +export const runtime: Runtime = { + os +}; diff --git a/test/unit/assorted/optional_require.test.ts b/test/unit/assorted/optional_require.test.ts index f6772baf2d..463f7f95ff 100644 --- a/test/unit/assorted/optional_require.test.ts +++ b/test/unit/assorted/optional_require.test.ts @@ -7,6 +7,7 @@ import { GSSAPI } from '../../../src/cmap/auth/gssapi'; import { compress } from '../../../src/cmap/wire_protocol/compression'; import { MongoMissingDependencyError } from '../../../src/error'; import { HostAddress } from '../../../src/utils'; +import { runtime } from '../../tools/utils'; function moduleExistsSync(moduleName) { return existsSync(resolve(__dirname, `../../../node_modules/${moduleName}`)); @@ -41,9 +42,13 @@ describe('optionalRequire', function () { const gssapi = new GSSAPI(); const error = await gssapi - .auth(new AuthContext(null, true, { - hostAddress: new HostAddress('a'), credentials: true, runtime: { os: require('os') } - })) + .auth( + new AuthContext(null, true, { + hostAddress: new HostAddress('a'), + credentials: true, + runtime + }) + ) .then( () => null, e => e diff --git a/test/unit/cmap/connect.test.ts b/test/unit/cmap/connect.test.ts index 145d9f0ff3..cd205de976 100644 --- a/test/unit/cmap/connect.test.ts +++ b/test/unit/cmap/connect.test.ts @@ -15,6 +15,7 @@ import { CancellationToken } from '../../../src/mongo_types'; import { HostAddress, isHello } from '../../../src/utils'; import { genClusterTime } from '../../tools/common'; import * as mock from '../../tools/mongodb-mock/index'; +import { runtime } from '../../tools/utils'; const CONNECT_DEFAULTS = { id: 1, @@ -211,7 +212,7 @@ describe('Connect Tests', function () { options: { ...CONNECT_DEFAULTS, metadata: makeClientMetadata([], { - runtime: { os: require('os') } + runtime }) } }; @@ -242,7 +243,8 @@ describe('Connect Tests', function () { } ], { - appName: longAppName, runtime: { os: require('os') } + appName: longAppName, + runtime } ); const longAuthContext = { @@ -272,7 +274,7 @@ describe('Connect Tests', function () { options: { ...CONNECT_DEFAULTS, metadata: makeClientMetadata([], { - runtime: { os: require('os') } + runtime }) } }; @@ -304,7 +306,7 @@ describe('Connect Tests', function () { ], { appName: longAppName, - runtime: { os: require('os') } + runtime } ); const longAuthContext = { diff --git a/test/unit/cmap/handshake/client_metadata.test.ts b/test/unit/cmap/handshake/client_metadata.test.ts index b4b19b1720..87fd3efcfb 100644 --- a/test/unit/cmap/handshake/client_metadata.test.ts +++ b/test/unit/cmap/handshake/client_metadata.test.ts @@ -12,11 +12,6 @@ import { makeClientMetadata } from '../../../../src/cmap/handshake/client_metadata'; import { MongoInvalidArgumentError } from '../../../../src/error'; -import { Runtime } from '../../../../src'; - -const runtime: Runtime = { - os: require('os') -}; describe('client metadata module', () => { afterEach(() => sinon.restore()); @@ -169,7 +164,9 @@ describe('client metadata module', () => { context('when driverInfo.platform is provided', () => { it('throws an error if driverInfo.platform is too large', async () => { - const error = await makeClientMetadata([{ platform: 'a'.repeat(512) }], { runtime }).catch(e => e); + const error = await makeClientMetadata([{ platform: 'a'.repeat(512) }], { runtime }).catch( + e => e + ); expect(error) .to.be.instanceOf(MongoInvalidArgumentError) .to.match(/platform/); @@ -195,7 +192,9 @@ describe('client metadata module', () => { context('when driverInfo.name is provided', () => { it('throws an error if driverInfo.name is too large', async () => { - const error = await makeClientMetadata([{ name: 'a'.repeat(512) }], { runtime }).catch(e => e); + const error = await makeClientMetadata([{ name: 'a'.repeat(512) }], { runtime }).catch( + e => e + ); expect(error).to.be.instanceOf(MongoInvalidArgumentError).to.match(/name/); }); @@ -219,7 +218,9 @@ describe('client metadata module', () => { context('when driverInfo.version is provided', () => { it('throws an error if driverInfo.version is too large', async () => { - const error = await makeClientMetadata([{ version: 'a'.repeat(512) }], { runtime }).catch(e => e); + const error = await makeClientMetadata([{ version: 'a'.repeat(512) }], { runtime }).catch( + e => e + ); expect(error) .to.be.instanceOf(MongoInvalidArgumentError) .to.match(/version/); @@ -540,7 +541,9 @@ describe('client metadata module', () => { }); it('does not attach it to the metadata', async () => { - expect(await makeClientMetadata([], { runtime })).not.to.have.nested.property('aws.memory_mb'); + expect(await makeClientMetadata([], { runtime })).not.to.have.nested.property( + 'aws.memory_mb' + ); }); }); }); diff --git a/test/unit/sdam/topology.test.ts b/test/unit/sdam/topology.test.ts index 1dab4f6a93..8db64288bd 100644 --- a/test/unit/sdam/topology.test.ts +++ b/test/unit/sdam/topology.test.ts @@ -28,12 +28,7 @@ import { TopologyDescription } from '../../../src/sdam/topology_description'; import { TimeoutContext } from '../../../src/timeout'; import { isHello, ns } from '../../../src/utils'; import * as mock from '../../tools/mongodb-mock/index'; -import { topologyWithPlaceholderClient } from '../../tools/utils'; -import { Runtime } from '../../../src'; - -const runtime: Runtime = { - os: require('os') -}; +import { runtime, topologyWithPlaceholderClient } from '../../tools/utils'; describe('Topology (unit)', function () { let client, topology; @@ -126,7 +121,7 @@ describe('Topology (unit)', function () { }); const server = await topology.selectServer('primary', { timeoutContext: ctx, - operationName: 'none', + operationName: 'none' }); const err = await server .command(new RunCursorCommandOperation(ns('admin.$cmd'), { ping: 1 }, {}), ctx) From 1d1c89ec58a6a4b5fa2ef4c866d82503a108bdd1 Mon Sep 17 00:00:00 2001 From: bailey Date: Wed, 28 Jan 2026 15:33:38 -0700 Subject: [PATCH 03/36] add adapter unit test --- test/unit/runtime_adapters.test.ts | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 test/unit/runtime_adapters.test.ts diff --git a/test/unit/runtime_adapters.test.ts b/test/unit/runtime_adapters.test.ts new file mode 100644 index 0000000000..d7ee11a70f --- /dev/null +++ b/test/unit/runtime_adapters.test.ts @@ -0,0 +1,30 @@ +import { expect } from "chai" +import { MongoClient, OsAdapter } from "../../src" +import * as os from 'os'; + +describe('Runtime Adapters tests', function () { + describe('`os`', function () { + describe('when no os adapter is provided', function () { + it(`defaults to Node's os module`, function () { + const client = new MongoClient('mongodb://localhost:27017'); + + expect(client.options.runtime.os).to.equal(os); + }) + }) + + describe('when an os adapter is provided', function () { + it(`uses the user provided adapter`, function () { + const osAdapter: OsAdapter = { + ...os + }; + const client = new MongoClient('mongodb://localhost:27017', { + runtimeAdapters: { + os: osAdapter + } + }); + + expect(client.options.runtime.os).to.equal(osAdapter); + }) + }) + }) +}) \ No newline at end of file From 58d8976ce7f3d0b7580859c9ded15871e77c6fd1 Mon Sep 17 00:00:00 2001 From: bailey Date: Wed, 28 Jan 2026 15:46:30 -0700 Subject: [PATCH 04/36] unit tests and integration tests --- .../connection.test.ts | 15 ++++-- .../cmap/handshake/client_metadata.test.ts | 1 + test/unit/runtime_adapters.test.ts | 49 ++++++++++--------- 3 files changed, 37 insertions(+), 28 deletions(-) diff --git a/test/integration/connection-monitoring-and-pooling/connection.test.ts b/test/integration/connection-monitoring-and-pooling/connection.test.ts index a20f36c7b6..b6aaf75969 100644 --- a/test/integration/connection-monitoring-and-pooling/connection.test.ts +++ b/test/integration/connection-monitoring-and-pooling/connection.test.ts @@ -22,7 +22,7 @@ import { LEGACY_HELLO_COMMAND } from '../../../src/constants'; import { Topology } from '../../../src/sdam/topology'; import { HostAddress, ns } from '../../../src/utils'; import * as mock from '../../tools/mongodb-mock/index'; -import { processTick, sleep } from '../../tools/utils'; +import { processTick, runtime, sleep } from '../../tools/utils'; import { assert as test, setupDatabase } from '../shared'; const commonConnectOptions = { @@ -49,7 +49,10 @@ describe('Connection', function () { ...commonConnectOptions, connectionType: Connection, ...this.configuration.options, - metadata: makeClientMetadata([], {}) + metadata: makeClientMetadata([], { + runtime + }), + runtime }; let conn; @@ -71,7 +74,8 @@ describe('Connection', function () { connectionType: Connection, ...this.configuration.options, monitorCommands: true, - metadata: makeClientMetadata([], {}) + runtime, + metadata: makeClientMetadata([], { runtime }) }; let conn; @@ -102,7 +106,10 @@ describe('Connection', function () { connectionType: Connection, ...this.configuration.options, monitorCommands: true, - metadata: makeClientMetadata([], {}) + runtime, + metadata: makeClientMetadata([], { + runtime + }) }; let conn; diff --git a/test/unit/cmap/handshake/client_metadata.test.ts b/test/unit/cmap/handshake/client_metadata.test.ts index 87fd3efcfb..a7c5e864d7 100644 --- a/test/unit/cmap/handshake/client_metadata.test.ts +++ b/test/unit/cmap/handshake/client_metadata.test.ts @@ -12,6 +12,7 @@ import { makeClientMetadata } from '../../../../src/cmap/handshake/client_metadata'; import { MongoInvalidArgumentError } from '../../../../src/error'; +import { runtime } from '../../../tools/utils'; describe('client metadata module', () => { afterEach(() => sinon.restore()); diff --git a/test/unit/runtime_adapters.test.ts b/test/unit/runtime_adapters.test.ts index d7ee11a70f..3980f9f1d7 100644 --- a/test/unit/runtime_adapters.test.ts +++ b/test/unit/runtime_adapters.test.ts @@ -1,30 +1,31 @@ -import { expect } from "chai" -import { MongoClient, OsAdapter } from "../../src" +import { expect } from 'chai'; import * as os from 'os'; +import { MongoClient, type OsAdapter } from '../../src'; + describe('Runtime Adapters tests', function () { - describe('`os`', function () { - describe('when no os adapter is provided', function () { - it(`defaults to Node's os module`, function () { - const client = new MongoClient('mongodb://localhost:27017'); + describe('`os`', function () { + describe('when no os adapter is provided', function () { + it(`defaults to Node's os module`, function () { + const client = new MongoClient('mongodb://localhost:27017'); - expect(client.options.runtime.os).to.equal(os); - }) - }) + expect(client.options.runtime.os).to.equal(os); + }); + }); - describe('when an os adapter is provided', function () { - it(`uses the user provided adapter`, function () { - const osAdapter: OsAdapter = { - ...os - }; - const client = new MongoClient('mongodb://localhost:27017', { - runtimeAdapters: { - os: osAdapter - } - }); + describe('when an os adapter is provided', function () { + it(`uses the user provided adapter`, function () { + const osAdapter: OsAdapter = { + ...os + }; + const client = new MongoClient('mongodb://localhost:27017', { + runtimeAdapters: { + os: osAdapter + } + }); - expect(client.options.runtime.os).to.equal(osAdapter); - }) - }) - }) -}) \ No newline at end of file + expect(client.options.runtime.os).to.equal(osAdapter); + }); + }); + }); +}); From 9e0e0ff1ca9fbdad1ccfe49d6dfcabea10738787 Mon Sep 17 00:00:00 2001 From: bailey Date: Mon, 2 Feb 2026 11:21:42 -0700 Subject: [PATCH 05/36] cleanup implementation, fix tests --- src/connection_string.ts | 9 ++------- src/mongo_client.ts | 6 +++++- src/runtime_adapters.ts | 29 ++++++++++++++++++++++++++--- test/tools/utils.ts | 9 +++++---- 4 files changed, 38 insertions(+), 15 deletions(-) diff --git a/src/connection_string.ts b/src/connection_string.ts index ce63e99ad9..06315a9686 100644 --- a/src/connection_string.ts +++ b/src/connection_string.ts @@ -20,7 +20,7 @@ import { import { MongoLoggableComponent, MongoLogger, SeverityLevel } from './mongo_logger'; import { ReadConcern, type ReadConcernLevel } from './read_concern'; import { ReadPreference, type ReadPreferenceMode } from './read_preference'; -import { type Runtime } from './runtime_adapters'; +import { resolveRuntimeAdapters } from './runtime_adapters'; import { ServerMonitoringMode } from './sdam/monitor'; import type { TagSet } from './sdam/server_description'; import { @@ -539,12 +539,7 @@ export function parseOptions( } ); - const runtime: Runtime = { - // eslint-disable-next-line @typescript-eslint/no-require-imports - os: options.runtimeAdapters?.os ?? require('os') - }; - - mongoOptions.runtime = runtime; + mongoOptions.runtime = resolveRuntimeAdapters(options); return mongoOptions; } diff --git a/src/mongo_client.ts b/src/mongo_client.ts index 75a2bc9fd2..87d969fee9 100644 --- a/src/mongo_client.ts +++ b/src/mongo_client.ts @@ -319,7 +319,11 @@ export interface MongoClientOptions extends BSONSerializeOptions, SupportedNodeC connectionType?: typeof Connection; /** @internal */ __skipPingOnConnect?: boolean; - /** @experimental */ + /** + * @experimental + * + * If provided, any adapters provided will be used in place of the corresponding Node.js module. + */ runtimeAdapters?: RuntimeAdapters; } diff --git a/src/runtime_adapters.ts b/src/runtime_adapters.ts index 3ad5e8751c..43f48f3934 100644 --- a/src/runtime_adapters.ts +++ b/src/runtime_adapters.ts @@ -1,14 +1,24 @@ +/* eslint-disable no-restricted-imports */ +// We squash the restricted import errors here because we are using type-only imports, which +// do not impact the driver's actual runtime dependencies. + +import type * as os from 'os'; + +import { type MongoClientOptions } from './mongo_client'; + /** * @public * @experimental + * + * Represents the set of dependencies that the driver uses from the [Node.js OS module](https://nodejs.org/api/os.html). */ -export type OsAdapter = Pick; +export type OsAdapter = Pick; /** * @public * @experimental * - * This type represents the interface that the driver needs from the runtime in order to function. + * This type represents the set of dependencies that the driver needs from the Javascript runtime in order to function. */ export interface RuntimeAdapters { os?: OsAdapter; @@ -18,8 +28,21 @@ export interface RuntimeAdapters { * @internal * * Represents a complete, parsed set of runtime adapters. After options parsing, all adapters - * are always present (either using the user's provided adapter, or defaulting to Nodejs' module). + * are always present (either using the user's provided adapter, or defaulting to the Node.js module). */ export interface Runtime { os: OsAdapter; } + +/** + * @internal + * + * Given a MongoClientOptions, this function resolves the set of runtime options, providing Nodejs implementations if + * not provided by in `options`, and returns a `Runtime`. + */ +export function resolveRuntimeAdapters(options: MongoClientOptions): Runtime { + return { + // eslint-disable-next-line @typescript-eslint/no-require-imports + os: options.runtimeAdapters?.os ?? require('os') + }; +} diff --git a/test/tools/utils.ts b/test/tools/utils.ts index 97def9d179..d3948d773c 100644 --- a/test/tools/utils.ts +++ b/test/tools/utils.ts @@ -7,7 +7,6 @@ import * as path from 'node:path'; import { EJSON } from 'bson'; import * as BSON from 'bson'; import { expect } from 'chai'; -import * as os from 'os'; import * as process from 'process'; import { Readable } from 'stream'; import { setTimeout } from 'timers'; @@ -24,6 +23,7 @@ import { type TopologyOptions } from '../../src'; import { OP_MSG } from '../../src/cmap/wire_protocol/constants'; +import { resolveRuntimeAdapters } from '../../src/runtime_adapters'; import { Topology } from '../../src/sdam/topology'; import { processTimeMS } from '../../src/utils'; import { type TestConfiguration } from './runner/config'; @@ -607,6 +607,7 @@ export function configureMongocryptdSpawnHooks( }; } -export const runtime: Runtime = { - os -}; +/** + * A `Runtime` that resolves to entirely Nodejs modules, useful when tests must provide a default `runtime` object to an API. + */ +export const runtime: Runtime = resolveRuntimeAdapters({}); From 0738ef88f3a7d519d049f7c88cec7093b975d9e9 Mon Sep 17 00:00:00 2001 From: bailey Date: Mon, 2 Feb 2026 13:30:18 -0700 Subject: [PATCH 06/36] comments --- src/runtime_adapters.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/runtime_adapters.ts b/src/runtime_adapters.ts index 43f48f3934..bb998d4bd0 100644 --- a/src/runtime_adapters.ts +++ b/src/runtime_adapters.ts @@ -1,6 +1,8 @@ -/* eslint-disable no-restricted-imports */ +/* eslint-disable no-restricted-imports, @typescript-eslint/no-require-imports */ + // We squash the restricted import errors here because we are using type-only imports, which // do not impact the driver's actual runtime dependencies. +// We also allow restricted imports in this file, because we expect this file to be the only place actually importing restricted Node APIs. import type * as os from 'os'; @@ -42,7 +44,6 @@ export interface Runtime { */ export function resolveRuntimeAdapters(options: MongoClientOptions): Runtime { return { - // eslint-disable-next-line @typescript-eslint/no-require-imports os: options.runtimeAdapters?.os ?? require('os') }; } From 358ede2cc24b0fab4ed5cb9272fbfa36465c270d Mon Sep 17 00:00:00 2001 From: bailey Date: Mon, 2 Feb 2026 16:46:34 -0700 Subject: [PATCH 07/36] working POC bundle + context --- .gitignore | 1 + package-lock.json | 502 ++++++++++++++++++++++++- package.json | 6 +- test/integration/crud/crud_api.test.ts | 27 +- test/tools/runner/config.ts | 65 +++- 5 files changed, 576 insertions(+), 25 deletions(-) diff --git a/.gitignore b/.gitignore index ffc4acb3e9..9ba7a0df0e 100644 --- a/.gitignore +++ b/.gitignore @@ -108,3 +108,4 @@ uri.txt crypt_shared.sh *keytab +driver.bundle.js diff --git a/package-lock.json b/package-lock.json index cbf0eb13e7..27fbd15270 100644 --- a/package-lock.json +++ b/package-lock.json @@ -37,6 +37,7 @@ "chai": "^4.4.1", "chai-subset": "^1.6.0", "chalk": "^4.1.2", + "esbuild": "^0.27.2", "eslint": "^9.39.1", "eslint-config-prettier": "^10.1.8", "eslint-plugin-mocha": "^10.4.1", @@ -847,6 +848,7 @@ "integrity": "sha512-e7jT4DxYvIDLk1ZHmU/m/mB19rex9sv0c2ftBtjSBv+kVM/902eh0fINUzD7UwLLNR+jU585GxUJ8/EBfAM5fw==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "@babel/code-frame": "^7.27.1", "@babel/generator": "^7.28.5", @@ -1141,6 +1143,448 @@ "tslib": "^2.4.0" } }, + "node_modules/@esbuild/aix-ppc64": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.27.2.tgz", + "integrity": "sha512-GZMB+a0mOMZs4MpDbj8RJp4cw+w1WV5NYD6xzgvzUJ5Ek2jerwfO2eADyI6ExDSUED+1X8aMbegahsJi+8mgpw==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "aix" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-arm": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.27.2.tgz", + "integrity": "sha512-DVNI8jlPa7Ujbr1yjU2PfUSRtAUZPG9I1RwW4F4xFB1Imiu2on0ADiI/c3td+KmDtVKNbi+nffGDQMfcIMkwIA==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-arm64": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.27.2.tgz", + "integrity": "sha512-pvz8ZZ7ot/RBphf8fv60ljmaoydPU12VuXHImtAs0XhLLw+EXBi2BLe3OYSBslR4rryHvweW5gmkKFwTiFy6KA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-x64": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.27.2.tgz", + "integrity": "sha512-z8Ank4Byh4TJJOh4wpz8g2vDy75zFL0TlZlkUkEwYXuPSgX8yzep596n6mT7905kA9uHZsf/o2OJZubl2l3M7A==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/darwin-arm64": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.27.2.tgz", + "integrity": "sha512-davCD2Zc80nzDVRwXTcQP/28fiJbcOwvdolL0sOiOsbwBa72kegmVU0Wrh1MYrbuCL98Omp5dVhQFWRKR2ZAlg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/darwin-x64": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.27.2.tgz", + "integrity": "sha512-ZxtijOmlQCBWGwbVmwOF/UCzuGIbUkqB1faQRf5akQmxRJ1ujusWsb3CVfk/9iZKr2L5SMU5wPBi1UWbvL+VQA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/freebsd-arm64": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.27.2.tgz", + "integrity": "sha512-lS/9CN+rgqQ9czogxlMcBMGd+l8Q3Nj1MFQwBZJyoEKI50XGxwuzznYdwcav6lpOGv5BqaZXqvBSiB/kJ5op+g==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/freebsd-x64": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.27.2.tgz", + "integrity": "sha512-tAfqtNYb4YgPnJlEFu4c212HYjQWSO/w/h/lQaBK7RbwGIkBOuNKQI9tqWzx7Wtp7bTPaGC6MJvWI608P3wXYA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-arm": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.27.2.tgz", + "integrity": "sha512-vWfq4GaIMP9AIe4yj1ZUW18RDhx6EPQKjwe7n8BbIecFtCQG4CfHGaHuh7fdfq+y3LIA2vGS/o9ZBGVxIDi9hw==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-arm64": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.27.2.tgz", + "integrity": "sha512-hYxN8pr66NsCCiRFkHUAsxylNOcAQaxSSkHMMjcpx0si13t1LHFphxJZUiGwojB1a/Hd5OiPIqDdXONia6bhTw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-ia32": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.27.2.tgz", + "integrity": "sha512-MJt5BRRSScPDwG2hLelYhAAKh9imjHK5+NE/tvnRLbIqUWa+0E9N4WNMjmp/kXXPHZGqPLxggwVhz7QP8CTR8w==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-loong64": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.27.2.tgz", + "integrity": "sha512-lugyF1atnAT463aO6KPshVCJK5NgRnU4yb3FUumyVz+cGvZbontBgzeGFO1nF+dPueHD367a2ZXe1NtUkAjOtg==", + "cpu": [ + "loong64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-mips64el": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.27.2.tgz", + "integrity": "sha512-nlP2I6ArEBewvJ2gjrrkESEZkB5mIoaTswuqNFRv/WYd+ATtUpe9Y09RnJvgvdag7he0OWgEZWhviS1OTOKixw==", + "cpu": [ + "mips64el" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-ppc64": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.27.2.tgz", + "integrity": "sha512-C92gnpey7tUQONqg1n6dKVbx3vphKtTHJaNG2Ok9lGwbZil6DrfyecMsp9CrmXGQJmZ7iiVXvvZH6Ml5hL6XdQ==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-riscv64": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.27.2.tgz", + "integrity": "sha512-B5BOmojNtUyN8AXlK0QJyvjEZkWwy/FKvakkTDCziX95AowLZKR6aCDhG7LeF7uMCXEJqwa8Bejz5LTPYm8AvA==", + "cpu": [ + "riscv64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-s390x": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.27.2.tgz", + "integrity": "sha512-p4bm9+wsPwup5Z8f4EpfN63qNagQ47Ua2znaqGH6bqLlmJ4bx97Y9JdqxgGZ6Y8xVTixUnEkoKSHcpRlDnNr5w==", + "cpu": [ + "s390x" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-x64": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.27.2.tgz", + "integrity": "sha512-uwp2Tip5aPmH+NRUwTcfLb+W32WXjpFejTIOWZFw/v7/KnpCDKG66u4DLcurQpiYTiYwQ9B7KOeMJvLCu/OvbA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/netbsd-arm64": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-arm64/-/netbsd-arm64-0.27.2.tgz", + "integrity": "sha512-Kj6DiBlwXrPsCRDeRvGAUb/LNrBASrfqAIok+xB0LxK8CHqxZ037viF13ugfsIpePH93mX7xfJp97cyDuTZ3cw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/netbsd-x64": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.27.2.tgz", + "integrity": "sha512-HwGDZ0VLVBY3Y+Nw0JexZy9o/nUAWq9MlV7cahpaXKW6TOzfVno3y3/M8Ga8u8Yr7GldLOov27xiCnqRZf0tCA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openbsd-arm64": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-arm64/-/openbsd-arm64-0.27.2.tgz", + "integrity": "sha512-DNIHH2BPQ5551A7oSHD0CKbwIA/Ox7+78/AWkbS5QoRzaqlev2uFayfSxq68EkonB+IKjiuxBFoV8ESJy8bOHA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openbsd-x64": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.27.2.tgz", + "integrity": "sha512-/it7w9Nb7+0KFIzjalNJVR5bOzA9Vay+yIPLVHfIQYG/j+j9VTH84aNB8ExGKPU4AzfaEvN9/V4HV+F+vo8OEg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openharmony-arm64": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/@esbuild/openharmony-arm64/-/openharmony-arm64-0.27.2.tgz", + "integrity": "sha512-LRBbCmiU51IXfeXk59csuX/aSaToeG7w48nMwA6049Y4J4+VbWALAuXcs+qcD04rHDuSCSRKdmY63sruDS5qag==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openharmony" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/sunos-x64": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.27.2.tgz", + "integrity": "sha512-kMtx1yqJHTmqaqHPAzKCAkDaKsffmXkPHThSfRwZGyuqyIeBvf08KSsYXl+abf5HDAPMJIPnbBfXvP2ZC2TfHg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "sunos" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-arm64": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.27.2.tgz", + "integrity": "sha512-Yaf78O/B3Kkh+nKABUF++bvJv5Ijoy9AN1ww904rOXZFLWVc5OLOfL56W+C8F9xn5JQZa3UX6m+IktJnIb1Jjg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-ia32": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.27.2.tgz", + "integrity": "sha512-Iuws0kxo4yusk7sw70Xa2E2imZU5HoixzxfGCdxwBdhiDgt9vX9VUCBhqcwY7/uh//78A1hMkkROMJq9l27oLQ==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-x64": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.27.2.tgz", + "integrity": "sha512-sRdU18mcKf7F+YgheI/zGf5alZatMUTKj/jNS6l744f9u3WFu4v7twcUI9vu4mknF4Y9aDlblIie0IM+5xxaqQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, "node_modules/@eslint-community/eslint-utils": { "version": "4.9.0", "resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.9.0.tgz", @@ -3025,7 +3469,8 @@ "resolved": "https://registry.npmjs.org/@types/chai/-/chai-4.3.20.tgz", "integrity": "sha512-/pC9HAB5I/xMlc5FP77qjCnI16ChlJfW0tGa0IUcFn38VJrTV6DeZ60NU5KZBtaOZqjdpwTWohz5HU1RrhiYxQ==", "dev": true, - "license": "MIT" + "license": "MIT", + "peer": true }, "node_modules/@types/chai-subset": { "version": "1.3.6", @@ -3127,6 +3572,7 @@ "integrity": "sha512-BICHQ67iqxQGFSzfCFTT7MRQ5XcBjG5aeKh5Ok38UBbPe5fxTyE+aHFxwVrGyr8GNlqFMLKD1D3P2K/1ks8tog==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "undici-types": "~6.21.0" } @@ -3258,6 +3704,7 @@ "integrity": "sha512-sbaQ27XBUopBkRiuY/P9sWGOWUW4rl8fDoHIUmLpZd8uldsTyB4/Zg6bWTegPoTLnKj9Hqgn3QD6cjPNB32Odw==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "@eslint-community/regexpp": "^4.10.0", "@typescript-eslint/scope-manager": "8.46.3", @@ -3288,6 +3735,7 @@ "integrity": "sha512-6m1I5RmHBGTnUGS113G04DMu3CpSdxCAU/UvtjNWL4Nuf3MW9tQhiJqRlHzChIkhy6kZSAQmc+I1bcGjE3yNKg==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "@typescript-eslint/scope-manager": "8.46.3", "@typescript-eslint/types": "8.46.3", @@ -3533,6 +3981,7 @@ "integrity": "sha512-NZyJarBfL7nWwIq+FDL6Zp/yHEhePMNnnJ0y3qfieCrmNvYct8uvtiV41UvlSe6apAfk0fY1FbWx+NwfmpvtTg==", "dev": true, "license": "MIT", + "peer": true, "bin": { "acorn": "bin/acorn" }, @@ -3593,6 +4042,7 @@ "integrity": "sha512-sRu1kpcO9yLtYxBKvqfTeh9KzZEwO3STyX1HT+4CaDzC6HpTGYhIhPIzj9XuKU7KYDwnaeh5hcOwjy1QuJzBPA==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "fast-deep-equal": "^3.1.1", "json-schema-traverse": "^1.0.0", @@ -3908,6 +4358,7 @@ } ], "license": "MIT", + "peer": true, "dependencies": { "baseline-browser-mapping": "^2.8.19", "caniuse-lite": "^1.0.30001751", @@ -4085,6 +4536,7 @@ "integrity": "sha512-RITGBfijLkBddZvnn8jdqoTypxvqbOLYQkGGxXzeFjVHvudaPw0HNFD9x928/eUwYWd2dPCugVqspGALTZZQKw==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "assertion-error": "^1.1.0", "check-error": "^1.0.3", @@ -4655,6 +5107,48 @@ "dev": true, "license": "MIT" }, + "node_modules/esbuild": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.27.2.tgz", + "integrity": "sha512-HyNQImnsOC7X9PMNaCIeAm4ISCQXs5a5YasTXVliKv4uuBo1dKrG0A+uQS8M5eXjVMnLg3WgXaKvprHlFJQffw==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "bin": { + "esbuild": "bin/esbuild" + }, + "engines": { + "node": ">=18" + }, + "optionalDependencies": { + "@esbuild/aix-ppc64": "0.27.2", + "@esbuild/android-arm": "0.27.2", + "@esbuild/android-arm64": "0.27.2", + "@esbuild/android-x64": "0.27.2", + "@esbuild/darwin-arm64": "0.27.2", + "@esbuild/darwin-x64": "0.27.2", + "@esbuild/freebsd-arm64": "0.27.2", + "@esbuild/freebsd-x64": "0.27.2", + "@esbuild/linux-arm": "0.27.2", + "@esbuild/linux-arm64": "0.27.2", + "@esbuild/linux-ia32": "0.27.2", + "@esbuild/linux-loong64": "0.27.2", + "@esbuild/linux-mips64el": "0.27.2", + "@esbuild/linux-ppc64": "0.27.2", + "@esbuild/linux-riscv64": "0.27.2", + "@esbuild/linux-s390x": "0.27.2", + "@esbuild/linux-x64": "0.27.2", + "@esbuild/netbsd-arm64": "0.27.2", + "@esbuild/netbsd-x64": "0.27.2", + "@esbuild/openbsd-arm64": "0.27.2", + "@esbuild/openbsd-x64": "0.27.2", + "@esbuild/openharmony-arm64": "0.27.2", + "@esbuild/sunos-x64": "0.27.2", + "@esbuild/win32-arm64": "0.27.2", + "@esbuild/win32-ia32": "0.27.2", + "@esbuild/win32-x64": "0.27.2" + } + }, "node_modules/escalade": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.2.0.tgz", @@ -4691,6 +5185,7 @@ "integrity": "sha512-BhHmn2yNOFA9H9JmmIVKJmd288g9hrVRDkdoIgRCRuSySRUHH7r/DI6aAXW9T1WwUuY3DFgrcaqB+deURBLR5g==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "@eslint-community/eslint-utils": "^4.8.0", "@eslint-community/regexpp": "^4.12.1", @@ -4751,6 +5246,7 @@ "integrity": "sha512-82GZUjRS0p/jganf6q1rEO25VSoHH0hKPCTrgillPjdI/3bgBhAE1QzHrHTizjpRvy6pGAvKjDJtk2pF9NDq8w==", "dev": true, "license": "MIT", + "peer": true, "bin": { "eslint-config-prettier": "bin/cli.js" }, @@ -7325,6 +7821,7 @@ "integrity": "sha512-U42vQ4czpKa0QdI1hu950XuNhYqgoM+ZF1HT+VuUHL9hPfDPVvNQyltmMqdE9bUHMVa+8yNbc3QKTj8zQhlVxQ==", "dev": true, "license": "ISC", + "peer": true, "dependencies": { "@istanbuljs/load-nyc-config": "^1.0.0", "@istanbuljs/schema": "^0.1.2", @@ -8009,6 +8506,7 @@ "integrity": "sha512-I7AIg5boAr5R0FFtJ6rCfD+LFsWHp81dolrFD8S79U9tb8Az2nGrJncnMSnys+bpQJfRUzqs9hnA81OAA3hCuQ==", "dev": true, "license": "MIT", + "peer": true, "bin": { "prettier": "bin/prettier.cjs" }, @@ -8864,6 +9362,7 @@ "integrity": "sha512-a2N2TDY1uGviajJ6r4D1CyRAkzE9NNVlYOV1wX5xQDuAk0ONgzgRl0EjCQuRCPxOwp13ghsMwt9Gdldujs39qw==", "dev": true, "license": "BSD-3-Clause", + "peer": true, "dependencies": { "@sinonjs/commons": "^3.0.1", "@sinonjs/fake-timers": "11.2.2", @@ -9646,6 +10145,7 @@ "integrity": "sha512-p1diW6TqL9L07nNxvRMM7hMMw4c5XOo/1ibL4aAIGmSAt9slTE1Xgw5KWuof2uTOvCg9BY7ZRi+GaF+7sfgPeQ==", "dev": true, "license": "Apache-2.0", + "peer": true, "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" diff --git a/package.json b/package.json index 6daf61d6d5..00c194d4fb 100644 --- a/package.json +++ b/package.json @@ -85,6 +85,7 @@ "chai": "^4.4.1", "chai-subset": "^1.6.0", "chalk": "^4.1.2", + "esbuild": "^0.27.2", "eslint": "^9.39.1", "eslint-config-prettier": "^10.1.8", "eslint-plugin-mocha": "^10.4.1", @@ -154,6 +155,9 @@ "check:csfle": "nyc mocha --config test/mocha_mongodb.js test/integration/client-side-encryption", "check:snappy": "nyc mocha test/unit/assorted/snappy.test.js", "check:x509": "nyc mocha test/manual/x509_auth.test.ts", + "check:runtime-independence": "ts-node test/tools/runner/vm_runner.ts test/integration/change-streams/change_stream.test.ts", + "bundle:driver": "node etc/bundle-driver.mjs", + "test:bundled": "npm run bundle:driver && npm run check:test", "fix:eslint": "npm run check:eslint -- --fix", "prepare": "node etc/prepare.js", "preview:docs": "ts-node etc/docs/preview.ts", @@ -170,4 +174,4 @@ "moduleResolution": "node" } } -} +} \ No newline at end of file diff --git a/test/integration/crud/crud_api.test.ts b/test/integration/crud/crud_api.test.ts index cedea9d867..d6029553c2 100644 --- a/test/integration/crud/crud_api.test.ts +++ b/test/integration/crud/crud_api.test.ts @@ -3,27 +3,37 @@ import { finished } from 'node:stream/promises'; import { expect } from 'chai'; import * as sinon from 'sinon'; -import { +import { loadContextifiedMongoDBModule } from '../../tools/runner/vm_context_helper'; +import { type FailCommandFailPoint } from '../../tools/utils'; +import { assert as test } from '../shared'; + +// Load MongoDB module in VM context +const mongodb = loadContextifiedMongoDBModule(); + +// Extract the exports we need from the contextified module +const { Collection, CommandFailedEvent, - type CommandStartedEvent, CommandSucceededEvent, - type Db, MongoBulkWriteError, - type MongoClient, + MongoClient, MongoServerError, ObjectId, ReturnDocument -} from '../../../src'; -import { type FailCommandFailPoint } from '../../tools/utils'; -import { assert as test } from '../shared'; +} = mongodb; + +type MongoClient = typeof mongodb.MongoClient.prototype; +type Db = typeof mongodb.Db.prototype; +type CommandStartedEvent = typeof mongodb.CommandStartedEvent.prototype; const DB_NAME = 'crud_api_tests'; -describe('CRUD API', function () { +describe.only('CRUD API', function () { let client: MongoClient; beforeEach(async function () { + this.configuration.mongodb = mongodb; + client = this.configuration.newClient(); client.s.options.dbName = DB_NAME; // setup the default db @@ -817,6 +827,7 @@ describe('CRUD API', function () { let collection: Collection; beforeEach(async function () { + this.configuration.mongodb = mongodb; client = this.configuration.newClient({ monitorCommands: true }); events = []; client.on('commandStarted', commandStarted => diff --git a/test/tools/runner/config.ts b/test/tools/runner/config.ts index adcb31674a..0e57a18a3e 100644 --- a/test/tools/runner/config.ts +++ b/test/tools/runner/config.ts @@ -114,20 +114,32 @@ export class TestConfiguration { filters: Record; compressor: CompressorName | null; + // Optional: contextified MongoDB module exports for VM-based testing + private mongodb?: any; + constructor( private uri: string, - private context: Record + private context: Record, + mongodb?: any // Optional contextified mongodb module ) { + this.mongodb = mongodb; + const url = new ConnectionString(uri); const { hosts } = url; - const hostAddresses = hosts.map(HostAddress.fromString); + const hostAddresses = hosts.map( + this.mongodb ? this.mongodb.HostAddress.fromString : HostAddress.fromString + ); this.version = context.version; this.clientSideEncryption = context.clientSideEncryption; this.cryptSharedVersion = context.cryptShared; this.parameters = { ...context.parameters }; this.singleMongosLoadBalancerUri = context.singleMongosLoadBalancerUri; this.multiMongosLoadBalancerUri = context.multiMongosLoadBalancerUri; - this.topologyType = this.isLoadBalanced ? TopologyType.LoadBalanced : context.topologyType; + this.topologyType = this.isLoadBalanced + ? this.mongodb + ? this.mongodb.TopologyType.LoadBalanced + : TopologyType.LoadBalanced + : context.topologyType; this.buildInfo = context.buildInfo; this.serverApi = context.serverApi; this.isSrv = uri.indexOf('mongodb+srv') > -1; @@ -229,6 +241,14 @@ export class TestConfiguration { serverOptions = Object.assign(baseOptions, getEnvironmentalOptions(), serverOptions); + // If using contextified mongodb, inject Node.js runtime adapters + if (this.mongodb) { + serverOptions.runtimeAdapters = { + os: require('os'), + ...serverOptions.runtimeAdapters + }; + } + if (this.loggingEnabled && !Object.hasOwn(serverOptions, 'mongodbLogPath')) { serverOptions = this.setupLogging(serverOptions); } @@ -239,7 +259,8 @@ export class TestConfiguration { throw new Error(`Cannot use options to specify host/port, must be in ${urlOrQueryOptions}`); } - return new MongoClient(urlOrQueryOptions, serverOptions); + const ClientConstructor = this.mongodb ? this.mongodb.MongoClient : MongoClient; + return new ClientConstructor(urlOrQueryOptions, serverOptions); } const queryOptions = urlOrQueryOptions ?? {}; @@ -283,7 +304,10 @@ export class TestConfiguration { delete queryOptions.writeConcern; } - if (this.topologyType === TopologyType.LoadBalanced) { + const LoadBalancedType = this.mongodb + ? this.mongodb.TopologyType.LoadBalanced + : TopologyType.LoadBalanced; + if (this.topologyType === LoadBalancedType) { queryOptions.loadBalanced = true; } @@ -317,7 +341,8 @@ export class TestConfiguration { const connectionString = url.format(urlOptions); - return new MongoClient(connectionString, serverOptions); + const ClientConstructor = this.mongodb ? this.mongodb.MongoClient : MongoClient; + return new ClientConstructor(connectionString, serverOptions); } /** @@ -439,7 +464,8 @@ export class TestConfiguration { } writeConcernMax(): { writeConcern: WriteConcernSettings } { - if (this.topologyType !== TopologyType.Single) { + const SingleType = this.mongodb ? this.mongodb.TopologyType.Single : TopologyType.Single; + if (this.topologyType !== SingleType) { return { writeConcern: { w: 'majority', wtimeoutMS: 30000 } }; } @@ -451,7 +477,7 @@ export class TestConfiguration { } makeAtlasTestConfiguration(): AtlasTestConfiguration { - return new AtlasTestConfiguration(this.uri, this.context); + return new AtlasTestConfiguration(this.uri, this.context, this.mongodb); } loggingEnabled = false; @@ -463,7 +489,8 @@ export class TestConfiguration { testsToEnableLogging = flakyTests; setupLogging(options: MongoClientOptions, id?: string) { - id ??= new ObjectId().toString(); + const ObjectIdConstructor = this.mongodb ? this.mongodb.ObjectId : ObjectId; + id ??= new ObjectIdConstructor().toString(); this.logs = []; const write = log => this.logs.push({ t: log.t, id, ...log }); options.mongodbLogPath = { write }; @@ -478,6 +505,9 @@ export class TestConfiguration { afterEachLogging(ctx: Context) { if (this.loggingEnabled && ctx.currentTest.state === 'failed') { + const LongConstructor = this.mongodb ? this.mongodb.Long : Long; + const DoubleConstructor = this.mongodb ? this.mongodb.Double : Double; + for (const log of this.logs) { console.error( JSON.stringify( @@ -486,12 +516,13 @@ export class TestConfiguration { if (types.isMap(value)) return { Map: Array.from(value.entries()) }; if (types.isSet(value)) return { Set: Array.from(value.values()) }; if (types.isNativeError(value)) return { [value.name]: util.inspect(value) }; - if (typeof value === 'bigint') return { bigint: new Long(value).toExtendedJSON() }; + if (typeof value === 'bigint') + return { bigint: new LongConstructor(value).toExtendedJSON() }; if (typeof value === 'symbol') return `Symbol(${value.description})`; if (typeof value === 'number') { if (Number.isNaN(value) || !Number.isFinite(value) || Object.is(value, -0)) // @ts-expect-error: toExtendedJSON internal on double but not on long - return { number: new Double(value).toExtendedJSON() }; + return { number: new DoubleConstructor(value).toExtendedJSON() }; } if (Buffer.isBuffer(value)) return { [value.constructor.name]: Buffer.prototype.base64Slice.call(value) }; @@ -515,8 +546,10 @@ export class TestConfiguration { */ export class AtlasTestConfiguration extends TestConfiguration { override newClient(): MongoClient { - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - return new MongoClient(process.env.MONGODB_URI!); + const ClientConstructor = (this as any).mongodb + ? (this as any).mongodb.MongoClient + : MongoClient; + return new ClientConstructor(process.env.MONGODB_URI!); } override url(): string { @@ -530,8 +563,10 @@ export class AtlasTestConfiguration extends TestConfiguration { */ export class AstrolabeTestConfiguration extends TestConfiguration { override newClient(): MongoClient { - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - return new MongoClient(process.env.DRIVERS_ATLAS_TESTING_URI!); + const ClientConstructor = (this as any).mongodb + ? (this as any).mongodb.MongoClient + : MongoClient; + return new ClientConstructor(process.env.DRIVERS_ATLAS_TESTING_URI!); } override url(): string { From c8e5888468835861e5c36e60cc25a37780687e3b Mon Sep 17 00:00:00 2001 From: bailey Date: Mon, 2 Feb 2026 16:46:45 -0700 Subject: [PATCH 08/36] working POC bundle + context --- etc/bundle-driver.mjs | 43 ++++++++ test/mongodb.ts | 140 +++++++++++++++++++++++++ test/tools/runner/vm_context_helper.ts | 129 +++++++++++++++++++++++ 3 files changed, 312 insertions(+) create mode 100755 etc/bundle-driver.mjs create mode 100644 test/mongodb.ts create mode 100644 test/tools/runner/vm_context_helper.ts diff --git a/etc/bundle-driver.mjs b/etc/bundle-driver.mjs new file mode 100755 index 0000000000..e12420ba2a --- /dev/null +++ b/etc/bundle-driver.mjs @@ -0,0 +1,43 @@ +#!/usr/bin/env node +import * as esbuild from 'esbuild'; +import { fileURLToPath } from 'node:url'; +import { isBuiltin } from 'node:module'; +import path from 'node:path'; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); +const rootDir = path.join(__dirname, '..'); + +await esbuild.build({ + entryPoints: [path.join(rootDir, 'src/index.ts')], + bundle: true, + outfile: path.join(rootDir, 'test/tools/runner/driver.bundle.js'), + platform: 'node', + format: 'cjs', + target: 'node20', + external: [ + 'bson', + 'mongodb-connection-string-url', + '@mongodb-js/saslprep', + '@mongodb-js/zstd', + 'mongodb-client-encryption', + 'snappy', + '@napi-rs/snappy*', + 'kerberos', + 'gcp-metadata', + '@aws-sdk/credential-providers' + ], + plugins: [{ + name: 'externalize-node-builtins', + setup(build) { + build.onResolve({ filter: /.*/ }, args => { + if (isBuiltin(args.path)) { + return { path: args.path, external: true }; + } + }); + } + }], + sourcemap: 'inline', + logLevel: 'info' +}); + +console.log('✓ Driver bundle created at test/tools/runner/driver.bundle.js'); \ No newline at end of file diff --git a/test/mongodb.ts b/test/mongodb.ts new file mode 100644 index 0000000000..b289249eb6 --- /dev/null +++ b/test/mongodb.ts @@ -0,0 +1,140 @@ +import * as fs from 'node:fs'; +import * as path from 'node:path'; + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function printExports() { + function* walk(root: string): Generator { + const directoryContents = fs.readdirSync(root); + for (const filepath of directoryContents) { + const fullPath = path.join(root, filepath); + const stat = fs.statSync(fullPath); + if (stat.isDirectory()) { + yield* walk(fullPath); + } else if (stat.isFile()) { + yield fullPath; + } + } + } + const driverSourceFiles = Array.from(walk(path.resolve(__dirname, '..', 'src'))); + + for (const srcFile of driverSourceFiles) { + console.log(`export * from '${path.relative(__dirname, srcFile)}';`); + } +} + +export * from '../src/admin'; +export * from '../src/bson'; +export * from '../src/bulk/common'; +export * from '../src/bulk/ordered'; +export * from '../src/bulk/unordered'; +export * from '../src/change_stream'; +export * from '../src/client-side-encryption/auto_encrypter'; +export * from '../src/client-side-encryption/client_encryption'; +export * from '../src/client-side-encryption/errors'; +export * from '../src/client-side-encryption/mongocryptd_manager'; +export * from '../src/client-side-encryption/providers/aws'; +export * from '../src/client-side-encryption/providers/azure'; +export * from '../src/client-side-encryption/providers/gcp'; +export * from '../src/client-side-encryption/providers/index'; +export * from '../src/client-side-encryption/state_machine'; +export * from '../src/cmap/auth/auth_provider'; +export * from '../src/cmap/auth/aws_temporary_credentials'; +export * from '../src/cmap/auth/gssapi'; +export * from '../src/cmap/auth/mongo_credentials'; +export * from '../src/cmap/auth/mongodb_aws'; +export * from '../src/cmap/auth/mongodb_oidc'; +export * from '../src/cmap/auth/mongodb_oidc/automated_callback_workflow'; +export * from '../src/cmap/auth/mongodb_oidc/azure_machine_workflow'; +export * from '../src/cmap/auth/mongodb_oidc/callback_workflow'; +export * from '../src/cmap/auth/plain'; +export * from '../src/cmap/auth/providers'; +export * from '../src/cmap/auth/scram'; +export * from '../src/cmap/auth/x509'; +export * from '../src/cmap/command_monitoring_events'; +export * from '../src/cmap/commands'; +export * from '../src/cmap/connect'; +export * from '../src/cmap/connection'; +export * from '../src/cmap/connection_pool'; +export * from '../src/cmap/connection_pool_events'; +export * from '../src/cmap/errors'; +export * from '../src/cmap/handshake/client_metadata'; +export * from '../src/cmap/metrics'; +export * from '../src/cmap/stream_description'; +export * from '../src/cmap/wire_protocol/compression'; +export * from '../src/cmap/wire_protocol/constants'; +export * from '../src/cmap/wire_protocol/on_demand/document'; +export * from '../src/cmap/wire_protocol/responses'; +export * from '../src/cmap/wire_protocol/shared'; +export * from '../src/collection'; +export * from '../src/connection_string'; +export * from '../src/constants'; +export * from '../src/cursor/abstract_cursor'; +export * from '../src/cursor/aggregation_cursor'; +export * from '../src/cursor/change_stream_cursor'; +export * from '../src/cursor/find_cursor'; +export * from '../src/cursor/list_collections_cursor'; +export * from '../src/cursor/list_indexes_cursor'; +export * from '../src/cursor/run_command_cursor'; +export * from '../src/db'; +export * from '../src/deps'; +export * from '../src/encrypter'; +export * from '../src/error'; +export * from '../src/explain'; +export * from '../src/gridfs/download'; +export * from '../src/gridfs/index'; +export * from '../src/gridfs/upload'; +export * from '../src/mongo_client'; +export * from '../src/mongo_logger'; +export * from '../src/mongo_types'; +export * from '../src/operations/aggregate'; +export * from '../src/operations/client_bulk_write/command_builder'; +export * from '../src/operations/client_bulk_write/common'; +export * from '../src/operations/client_bulk_write/results_merger'; +export * from '../src/operations/command'; +export * from '../src/operations/count'; +export * from '../src/operations/create_collection'; +export * from '../src/operations/delete'; +export * from '../src/operations/distinct'; +export * from '../src/operations/drop'; +export * from '../src/operations/estimated_document_count'; +export * from '../src/operations/execute_operation'; +export * from '../src/operations/find'; +export * from '../src/operations/find_and_modify'; +export * from '../src/operations/get_more'; +export * from '../src/operations/indexes'; +export * from '../src/operations/insert'; +export * from '../src/operations/kill_cursors'; +export * from '../src/operations/list_collections'; +export * from '../src/operations/list_databases'; +export * from '../src/operations/operation'; +export * from '../src/operations/profiling_level'; +export * from '../src/operations/remove_user'; +export * from '../src/operations/rename'; +export * from '../src/operations/run_command'; +export * from '../src/operations/search_indexes/create'; +export * from '../src/operations/search_indexes/drop'; +export * from '../src/operations/search_indexes/update'; +export * from '../src/operations/set_profiling_level'; +export * from '../src/operations/stats'; +export * from '../src/operations/update'; +export * from '../src/operations/validate_collection'; +export * from '../src/read_concern'; +export * from '../src/read_preference'; +export * from '../src/sdam/common'; +export * from '../src/sdam/events'; +export * from '../src/sdam/monitor'; +export * from '../src/sdam/server'; +export * from '../src/sdam/server_description'; +export * from '../src/sdam/server_selection'; +export * from '../src/sdam/srv_polling'; +export * from '../src/sdam/topology'; +export * from '../src/sdam/topology_description'; +export * from '../src/sessions'; +export * from '../src/sort'; +export * from '../src/timeout'; +export * from '../src/transactions'; +export * from '../src/utils'; +export * from '../src/write_concern'; + +// Must be last for precedence +export * from '../src/index'; diff --git a/test/tools/runner/vm_context_helper.ts b/test/tools/runner/vm_context_helper.ts new file mode 100644 index 0000000000..fbb142828f --- /dev/null +++ b/test/tools/runner/vm_context_helper.ts @@ -0,0 +1,129 @@ +/* eslint-disable no-restricted-globals, @typescript-eslint/no-require-imports */ + +import * as fs from 'node:fs'; +import { isBuiltin } from 'node:module'; +import * as path from 'node:path'; +import * as vm from 'node:vm'; + +/** + * Creates a require function that blocks access to specified core modules + */ +function createRestrictedRequire() { + const blockedModules = new Set(['os']); + + return function restrictedRequire(moduleName: string) { + // Block core modules + if (isBuiltin(moduleName) && blockedModules.has(moduleName)) { + throw new Error(`Access to core module '${moduleName}' is restricted in this context`); + } + + return require(moduleName); + } as NodeRequire; +} + +// Create a sandbox context with necessary globals +const sandbox = vm.createContext({ + __proto__: null, + + // Console and timing + console: console, + AbortController: AbortController, + AbortSignal: AbortSignal, + Date: global.Date, + Error: global.Error, + URL: global.URL, + URLSearchParams: global.URLSearchParams, + queueMicrotask: queueMicrotask, + performance: global.performance, + setTimeout: global.setTimeout, + clearTimeout: global.clearTimeout, + setInterval: global.setInterval, + clearInterval: global.clearInterval, + setImmediate: global.setImmediate, + clearImmediate: global.clearImmediate, + + // Process + process: process, + + // Global objects needed for runtime + Buffer: Buffer, + Promise: Promise, + Map: Map, + Set: Set, + WeakMap: WeakMap, + WeakSet: WeakSet, + ArrayBuffer: ArrayBuffer, + SharedArrayBuffer: SharedArrayBuffer, + Atomics: Atomics, + DataView: DataView, + Int8Array: Int8Array, + Uint8Array: Uint8Array, + Uint8ClampedArray: Uint8ClampedArray, + Int16Array: Int16Array, + Uint16Array: Uint16Array, + Int32Array: Int32Array, + Uint32Array: Uint32Array, + Float32Array: Float32Array, + Float64Array: Float64Array, + BigInt64Array: BigInt64Array, + BigUint64Array: BigUint64Array, + + // Other necessary globals + TextEncoder: global.TextEncoder, + TextDecoder: global.TextDecoder, + BigInt: global.BigInt, + Symbol: Symbol, + Proxy: Proxy, + Reflect: Reflect, + Object: Object, + Array: Array, + Function: Function, + String: String, + Number: Number, + Boolean: Boolean, + RegExp: RegExp, + Math: Math, + JSON: JSON, + Intl: global.Intl, + + // Custom require that blocks core modules + require: createRestrictedRequire(), + + // Needed for some modules + global: undefined as any, + globalThis: undefined as any +}); + +// Make global and globalThis point to the sandbox +sandbox.global = sandbox; +sandbox.globalThis = sandbox; + +/** + * Load the bundled MongoDB driver module in a VM context + * This allows us to control the globals that the driver has access to + */ +export function loadContextifiedMongoDBModule() { + const bundlePath = path.join(__dirname, 'driver.bundle.js'); + + if (!fs.existsSync(bundlePath)) { + throw new Error(`Driver bundle not found at ${bundlePath}. Run 'npm run bundle:driver' first.`); + } + + const bundleCode = fs.readFileSync(bundlePath, 'utf8'); + + const exportsContainer = {}; + const moduleContainer = { exports: exportsContainer }; + + // Wrap the bundle in a CommonJS-style wrapper + const wrapper = `(function(exports, module, require) { + ${bundleCode} + })`; + + const script = new vm.Script(wrapper, { filename: bundlePath }); + const fn = script.runInContext(sandbox); + + // Execute the bundle with the restricted require from the sandbox + fn(moduleContainer.exports, moduleContainer, sandbox.require); + + return moduleContainer.exports; +} From 7f2bd3458305ba154ea1f03e8b308da325c97530 Mon Sep 17 00:00:00 2001 From: Pavel Safronov Date: Thu, 19 Feb 2026 12:48:22 -0800 Subject: [PATCH 09/36] got some things working, now figuring out the general types in tests --- .gitignore | 1 + etc/build-runtime-barrel.mjs | 21 +++++++ etc/bundle-driver.mjs | 75 +++++++++++++----------- package.json | 10 +++- test/integration/crud/crud_api.test.ts | 81 +++++++++++++++----------- test/mongodb.ts | 16 ++--- test/mongodb_bundled.ts | 72 +++++++++++++++++++++++ test/mongodb_runtime-testing.ts | 4 ++ test/tools/runner/config.ts | 70 ++++++++-------------- test/tools/runner/vm_context_helper.ts | 4 +- test/tools/utils.ts | 5 ++ tsconfig.json | 2 +- 12 files changed, 234 insertions(+), 127 deletions(-) create mode 100644 etc/build-runtime-barrel.mjs create mode 100644 test/mongodb_bundled.ts create mode 100644 test/mongodb_runtime-testing.ts diff --git a/.gitignore b/.gitignore index 9ba7a0df0e..ff5518925b 100644 --- a/.gitignore +++ b/.gitignore @@ -109,3 +109,4 @@ crypt_shared.sh *keytab driver.bundle.js +test/tools/runner/bundle/ diff --git a/etc/build-runtime-barrel.mjs b/etc/build-runtime-barrel.mjs new file mode 100644 index 0000000000..afb34360a9 --- /dev/null +++ b/etc/build-runtime-barrel.mjs @@ -0,0 +1,21 @@ +import fs from 'node:fs/promises'; +import path from 'node:path'; +import { fileURLToPath } from 'node:url'; + +// eslint-disable-next-line no-restricted-globals +const useBundled = process.env.MONGODB_BUNDLED === 'true'; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); +const rootDir = path.join(__dirname, '..'); +const outputBarrelFile = path.join(rootDir, 'test/mongodb_runtime-testing.ts'); +const source = useBundled ? './mongodb_bundled' : './mongodb'; + +const contents = + `// This file is auto-generated. Do not edit.\n` + + `// Run 'npm run build:runtime-barrel' to regenerate.\n` + + `export const runNodelessTests = ${useBundled};\n` + + `export * from '${source}';\n`; +await fs.writeFile(outputBarrelFile, contents); + +// eslint-disable-next-line no-console +console.log(`✓ ${outputBarrelFile} now re-exports from ${source}`); diff --git a/etc/bundle-driver.mjs b/etc/bundle-driver.mjs index e12420ba2a..f007d00f06 100755 --- a/etc/bundle-driver.mjs +++ b/etc/bundle-driver.mjs @@ -1,43 +1,52 @@ #!/usr/bin/env node -import * as esbuild from 'esbuild'; -import { fileURLToPath } from 'node:url'; +import fs from 'node:fs/promises'; import { isBuiltin } from 'node:module'; import path from 'node:path'; +import { fileURLToPath } from 'node:url'; + +import * as esbuild from 'esbuild'; const __dirname = path.dirname(fileURLToPath(import.meta.url)); const rootDir = path.join(__dirname, '..'); +const outdir = path.join(rootDir, 'test/tools/runner/bundle/'); +await fs.rm(outdir, { recursive: true, force: true }); + +const outputBundleFile = path.join(outdir, 'driver-bundle.js'); await esbuild.build({ - entryPoints: [path.join(rootDir, 'src/index.ts')], - bundle: true, - outfile: path.join(rootDir, 'test/tools/runner/driver.bundle.js'), - platform: 'node', - format: 'cjs', - target: 'node20', - external: [ - 'bson', - 'mongodb-connection-string-url', - '@mongodb-js/saslprep', - '@mongodb-js/zstd', - 'mongodb-client-encryption', - 'snappy', - '@napi-rs/snappy*', - 'kerberos', - 'gcp-metadata', - '@aws-sdk/credential-providers' - ], - plugins: [{ - name: 'externalize-node-builtins', - setup(build) { - build.onResolve({ filter: /.*/ }, args => { - if (isBuiltin(args.path)) { - return { path: args.path, external: true }; - } - }); - } - }], - sourcemap: 'inline', - logLevel: 'info' + entryPoints: [path.join(rootDir, 'test/mongodb.ts')], + bundle: true, + outfile: outputBundleFile, + platform: 'node', + format: 'cjs', + target: 'node20', + external: [ + 'bson', + 'mongodb-connection-string-url', + '@mongodb-js/saslprep', + '@mongodb-js/zstd', + 'mongodb-client-encryption', + 'snappy', + '@napi-rs/snappy*', + 'kerberos', + 'gcp-metadata', + '@aws-sdk/credential-providers' + ], + plugins: [ + { + name: 'externalize-node-builtins', + setup(build) { + build.onResolve({ filter: /.*/ }, args => { + if (isBuiltin(args.path)) { + return { path: args.path, external: true }; + } + }); + } + } + ], + sourcemap: 'inline', + logLevel: 'info' }); -console.log('✓ Driver bundle created at test/tools/runner/driver.bundle.js'); \ No newline at end of file +// eslint-disable-next-line no-console +console.log(`✓ Driver bundle created at ${outputBundleFile}`); diff --git a/package.json b/package.json index 846303354f..8e19cb9e85 100644 --- a/package.json +++ b/package.json @@ -142,6 +142,7 @@ "check:search-indexes": "nyc mocha --config test/mocha_mongodb.js test/manual/search-index-management.prose.test.ts", "check:test": "mocha --config test/mocha_mongodb.js test/integration", "check:unit": "nyc mocha test/unit", + "check:unit-bundled": "MONGODB_BUNDLED=true npm run build:bundle && npm run check:unit", "check:ts": "node ./node_modules/typescript/bin/tsc -v && node ./node_modules/typescript/bin/tsc --noEmit", "check:atlas": "nyc mocha --config test/manual/mocharc.js test/manual/atlas_connectivity.test.ts", "check:drivers-atlas-testing": "nyc mocha --config test/mocha_mongodb.js test/atlas/drivers_atlas_testing.test.ts", @@ -155,9 +156,12 @@ "check:csfle": "nyc mocha --config test/mocha_mongodb.js test/integration/client-side-encryption", "check:snappy": "nyc mocha test/unit/assorted/snappy.test.js", "check:x509": "nyc mocha test/manual/x509_auth.test.ts", - "check:runtime-independence": "ts-node test/tools/runner/vm_runner.ts test/integration/change-streams/change_stream.test.ts", + "check:runtime-independence": "ts-node test/tools/runner/vm_context_helper.ts test/integration/change-streams/change_stream.test.ts", + "check:test-bundled": "MONGODB_BUNDLED=true npm run build:bundle && npm run check:test", + "build:bundle": "npm run bundle:driver && npm run bundle:types && npm run build:runtime-barrel", + "build:runtime-barrel": "node etc/build-runtime-barrel.mjs", "bundle:driver": "node etc/bundle-driver.mjs", - "test:bundled": "npm run bundle:driver && npm run check:test", + "bundle:types": "npx tsc --project ./tsconfig.json --declaration --emitDeclarationOnly --declarationDir test/tools/runner/bundle/types", "fix:eslint": "npm run check:eslint -- --fix", "prepare": "node etc/prepare.js", "preview:docs": "ts-node etc/docs/preview.ts", @@ -174,4 +178,4 @@ "moduleResolution": "node" } } -} \ No newline at end of file +} diff --git a/test/integration/crud/crud_api.test.ts b/test/integration/crud/crud_api.test.ts index d6029553c2..fced0597ac 100644 --- a/test/integration/crud/crud_api.test.ts +++ b/test/integration/crud/crud_api.test.ts @@ -3,28 +3,21 @@ import { finished } from 'node:stream/promises'; import { expect } from 'chai'; import * as sinon from 'sinon'; -import { loadContextifiedMongoDBModule } from '../../tools/runner/vm_context_helper'; -import { type FailCommandFailPoint } from '../../tools/utils'; -import { assert as test } from '../shared'; - -// Load MongoDB module in VM context -const mongodb = loadContextifiedMongoDBModule(); - -// Extract the exports we need from the contextified module -const { +import { Collection, CommandFailedEvent, + type CommandStartedEvent, CommandSucceededEvent, + type Db, MongoBulkWriteError, - MongoClient, + type MongoClient, MongoServerError, ObjectId, - ReturnDocument -} = mongodb; - -type MongoClient = typeof mongodb.MongoClient.prototype; -type Db = typeof mongodb.Db.prototype; -type CommandStartedEvent = typeof mongodb.CommandStartedEvent.prototype; + ReturnDocument, + runNodelessTests +} from '../../mongodb_runtime-testing'; +import { ensureTypeByName, type FailCommandFailPoint } from '../../tools/utils'; +import { assert as test } from '../shared'; const DB_NAME = 'crud_api_tests'; @@ -32,8 +25,6 @@ describe.only('CRUD API', function () { let client: MongoClient; beforeEach(async function () { - this.configuration.mongodb = mongodb; - client = this.configuration.newClient(); client.s.options.dbName = DB_NAME; // setup the default db @@ -113,9 +104,13 @@ describe.only('CRUD API', function () { const spy = sinon.spy(Collection.prototype, 'find'); const result = await collection.findOne({}); expect(result).to.deep.equal({ _id: 1 }); - expect(events.at(0)).to.be.instanceOf(CommandSucceededEvent); - expect(spy.returnValues.at(0)).to.have.property('closed', true); - expect(spy.returnValues.at(0)).to.have.nested.property('session.hasEnded', true); + if (runNodelessTests) { + expect(ensureTypeByName(events.at(0), 'CommandSucceededEvent')).to.be.true; + } else { + expect(events.at(0)).to.be.instanceOf(CommandSucceededEvent); + expect(spy.returnValues.at(0)).to.have.property('closed', true); + expect(spy.returnValues.at(0)).to.have.nested.property('session.hasEnded', true); + } }); }); @@ -145,10 +140,14 @@ describe.only('CRUD API', function () { it('the cursor for findOne is closed', async function () { const spy = sinon.spy(Collection.prototype, 'find'); const error = await collection.findOne({}).catch(error => error); - expect(error).to.be.instanceOf(MongoServerError); - expect(events.at(0)).to.be.instanceOf(CommandFailedEvent); - expect(spy.returnValues.at(0)).to.have.property('closed', true); - expect(spy.returnValues.at(0)).to.have.nested.property('session.hasEnded', true); + if (runNodelessTests) { + expect(ensureTypeByName(error, 'MongoServerError')).to.be.true; + } else { + expect(error).to.be.instanceOf(MongoServerError); + expect(events.at(0)).to.be.instanceOf(CommandFailedEvent); + expect(spy.returnValues.at(0)).to.have.property('closed', true); + expect(spy.returnValues.at(0)).to.have.nested.property('session.hasEnded', true); + } }); }); }); @@ -183,9 +182,13 @@ describe.only('CRUD API', function () { const spy = sinon.spy(Collection.prototype, 'aggregate'); const result = await collection.countDocuments({}); expect(result).to.deep.equal(2); - expect(events[0]).to.be.instanceOf(CommandSucceededEvent); - expect(spy.returnValues[0]).to.have.property('closed', true); - expect(spy.returnValues[0]).to.have.nested.property('session.hasEnded', true); + if (runNodelessTests) { + expect(ensureTypeByName(events[0], 'CommandSucceededEvent')).to.be.true; + } else { + expect(events[0]).to.be.instanceOf(CommandSucceededEvent); + expect(spy.returnValues[0]).to.have.property('closed', true); + expect(spy.returnValues[0]).to.have.nested.property('session.hasEnded', true); + } }); }); @@ -215,10 +218,14 @@ describe.only('CRUD API', function () { it('the cursor for countDocuments is closed', async function () { const spy = sinon.spy(Collection.prototype, 'aggregate'); const error = await collection.countDocuments({}).catch(error => error); - expect(error).to.be.instanceOf(MongoServerError); - expect(events.at(0)).to.be.instanceOf(CommandFailedEvent); - expect(spy.returnValues.at(0)).to.have.property('closed', true); - expect(spy.returnValues.at(0)).to.have.nested.property('session.hasEnded', true); + if (runNodelessTests) { + expect(ensureTypeByName(error, 'MongoServerError')).to.be.true; + } else { + expect(error).to.be.instanceOf(MongoServerError); + expect(events.at(0)).to.be.instanceOf(CommandFailedEvent); + expect(spy.returnValues.at(0)).to.have.property('closed', true); + expect(spy.returnValues.at(0)).to.have.nested.property('session.hasEnded', true); + } }); }); }); @@ -795,7 +802,11 @@ describe.only('CRUD API', function () { .bulkWrite(ops, { ordered: false, writeConcern: { w: 1 } }) .catch(error => error); - expect(error).to.be.instanceOf(MongoBulkWriteError); + if (runNodelessTests) { + expect(ensureTypeByName(error, 'MongoBulkWriteError')).to.be.true; + } else { + expect(error).to.be.instanceOf(MongoBulkWriteError); + } // 1004 because one of them is duplicate key // but since it is unordered we continued to write expect(error).to.have.property('insertedCount', 1004); @@ -818,7 +829,8 @@ describe.only('CRUD API', function () { .collection('t20_1') .bulkWrite(ops, { ordered: true, writeConcern: { w: 1 } }) .catch(err => err); - expect(err).to.be.instanceOf(MongoBulkWriteError); + // expect(err).to.be.instanceOf(MongoBulkWriteError); + expect(ensureTypeByName(err, 'MongoBulkWriteError')).to.be.true; }); describe('sort support', function () { @@ -827,7 +839,6 @@ describe.only('CRUD API', function () { let collection: Collection; beforeEach(async function () { - this.configuration.mongodb = mongodb; client = this.configuration.newClient({ monitorCommands: true }); events = []; client.on('commandStarted', commandStarted => diff --git a/test/mongodb.ts b/test/mongodb.ts index dfc50e2d0d..9c3234acd7 100644 --- a/test/mongodb.ts +++ b/test/mongodb.ts @@ -58,13 +58,13 @@ export * from '../src/constants'; export * from '../src/cursor/abstract_cursor'; export * from '../src/cursor/aggregation_cursor'; export * from '../src/cursor/change_stream_cursor'; -export * from '../src/cursor/find_cursor'; -export * from '../src/cursor/list_collections_cursor'; -export * from '../src/cursor/list_indexes_cursor'; export * from '../src/cursor/client_bulk_write_cursor'; export * from '../src/cursor/explainable_cursor'; export * from '../src/cursor/find_cursor'; +export * from '../src/cursor/find_cursor'; export * from '../src/cursor/list_collections_cursor'; +export * from '../src/cursor/list_collections_cursor'; +export * from '../src/cursor/list_indexes_cursor'; export * from '../src/cursor/list_indexes_cursor'; export * from '../src/cursor/list_search_indexes_cursor'; export * from '../src/cursor/run_command_cursor'; @@ -77,17 +77,17 @@ export * from '../src/gridfs/download'; export * from '../src/gridfs/index'; export * from '../src/gridfs/upload'; export * from '../src/mongo_client'; -export * from '../src/mongo_logger'; -export * from '../src/mongo_types'; -export * from '../src/operations/aggregate'; -export * from '../src/operations/client_bulk_write/command_builder'; -export * from '../src/operations/client_bulk_write/common'; export * from '../src/mongo_client_auth_providers'; export * from '../src/mongo_logger'; +export * from '../src/mongo_logger'; export * from '../src/mongo_types'; +export * from '../src/mongo_types'; +export * from '../src/operations/aggregate'; export * from '../src/operations/aggregate'; export * from '../src/operations/client_bulk_write/client_bulk_write'; export * from '../src/operations/client_bulk_write/command_builder'; +export * from '../src/operations/client_bulk_write/command_builder'; +export * from '../src/operations/client_bulk_write/common'; export * from '../src/operations/client_bulk_write/common'; export * from '../src/operations/client_bulk_write/executor'; export * from '../src/operations/client_bulk_write/results_merger'; diff --git a/test/mongodb_bundled.ts b/test/mongodb_bundled.ts new file mode 100644 index 0000000000..6394d50892 --- /dev/null +++ b/test/mongodb_bundled.ts @@ -0,0 +1,72 @@ +import { loadContextifiedMongoDBModule } from './tools/runner/vm_context_helper'; + +type all = typeof import('./mongodb'); +let exportSource: all; +try { + exportSource = loadContextifiedMongoDBModule() as all; +} catch (error) { + throw new Error( + `Failed to load contextified MongoDB module: ${error instanceof Error ? error.message : String(error)}` + ); +} + +// Export public API from the contextified module +export const { + aws4Sign, + Collection, + CommandFailedEvent, + CommandStartedEvent, + CommandSucceededEvent, + Db, + Double, + HostAddress, + isHello, + Long, + MongoAPIError, + MongoBulkWriteError, + MongoClient, + MongoCredentials, + MongoInvalidArgumentError, + MongoLoggableComponent, + MongoLogger, + MongoParseError, + MongoServerError, + ObjectId, + parseOptions, + ReadConcern, + ReadPreference, + resolveSRVRecord, + ReturnDocument, + ServerApiVersion, + SeverityLevel, + TopologyType, + WriteConcern +} = exportSource; + +// Export types from the contextified module +export type { + AuthMechanism, + CompressorName, + MongoClientOptions, + ServerApi, + WriteConcernSettings +} from './tools/runner/bundle/types/index'; + +// Export "clashing" types from the contextified module. +// These are types that clash with the objects of the same name (eg Collection), so we need to export them separately to avoid type errors. +import type { + Collection as _CollectionType, + CommandFailedEvent as _CommandFailedEventType, + CommandStartedEvent as _CommandStartedEventType, + CommandSucceededEvent as _CommandSucceededEventType, + HostAddress as _HostAddressType, + MongoClient as _MongoClientType, + TopologyType as _TopologyType +} from './tools/runner/bundle/types/index'; +export type Collection = _CollectionType; +export type CommandFailedEvent = _CommandFailedEventType; +export type CommandStartedEvent = _CommandStartedEventType; +export type CommandSucceededEvent = _CommandSucceededEventType; +export type HostAddress = _HostAddressType; +export type MongoClient = _MongoClientType; +export type TopologyType = _TopologyType; diff --git a/test/mongodb_runtime-testing.ts b/test/mongodb_runtime-testing.ts new file mode 100644 index 0000000000..c69c911ce1 --- /dev/null +++ b/test/mongodb_runtime-testing.ts @@ -0,0 +1,4 @@ +// This file is auto-generated. Do not edit. +// Run 'npm run build:runtime-barrel' to regenerate. +export const runNodelessTests = true; +export * from './mongodb_bundled'; diff --git a/test/tools/runner/config.ts b/test/tools/runner/config.ts index a04ea89747..265be7a926 100644 --- a/test/tools/runner/config.ts +++ b/test/tools/runner/config.ts @@ -17,10 +17,11 @@ import { MongoClient, type MongoClientOptions, ObjectId, + runNodelessTests, type ServerApi, TopologyType, type WriteConcernSettings -} from '../../mongodb'; +} from '../../mongodb_runtime-testing'; import { getEnvironmentalOptions } from '../utils'; import { type Filter } from './filters/filter'; import { flakyTests } from './flaky'; @@ -114,32 +115,20 @@ export class TestConfiguration { filters: Record; compressor: CompressorName | null; - // Optional: contextified MongoDB module exports for VM-based testing - private mongodb?: any; - constructor( private uri: string, - private context: Record, - mongodb?: any // Optional contextified mongodb module + private context: Record ) { - this.mongodb = mongodb; - const url = new ConnectionString(uri); const { hosts } = url; - const hostAddresses = hosts.map( - this.mongodb ? this.mongodb.HostAddress.fromString : HostAddress.fromString - ); + const hostAddresses = hosts.map(HostAddress.fromString); this.version = context.version; this.clientSideEncryption = context.clientSideEncryption; this.cryptSharedVersion = context.cryptShared; this.parameters = { ...context.parameters }; this.singleMongosLoadBalancerUri = context.singleMongosLoadBalancerUri; this.multiMongosLoadBalancerUri = context.multiMongosLoadBalancerUri; - this.topologyType = this.isLoadBalanced - ? this.mongodb - ? this.mongodb.TopologyType.LoadBalanced - : TopologyType.LoadBalanced - : context.topologyType; + this.topologyType = this.isLoadBalanced ? TopologyType.LoadBalanced : context.topologyType; this.buildInfo = context.buildInfo; this.serverApi = context.serverApi; this.isSrv = uri.indexOf('mongodb+srv') > -1; @@ -232,7 +221,10 @@ export class TestConfiguration { return uri.indexOf('MONGODB-OIDC') > -1 && uri.indexOf(`ENVIRONMENT:${env}`) > -1; } - newClient(urlOrQueryOptions?: string | Record, serverOptions?: MongoClientOptions) { + newClient( + urlOrQueryOptions?: string | Record, + serverOptions?: MongoClientOptions + ): MongoClient { const baseOptions: MongoClientOptions = this.compressor ? { compressors: this.compressor @@ -240,10 +232,10 @@ export class TestConfiguration { : {}; serverOptions = Object.assign(baseOptions, getEnvironmentalOptions(), serverOptions); - // If using contextified mongodb, inject Node.js runtime adapters - if (this.mongodb) { + if (runNodelessTests) { serverOptions.runtimeAdapters = { + // eslint-disable-next-line @typescript-eslint/no-require-imports os: require('os'), ...serverOptions.runtimeAdapters }; @@ -259,8 +251,8 @@ export class TestConfiguration { throw new Error(`Cannot use options to specify host/port, must be in ${urlOrQueryOptions}`); } - const ClientConstructor = this.mongodb ? this.mongodb.MongoClient : MongoClient; - return new ClientConstructor(urlOrQueryOptions, serverOptions); + const newClient: MongoClient = new MongoClient(urlOrQueryOptions, serverOptions); + return newClient; } const queryOptions = urlOrQueryOptions ?? {}; @@ -304,10 +296,7 @@ export class TestConfiguration { delete queryOptions.writeConcern; } - const LoadBalancedType = this.mongodb - ? this.mongodb.TopologyType.LoadBalanced - : TopologyType.LoadBalanced; - if (this.topologyType === LoadBalancedType) { + if (this.topologyType === TopologyType.LoadBalanced) { queryOptions.loadBalanced = true; } @@ -341,8 +330,7 @@ export class TestConfiguration { const connectionString = url.format(urlOptions); - const ClientConstructor = this.mongodb ? this.mongodb.MongoClient : MongoClient; - return new ClientConstructor(connectionString, serverOptions); + return new MongoClient(connectionString, serverOptions); } /** @@ -464,8 +452,7 @@ export class TestConfiguration { } writeConcernMax(): { writeConcern: WriteConcernSettings } { - const SingleType = this.mongodb ? this.mongodb.TopologyType.Single : TopologyType.Single; - if (this.topologyType !== SingleType) { + if (this.topologyType !== TopologyType.Single) { return { writeConcern: { w: 'majority', wtimeoutMS: 30000 } }; } @@ -477,7 +464,7 @@ export class TestConfiguration { } makeAtlasTestConfiguration(): AtlasTestConfiguration { - return new AtlasTestConfiguration(this.uri, this.context, this.mongodb); + return new AtlasTestConfiguration(this.uri, this.context); } loggingEnabled = false; @@ -489,8 +476,7 @@ export class TestConfiguration { testsToEnableLogging = flakyTests; setupLogging(options: MongoClientOptions, id?: string) { - const ObjectIdConstructor = this.mongodb ? this.mongodb.ObjectId : ObjectId; - id ??= new ObjectIdConstructor().toString(); + id ??= new ObjectId().toString(); this.logs = []; const write = log => this.logs.push({ t: log.t, id, ...log }); options.mongodbLogPath = { write }; @@ -505,9 +491,6 @@ export class TestConfiguration { afterEachLogging(ctx: Context) { if (this.loggingEnabled && ctx.currentTest.state === 'failed') { - const LongConstructor = this.mongodb ? this.mongodb.Long : Long; - const DoubleConstructor = this.mongodb ? this.mongodb.Double : Double; - for (const log of this.logs) { console.error( JSON.stringify( @@ -516,13 +499,12 @@ export class TestConfiguration { if (types.isMap(value)) return { Map: Array.from(value.entries()) }; if (types.isSet(value)) return { Set: Array.from(value.values()) }; if (types.isNativeError(value)) return { [value.name]: util.inspect(value) }; - if (typeof value === 'bigint') - return { bigint: new LongConstructor(value).toExtendedJSON() }; + if (typeof value === 'bigint') return { bigint: new Long(value).toExtendedJSON() }; if (typeof value === 'symbol') return `Symbol(${value.description})`; if (typeof value === 'number') { if (Number.isNaN(value) || !Number.isFinite(value) || Object.is(value, -0)) // @ts-expect-error: toExtendedJSON internal on double but not on long - return { number: new DoubleConstructor(value).toExtendedJSON() }; + return { number: new Double(value).toExtendedJSON() }; } if (Buffer.isBuffer(value)) return { [value.constructor.name]: Buffer.prototype.base64Slice.call(value) }; @@ -546,10 +528,8 @@ export class TestConfiguration { */ export class AtlasTestConfiguration extends TestConfiguration { override newClient(): MongoClient { - const ClientConstructor = (this as any).mongodb - ? (this as any).mongodb.MongoClient - : MongoClient; - return new ClientConstructor(process.env.MONGODB_URI!); + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + return new MongoClient(process.env.MONGODB_URI!); } override url(): string { @@ -563,10 +543,8 @@ export class AtlasTestConfiguration extends TestConfiguration { */ export class AstrolabeTestConfiguration extends TestConfiguration { override newClient(): MongoClient { - const ClientConstructor = (this as any).mongodb - ? (this as any).mongodb.MongoClient - : MongoClient; - return new ClientConstructor(process.env.DRIVERS_ATLAS_TESTING_URI!); + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + return new MongoClient(process.env.DRIVERS_ATLAS_TESTING_URI!); } override url(): string { diff --git a/test/tools/runner/vm_context_helper.ts b/test/tools/runner/vm_context_helper.ts index fbb142828f..fa3ac2ccad 100644 --- a/test/tools/runner/vm_context_helper.ts +++ b/test/tools/runner/vm_context_helper.ts @@ -47,6 +47,7 @@ const sandbox = vm.createContext({ // Global objects needed for runtime Buffer: Buffer, + Headers: global.Headers, Promise: Promise, Map: Map, Set: Set, @@ -85,6 +86,7 @@ const sandbox = vm.createContext({ Math: Math, JSON: JSON, Intl: global.Intl, + crypto: global.crypto, // Custom require that blocks core modules require: createRestrictedRequire(), @@ -103,7 +105,7 @@ sandbox.globalThis = sandbox; * This allows us to control the globals that the driver has access to */ export function loadContextifiedMongoDBModule() { - const bundlePath = path.join(__dirname, 'driver.bundle.js'); + const bundlePath = path.join(__dirname, 'bundle/driver-bundle.js'); if (!fs.existsSync(bundlePath)) { throw new Error(`Driver bundle not found at ${bundlePath}. Run 'npm run bundle:driver' first.`); diff --git a/test/tools/utils.ts b/test/tools/utils.ts index d587e9864d..cb26f844ad 100644 --- a/test/tools/utils.ts +++ b/test/tools/utils.ts @@ -32,6 +32,11 @@ export function ensureCalledWith(stub: any, args: any[]) { args.forEach((m: any) => expect(stub).to.have.been.calledWith(m)); } +export function ensureTypeByName(obj: any, typeName: string) { + const isType = obj != null && obj.constructor != null && obj.constructor.name === typeName; + return isType; +} + export class EventCollector { private _events: Record; private _timeout: number; diff --git a/tsconfig.json b/tsconfig.json index 74fb09c6ff..6604ef2871 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -43,4 +43,4 @@ "include": [ "src/**/*" ] -} \ No newline at end of file +} From 875174b680316fa9596ab9772a73665485cb9ec9 Mon Sep 17 00:00:00 2001 From: Pavel Safronov Date: Thu, 19 Feb 2026 13:09:49 -0800 Subject: [PATCH 10/36] improve tooling and migrate timeout.test.ts to new format --- package.json | 6 ++++-- test/mongodb_bundled.ts | 8 ++++++++ test/mongodb_runtime-testing.ts | 4 ++-- test/unit/timeout.test.ts | 2 +- 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 8e19cb9e85..ca6aa9a3f7 100644 --- a/package.json +++ b/package.json @@ -142,7 +142,7 @@ "check:search-indexes": "nyc mocha --config test/mocha_mongodb.js test/manual/search-index-management.prose.test.ts", "check:test": "mocha --config test/mocha_mongodb.js test/integration", "check:unit": "nyc mocha test/unit", - "check:unit-bundled": "MONGODB_BUNDLED=true npm run build:bundle && npm run check:unit", + "check:unit-bundled": "npm run switch:to-bundled && npm run check:unit || npm run switch:to-unbundled", "check:ts": "node ./node_modules/typescript/bin/tsc -v && node ./node_modules/typescript/bin/tsc --noEmit", "check:atlas": "nyc mocha --config test/manual/mocharc.js test/manual/atlas_connectivity.test.ts", "check:drivers-atlas-testing": "nyc mocha --config test/mocha_mongodb.js test/atlas/drivers_atlas_testing.test.ts", @@ -157,7 +157,7 @@ "check:snappy": "nyc mocha test/unit/assorted/snappy.test.js", "check:x509": "nyc mocha test/manual/x509_auth.test.ts", "check:runtime-independence": "ts-node test/tools/runner/vm_context_helper.ts test/integration/change-streams/change_stream.test.ts", - "check:test-bundled": "MONGODB_BUNDLED=true npm run build:bundle && npm run check:test", + "check:test-bundled": "npm run switch:to-bundled && npm run check:test || npm run switch:to-unbundled", "build:bundle": "npm run bundle:driver && npm run bundle:types && npm run build:runtime-barrel", "build:runtime-barrel": "node etc/build-runtime-barrel.mjs", "bundle:driver": "node etc/bundle-driver.mjs", @@ -165,6 +165,8 @@ "fix:eslint": "npm run check:eslint -- --fix", "prepare": "node etc/prepare.js", "preview:docs": "ts-node etc/docs/preview.ts", + "switch:to-bundled": "MONGODB_BUNDLED=true npm run build:runtime-barrel", + "switch:to-unbundled": "MONGODB_BUNDLED=false npm run build:runtime-barrel", "test": "npm run check:lint && npm run test:all", "test:all": "npm run check:unit && npm run check:test", "update:docs": "npm run build:docs -- --yes" diff --git a/test/mongodb_bundled.ts b/test/mongodb_bundled.ts index 6394d50892..5d8c0f260c 100644 --- a/test/mongodb_bundled.ts +++ b/test/mongodb_bundled.ts @@ -17,10 +17,12 @@ export const { CommandFailedEvent, CommandStartedEvent, CommandSucceededEvent, + CSOTTimeoutContext, Db, Double, HostAddress, isHello, + LegacyTimeoutContext, Long, MongoAPIError, MongoBulkWriteError, @@ -31,6 +33,7 @@ export const { MongoLogger, MongoParseError, MongoServerError, + MongoRuntimeError, ObjectId, parseOptions, ReadConcern, @@ -39,6 +42,9 @@ export const { ReturnDocument, ServerApiVersion, SeverityLevel, + Timeout, + TimeoutContext, + TimeoutError, TopologyType, WriteConcern } = exportSource; @@ -61,6 +67,7 @@ import type { CommandSucceededEvent as _CommandSucceededEventType, HostAddress as _HostAddressType, MongoClient as _MongoClientType, + Timeout as _TimeoutType, TopologyType as _TopologyType } from './tools/runner/bundle/types/index'; export type Collection = _CollectionType; @@ -69,4 +76,5 @@ export type CommandStartedEvent = _CommandStartedEventType; export type CommandSucceededEvent = _CommandSucceededEventType; export type HostAddress = _HostAddressType; export type MongoClient = _MongoClientType; +export type Timeout = _TimeoutType; export type TopologyType = _TopologyType; diff --git a/test/mongodb_runtime-testing.ts b/test/mongodb_runtime-testing.ts index c69c911ce1..d0b07fef47 100644 --- a/test/mongodb_runtime-testing.ts +++ b/test/mongodb_runtime-testing.ts @@ -1,4 +1,4 @@ // This file is auto-generated. Do not edit. // Run 'npm run build:runtime-barrel' to regenerate. -export const runNodelessTests = true; -export * from './mongodb_bundled'; +export const runNodelessTests = false; +export * from './mongodb'; diff --git a/test/unit/timeout.test.ts b/test/unit/timeout.test.ts index 1dd7e83feb..5fbdf0c7a5 100644 --- a/test/unit/timeout.test.ts +++ b/test/unit/timeout.test.ts @@ -8,7 +8,7 @@ import { Timeout, TimeoutContext, TimeoutError -} from '../mongodb'; +} from '../mongodb_runtime-testing'; describe('Timeout', function () { let timeout: Timeout; From 7d9cf78b3c350f042de57f3bff82b812fbda7313 Mon Sep 17 00:00:00 2001 From: Pavel Safronov Date: Thu, 19 Feb 2026 16:51:00 -0800 Subject: [PATCH 11/36] added better message to restricted require error, including the source location --- package.json | 6 +++--- test/tools/runner/vm_context_helper.ts | 6 +++++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index ca6aa9a3f7..44cffac996 100644 --- a/package.json +++ b/package.json @@ -142,7 +142,7 @@ "check:search-indexes": "nyc mocha --config test/mocha_mongodb.js test/manual/search-index-management.prose.test.ts", "check:test": "mocha --config test/mocha_mongodb.js test/integration", "check:unit": "nyc mocha test/unit", - "check:unit-bundled": "npm run switch:to-bundled && npm run check:unit || npm run switch:to-unbundled", + "check:unit-bundled": "npm run build:bundle && npm run switch:to-bundled && npm run check:unit ; npm run switch:to-unbundled", "check:ts": "node ./node_modules/typescript/bin/tsc -v && node ./node_modules/typescript/bin/tsc --noEmit", "check:atlas": "nyc mocha --config test/manual/mocharc.js test/manual/atlas_connectivity.test.ts", "check:drivers-atlas-testing": "nyc mocha --config test/mocha_mongodb.js test/atlas/drivers_atlas_testing.test.ts", @@ -157,8 +157,8 @@ "check:snappy": "nyc mocha test/unit/assorted/snappy.test.js", "check:x509": "nyc mocha test/manual/x509_auth.test.ts", "check:runtime-independence": "ts-node test/tools/runner/vm_context_helper.ts test/integration/change-streams/change_stream.test.ts", - "check:test-bundled": "npm run switch:to-bundled && npm run check:test || npm run switch:to-unbundled", - "build:bundle": "npm run bundle:driver && npm run bundle:types && npm run build:runtime-barrel", + "check:test-bundled": "npm run build:bundle && npm run switch:to-bundled&& npm run check:test ; npm run switch:to-unbundled", + "build:bundle": "npm run bundle:driver && npm run bundle:types", "build:runtime-barrel": "node etc/build-runtime-barrel.mjs", "bundle:driver": "node etc/bundle-driver.mjs", "bundle:types": "npx tsc --project ./tsconfig.json --declaration --emitDeclarationOnly --declarationDir test/tools/runner/bundle/types", diff --git a/test/tools/runner/vm_context_helper.ts b/test/tools/runner/vm_context_helper.ts index fa3ac2ccad..93b0390b3a 100644 --- a/test/tools/runner/vm_context_helper.ts +++ b/test/tools/runner/vm_context_helper.ts @@ -14,7 +14,11 @@ function createRestrictedRequire() { return function restrictedRequire(moduleName: string) { // Block core modules if (isBuiltin(moduleName) && blockedModules.has(moduleName)) { - throw new Error(`Access to core module '${moduleName}' is restricted in this context`); + const sourceFile = new Error().stack.split('\n')[2]?.replace('at', '').trim(); + const source = sourceFile ? `from ${sourceFile}` : 'from an unknown source'; + throw new Error( + `Access to core module '${moduleName}' (${source}) is restricted in this context` + ); } return require(moduleName); From b17b6656e716e5826606f2f422f8c08b3ec51147 Mon Sep 17 00:00:00 2001 From: Pavel Safronov Date: Thu, 19 Feb 2026 16:57:22 -0800 Subject: [PATCH 12/36] keep wrapper on the same line as the bundle code, so we have accurate line references --- test/tools/runner/vm_context_helper.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/test/tools/runner/vm_context_helper.ts b/test/tools/runner/vm_context_helper.ts index 93b0390b3a..c19b7cd16c 100644 --- a/test/tools/runner/vm_context_helper.ts +++ b/test/tools/runner/vm_context_helper.ts @@ -121,9 +121,7 @@ export function loadContextifiedMongoDBModule() { const moduleContainer = { exports: exportsContainer }; // Wrap the bundle in a CommonJS-style wrapper - const wrapper = `(function(exports, module, require) { - ${bundleCode} - })`; + const wrapper = `(function(exports, module, require) {${bundleCode}})`; const script = new vm.Script(wrapper, { filename: bundlePath }); const fn = script.runInContext(sandbox); From d23ee71a53a7b43785812eb423659208796eed8a Mon Sep 17 00:00:00 2001 From: Pavel Safronov Date: Fri, 20 Feb 2026 08:20:45 -0800 Subject: [PATCH 13/36] added readme info about the current approach --- package.json | 2 +- test/readme.md | 66 +++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 66 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 44cffac996..8fac3b1665 100644 --- a/package.json +++ b/package.json @@ -157,7 +157,7 @@ "check:snappy": "nyc mocha test/unit/assorted/snappy.test.js", "check:x509": "nyc mocha test/manual/x509_auth.test.ts", "check:runtime-independence": "ts-node test/tools/runner/vm_context_helper.ts test/integration/change-streams/change_stream.test.ts", - "check:test-bundled": "npm run build:bundle && npm run switch:to-bundled&& npm run check:test ; npm run switch:to-unbundled", + "check:test-bundled": "npm run build:bundle && npm run switch:to-bundled && npm run check:test ; npm run switch:to-unbundled", "build:bundle": "npm run bundle:driver && npm run bundle:types", "build:runtime-barrel": "node etc/build-runtime-barrel.mjs", "bundle:driver": "node etc/bundle-driver.mjs", diff --git a/test/readme.md b/test/readme.md index 9baec61585..6085f4029a 100644 --- a/test/readme.md +++ b/test/readme.md @@ -43,9 +43,15 @@ about the types of tests and how to run them. - [AWS Authentication tests](#aws-authentication-tests) - [Running AWS tests](#running-aws-tests) - [Container Tests](#container-tests) + - [Node-less Runtime Testing](#node-less-runtime-testing) + - [Design](#design) + - [Adding tests to be tested with Node-less Runtime](#adding-tests-to-be-tested-with-node-less-runtime) + - [Running tests in Node-less Runtime](#running-tests-in-node-less-runtime) + - [Running tests manually in Node-less Runtime](#running-tests-manually-in-node-less-runtime) - [GCP](#gcp) - [Azure](#azure) - [AWS](#aws) + - [Running tests with TLS](#running-tests-with-tls) - [TODO Special Env Sections](#todo-special-env-sections) - [Testing driver changes with mongosh](#testing-driver-changes-with-mongosh) - [Point mongosh to the driver](#point-mongosh-to-the-driver) @@ -715,6 +721,64 @@ our existing integration test suite and run Evergreen patches against a single i _Note that in cases where the tests need to run longer than one hour to ensure that tokens expire that the mocha timeout must be increased in order for the test not to timeout._ +### Node-less Runtime Testing + +We are starting to remove explicit Node requirements, and are making it possible for users to provide us with the required functionality. + +To that end, need to run our tests in a Node-less environment. These tests need to fail if our code erroneously uses Node. + +#### Design + +The approach we are taking is to modify our unit and integration tests to run against a patched version of the driver, where any illegal `require` calls are blocked. + +Here are a few of the relevant components of this system: + +1. [test/mongodb.ts](test/mongodb.ts) + - Test entrypoint that exports Driver and all internal types. +2. [etc/bundle-driver.mjs](etc/bundle-driver.mjs) + - Creates a CommonJS bundle (Driver and all internal types) from `test/mongodb.ts`. +3. [test/tools/runner/vm_context_helper.ts](./tools/runner/vm_context_helper.ts) + - Special VM that blocks specific `require` calls. +4. [test/mongodb_bundled.ts](./mongodb_bundled.ts) + - Exports MongoDB from CommonJS bundle created by `etc/bundle-driver.mjs`, using `vm_context_helper.ts` to detect usages of blocked `require` calls. + - This file is currently maintained by hand and needs to export types explicitly. We may want to generate this file as well. +5. [test/mongodb_runtime-testing.ts](./mongodb_runtime-testing.ts) + - Generated "barrel file". It exports either `test/mongodb.ts` (Driver + all internal types) or `test/mongodb_bundled.ts` (Driver + all internal types, loaded from bundle, and using `vm_context_helper.ts` to block `require` calls.) +6. [etc/build-runtime-barrel.mjs](./etc/build-runtime-barrel.mjs) + - Generates the barrel file `test/mongodb_runtime-testing.ts` based on `MONGODB_BUNDLED` env var. + +#### Adding tests to be tested with Node-less Runtime + +Change the test's import from + `} from '../../mongodb';` +to + `} from '../../mongodb_runtime-testing';` + +#### Running tests in Node-less Runtime + +To run opted-in unit or integration tests in a Node-less runtime, run: + + `npm run check:unit-bundled` +or + `npm run check:test-bundled` + +Either command will: + +1. Create a bundle from `test/mongodb.ts` +2. Regenerate the barrel file to export from the generated bundle +3. Run unit or integ tests +4. Regenerate the barrel file to export from the test entry point + +#### Running tests manually in Node-less Runtime + +Call the following command to regenerate the barrel file to import from the bundle: + `npm run switch:to-bundled` + +Call the following command to rebuild the bundle: + `npm run build:bundle` + +You can now run the unit or integ tests locally and they will be importing from the patched bundle. + ## GCP 1. Add a new GCP prose test to `test/integration/auth/mongodb_oidc_gcp.prose.06.test.ts` that mimics the behaviour that @@ -748,7 +812,7 @@ We tests TLS in two suites in CI: Setting up a local environment is the same for both suites. -First, configure a server with TLS enabled by following the steps in [Runing the Tests Locally](#Running-the-Tests-Locally) with the environment +First, configure a server with TLS enabled by following the steps in [Runing the Tests Locally](#Running-the-Tests-Locally) with the environment variable `SSL=SSL` set. Then, in addition to setting the `MONGODB_URI` environment varialbe, set the following environment variables: From f45d754729fcc185f5e4ff45d7d3ae79441ae784 Mon Sep 17 00:00:00 2001 From: Pavel Safronov Date: Fri, 20 Feb 2026 09:29:25 -0800 Subject: [PATCH 14/36] minor changes to get unit and integ tests working --- test/mongodb_bundled.ts | 2 ++ test/readme.md | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/test/mongodb_bundled.ts b/test/mongodb_bundled.ts index 5d8c0f260c..f6ae438176 100644 --- a/test/mongodb_bundled.ts +++ b/test/mongodb_bundled.ts @@ -65,6 +65,7 @@ import type { CommandFailedEvent as _CommandFailedEventType, CommandStartedEvent as _CommandStartedEventType, CommandSucceededEvent as _CommandSucceededEventType, + CSOTTimeoutContext as _CSOTTimeoutContextType, HostAddress as _HostAddressType, MongoClient as _MongoClientType, Timeout as _TimeoutType, @@ -74,6 +75,7 @@ export type Collection = _CollectionType; export type CommandFailedEvent = _CommandFailedEventType; export type CommandStartedEvent = _CommandStartedEventType; export type CommandSucceededEvent = _CommandSucceededEventType; +export type CSOTTimeoutContext = _CSOTTimeoutContextType; export type HostAddress = _HostAddressType; export type MongoClient = _MongoClientType; export type Timeout = _TimeoutType; diff --git a/test/readme.md b/test/readme.md index 6085f4029a..503ba1a9f6 100644 --- a/test/readme.md +++ b/test/readme.md @@ -778,6 +778,15 @@ Call the following command to rebuild the bundle: `npm run build:bundle` You can now run the unit or integ tests locally and they will be importing from the patched bundle. + `npm run check:unit` +or + `npm run check:test` +or through an IDE. + +Note that you don't need to run `*-bundled` scripts after switching. + +To revert the barrel file changes, run: + `npm run switch:to-unbundled` ## GCP From bb11d48430694ad79a02837d7ce3f2baf9452bfe Mon Sep 17 00:00:00 2001 From: Pavel Safronov Date: Fri, 20 Feb 2026 12:45:07 -0800 Subject: [PATCH 15/36] added a nodeless build variant --- .evergreen/config.yml | 97 ++++++++++++++++++++++++++ .evergreen/generate_evergreen_tasks.js | 14 ++++ package.json | 8 +-- test/integration/crud/crud_api.test.ts | 2 +- 4 files changed, 116 insertions(+), 5 deletions(-) diff --git a/.evergreen/config.yml b/.evergreen/config.yml index 08808893c0..7eafc43499 100644 --- a/.evergreen/config.yml +++ b/.evergreen/config.yml @@ -3725,6 +3725,60 @@ buildvariants: - test-tls-support-5.0 - test-tls-support-4.4 - test-tls-support-4.2 + - name: rhel80-large-nodeless + display_name: rhel8 Nodeless + run_on: rhel80-large + expansions: + MONGODB_BUNDLED: true + NODE_LTS_VERSION: latest + CLIENT_ENCRYPTION: true + tasks: + - test-latest-server + - test-latest-replica_set + - test-latest-sharded_cluster + - test-rapid-server + - test-rapid-replica_set + - test-rapid-sharded_cluster + - test-8.0-server + - test-8.0-replica_set + - test-8.0-sharded_cluster + - test-7.0-server + - test-7.0-replica_set + - test-7.0-sharded_cluster + - test-6.0-server + - test-6.0-replica_set + - test-6.0-sharded_cluster + - test-5.0-server + - test-5.0-replica_set + - test-5.0-sharded_cluster + - test-4.4-server + - test-4.4-replica_set + - test-4.4-sharded_cluster + - test-4.2-server + - test-4.2-replica_set + - test-4.2-sharded_cluster + - test-latest-server-v1-api + - test-x509-authentication + - test-atlas-connectivity + - test-5.0-load-balanced + - test-6.0-load-balanced + - test-7.0-load-balanced + - test-8.0-load-balanced + - test-rapid-load-balanced + - test-latest-load-balanced + - test-auth-kerberos + - test-auth-ldap + - test-socks5-csfle + - test-socks5-tls + - test-snappy-compression + - test-zstd-compression + - test-tls-support-latest + - test-tls-support-8.0 + - test-tls-support-7.0 + - test-tls-support-6.0 + - test-tls-support-5.0 + - test-tls-support-4.4 + - test-tls-support-4.2 - name: windows-2022-latest-large-iron display_name: Windows Node20.19.0 run_on: windows-2022-latest-large @@ -3857,6 +3911,49 @@ buildvariants: - test-tls-support-5.0 - test-tls-support-4.4 - test-tls-support-4.2 + - name: windows-2022-latest-large-nodeless + display_name: Windows Nodeless + run_on: windows-2022-latest-large + expansions: + MONGODB_BUNDLED: true + NODE_LTS_VERSION: latest + CLIENT_ENCRYPTION: false + tasks: + - test-latest-server + - test-latest-replica_set + - test-latest-sharded_cluster + - test-rapid-server + - test-rapid-replica_set + - test-rapid-sharded_cluster + - test-8.0-server + - test-8.0-replica_set + - test-8.0-sharded_cluster + - test-7.0-server + - test-7.0-replica_set + - test-7.0-sharded_cluster + - test-6.0-server + - test-6.0-replica_set + - test-6.0-sharded_cluster + - test-5.0-server + - test-5.0-replica_set + - test-5.0-sharded_cluster + - test-4.4-server + - test-4.4-replica_set + - test-4.4-sharded_cluster + - test-4.2-server + - test-4.2-replica_set + - test-4.2-sharded_cluster + - test-latest-server-v1-api + - test-socks5-tls + - test-snappy-compression + - test-zstd-compression + - test-tls-support-latest + - test-tls-support-8.0 + - test-tls-support-7.0 + - test-tls-support-6.0 + - test-tls-support-5.0 + - test-tls-support-4.4 + - test-tls-support-4.2 - name: rhel8-node20.19.0-test-csfle-mongocryptd display_name: rhel 8 Node20.19.0 test mongocryptd run_on: rhel80-large diff --git a/.evergreen/generate_evergreen_tasks.js b/.evergreen/generate_evergreen_tasks.js index c18531b867..3ea18211ba 100644 --- a/.evergreen/generate_evergreen_tasks.js +++ b/.evergreen/generate_evergreen_tasks.js @@ -417,6 +417,20 @@ for (const { } BUILD_VARIANTS.push(buildVariantData); } + + // add Node-less variant + const buildVariantData = { + name: `${osName}-nodeless`, + display_name: `${osDisplayName} Nodeless`, + run_on, + expansions: { + MONGODB_BUNDLED: true, + NODE_LTS_VERSION: 'latest' + }, + tasks: tasks.map(({ name }) => name) + }; + buildVariantData.expansions.CLIENT_ENCRYPTION = clientEncryption; + BUILD_VARIANTS.push(buildVariantData); } // Running CSFLE tests with mongocryptd diff --git a/package.json b/package.json index 8fac3b1665..0d7583f908 100644 --- a/package.json +++ b/package.json @@ -140,8 +140,9 @@ "check:dependencies": "mocha test/action/dependency.test.ts", "check:dts": "node ./node_modules/typescript/bin/tsc --target es2023 --module commonjs --noEmit mongodb.d.ts && tsd", "check:search-indexes": "nyc mocha --config test/mocha_mongodb.js test/manual/search-index-management.prose.test.ts", - "check:test": "mocha --config test/mocha_mongodb.js test/integration", - "check:unit": "nyc mocha test/unit", + "check:test": "npm run build:bundle && nyc mocha --config test/mocha_mongodb.js test/integration", + "check:test-bundled": "npm run build:bundle && npm run switch:to-bundled && npm run check:test ; npm run switch:to-unbundled", + "check:unit": "npm run build:bundle && nyc mocha test/unit", "check:unit-bundled": "npm run build:bundle && npm run switch:to-bundled && npm run check:unit ; npm run switch:to-unbundled", "check:ts": "node ./node_modules/typescript/bin/tsc -v && node ./node_modules/typescript/bin/tsc --noEmit", "check:atlas": "nyc mocha --config test/manual/mocharc.js test/manual/atlas_connectivity.test.ts", @@ -157,8 +158,7 @@ "check:snappy": "nyc mocha test/unit/assorted/snappy.test.js", "check:x509": "nyc mocha test/manual/x509_auth.test.ts", "check:runtime-independence": "ts-node test/tools/runner/vm_context_helper.ts test/integration/change-streams/change_stream.test.ts", - "check:test-bundled": "npm run build:bundle && npm run switch:to-bundled && npm run check:test ; npm run switch:to-unbundled", - "build:bundle": "npm run bundle:driver && npm run bundle:types", + "build:bundle": "npm run bundle:driver && npm run bundle:types && npm run build:runtime-barrel", "build:runtime-barrel": "node etc/build-runtime-barrel.mjs", "bundle:driver": "node etc/bundle-driver.mjs", "bundle:types": "npx tsc --project ./tsconfig.json --declaration --emitDeclarationOnly --declarationDir test/tools/runner/bundle/types", diff --git a/test/integration/crud/crud_api.test.ts b/test/integration/crud/crud_api.test.ts index fced0597ac..a598848ef1 100644 --- a/test/integration/crud/crud_api.test.ts +++ b/test/integration/crud/crud_api.test.ts @@ -21,7 +21,7 @@ import { assert as test } from '../shared'; const DB_NAME = 'crud_api_tests'; -describe.only('CRUD API', function () { +describe('CRUD API', function () { let client: MongoClient; beforeEach(async function () { From 06273e7ad32f543618aeb7ed49ca4092fe074c64 Mon Sep 17 00:00:00 2001 From: Pavel Safronov Date: Mon, 23 Feb 2026 09:29:44 -0800 Subject: [PATCH 16/36] updated imports of all integ tests and added a bunch of new exports to the bundled export file --- package-lock.json | 29 +- package.json | 4 +- src/sdam/topology.ts | 2 +- test/integration/auth/auth.prose.test.ts | 7 +- .../auth/mongodb_aws.prose.test.ts | 6 +- test/integration/auth/mongodb_aws.test.ts | 2 +- .../auth/mongodb_oidc.prose.test.ts | 2 +- .../bson-decimal128/decimal128.test.ts | 2 +- .../change-streams/change_stream.test.ts | 2 +- .../change_streams.prose.test.ts | 2 +- ...nt_side_encryption.prose.06.corpus.test.ts | 2 +- ...t_side_encryption.prose.10.kms_tls.test.ts | 2 +- ..._side_encryption.prose.12.deadlock.test.ts | 2 +- ...ryption.prose.14.decryption_events.test.ts | 2 +- ..._encryption.prose.17.on_demand_gcp.test.ts | 2 +- ...ion.prose.18.azure_kms_mock_server.test.ts | 2 +- ...ncryption.prose.19.on_demand_azure.test.ts | 6 +- ...yption.prose.20.mongocryptd_client.test.ts | 2 +- ....21.automatic_data_encryption_keys.test.ts | 2 +- ...prose.22.range_explicit_encryption.test.ts | 2 +- ...prose.23.range_encryption_defaults.test.ts | 2 +- ...nt_side_encryption.prose.25.lookup.test.ts | 2 +- ...26.custom_aws_credential_providers.test.ts | 7 +- ...e_encryption.prose.27.text_queries.test.ts | 6 +- .../client_side_encryption.prose.test.ts | 2 +- .../client-side-encryption/driver.test.ts | 2 +- ...ient_side_operations_timeout.prose.test.ts | 2 +- ...lient_side_operations_timeout.unit.test.ts | 2 +- .../node_csot.test.ts | 2 +- .../collection-management/collection.test.ts | 7 +- .../collection_db_management.test.ts | 2 +- .../collection-management/view.test.ts | 2 +- ...mmand_logging_and_monitoring.prose.test.ts | 2 +- .../command_monitoring.test.ts | 2 +- .../connection.test.ts | 2 +- .../connection_pool.test.ts | 2 +- .../rtt_pinger.test.ts | 2 +- ...onnections_survive_step_down.prose.test.ts | 2 +- .../crud/abstract_operation.test.ts | 2 +- test/integration/crud/aggregation.test.ts | 6 +- test/integration/crud/bulk.test.ts | 2 +- .../crud/client_bulk_write.test.ts | 2 +- test/integration/crud/crud.prose.test.ts | 2 +- test/integration/crud/crud_api.test.ts | 13 +- .../crud/document_validation.test.ts | 6 +- test/integration/crud/explain.test.ts | 2 +- test/integration/crud/find.test.ts | 2 +- test/integration/crud/find_and_modify.test.ts | 2 +- .../crud/find_cursor_methods.test.ts | 2 +- test/integration/crud/insert.test.ts | 2 +- test/integration/crud/maxTimeMS.test.ts | 2 +- test/integration/crud/misc_cursors.test.ts | 2 +- test/integration/crud/remove.test.ts | 2 +- test/integration/crud/server_errors.test.ts | 2 +- test/integration/crud/stats.test.ts | 2 +- test/integration/crud/unicode.test.ts | 2 +- .../enumerate_databases.prose.test.ts | 2 +- test/integration/enumerate_databases.test.ts | 2 +- test/integration/gridfs/gridfs.test.ts | 2 +- test/integration/gridfs/gridfs_stream.test.ts | 8 +- .../search-index-management.test.ts | 6 +- test/integration/index_management.test.ts | 2 +- .../dns_seedlist.test.ts | 2 +- ...itial_dns_seedlist_discovery.prose.test.ts | 8 +- ...nitial_dns_seedlist_discovery.spec.test.ts | 2 +- .../mongodb-handshake.prose.test.ts | 2 +- .../mongodb-handshake.test.ts | 2 +- .../node-specific/abort_signal.test.ts | 2 +- .../node-specific/abstract_cursor.test.ts | 2 +- .../node-specific/async_dispose.test.ts | 2 +- .../node-specific/auto_connect.test.ts | 2 +- .../node-specific/auto_encrypter.test.ts | 2 +- .../bson-options/bsonRegExp.test.ts | 2 +- .../bson-options/ignore_undefined.test.ts | 2 +- .../bson-options/promote_values.test.ts | 2 +- .../node-specific/bson-options/raw.test.ts | 2 +- .../bson-options/use_bigint_64.test.ts | 2 +- .../bson-options/utf8_validation.test.ts | 2 +- .../node-specific/client_close.test.ts | 2 +- .../node-specific/client_encryption.test.ts | 2 +- .../comment_with_falsy_values.test.ts | 7 +- .../convert_socket_errors.test.ts | 2 +- .../node-specific/crypt_shared_lib.test.ts | 2 +- .../node-specific/cursor_stream.test.ts | 2 +- test/integration/node-specific/db.test.ts | 2 +- test/integration/node-specific/errors.test.ts | 6 +- test/integration/node-specific/ipv6.test.ts | 2 +- .../node-specific/mongo_client.test.ts | 2 +- .../node-specific/operation_examples.test.ts | 2 +- .../resource_tracking_script_builder.ts | 2 +- .../node-specific/topology.test.ts | 2 +- .../node-specific/validate_collection.test.ts | 2 +- test/integration/objectid.test.ts | 2 +- .../read-write-concern/readconcern.test.ts | 2 +- .../read-write-concern/write_concern.test.ts | 2 +- .../retryable_reads.spec.prose.test.ts | 2 +- .../non-server-retryable_writes.test.ts | 2 +- .../retryable_writes.spec.prose.test.ts | 2 +- .../run-command/run_command.test.ts | 2 +- .../run-command/run_cursor_command.test.ts | 2 +- .../server_description.test.ts | 2 +- .../server_discover_and_monitoring.test.ts | 2 +- ...ver_discovery_and_monitoring.prose.test.ts | 2 +- .../topology_description.test.ts | 2 +- .../server-selection/operation_count.test.ts | 2 +- .../server-selection/readpreference.test.ts | 2 +- ...er_selection.prose.operation_count.test.ts | 2 +- ...tion.prose.sharded_retryable_reads.test.ts | 2 +- ...ion.prose.sharded_retryable_writes.test.ts | 2 +- .../sessions/sessions.prose.test.ts | 2 +- test/integration/sessions/sessions.test.ts | 2 +- .../transactions-convenient-api.prose.test.ts | 6 +- .../transactions/transactions.prose.test.ts | 2 +- .../transactions/transactions.test.ts | 2 +- test/integration/uri-options/uri.test.ts | 2 +- test/mongodb_bundled.ts | 270 ++++++++++++++++-- test/tools/runner/vm_context_helper.ts | 26 +- test/tools/utils.ts | 9 +- 118 files changed, 470 insertions(+), 169 deletions(-) diff --git a/package-lock.json b/package-lock.json index 79889203ab..c04187daa9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -34,6 +34,7 @@ "@typescript-eslint/eslint-plugin": "^8.46.3", "@typescript-eslint/parser": "^8.31.1", "aws4": "^1.13.2", + "baseline-browser-mapping": "^2.10.0", "chai": "^4.4.1", "chai-subset": "^1.6.0", "chalk": "^4.1.2", @@ -848,7 +849,6 @@ "integrity": "sha512-e7jT4DxYvIDLk1ZHmU/m/mB19rex9sv0c2ftBtjSBv+kVM/902eh0fINUzD7UwLLNR+jU585GxUJ8/EBfAM5fw==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@babel/code-frame": "^7.27.1", "@babel/generator": "^7.28.5", @@ -3469,8 +3469,7 @@ "resolved": "https://registry.npmjs.org/@types/chai/-/chai-4.3.20.tgz", "integrity": "sha512-/pC9HAB5I/xMlc5FP77qjCnI16ChlJfW0tGa0IUcFn38VJrTV6DeZ60NU5KZBtaOZqjdpwTWohz5HU1RrhiYxQ==", "dev": true, - "license": "MIT", - "peer": true + "license": "MIT" }, "node_modules/@types/chai-subset": { "version": "1.3.6", @@ -3572,7 +3571,6 @@ "integrity": "sha512-BICHQ67iqxQGFSzfCFTT7MRQ5XcBjG5aeKh5Ok38UBbPe5fxTyE+aHFxwVrGyr8GNlqFMLKD1D3P2K/1ks8tog==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "undici-types": "~6.21.0" } @@ -3704,7 +3702,6 @@ "integrity": "sha512-sbaQ27XBUopBkRiuY/P9sWGOWUW4rl8fDoHIUmLpZd8uldsTyB4/Zg6bWTegPoTLnKj9Hqgn3QD6cjPNB32Odw==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@eslint-community/regexpp": "^4.10.0", "@typescript-eslint/scope-manager": "8.46.3", @@ -3735,7 +3732,6 @@ "integrity": "sha512-6m1I5RmHBGTnUGS113G04DMu3CpSdxCAU/UvtjNWL4Nuf3MW9tQhiJqRlHzChIkhy6kZSAQmc+I1bcGjE3yNKg==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@typescript-eslint/scope-manager": "8.46.3", "@typescript-eslint/types": "8.46.3", @@ -3981,7 +3977,6 @@ "integrity": "sha512-NZyJarBfL7nWwIq+FDL6Zp/yHEhePMNnnJ0y3qfieCrmNvYct8uvtiV41UvlSe6apAfk0fY1FbWx+NwfmpvtTg==", "dev": true, "license": "MIT", - "peer": true, "bin": { "acorn": "bin/acorn" }, @@ -4042,7 +4037,6 @@ "integrity": "sha512-sRu1kpcO9yLtYxBKvqfTeh9KzZEwO3STyX1HT+4CaDzC6HpTGYhIhPIzj9XuKU7KYDwnaeh5hcOwjy1QuJzBPA==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "fast-deep-equal": "^3.1.1", "json-schema-traverse": "^1.0.0", @@ -4248,13 +4242,16 @@ "license": "MIT" }, "node_modules/baseline-browser-mapping": { - "version": "2.8.25", - "resolved": "https://registry.npmjs.org/baseline-browser-mapping/-/baseline-browser-mapping-2.8.25.tgz", - "integrity": "sha512-2NovHVesVF5TXefsGX1yzx1xgr7+m9JQenvz6FQY3qd+YXkKkYiv+vTCc7OriP9mcDZpTC5mAOYN4ocd29+erA==", + "version": "2.10.0", + "resolved": "https://registry.npmjs.org/baseline-browser-mapping/-/baseline-browser-mapping-2.10.0.tgz", + "integrity": "sha512-lIyg0szRfYbiy67j9KN8IyeD7q7hcmqnJ1ddWmNt19ItGpNN64mnllmxUNFIOdOm6by97jlL6wfpTTJrmnjWAA==", "dev": true, "license": "Apache-2.0", "bin": { - "baseline-browser-mapping": "dist/cli.js" + "baseline-browser-mapping": "dist/cli.cjs" + }, + "engines": { + "node": ">=6.0.0" } }, "node_modules/bignumber.js": { @@ -4358,7 +4355,6 @@ } ], "license": "MIT", - "peer": true, "dependencies": { "baseline-browser-mapping": "^2.8.19", "caniuse-lite": "^1.0.30001751", @@ -4536,7 +4532,6 @@ "integrity": "sha512-RITGBfijLkBddZvnn8jdqoTypxvqbOLYQkGGxXzeFjVHvudaPw0HNFD9x928/eUwYWd2dPCugVqspGALTZZQKw==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "assertion-error": "^1.1.0", "check-error": "^1.0.3", @@ -5185,7 +5180,6 @@ "integrity": "sha512-BhHmn2yNOFA9H9JmmIVKJmd288g9hrVRDkdoIgRCRuSySRUHH7r/DI6aAXW9T1WwUuY3DFgrcaqB+deURBLR5g==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@eslint-community/eslint-utils": "^4.8.0", "@eslint-community/regexpp": "^4.12.1", @@ -5246,7 +5240,6 @@ "integrity": "sha512-82GZUjRS0p/jganf6q1rEO25VSoHH0hKPCTrgillPjdI/3bgBhAE1QzHrHTizjpRvy6pGAvKjDJtk2pF9NDq8w==", "dev": true, "license": "MIT", - "peer": true, "bin": { "eslint-config-prettier": "bin/cli.js" }, @@ -7821,7 +7814,6 @@ "integrity": "sha512-U42vQ4czpKa0QdI1hu950XuNhYqgoM+ZF1HT+VuUHL9hPfDPVvNQyltmMqdE9bUHMVa+8yNbc3QKTj8zQhlVxQ==", "dev": true, "license": "ISC", - "peer": true, "dependencies": { "@istanbuljs/load-nyc-config": "^1.0.0", "@istanbuljs/schema": "^0.1.2", @@ -8506,7 +8498,6 @@ "integrity": "sha512-I7AIg5boAr5R0FFtJ6rCfD+LFsWHp81dolrFD8S79U9tb8Az2nGrJncnMSnys+bpQJfRUzqs9hnA81OAA3hCuQ==", "dev": true, "license": "MIT", - "peer": true, "bin": { "prettier": "bin/prettier.cjs" }, @@ -9362,7 +9353,6 @@ "integrity": "sha512-a2N2TDY1uGviajJ6r4D1CyRAkzE9NNVlYOV1wX5xQDuAk0ONgzgRl0EjCQuRCPxOwp13ghsMwt9Gdldujs39qw==", "dev": true, "license": "BSD-3-Clause", - "peer": true, "dependencies": { "@sinonjs/commons": "^3.0.1", "@sinonjs/fake-timers": "11.2.2", @@ -10145,7 +10135,6 @@ "integrity": "sha512-p1diW6TqL9L07nNxvRMM7hMMw4c5XOo/1ibL4aAIGmSAt9slTE1Xgw5KWuof2uTOvCg9BY7ZRi+GaF+7sfgPeQ==", "dev": true, "license": "Apache-2.0", - "peer": true, "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" diff --git a/package.json b/package.json index 0d7583f908..506979984d 100644 --- a/package.json +++ b/package.json @@ -141,9 +141,9 @@ "check:dts": "node ./node_modules/typescript/bin/tsc --target es2023 --module commonjs --noEmit mongodb.d.ts && tsd", "check:search-indexes": "nyc mocha --config test/mocha_mongodb.js test/manual/search-index-management.prose.test.ts", "check:test": "npm run build:bundle && nyc mocha --config test/mocha_mongodb.js test/integration", - "check:test-bundled": "npm run build:bundle && npm run switch:to-bundled && npm run check:test ; npm run switch:to-unbundled", + "check:test-bundled": "MONGODB_BUNDLED=true npm run check:test", "check:unit": "npm run build:bundle && nyc mocha test/unit", - "check:unit-bundled": "npm run build:bundle && npm run switch:to-bundled && npm run check:unit ; npm run switch:to-unbundled", + "check:unit-bundled": "MONGODB_BUNDLED=true npm run check:unit", "check:ts": "node ./node_modules/typescript/bin/tsc -v && node ./node_modules/typescript/bin/tsc --noEmit", "check:atlas": "nyc mocha --config test/manual/mocharc.js test/manual/atlas_connectivity.test.ts", "check:drivers-atlas-testing": "nyc mocha --config test/mocha_mongodb.js test/atlas/drivers_atlas_testing.test.ts", diff --git a/src/sdam/topology.ts b/src/sdam/topology.ts index 2a158525fa..0c4ad62133 100644 --- a/src/sdam/topology.ts +++ b/src/sdam/topology.ts @@ -272,7 +272,7 @@ export class Topology extends TypedEventEmitter { for (const seed of seeds) { if (typeof seed === 'string') { seedlist.push(HostAddress.fromString(seed)); - } else if (seed instanceof HostAddress) { + } else if (seed instanceof HostAddress || (seed as any).constructor.name === 'HostAddress') { seedlist.push(seed); } else { // FIXME(NODE-3483): May need to be a MongoParseError diff --git a/test/integration/auth/auth.prose.test.ts b/test/integration/auth/auth.prose.test.ts index 1b2dfc2633..0c9dccddff 100644 --- a/test/integration/auth/auth.prose.test.ts +++ b/test/integration/auth/auth.prose.test.ts @@ -2,7 +2,12 @@ import { expect } from 'chai'; import * as process from 'process'; import * as sinon from 'sinon'; -import { Connection, LEGACY_HELLO_COMMAND, type MongoClient, ScramSHA256 } from '../../mongodb'; +import { + Connection, + LEGACY_HELLO_COMMAND, + type MongoClient, + ScramSHA256 +} from '../../mongodb_runtime-testing'; import { type TestConfiguration } from '../../tools/runner/config'; function makeConnectionString(config, username, password) { diff --git a/test/integration/auth/mongodb_aws.prose.test.ts b/test/integration/auth/mongodb_aws.prose.test.ts index 33e8502a3e..b15e54aa46 100644 --- a/test/integration/auth/mongodb_aws.prose.test.ts +++ b/test/integration/auth/mongodb_aws.prose.test.ts @@ -1,7 +1,11 @@ import { expect } from 'chai'; import * as process from 'process'; -import { AWSSDKCredentialProvider, type MongoClient, MongoServerError } from '../../mongodb'; +import { + AWSSDKCredentialProvider, + type MongoClient, + MongoServerError +} from '../../mongodb_runtime-testing'; const isMongoDBAWSAuthEnvironment = (process.env.MONGODB_URI ?? '').includes('MONGODB-AWS'); describe('MONGODB-AWS Prose Tests', function () { diff --git a/test/integration/auth/mongodb_aws.test.ts b/test/integration/auth/mongodb_aws.test.ts index 95b792e864..02aeef047d 100644 --- a/test/integration/auth/mongodb_aws.test.ts +++ b/test/integration/auth/mongodb_aws.test.ts @@ -21,7 +21,7 @@ import { MongoServerError, refreshKMSCredentials, setDifference -} from '../../mongodb'; +} from '../../mongodb_runtime-testing'; const isMongoDBAWSAuthEnvironment = (process.env.MONGODB_URI ?? '').includes('MONGODB-AWS'); describe('MONGODB-AWS', function () { diff --git a/test/integration/auth/mongodb_oidc.prose.test.ts b/test/integration/auth/mongodb_oidc.prose.test.ts index a7e89876a6..06db99a52c 100644 --- a/test/integration/auth/mongodb_oidc.prose.test.ts +++ b/test/integration/auth/mongodb_oidc.prose.test.ts @@ -14,7 +14,7 @@ import { type OIDCCallbackFunction, type OIDCCallbackParams, type OIDCResponse -} from '../../mongodb'; +} from '../../mongodb_runtime-testing'; const createCallback = (tokenFile = 'test_user1', expiresInSeconds?: number, extraFields?: any) => { return async (params: OIDCCallbackParams) => { const token = await readFile(path.join(process.env.OIDC_TOKEN_DIR, tokenFile), { diff --git a/test/integration/bson-decimal128/decimal128.test.ts b/test/integration/bson-decimal128/decimal128.test.ts index 9797ce6206..4dca2f6831 100644 --- a/test/integration/bson-decimal128/decimal128.test.ts +++ b/test/integration/bson-decimal128/decimal128.test.ts @@ -1,6 +1,6 @@ import { expect } from 'chai'; -import { type Collection, Decimal128, type MongoClient } from '../../mongodb'; +import { type Collection, Decimal128, type MongoClient } from '../../mongodb_runtime-testing'; describe('Decimal128', function () { let client: MongoClient; diff --git a/test/integration/change-streams/change_stream.test.ts b/test/integration/change-streams/change_stream.test.ts index fbdc5e4561..2ed1891c2d 100644 --- a/test/integration/change-streams/change_stream.test.ts +++ b/test/integration/change-streams/change_stream.test.ts @@ -22,7 +22,7 @@ import { MongoServerError, ReadPreference, type ResumeToken -} from '../../mongodb'; +} from '../../mongodb_runtime-testing'; import * as mock from '../../tools/mongodb-mock/index'; import { TestBuilder, UnifiedTestSuiteBuilder } from '../../tools/unified_suite_builder'; import { type FailCommandFailPoint, sleep } from '../../tools/utils'; diff --git a/test/integration/change-streams/change_streams.prose.test.ts b/test/integration/change-streams/change_streams.prose.test.ts index d655036b70..e4802da438 100644 --- a/test/integration/change-streams/change_streams.prose.test.ts +++ b/test/integration/change-streams/change_streams.prose.test.ts @@ -16,7 +16,7 @@ import { MongoNetworkError, ObjectId, Timestamp -} from '../../mongodb'; +} from '../../mongodb_runtime-testing'; import * as mock from '../../tools/mongodb-mock/index'; import { setupDatabase } from '../shared'; diff --git a/test/integration/client-side-encryption/client_side_encryption.prose.06.corpus.test.ts b/test/integration/client-side-encryption/client_side_encryption.prose.06.corpus.test.ts index 357acc49bb..e3b6486e75 100644 --- a/test/integration/client-side-encryption/client_side_encryption.prose.06.corpus.test.ts +++ b/test/integration/client-side-encryption/client_side_encryption.prose.06.corpus.test.ts @@ -7,7 +7,7 @@ import * as path from 'path'; import * as process from 'process'; import { getCSFLEKMSProviders } from '../../csfle-kms-providers'; -import { ClientEncryption, type MongoClient, WriteConcern } from '../../mongodb'; +import { ClientEncryption, type MongoClient, WriteConcern } from '../../mongodb_runtime-testing'; import { getEncryptExtraOptions } from '../../tools/utils'; describe('Client Side Encryption Prose Corpus Test', function () { diff --git a/test/integration/client-side-encryption/client_side_encryption.prose.10.kms_tls.test.ts b/test/integration/client-side-encryption/client_side_encryption.prose.10.kms_tls.test.ts index c6121eedf3..746269c701 100644 --- a/test/integration/client-side-encryption/client_side_encryption.prose.10.kms_tls.test.ts +++ b/test/integration/client-side-encryption/client_side_encryption.prose.10.kms_tls.test.ts @@ -3,7 +3,7 @@ import * as process from 'process'; import { satisfies } from 'semver'; import { getCSFLEKMSProviders } from '../../csfle-kms-providers'; -import { ClientEncryption, type MongoClient } from '../../mongodb'; +import { ClientEncryption, type MongoClient } from '../../mongodb_runtime-testing'; const metadata: MongoDBMetadataUI = { requires: { diff --git a/test/integration/client-side-encryption/client_side_encryption.prose.12.deadlock.test.ts b/test/integration/client-side-encryption/client_side_encryption.prose.12.deadlock.test.ts index 2009a787d4..caab1755ce 100644 --- a/test/integration/client-side-encryption/client_side_encryption.prose.12.deadlock.test.ts +++ b/test/integration/client-side-encryption/client_side_encryption.prose.12.deadlock.test.ts @@ -9,7 +9,7 @@ import { type CommandStartedEvent, type MongoClient, type MongoClientOptions -} from '../../mongodb'; +} from '../../mongodb_runtime-testing'; import { type TestConfiguration } from '../../tools/runner/config'; import { getEncryptExtraOptions } from '../../tools/utils'; import { dropCollection } from '../shared'; diff --git a/test/integration/client-side-encryption/client_side_encryption.prose.14.decryption_events.test.ts b/test/integration/client-side-encryption/client_side_encryption.prose.14.decryption_events.test.ts index 7f4563ff3a..0c25f5c866 100644 --- a/test/integration/client-side-encryption/client_side_encryption.prose.14.decryption_events.test.ts +++ b/test/integration/client-side-encryption/client_side_encryption.prose.14.decryption_events.test.ts @@ -8,7 +8,7 @@ import { type CommandSucceededEvent, type MongoClient, MongoNetworkError -} from '../../mongodb'; +} from '../../mongodb_runtime-testing'; import { getEncryptExtraOptions } from '../../tools/utils'; const metadata: MongoDBMetadataUI = { diff --git a/test/integration/client-side-encryption/client_side_encryption.prose.17.on_demand_gcp.test.ts b/test/integration/client-side-encryption/client_side_encryption.prose.17.on_demand_gcp.test.ts index c319b20b89..e0ab6d2f73 100644 --- a/test/integration/client-side-encryption/client_side_encryption.prose.17.on_demand_gcp.test.ts +++ b/test/integration/client-side-encryption/client_side_encryption.prose.17.on_demand_gcp.test.ts @@ -1,7 +1,7 @@ import { expect } from 'chai'; import { env } from 'process'; -import { Binary, ClientEncryption } from '../../mongodb'; +import { Binary, ClientEncryption } from '../../mongodb_runtime-testing'; const dataKeyOptions = { masterKey: { projectId: 'devprod-drivers', diff --git a/test/integration/client-side-encryption/client_side_encryption.prose.18.azure_kms_mock_server.test.ts b/test/integration/client-side-encryption/client_side_encryption.prose.18.azure_kms_mock_server.test.ts index 3ceb767922..bd23b52005 100644 --- a/test/integration/client-side-encryption/client_side_encryption.prose.18.azure_kms_mock_server.test.ts +++ b/test/integration/client-side-encryption/client_side_encryption.prose.18.azure_kms_mock_server.test.ts @@ -5,7 +5,7 @@ import { type Document, fetchAzureKMSToken, MongoCryptAzureKMSRequestError -} from '../../mongodb'; +} from '../../mongodb_runtime-testing'; const BASE_URL = new URL(`http://127.0.0.1:8080/metadata/identity/oauth2/token`); class KMSRequestOptions implements AzureKMSRequestOptions { url: URL = BASE_URL; diff --git a/test/integration/client-side-encryption/client_side_encryption.prose.19.on_demand_azure.test.ts b/test/integration/client-side-encryption/client_side_encryption.prose.19.on_demand_azure.test.ts index 2c5492739f..14dd42a2e7 100644 --- a/test/integration/client-side-encryption/client_side_encryption.prose.19.on_demand_azure.test.ts +++ b/test/integration/client-side-encryption/client_side_encryption.prose.19.on_demand_azure.test.ts @@ -1,7 +1,11 @@ import { expect } from 'chai'; import { env } from 'process'; -import { Binary, ClientEncryption, MongoCryptAzureKMSRequestError } from '../../mongodb'; +import { + Binary, + ClientEncryption, + MongoCryptAzureKMSRequestError +} from '../../mongodb_runtime-testing'; const dataKeyOptions = { masterKey: { keyVaultEndpoint: 'https://drivers-2411-keyvault.vault.azure.net/', diff --git a/test/integration/client-side-encryption/client_side_encryption.prose.20.mongocryptd_client.test.ts b/test/integration/client-side-encryption/client_side_encryption.prose.20.mongocryptd_client.test.ts index 98bd88a9bd..d7e49cfb91 100644 --- a/test/integration/client-side-encryption/client_side_encryption.prose.20.mongocryptd_client.test.ts +++ b/test/integration/client-side-encryption/client_side_encryption.prose.20.mongocryptd_client.test.ts @@ -3,7 +3,7 @@ import { once } from 'events'; import { createServer, type Server } from 'net'; import { getCSFLEKMSProviders } from '../../csfle-kms-providers'; -import { type MongoClient } from '../../mongodb'; +import { type MongoClient } from '../../mongodb_runtime-testing'; import { getEncryptExtraOptions } from '../../tools/utils'; describe('20. Bypass creating mongocryptd client when shared library is loaded', function () { diff --git a/test/integration/client-side-encryption/client_side_encryption.prose.21.automatic_data_encryption_keys.test.ts b/test/integration/client-side-encryption/client_side_encryption.prose.21.automatic_data_encryption_keys.test.ts index b1ff4a6f07..e4244518ca 100644 --- a/test/integration/client-side-encryption/client_side_encryption.prose.21.automatic_data_encryption_keys.test.ts +++ b/test/integration/client-side-encryption/client_side_encryption.prose.21.automatic_data_encryption_keys.test.ts @@ -11,7 +11,7 @@ import { type Db, MongoCryptCreateEncryptedCollectionError, MongoServerError -} from '../../mongodb'; +} from '../../mongodb_runtime-testing'; const metadata: MongoDBMetadataUI = { requires: { clientSideEncryption: true, diff --git a/test/integration/client-side-encryption/client_side_encryption.prose.22.range_explicit_encryption.test.ts b/test/integration/client-side-encryption/client_side_encryption.prose.22.range_explicit_encryption.test.ts index 6257039008..8b998d3dbc 100644 --- a/test/integration/client-side-encryption/client_side_encryption.prose.22.range_explicit_encryption.test.ts +++ b/test/integration/client-side-encryption/client_side_encryption.prose.22.range_explicit_encryption.test.ts @@ -12,7 +12,7 @@ import { Long, type MongoClient, MongoCryptError -} from '../../mongodb'; +} from '../../mongodb_runtime-testing'; const getKmsProviders = () => { const result = getCSFLEKMSProviders(); diff --git a/test/integration/client-side-encryption/client_side_encryption.prose.23.range_encryption_defaults.test.ts b/test/integration/client-side-encryption/client_side_encryption.prose.23.range_encryption_defaults.test.ts index 97f81e5e33..309214f4df 100644 --- a/test/integration/client-side-encryption/client_side_encryption.prose.23.range_encryption_defaults.test.ts +++ b/test/integration/client-side-encryption/client_side_encryption.prose.23.range_encryption_defaults.test.ts @@ -1,7 +1,7 @@ import { expect } from 'chai'; import { getCSFLEKMSProviders } from '../../csfle-kms-providers'; -import { type Binary, ClientEncryption, Int32, Long } from '../../mongodb'; +import { type Binary, ClientEncryption, Int32, Long } from '../../mongodb_runtime-testing'; const metaData: MongoDBMetadataUI = { requires: { clientSideEncryption: '>=6.1.0', diff --git a/test/integration/client-side-encryption/client_side_encryption.prose.25.lookup.test.ts b/test/integration/client-side-encryption/client_side_encryption.prose.25.lookup.test.ts index 0c873ee1cc..0f9b4154d3 100644 --- a/test/integration/client-side-encryption/client_side_encryption.prose.25.lookup.test.ts +++ b/test/integration/client-side-encryption/client_side_encryption.prose.25.lookup.test.ts @@ -4,7 +4,7 @@ import * as path from 'node:path'; import { expect } from 'chai'; import { getCSFLEKMSProviders } from '../../csfle-kms-providers'; -import { BSON, type Document, type MongoClient } from '../../mongodb'; +import { BSON, type Document, type MongoClient } from '../../mongodb_runtime-testing'; import { type TestConfiguration } from '../../tools/runner/config'; import { getEncryptExtraOptions } from '../../tools/utils'; diff --git a/test/integration/client-side-encryption/client_side_encryption.prose.26.custom_aws_credential_providers.test.ts b/test/integration/client-side-encryption/client_side_encryption.prose.26.custom_aws_credential_providers.test.ts index 0a77a06c77..bc14888827 100644 --- a/test/integration/client-side-encryption/client_side_encryption.prose.26.custom_aws_credential_providers.test.ts +++ b/test/integration/client-side-encryption/client_side_encryption.prose.26.custom_aws_credential_providers.test.ts @@ -1,7 +1,12 @@ import { expect } from 'chai'; import * as process from 'process'; -import { AWSSDKCredentialProvider, Binary, ClientEncryption, MongoClient } from '../../mongodb'; +import { + AWSSDKCredentialProvider, + Binary, + ClientEncryption, + MongoClient +} from '../../mongodb_runtime-testing'; import { getEncryptExtraOptions } from '../../tools/utils'; const metadata: MongoDBMetadataUI = { diff --git a/test/integration/client-side-encryption/client_side_encryption.prose.27.text_queries.test.ts b/test/integration/client-side-encryption/client_side_encryption.prose.27.text_queries.test.ts index 1159b3360d..9f4107dcda 100644 --- a/test/integration/client-side-encryption/client_side_encryption.prose.27.text_queries.test.ts +++ b/test/integration/client-side-encryption/client_side_encryption.prose.27.text_queries.test.ts @@ -5,7 +5,11 @@ import { type Binary, type Document, EJSON } from 'bson'; import { expect } from 'chai'; import { getCSFLEKMSProviders } from '../../csfle-kms-providers'; -import { ClientEncryption, type MongoClient, MongoDBCollectionNamespace } from '../../mongodb'; +import { + ClientEncryption, + type MongoClient, + MongoDBCollectionNamespace +} from '../../mongodb_runtime-testing'; const metadata: MongoDBMetadataUI = { requires: { clientSideEncryption: '>=6.4.0', diff --git a/test/integration/client-side-encryption/client_side_encryption.prose.test.ts b/test/integration/client-side-encryption/client_side_encryption.prose.test.ts index 42ed8dcfe0..c6f541529d 100644 --- a/test/integration/client-side-encryption/client_side_encryption.prose.test.ts +++ b/test/integration/client-side-encryption/client_side_encryption.prose.test.ts @@ -14,7 +14,7 @@ import { MongoRuntimeError, MongoServerError, MongoServerSelectionError -} from '../../mongodb'; +} from '../../mongodb_runtime-testing'; import { AlpineTestConfiguration } from '../../tools/runner/config'; import { getEncryptExtraOptions } from '../../tools/utils'; import { APMEventCollector, dropCollection } from '../shared'; diff --git a/test/integration/client-side-encryption/driver.test.ts b/test/integration/client-side-encryption/driver.test.ts index 65592e9f37..a761022cba 100644 --- a/test/integration/client-side-encryption/driver.test.ts +++ b/test/integration/client-side-encryption/driver.test.ts @@ -22,7 +22,7 @@ import { resolveTimeoutOptions, StateMachine, TimeoutContext -} from '../../mongodb'; +} from '../../mongodb_runtime-testing'; import { clearFailPoint, configureFailPoint, diff --git a/test/integration/client-side-operations-timeout/client_side_operations_timeout.prose.test.ts b/test/integration/client-side-operations-timeout/client_side_operations_timeout.prose.test.ts index a00601a0f2..c3dbde8127 100644 --- a/test/integration/client-side-operations-timeout/client_side_operations_timeout.prose.test.ts +++ b/test/integration/client-side-operations-timeout/client_side_operations_timeout.prose.test.ts @@ -20,7 +20,7 @@ import { ObjectId, processTimeMS, squashError -} from '../../mongodb'; +} from '../../mongodb_runtime-testing'; import { clearFailPoint, configureFailPoint, diff --git a/test/integration/client-side-operations-timeout/client_side_operations_timeout.unit.test.ts b/test/integration/client-side-operations-timeout/client_side_operations_timeout.unit.test.ts index 10ecbe3629..c9c314416b 100644 --- a/test/integration/client-side-operations-timeout/client_side_operations_timeout.unit.test.ts +++ b/test/integration/client-side-operations-timeout/client_side_operations_timeout.unit.test.ts @@ -21,7 +21,7 @@ import { Timeout, TimeoutContext, Topology -} from '../../mongodb'; +} from '../../mongodb_runtime-testing'; import { measureDuration, sleep } from '../../tools/utils'; import { createTimerSandbox } from '../../unit/timer_sandbox'; diff --git a/test/integration/client-side-operations-timeout/node_csot.test.ts b/test/integration/client-side-operations-timeout/node_csot.test.ts index 7aad267083..613084f114 100644 --- a/test/integration/client-side-operations-timeout/node_csot.test.ts +++ b/test/integration/client-side-operations-timeout/node_csot.test.ts @@ -30,7 +30,7 @@ import { ObjectId, promiseWithResolvers, TopologyType -} from '../../mongodb'; +} from '../../mongodb_runtime-testing'; import { type FailCommandFailPoint, type FailPoint, waitUntilPoolsFilled } from '../../tools/utils'; const metadata = { requires: { mongodb: '>=4.4' } }; diff --git a/test/integration/collection-management/collection.test.ts b/test/integration/collection-management/collection.test.ts index 4a4b4b532d..4eb8d01247 100644 --- a/test/integration/collection-management/collection.test.ts +++ b/test/integration/collection-management/collection.test.ts @@ -1,6 +1,11 @@ import { expect } from 'chai'; -import { Collection, type Db, type MongoClient, MongoServerError } from '../../mongodb'; +import { + Collection, + type Db, + type MongoClient, + MongoServerError +} from '../../mongodb_runtime-testing'; import { type TestConfiguration } from '../../tools/runner/config'; import { type FailCommandFailPoint } from '../../tools/utils'; import { setupDatabase } from '../shared'; diff --git a/test/integration/collection-management/collection_db_management.test.ts b/test/integration/collection-management/collection_db_management.test.ts index 327c7f4113..6c03d8850d 100644 --- a/test/integration/collection-management/collection_db_management.test.ts +++ b/test/integration/collection-management/collection_db_management.test.ts @@ -1,6 +1,6 @@ import { expect } from 'chai'; -import { Collection, type Db, type MongoClient, ObjectId } from '../../mongodb'; +import { Collection, type Db, type MongoClient, ObjectId } from '../../mongodb_runtime-testing'; describe('Collection Management and Db Management', function () { let client: MongoClient; diff --git a/test/integration/collection-management/view.test.ts b/test/integration/collection-management/view.test.ts index 88b30d03f3..ab4029356b 100644 --- a/test/integration/collection-management/view.test.ts +++ b/test/integration/collection-management/view.test.ts @@ -1,6 +1,6 @@ import { expect } from 'chai'; -import { type CollectionInfo, type Db, type MongoClient } from '../../mongodb'; +import { type CollectionInfo, type Db, type MongoClient } from '../../mongodb_runtime-testing'; describe('Views', function () { let client: MongoClient; diff --git a/test/integration/command-logging-and-monitoring/command_logging_and_monitoring.prose.test.ts b/test/integration/command-logging-and-monitoring/command_logging_and_monitoring.prose.test.ts index 5417a51688..0e3f8600ed 100644 --- a/test/integration/command-logging-and-monitoring/command_logging_and_monitoring.prose.test.ts +++ b/test/integration/command-logging-and-monitoring/command_logging_and_monitoring.prose.test.ts @@ -1,6 +1,6 @@ import { expect } from 'chai'; -import { DEFAULT_MAX_DOCUMENT_LENGTH, type Document } from '../../mongodb'; +import { DEFAULT_MAX_DOCUMENT_LENGTH, type Document } from '../../mongodb_runtime-testing'; describe('Command Logging and Monitoring Prose Tests', function () { const ELLIPSES_LENGTH = 3; let client; diff --git a/test/integration/command-logging-and-monitoring/command_monitoring.test.ts b/test/integration/command-logging-and-monitoring/command_monitoring.test.ts index 9242770d46..6d383d447a 100644 --- a/test/integration/command-logging-and-monitoring/command_monitoring.test.ts +++ b/test/integration/command-logging-and-monitoring/command_monitoring.test.ts @@ -1,6 +1,6 @@ import { expect } from 'chai'; -import { type MongoClient, ObjectId, ReadPreference } from '../../mongodb'; +import { type MongoClient, ObjectId, ReadPreference } from '../../mongodb_runtime-testing'; import { filterForCommands, setupDatabase } from '../shared'; describe('Command Monitoring', function () { diff --git a/test/integration/connection-monitoring-and-pooling/connection.test.ts b/test/integration/connection-monitoring-and-pooling/connection.test.ts index 0a1dc572bc..ae89bfe7d1 100644 --- a/test/integration/connection-monitoring-and-pooling/connection.test.ts +++ b/test/integration/connection-monitoring-and-pooling/connection.test.ts @@ -21,7 +21,7 @@ import { ns, ServerHeartbeatStartedEvent, Topology -} from '../../mongodb'; +} from '../../mongodb_runtime-testing'; import * as mock from '../../tools/mongodb-mock/index'; import { processTick, runtime, sleep } from '../../tools/utils'; import { assert as test, setupDatabase } from '../shared'; diff --git a/test/integration/connection-monitoring-and-pooling/connection_pool.test.ts b/test/integration/connection-monitoring-and-pooling/connection_pool.test.ts index d073b5a112..c377abdebf 100644 --- a/test/integration/connection-monitoring-and-pooling/connection_pool.test.ts +++ b/test/integration/connection-monitoring-and-pooling/connection_pool.test.ts @@ -8,7 +8,7 @@ import { type Db, type MongoClient, type Server -} from '../../mongodb'; +} from '../../mongodb_runtime-testing'; import { clearFailPoint, configureFailPoint, sleep } from '../../tools/utils'; describe('Connection Pool', function () { diff --git a/test/integration/connection-monitoring-and-pooling/rtt_pinger.test.ts b/test/integration/connection-monitoring-and-pooling/rtt_pinger.test.ts index 5b659290ef..7acce6b6a1 100644 --- a/test/integration/connection-monitoring-and-pooling/rtt_pinger.test.ts +++ b/test/integration/connection-monitoring-and-pooling/rtt_pinger.test.ts @@ -7,7 +7,7 @@ import { LEGACY_HELLO_COMMAND, type MongoClient, type RTTPinger -} from '../../mongodb'; +} from '../../mongodb_runtime-testing'; import { sleep } from '../../tools/utils'; /** diff --git a/test/integration/connections-survive-step-down/connections_survive_step_down.prose.test.ts b/test/integration/connections-survive-step-down/connections_survive_step_down.prose.test.ts index 3ba24d9587..70801d9d73 100644 --- a/test/integration/connections-survive-step-down/connections_survive_step_down.prose.test.ts +++ b/test/integration/connections-survive-step-down/connections_survive_step_down.prose.test.ts @@ -8,7 +8,7 @@ import { MONGODB_ERROR_CODES, MongoServerError, ReadPreference -} from '../../mongodb'; +} from '../../mongodb_runtime-testing'; import { type FailCommandFailPoint } from '../../tools/utils'; describe('Connections Survive Primary Step Down - prose', function () { diff --git a/test/integration/crud/abstract_operation.test.ts b/test/integration/crud/abstract_operation.test.ts index 777e2a38fc..6f2c1e975f 100644 --- a/test/integration/crud/abstract_operation.test.ts +++ b/test/integration/crud/abstract_operation.test.ts @@ -48,7 +48,7 @@ import { UpdateOperation, UpdateSearchIndexOperation, ValidateCollectionOperation -} from '../../mongodb'; +} from '../../mongodb_runtime-testing'; describe('abstract operation', function () { describe('command name getter', function () { diff --git a/test/integration/crud/aggregation.test.ts b/test/integration/crud/aggregation.test.ts index 915d9c9de3..eafeffd565 100644 --- a/test/integration/crud/aggregation.test.ts +++ b/test/integration/crud/aggregation.test.ts @@ -1,6 +1,10 @@ import { expect } from 'chai'; -import { type MongoClient, MongoInvalidArgumentError, MongoServerError } from '../../mongodb'; +import { + type MongoClient, + MongoInvalidArgumentError, + MongoServerError +} from '../../mongodb_runtime-testing'; import { filterForCommands } from '../shared'; describe('Aggregation', function () { diff --git a/test/integration/crud/bulk.test.ts b/test/integration/crud/bulk.test.ts index 0f8ae3ae60..9a13e6aab2 100644 --- a/test/integration/crud/bulk.test.ts +++ b/test/integration/crud/bulk.test.ts @@ -11,7 +11,7 @@ import { type MongoClient, MongoDriverError, MongoInvalidArgumentError -} from '../../mongodb'; +} from '../../mongodb_runtime-testing'; import { assert as test } from '../shared'; const MAX_BSON_SIZE = 16777216; diff --git a/test/integration/crud/client_bulk_write.test.ts b/test/integration/crud/client_bulk_write.test.ts index acb05b2e01..b288e529f7 100644 --- a/test/integration/crud/client_bulk_write.test.ts +++ b/test/integration/crud/client_bulk_write.test.ts @@ -9,7 +9,7 @@ import { MongoOperationTimeoutError, processTimeMS, TimeoutContext -} from '../../mongodb'; +} from '../../mongodb_runtime-testing'; import { clearFailPoint, configureFailPoint, diff --git a/test/integration/crud/crud.prose.test.ts b/test/integration/crud/crud.prose.test.ts index 302abeb247..f018381d87 100644 --- a/test/integration/crud/crud.prose.test.ts +++ b/test/integration/crud/crud.prose.test.ts @@ -12,7 +12,7 @@ import { MongoClientBulkWriteError, MongoInvalidArgumentError, MongoServerError -} from '../../mongodb'; +} from '../../mongodb_runtime-testing'; import { getEncryptExtraOptions } from '../../tools/utils'; import { filterForCommands } from '../shared'; diff --git a/test/integration/crud/crud_api.test.ts b/test/integration/crud/crud_api.test.ts index a598848ef1..8d0952a65a 100644 --- a/test/integration/crud/crud_api.test.ts +++ b/test/integration/crud/crud_api.test.ts @@ -105,7 +105,7 @@ describe('CRUD API', function () { const result = await collection.findOne({}); expect(result).to.deep.equal({ _id: 1 }); if (runNodelessTests) { - expect(ensureTypeByName(events.at(0), 'CommandSucceededEvent')).to.be.true; + ensureTypeByName(events.at(0), 'CommandSucceededEvent'); } else { expect(events.at(0)).to.be.instanceOf(CommandSucceededEvent); expect(spy.returnValues.at(0)).to.have.property('closed', true); @@ -141,7 +141,7 @@ describe('CRUD API', function () { const spy = sinon.spy(Collection.prototype, 'find'); const error = await collection.findOne({}).catch(error => error); if (runNodelessTests) { - expect(ensureTypeByName(error, 'MongoServerError')).to.be.true; + ensureTypeByName(error, 'MongoServerError'); } else { expect(error).to.be.instanceOf(MongoServerError); expect(events.at(0)).to.be.instanceOf(CommandFailedEvent); @@ -183,7 +183,7 @@ describe('CRUD API', function () { const result = await collection.countDocuments({}); expect(result).to.deep.equal(2); if (runNodelessTests) { - expect(ensureTypeByName(events[0], 'CommandSucceededEvent')).to.be.true; + ensureTypeByName(events[0], 'CommandSucceededEvent'); } else { expect(events[0]).to.be.instanceOf(CommandSucceededEvent); expect(spy.returnValues[0]).to.have.property('closed', true); @@ -219,7 +219,7 @@ describe('CRUD API', function () { const spy = sinon.spy(Collection.prototype, 'aggregate'); const error = await collection.countDocuments({}).catch(error => error); if (runNodelessTests) { - expect(ensureTypeByName(error, 'MongoServerError')).to.be.true; + ensureTypeByName(error, 'MongoServerError'); } else { expect(error).to.be.instanceOf(MongoServerError); expect(events.at(0)).to.be.instanceOf(CommandFailedEvent); @@ -803,7 +803,7 @@ describe('CRUD API', function () { .catch(error => error); if (runNodelessTests) { - expect(ensureTypeByName(error, 'MongoBulkWriteError')).to.be.true; + ensureTypeByName(error, 'MongoBulkWriteError'); } else { expect(error).to.be.instanceOf(MongoBulkWriteError); } @@ -829,8 +829,7 @@ describe('CRUD API', function () { .collection('t20_1') .bulkWrite(ops, { ordered: true, writeConcern: { w: 1 } }) .catch(err => err); - // expect(err).to.be.instanceOf(MongoBulkWriteError); - expect(ensureTypeByName(err, 'MongoBulkWriteError')).to.be.true; + ensureTypeByName(err, 'MongoBulkWriteError'); }); describe('sort support', function () { diff --git a/test/integration/crud/document_validation.test.ts b/test/integration/crud/document_validation.test.ts index 4ef0f8e946..75da7b91df 100644 --- a/test/integration/crud/document_validation.test.ts +++ b/test/integration/crud/document_validation.test.ts @@ -1,6 +1,10 @@ import { expect } from 'chai'; -import { MongoBulkWriteError, type MongoClient, MongoServerError } from '../../mongodb'; +import { + MongoBulkWriteError, + type MongoClient, + MongoServerError +} from '../../mongodb_runtime-testing'; import { setupDatabase } from '../shared'; describe('Document Validation', function () { diff --git a/test/integration/crud/explain.test.ts b/test/integration/crud/explain.test.ts index 8236cbf00e..4ac6f0bde9 100644 --- a/test/integration/crud/explain.test.ts +++ b/test/integration/crud/explain.test.ts @@ -9,7 +9,7 @@ import { type MongoClient, MongoOperationTimeoutError, MongoServerError -} from '../../mongodb'; +} from '../../mongodb_runtime-testing'; import { clearFailPoint, configureFailPoint, measureDuration } from '../../tools/utils'; import { filterForCommands } from '../shared'; diff --git a/test/integration/crud/find.test.ts b/test/integration/crud/find.test.ts index bb6fc2146e..36f565e09b 100644 --- a/test/integration/crud/find.test.ts +++ b/test/integration/crud/find.test.ts @@ -9,7 +9,7 @@ import { MongoServerError, ObjectId, ReturnDocument -} from '../../mongodb'; +} from '../../mongodb_runtime-testing'; import { assert as test, filterForCommands } from '../shared'; describe('Find', function () { diff --git a/test/integration/crud/find_and_modify.test.ts b/test/integration/crud/find_and_modify.test.ts index 524ad7b06a..c437849e6d 100644 --- a/test/integration/crud/find_and_modify.test.ts +++ b/test/integration/crud/find_and_modify.test.ts @@ -6,7 +6,7 @@ import { type MongoClient, MongoServerError, ObjectId -} from '../../mongodb'; +} from '../../mongodb_runtime-testing'; import { setupDatabase } from '../shared'; describe('Collection (#findOneAnd...)', function () { diff --git a/test/integration/crud/find_cursor_methods.test.ts b/test/integration/crud/find_cursor_methods.test.ts index fd2b66f679..566ef09c01 100644 --- a/test/integration/crud/find_cursor_methods.test.ts +++ b/test/integration/crud/find_cursor_methods.test.ts @@ -9,7 +9,7 @@ import { MongoCursorExhaustedError, promiseWithResolvers, TimeoutContext -} from '../../mongodb'; +} from '../../mongodb_runtime-testing'; import { filterForCommands } from '../shared'; describe('Find Cursor', function () { diff --git a/test/integration/crud/insert.test.ts b/test/integration/crud/insert.test.ts index b649d6a5b5..b16e5fa2e2 100644 --- a/test/integration/crud/insert.test.ts +++ b/test/integration/crud/insert.test.ts @@ -23,7 +23,7 @@ import { ObjectId, ReturnDocument, Timestamp -} from '../../mongodb'; +} from '../../mongodb_runtime-testing'; import { assert as test, setupDatabase } from '../shared'; describe('crud - insert', function () { diff --git a/test/integration/crud/maxTimeMS.test.ts b/test/integration/crud/maxTimeMS.test.ts index f4d83ddc2f..b681068bd5 100644 --- a/test/integration/crud/maxTimeMS.test.ts +++ b/test/integration/crud/maxTimeMS.test.ts @@ -8,7 +8,7 @@ import { type MongoClient, MongoCursorExhaustedError, MongoServerError -} from '../../mongodb'; +} from '../../mongodb_runtime-testing'; describe('MaxTimeMS', function () { let client: MongoClient; diff --git a/test/integration/crud/misc_cursors.test.ts b/test/integration/crud/misc_cursors.test.ts index 70a8ccf196..da8a43564e 100644 --- a/test/integration/crud/misc_cursors.test.ts +++ b/test/integration/crud/misc_cursors.test.ts @@ -7,7 +7,7 @@ import { MongoClientClosedError, ReadPreference, ServerType -} from '../../mongodb'; +} from '../../mongodb_runtime-testing'; import { runLater, sleep } from '../../tools/utils'; import { assert as test, filterForCommands, setupDatabase } from '../shared'; diff --git a/test/integration/crud/remove.test.ts b/test/integration/crud/remove.test.ts index 6e5ea8b41d..fc7bca60fe 100644 --- a/test/integration/crud/remove.test.ts +++ b/test/integration/crud/remove.test.ts @@ -1,6 +1,6 @@ import { expect } from 'chai'; -import { type MongoClient } from '../../mongodb'; +import { type MongoClient } from '../../mongodb_runtime-testing'; describe('Remove', function () { let client: MongoClient; diff --git a/test/integration/crud/server_errors.test.ts b/test/integration/crud/server_errors.test.ts index b3f0191e07..dcf5859e40 100644 --- a/test/integration/crud/server_errors.test.ts +++ b/test/integration/crud/server_errors.test.ts @@ -1,6 +1,6 @@ import { expect } from 'chai'; -import { type MongoClient, MongoServerError } from '../../mongodb'; +import { type MongoClient, MongoServerError } from '../../mongodb_runtime-testing'; import { setupDatabase } from '../shared'; describe('Errors', function () { diff --git a/test/integration/crud/stats.test.ts b/test/integration/crud/stats.test.ts index aadb9dedac..a1fa060736 100644 --- a/test/integration/crud/stats.test.ts +++ b/test/integration/crud/stats.test.ts @@ -1,6 +1,6 @@ import { expect } from 'chai'; -import { type MongoClient } from '../../mongodb'; +import { type MongoClient } from '../../mongodb_runtime-testing'; describe('stats', function () { let client: MongoClient; diff --git a/test/integration/crud/unicode.test.ts b/test/integration/crud/unicode.test.ts index 8d4e898f2a..671c63e542 100644 --- a/test/integration/crud/unicode.test.ts +++ b/test/integration/crud/unicode.test.ts @@ -2,7 +2,7 @@ import { expect } from 'chai'; import * as process from 'process'; import { satisfies } from 'semver'; -import type { MongoClient } from '../../mongodb'; +import type { MongoClient } from '../../mongodb_runtime-testing'; import { assert as test, setupDatabase } from '../shared'; describe('Unicode', function () { diff --git a/test/integration/enumerate_databases.prose.test.ts b/test/integration/enumerate_databases.prose.test.ts index 9528d68fad..154eb26079 100644 --- a/test/integration/enumerate_databases.prose.test.ts +++ b/test/integration/enumerate_databases.prose.test.ts @@ -1,6 +1,6 @@ import { expect } from 'chai'; -import type { MongoClient } from '../mongodb'; +import type { MongoClient } from '../mongodb_runtime-testing'; const REQUIRED_DBS = ['admin', 'local', 'config']; const DB_NAME = 'listDatabasesTest'; diff --git a/test/integration/enumerate_databases.test.ts b/test/integration/enumerate_databases.test.ts index 0b52ade130..f6d8311edb 100644 --- a/test/integration/enumerate_databases.test.ts +++ b/test/integration/enumerate_databases.test.ts @@ -1,7 +1,7 @@ import { expect } from 'chai'; import { once } from 'events'; -import { type MongoClient, MongoServerError } from '../mongodb'; +import { type MongoClient, MongoServerError } from '../mongodb_runtime-testing'; import { TestBuilder, UnifiedTestSuiteBuilder } from '../tools/unified_suite_builder'; const metadata: MongoDBMetadataUI = { diff --git a/test/integration/gridfs/gridfs.test.ts b/test/integration/gridfs/gridfs.test.ts index 20ac793e80..a03e25a891 100644 --- a/test/integration/gridfs/gridfs.test.ts +++ b/test/integration/gridfs/gridfs.test.ts @@ -8,7 +8,7 @@ import { GridFSBucket, type MongoClient, ObjectId -} from '../../mongodb'; +} from '../../mongodb_runtime-testing'; import { sleep } from '../../tools/utils'; describe('GridFS', () => { diff --git a/test/integration/gridfs/gridfs_stream.test.ts b/test/integration/gridfs/gridfs_stream.test.ts index df34a239a6..5174d74def 100644 --- a/test/integration/gridfs/gridfs_stream.test.ts +++ b/test/integration/gridfs/gridfs_stream.test.ts @@ -7,7 +7,13 @@ import { promisify } from 'node:util'; import { expect } from 'chai'; import * as sinon from 'sinon'; -import { type Db, GridFSBucket, MongoAPIError, type MongoClient, ObjectId } from '../../mongodb'; +import { + type Db, + GridFSBucket, + MongoAPIError, + type MongoClient, + ObjectId +} from '../../mongodb_runtime-testing'; describe('GridFS Stream', function () { let client: MongoClient; diff --git a/test/integration/index-management/search-index-management.test.ts b/test/integration/index-management/search-index-management.test.ts index 39d17f2281..e85422e065 100644 --- a/test/integration/index-management/search-index-management.test.ts +++ b/test/integration/index-management/search-index-management.test.ts @@ -1,6 +1,10 @@ import { expect } from 'chai'; -import { type Collection, type CommandStartedEvent, type MongoClient } from '../../mongodb'; +import { + type Collection, + type CommandStartedEvent, + type MongoClient +} from '../../mongodb_runtime-testing'; describe('Search Index Management Integration Tests', function () { describe('read concern and write concern ', function () { diff --git a/test/integration/index_management.test.ts b/test/integration/index_management.test.ts index d824dea7d7..0316c07ab4 100644 --- a/test/integration/index_management.test.ts +++ b/test/integration/index_management.test.ts @@ -7,7 +7,7 @@ import { type Db, type MongoClient, MongoServerError -} from '../mongodb'; +} from '../mongodb_runtime-testing'; import { type FailCommandFailPoint } from '../tools/utils'; import { assert as test, filterForCommands, setupDatabase } from './shared'; diff --git a/test/integration/initial-dns-seedlist-discovery/dns_seedlist.test.ts b/test/integration/initial-dns-seedlist-discovery/dns_seedlist.test.ts index a27172c574..97e649e4b2 100644 --- a/test/integration/initial-dns-seedlist-discovery/dns_seedlist.test.ts +++ b/test/integration/initial-dns-seedlist-discovery/dns_seedlist.test.ts @@ -2,7 +2,7 @@ import { expect } from 'chai'; import * as dns from 'dns'; import * as sinon from 'sinon'; -import { MongoClient } from '../../mongodb'; +import { MongoClient } from '../../mongodb_runtime-testing'; const metadata: MongoDBMetadataUI = { requires: { topology: '!single', tls: 'disabled' } }; diff --git a/test/integration/initial-dns-seedlist-discovery/initial_dns_seedlist_discovery.prose.test.ts b/test/integration/initial-dns-seedlist-discovery/initial_dns_seedlist_discovery.prose.test.ts index 3f931c019c..185f111f77 100644 --- a/test/integration/initial-dns-seedlist-discovery/initial_dns_seedlist_discovery.prose.test.ts +++ b/test/integration/initial-dns-seedlist-discovery/initial_dns_seedlist_discovery.prose.test.ts @@ -2,7 +2,13 @@ import { expect } from 'chai'; import * as dns from 'dns'; import * as sinon from 'sinon'; -import { ConnectionPool, MongoAPIError, Server, ServerDescription, Topology } from '../../mongodb'; +import { + ConnectionPool, + MongoAPIError, + Server, + ServerDescription, + Topology +} from '../../mongodb_runtime-testing'; import { topologyWithPlaceholderClient } from '../../tools/utils'; describe('Initial DNS Seedlist Discovery (Prose Tests)', () => { diff --git a/test/integration/initial-dns-seedlist-discovery/initial_dns_seedlist_discovery.spec.test.ts b/test/integration/initial-dns-seedlist-discovery/initial_dns_seedlist_discovery.spec.test.ts index 141c5d6fe5..9fa8510852 100644 --- a/test/integration/initial-dns-seedlist-discovery/initial_dns_seedlist_discovery.spec.test.ts +++ b/test/integration/initial-dns-seedlist-discovery/initial_dns_seedlist_discovery.spec.test.ts @@ -4,7 +4,7 @@ import * as fs from 'fs'; import * as path from 'path'; import { promisify } from 'util'; -import { HostAddress, MongoClient } from '../../mongodb'; +import { HostAddress, MongoClient } from '../../mongodb_runtime-testing'; function makeTest(test, topology) { let client; diff --git a/test/integration/mongodb-handshake/mongodb-handshake.prose.test.ts b/test/integration/mongodb-handshake/mongodb-handshake.prose.test.ts index 6b9dad6099..b643c64c76 100644 --- a/test/integration/mongodb-handshake/mongodb-handshake.prose.test.ts +++ b/test/integration/mongodb-handshake/mongodb-handshake.prose.test.ts @@ -11,7 +11,7 @@ import { isDriverInfoEqual, LEGACY_HELLO_COMMAND, type MongoClient -} from '../../mongodb'; +} from '../../mongodb_runtime-testing'; import { sleep } from '../../tools/utils'; type EnvironmentVariables = Array<[string, string]>; diff --git a/test/integration/mongodb-handshake/mongodb-handshake.test.ts b/test/integration/mongodb-handshake/mongodb-handshake.test.ts index 528fb0d1c4..a7b162f4c0 100644 --- a/test/integration/mongodb-handshake/mongodb-handshake.test.ts +++ b/test/integration/mongodb-handshake/mongodb-handshake.test.ts @@ -9,7 +9,7 @@ import { OpMsgRequest, OpQueryRequest, ServerApiVersion -} from '../../mongodb'; +} from '../../mongodb_runtime-testing'; describe('MongoDB Handshake', () => { let client; diff --git a/test/integration/node-specific/abort_signal.test.ts b/test/integration/node-specific/abort_signal.test.ts index 6cec61ec39..85bdf4762f 100644 --- a/test/integration/node-specific/abort_signal.test.ts +++ b/test/integration/node-specific/abort_signal.test.ts @@ -22,7 +22,7 @@ import { ReadPreference, setDifference, StateMachine -} from '../../mongodb'; +} from '../../mongodb_runtime-testing'; import { clearFailPoint, configureFailPoint, diff --git a/test/integration/node-specific/abstract_cursor.test.ts b/test/integration/node-specific/abstract_cursor.test.ts index 3a39cfe03e..8da033447a 100644 --- a/test/integration/node-specific/abstract_cursor.test.ts +++ b/test/integration/node-specific/abstract_cursor.test.ts @@ -16,7 +16,7 @@ import { MongoCursorExhaustedError, MongoOperationTimeoutError, TimeoutContext -} from '../../mongodb'; +} from '../../mongodb_runtime-testing'; import { clearFailPoint, configureFailPoint } from '../../tools/utils'; import { filterForCommands } from '../shared'; diff --git a/test/integration/node-specific/async_dispose.test.ts b/test/integration/node-specific/async_dispose.test.ts index 729b665455..223df65dbd 100644 --- a/test/integration/node-specific/async_dispose.test.ts +++ b/test/integration/node-specific/async_dispose.test.ts @@ -1,7 +1,7 @@ import { expect } from 'chai'; import * as sinon from 'sinon'; -import { type MongoClient } from '../../mongodb'; +import { type MongoClient } from '../../mongodb_runtime-testing'; describe('Symbol.asyncDispose implementation tests', function () { let client: MongoClient; diff --git a/test/integration/node-specific/auto_connect.test.ts b/test/integration/node-specific/auto_connect.test.ts index f085004963..c92a3d46e2 100644 --- a/test/integration/node-specific/auto_connect.test.ts +++ b/test/integration/node-specific/auto_connect.test.ts @@ -12,7 +12,7 @@ import { ProfilingLevel, Topology, TopologyType -} from '../../mongodb'; +} from '../../mongodb_runtime-testing'; import { sleep } from '../../tools/utils'; describe('When executing an operation for the first time', () => { diff --git a/test/integration/node-specific/auto_encrypter.test.ts b/test/integration/node-specific/auto_encrypter.test.ts index 1f29951e1b..2d28acb90d 100644 --- a/test/integration/node-specific/auto_encrypter.test.ts +++ b/test/integration/node-specific/auto_encrypter.test.ts @@ -9,7 +9,7 @@ import { MongoRuntimeError, StateMachine, type UUID -} from '../../mongodb'; +} from '../../mongodb_runtime-testing'; describe('mongocryptd auto spawn', function () { let client: MongoClient; const kmsProviders: KMSProviders = { diff --git a/test/integration/node-specific/bson-options/bsonRegExp.test.ts b/test/integration/node-specific/bson-options/bsonRegExp.test.ts index d1c06f538c..bd9636dc58 100644 --- a/test/integration/node-specific/bson-options/bsonRegExp.test.ts +++ b/test/integration/node-specific/bson-options/bsonRegExp.test.ts @@ -1,6 +1,6 @@ import { expect } from 'chai'; -import { BSONRegExp, type MongoClient } from '../../../mongodb'; +import { BSONRegExp, type MongoClient } from '../../../mongodb_runtime-testing'; describe('BSONRegExp', () => { describe('bsonRegExp option', () => { diff --git a/test/integration/node-specific/bson-options/ignore_undefined.test.ts b/test/integration/node-specific/bson-options/ignore_undefined.test.ts index 0cbcf43b9c..83fe2b0972 100644 --- a/test/integration/node-specific/bson-options/ignore_undefined.test.ts +++ b/test/integration/node-specific/bson-options/ignore_undefined.test.ts @@ -1,6 +1,6 @@ import { expect } from 'chai'; -import { type MongoClient, ObjectId } from '../../../mongodb'; +import { type MongoClient, ObjectId } from '../../../mongodb_runtime-testing'; import { assert as test, setupDatabase } from '../../shared'; describe('Ignore Undefined', function () { diff --git a/test/integration/node-specific/bson-options/promote_values.test.ts b/test/integration/node-specific/bson-options/promote_values.test.ts index 6be7e9960c..fa2d4d98cb 100644 --- a/test/integration/node-specific/bson-options/promote_values.test.ts +++ b/test/integration/node-specific/bson-options/promote_values.test.ts @@ -1,6 +1,6 @@ import { expect } from 'chai'; -import { Double, Int32, Long } from '../../../mongodb'; +import { Double, Int32, Long } from '../../../mongodb_runtime-testing'; import { assert as test, setupDatabase } from '../../shared'; describe('Promote Values', function () { diff --git a/test/integration/node-specific/bson-options/raw.test.ts b/test/integration/node-specific/bson-options/raw.test.ts index 455344f9a9..85b740f2ba 100644 --- a/test/integration/node-specific/bson-options/raw.test.ts +++ b/test/integration/node-specific/bson-options/raw.test.ts @@ -1,6 +1,6 @@ import { expect } from 'chai'; -import { type Collection, type MongoClient, ObjectId } from '../../../mongodb'; +import { type Collection, type MongoClient, ObjectId } from '../../../mongodb_runtime-testing'; describe('raw bson support', () => { describe('raw', () => { diff --git a/test/integration/node-specific/bson-options/use_bigint_64.test.ts b/test/integration/node-specific/bson-options/use_bigint_64.test.ts index 8adec9807d..78070ebe0f 100644 --- a/test/integration/node-specific/bson-options/use_bigint_64.test.ts +++ b/test/integration/node-specific/bson-options/use_bigint_64.test.ts @@ -9,7 +9,7 @@ import { MongoAPIError, type MongoClient, type WithId -} from '../../../mongodb'; +} from '../../../mongodb_runtime-testing'; describe('useBigInt64 option', function () { let client: MongoClient; let db: Db; diff --git a/test/integration/node-specific/bson-options/utf8_validation.test.ts b/test/integration/node-specific/bson-options/utf8_validation.test.ts index e9920834bd..31d5af7c49 100644 --- a/test/integration/node-specific/bson-options/utf8_validation.test.ts +++ b/test/integration/node-specific/bson-options/utf8_validation.test.ts @@ -10,7 +10,7 @@ import { type MongoClient, MongoServerError, OpMsgResponse -} from '../../../mongodb'; +} from '../../../mongodb_runtime-testing'; describe('class MongoDBResponse', () => { let client; diff --git a/test/integration/node-specific/client_close.test.ts b/test/integration/node-specific/client_close.test.ts index 98053aa0af..887f724ae6 100644 --- a/test/integration/node-specific/client_close.test.ts +++ b/test/integration/node-specific/client_close.test.ts @@ -9,7 +9,7 @@ import { type CommandStartedEvent, type FindCursor, type MongoClient -} from '../../mongodb'; +} from '../../mongodb_runtime-testing'; import { configureMongocryptdSpawnHooks } from '../../tools/utils'; import { filterForCommands } from '../shared'; import { runScriptAndGetProcessInfo } from './resource_tracking_script_builder'; diff --git a/test/integration/node-specific/client_encryption.test.ts b/test/integration/node-specific/client_encryption.test.ts index 033b27e08f..c171f17f93 100644 --- a/test/integration/node-specific/client_encryption.test.ts +++ b/test/integration/node-specific/client_encryption.test.ts @@ -14,7 +14,7 @@ import { MongoCryptInvalidArgumentError, StateMachine, UUID -} from '../../mongodb'; +} from '../../mongodb_runtime-testing'; function readHttpResponse(path) { let data = readFileSync(path, 'utf8').toString(); data = data.split('\n').join('\r\n'); diff --git a/test/integration/node-specific/comment_with_falsy_values.test.ts b/test/integration/node-specific/comment_with_falsy_values.test.ts index 6d0819fd33..74d6e9a1aa 100644 --- a/test/integration/node-specific/comment_with_falsy_values.test.ts +++ b/test/integration/node-specific/comment_with_falsy_values.test.ts @@ -1,6 +1,11 @@ import { expect } from 'chai'; -import { type Collection, type CommandStartedEvent, Long, type MongoClient } from '../../mongodb'; +import { + type Collection, + type CommandStartedEvent, + Long, + type MongoClient +} from '../../mongodb_runtime-testing'; import { TestBuilder, UnifiedTestSuiteBuilder } from '../../tools/unified_suite_builder'; const falsyValues = [0, false, '', Long.ZERO, null, NaN] as const; diff --git a/test/integration/node-specific/convert_socket_errors.test.ts b/test/integration/node-specific/convert_socket_errors.test.ts index e13a216711..4b2772af8f 100644 --- a/test/integration/node-specific/convert_socket_errors.test.ts +++ b/test/integration/node-specific/convert_socket_errors.test.ts @@ -10,7 +10,7 @@ import { type MongoClient, MongoNetworkError, ns -} from '../../mongodb'; +} from '../../mongodb_runtime-testing'; import { clearFailPoint, configureFailPoint } from '../../tools/utils'; import { filterForCommands } from '../shared'; diff --git a/test/integration/node-specific/crypt_shared_lib.test.ts b/test/integration/node-specific/crypt_shared_lib.test.ts index 5020e8579d..28bdbcaba9 100644 --- a/test/integration/node-specific/crypt_shared_lib.test.ts +++ b/test/integration/node-specific/crypt_shared_lib.test.ts @@ -3,7 +3,7 @@ import { spawnSync } from 'child_process'; import { dirname } from 'path'; import * as process from 'process'; -import { EJSON } from '../../mongodb'; +import { EJSON } from '../../mongodb_runtime-testing'; import { getEncryptExtraOptions } from '../../tools/utils'; describe('crypt shared library', () => { diff --git a/test/integration/node-specific/cursor_stream.test.ts b/test/integration/node-specific/cursor_stream.test.ts index 4181b1c025..cc6eb0ec9c 100644 --- a/test/integration/node-specific/cursor_stream.test.ts +++ b/test/integration/node-specific/cursor_stream.test.ts @@ -10,7 +10,7 @@ import { type Db, type MongoClient, MongoServerError -} from '../../mongodb'; +} from '../../mongodb_runtime-testing'; import { sleep } from '../../tools/utils'; describe('Cursor Streams', function () { diff --git a/test/integration/node-specific/db.test.ts b/test/integration/node-specific/db.test.ts index 6b8541667e..7ac960353a 100644 --- a/test/integration/node-specific/db.test.ts +++ b/test/integration/node-specific/db.test.ts @@ -6,7 +6,7 @@ import { MongoClient, MongoInvalidArgumentError, MongoServerError -} from '../../mongodb'; +} from '../../mongodb_runtime-testing'; import { setupDatabase } from '../shared'; describe('Db', function () { diff --git a/test/integration/node-specific/errors.test.ts b/test/integration/node-specific/errors.test.ts index ff00db6564..abeecf5365 100644 --- a/test/integration/node-specific/errors.test.ts +++ b/test/integration/node-specific/errors.test.ts @@ -1,6 +1,10 @@ import { expect } from 'chai'; -import { MongoClient, MongoServerSelectionError, ReadPreference } from '../../mongodb'; +import { + MongoClient, + MongoServerSelectionError, + ReadPreference +} from '../../mongodb_runtime-testing'; describe('Error (Integration)', function () { it('NODE-5296: handles aggregate errors from dns lookup', async function () { diff --git a/test/integration/node-specific/ipv6.test.ts b/test/integration/node-specific/ipv6.test.ts index 1353415817..253fcb8957 100644 --- a/test/integration/node-specific/ipv6.test.ts +++ b/test/integration/node-specific/ipv6.test.ts @@ -8,7 +8,7 @@ import { type MongoClient, ReadPreference, TopologyType -} from '../../mongodb'; +} from '../../mongodb_runtime-testing'; describe('IPv6 Addresses', () => { let client: MongoClient; diff --git a/test/integration/node-specific/mongo_client.test.ts b/test/integration/node-specific/mongo_client.test.ts index 65eeb73ad2..9e3de614f0 100644 --- a/test/integration/node-specific/mongo_client.test.ts +++ b/test/integration/node-specific/mongo_client.test.ts @@ -17,7 +17,7 @@ import { ReadPreference, ServerDescription, Topology -} from '../../mongodb'; +} from '../../mongodb_runtime-testing'; import { clearFailPoint, configureFailPoint } from '../../tools/utils'; import { setupDatabase } from '../shared'; diff --git a/test/integration/node-specific/operation_examples.test.ts b/test/integration/node-specific/operation_examples.test.ts index 4573198f62..8f72dba3af 100644 --- a/test/integration/node-specific/operation_examples.test.ts +++ b/test/integration/node-specific/operation_examples.test.ts @@ -7,7 +7,7 @@ import { type MongoClient, ProfilingLevel, ReturnDocument -} from '../../mongodb'; +} from '../../mongodb_runtime-testing'; import { sleep as delay } from '../../tools/utils'; import { setupDatabase } from '../shared'; diff --git a/test/integration/node-specific/resource_tracking_script_builder.ts b/test/integration/node-specific/resource_tracking_script_builder.ts index fd835611c0..d2fb31bd93 100644 --- a/test/integration/node-specific/resource_tracking_script_builder.ts +++ b/test/integration/node-specific/resource_tracking_script_builder.ts @@ -9,7 +9,7 @@ import { AssertionError, expect } from 'chai'; import * as process from 'process'; import type * as timers from 'timers'; -import type * as mongodb from '../../mongodb'; +import type * as mongodb from '../../mongodb_runtime-testing'; import { type TestConfiguration } from '../../tools/runner/config'; import { type sleep } from '../../tools/utils'; diff --git a/test/integration/node-specific/topology.test.ts b/test/integration/node-specific/topology.test.ts index 4d2a223ff6..0e4e2999bc 100644 --- a/test/integration/node-specific/topology.test.ts +++ b/test/integration/node-specific/topology.test.ts @@ -1,6 +1,6 @@ import { expect } from 'chai'; -import { MongoClient, type MongoClientOptions, type Topology } from '../../mongodb'; +import { MongoClient, type MongoClientOptions, type Topology } from '../../mongodb_runtime-testing'; describe('Topology', function () { it('should correctly track states of a topology', { diff --git a/test/integration/node-specific/validate_collection.test.ts b/test/integration/node-specific/validate_collection.test.ts index b19f19e708..34aa7d5f4c 100644 --- a/test/integration/node-specific/validate_collection.test.ts +++ b/test/integration/node-specific/validate_collection.test.ts @@ -1,6 +1,6 @@ import { expect } from 'chai'; -import { ValidateCollectionOperation } from '../../mongodb'; +import { ValidateCollectionOperation } from '../../mongodb_runtime-testing'; describe('ValidateCollectionOperation', function () { let client; diff --git a/test/integration/objectid.test.ts b/test/integration/objectid.test.ts index e1b61b8b4e..6be14706fa 100644 --- a/test/integration/objectid.test.ts +++ b/test/integration/objectid.test.ts @@ -1,6 +1,6 @@ import { expect } from 'chai'; -import { type Collection, type Db, type MongoClient, ObjectId } from '../mongodb'; +import { type Collection, type Db, type MongoClient, ObjectId } from '../mongodb_runtime-testing'; import { sleep } from '../tools/utils'; // TODO(NODE-4989): Improve these tests, likely can be made unit tests, or migrated to CRUD coverage (find oid range) diff --git a/test/integration/read-write-concern/readconcern.test.ts b/test/integration/read-write-concern/readconcern.test.ts index 06348eaf4e..11c9947fe2 100644 --- a/test/integration/read-write-concern/readconcern.test.ts +++ b/test/integration/read-write-concern/readconcern.test.ts @@ -1,6 +1,6 @@ import { expect } from 'chai'; -import { type MongoClient, ReadConcernLevel } from '../../mongodb'; +import { type MongoClient, ReadConcernLevel } from '../../mongodb_runtime-testing'; import { filterForCommands, setupDatabase } from '../shared'; describe('ReadConcern', function () { diff --git a/test/integration/read-write-concern/write_concern.test.ts b/test/integration/read-write-concern/write_concern.test.ts index 44dfe658c2..728466d25f 100644 --- a/test/integration/read-write-concern/write_concern.test.ts +++ b/test/integration/read-write-concern/write_concern.test.ts @@ -11,7 +11,7 @@ import { LEGACY_HELLO_COMMAND, MongoClient, OpMsgRequest -} from '../../mongodb'; +} from '../../mongodb_runtime-testing'; import * as mock from '../../tools/mongodb-mock/index'; import { filterForCommands } from '../shared'; diff --git a/test/integration/retryable-reads/retryable_reads.spec.prose.test.ts b/test/integration/retryable-reads/retryable_reads.spec.prose.test.ts index ca0576d218..f99ec40fd0 100644 --- a/test/integration/retryable-reads/retryable_reads.spec.prose.test.ts +++ b/test/integration/retryable-reads/retryable_reads.spec.prose.test.ts @@ -1,7 +1,7 @@ /* eslint-disable @typescript-eslint/no-non-null-assertion */ import { expect } from 'chai'; -import { type Collection, type MongoClient } from '../../mongodb'; +import { type Collection, type MongoClient } from '../../mongodb_runtime-testing'; describe('Retryable Reads Spec Prose', () => { let client: MongoClient, failPointName; diff --git a/test/integration/retryable-writes/non-server-retryable_writes.test.ts b/test/integration/retryable-writes/non-server-retryable_writes.test.ts index 0e2a06c7cf..8065e47896 100644 --- a/test/integration/retryable-writes/non-server-retryable_writes.test.ts +++ b/test/integration/retryable-writes/non-server-retryable_writes.test.ts @@ -7,7 +7,7 @@ import { MongoWriteConcernError, PoolClearedError, Server -} from '../../mongodb'; +} from '../../mongodb_runtime-testing'; describe('Non Server Retryable Writes', function () { let client: MongoClient; let collection: Collection<{ _id: 1 }>; diff --git a/test/integration/retryable-writes/retryable_writes.spec.prose.test.ts b/test/integration/retryable-writes/retryable_writes.spec.prose.test.ts index 22f475978d..52118230b8 100644 --- a/test/integration/retryable-writes/retryable_writes.spec.prose.test.ts +++ b/test/integration/retryable-writes/retryable_writes.spec.prose.test.ts @@ -11,7 +11,7 @@ import { MongoServerError, MongoWriteConcernError, Server -} from '../../mongodb'; +} from '../../mongodb_runtime-testing'; import { sleep } from '../../tools/utils'; describe('Retryable Writes Spec Prose', () => { diff --git a/test/integration/run-command/run_command.test.ts b/test/integration/run-command/run_command.test.ts index e71d3887bf..64100a331b 100644 --- a/test/integration/run-command/run_command.test.ts +++ b/test/integration/run-command/run_command.test.ts @@ -7,7 +7,7 @@ import { ReadConcern, ReadPreference, WriteConcern -} from '../../mongodb'; +} from '../../mongodb_runtime-testing'; describe('RunCommand API', () => { let client: MongoClient; diff --git a/test/integration/run-command/run_cursor_command.test.ts b/test/integration/run-command/run_cursor_command.test.ts index 8b88c313f7..9fc86bda88 100644 --- a/test/integration/run-command/run_cursor_command.test.ts +++ b/test/integration/run-command/run_cursor_command.test.ts @@ -1,6 +1,6 @@ import { expect } from 'chai'; -import { type Db, type MongoClient } from '../../mongodb'; +import { type Db, type MongoClient } from '../../mongodb_runtime-testing'; describe('runCursorCommand API', () => { let client: MongoClient; diff --git a/test/integration/server-discovery-and-monitoring/server_description.test.ts b/test/integration/server-discovery-and-monitoring/server_description.test.ts index 0bc9112c4b..071298c083 100644 --- a/test/integration/server-discovery-and-monitoring/server_description.test.ts +++ b/test/integration/server-discovery-and-monitoring/server_description.test.ts @@ -1,6 +1,6 @@ import { expect } from 'chai'; -import { MongoClient } from '../../mongodb'; +import { MongoClient } from '../../mongodb_runtime-testing'; import { configureMongocryptdSpawnHooks } from '../../tools/utils'; describe('class ServerDescription', function () { diff --git a/test/integration/server-discovery-and-monitoring/server_discover_and_monitoring.test.ts b/test/integration/server-discovery-and-monitoring/server_discover_and_monitoring.test.ts index 282d081b45..06fe64c6aa 100644 --- a/test/integration/server-discovery-and-monitoring/server_discover_and_monitoring.test.ts +++ b/test/integration/server-discovery-and-monitoring/server_discover_and_monitoring.test.ts @@ -8,7 +8,7 @@ import { type MongoClient, promiseWithResolvers, type ServerHeartbeatSucceededEvent -} from '../../mongodb'; +} from '../../mongodb_runtime-testing'; import { loadSpecTests } from '../../spec'; import { runUnifiedSuite } from '../../tools/unified-spec-runner/runner'; diff --git a/test/integration/server-discovery-and-monitoring/server_discovery_and_monitoring.prose.test.ts b/test/integration/server-discovery-and-monitoring/server_discovery_and_monitoring.prose.test.ts index 1f4cec0057..59be8de218 100644 --- a/test/integration/server-discovery-and-monitoring/server_discovery_and_monitoring.prose.test.ts +++ b/test/integration/server-discovery-and-monitoring/server_discovery_and_monitoring.prose.test.ts @@ -9,7 +9,7 @@ import { type MongoClient, SERVER_HEARTBEAT_FAILED, SERVER_HEARTBEAT_SUCCEEDED -} from '../../mongodb'; +} from '../../mongodb_runtime-testing'; import { sleep } from '../../tools/utils'; describe('Server Discovery and Monitoring Prose Tests', function () { diff --git a/test/integration/server-discovery-and-monitoring/topology_description.test.ts b/test/integration/server-discovery-and-monitoring/topology_description.test.ts index 18a6824d1d..2a2dcb22d9 100644 --- a/test/integration/server-discovery-and-monitoring/topology_description.test.ts +++ b/test/integration/server-discovery-and-monitoring/topology_description.test.ts @@ -5,7 +5,7 @@ import { type MongoClient, type MongoClientOptions, TopologyType -} from '../../mongodb'; +} from '../../mongodb_runtime-testing'; describe('TopologyDescription (integration tests)', function () { let client: MongoClient; diff --git a/test/integration/server-selection/operation_count.test.ts b/test/integration/server-selection/operation_count.test.ts index 6f6a68f10a..8e953a32ef 100644 --- a/test/integration/server-selection/operation_count.test.ts +++ b/test/integration/server-selection/operation_count.test.ts @@ -6,7 +6,7 @@ import { type Collection, ConnectionPool, type MongoClient -} from '../../mongodb'; +} from '../../mongodb_runtime-testing'; import { type FailCommandFailPoint } from '../../tools/utils'; const testMetadata: MongoDBMetadataUI = { diff --git a/test/integration/server-selection/readpreference.test.ts b/test/integration/server-selection/readpreference.test.ts index e3ff9e47a8..90410e7714 100644 --- a/test/integration/server-selection/readpreference.test.ts +++ b/test/integration/server-selection/readpreference.test.ts @@ -5,7 +5,7 @@ import { type MongoClient, ReadPreference, Topology -} from '../../mongodb'; +} from '../../mongodb_runtime-testing'; import { assert as test, filterForCommands, setupDatabase } from '../shared'; describe('ReadPreference', function () { diff --git a/test/integration/server-selection/server_selection.prose.operation_count.test.ts b/test/integration/server-selection/server_selection.prose.operation_count.test.ts index b4a7d9bf47..c596eeaf5a 100644 --- a/test/integration/server-selection/server_selection.prose.operation_count.test.ts +++ b/test/integration/server-selection/server_selection.prose.operation_count.test.ts @@ -5,7 +5,7 @@ import { type CommandStartedEvent, HostAddress, type MongoClient -} from '../../mongodb'; +} from '../../mongodb_runtime-testing'; import { waitUntilPoolsFilled } from '../../tools/utils'; const failPoint = { diff --git a/test/integration/server-selection/server_selection.prose.sharded_retryable_reads.test.ts b/test/integration/server-selection/server_selection.prose.sharded_retryable_reads.test.ts index 3b72fe93eb..449926a614 100644 --- a/test/integration/server-selection/server_selection.prose.sharded_retryable_reads.test.ts +++ b/test/integration/server-selection/server_selection.prose.sharded_retryable_reads.test.ts @@ -1,6 +1,6 @@ import { expect } from 'chai'; -import type { CommandFailedEvent, CommandSucceededEvent } from '../../mongodb'; +import type { CommandFailedEvent, CommandSucceededEvent } from '../../mongodb_runtime-testing'; const TEST_METADATA = { requires: { mongodb: '>=4.2.9', topology: 'sharded' } }; const FAIL_COMMAND = { diff --git a/test/integration/server-selection/server_selection.prose.sharded_retryable_writes.test.ts b/test/integration/server-selection/server_selection.prose.sharded_retryable_writes.test.ts index 29cb5d11dd..86f03a8c1e 100644 --- a/test/integration/server-selection/server_selection.prose.sharded_retryable_writes.test.ts +++ b/test/integration/server-selection/server_selection.prose.sharded_retryable_writes.test.ts @@ -1,6 +1,6 @@ import { expect } from 'chai'; -import type { CommandFailedEvent, CommandSucceededEvent } from '../../mongodb'; +import type { CommandFailedEvent, CommandSucceededEvent } from '../../mongodb_runtime-testing'; const TEST_METADATA = { requires: { mongodb: '>=4.3.1', topology: 'sharded' } }; const FAIL_COMMAND = { diff --git a/test/integration/sessions/sessions.prose.test.ts b/test/integration/sessions/sessions.prose.test.ts index b6be8d763e..8da6dafe23 100644 --- a/test/integration/sessions/sessions.prose.test.ts +++ b/test/integration/sessions/sessions.prose.test.ts @@ -7,7 +7,7 @@ import { MongoClient, MongoDriverError, MongoInvalidArgumentError -} from '../../mongodb'; +} from '../../mongodb_runtime-testing'; import { configureMongocryptdSpawnHooks, sleep } from '../../tools/utils'; describe('Sessions Prose Tests', () => { diff --git a/test/integration/sessions/sessions.test.ts b/test/integration/sessions/sessions.test.ts index a4b292ca9d..0047b89ed4 100644 --- a/test/integration/sessions/sessions.test.ts +++ b/test/integration/sessions/sessions.test.ts @@ -6,7 +6,7 @@ import { LEGACY_HELLO_COMMAND, type MongoClient, MongoServerError -} from '../../mongodb'; +} from '../../mongodb_runtime-testing'; import type { TestConfiguration } from '../../tools/runner/config'; import { setupDatabase } from '../shared'; diff --git a/test/integration/transactions-convenient-api/transactions-convenient-api.prose.test.ts b/test/integration/transactions-convenient-api/transactions-convenient-api.prose.test.ts index 1f4e67687d..e32bf59bec 100644 --- a/test/integration/transactions-convenient-api/transactions-convenient-api.prose.test.ts +++ b/test/integration/transactions-convenient-api/transactions-convenient-api.prose.test.ts @@ -2,7 +2,11 @@ import { expect } from 'chai'; import { test } from 'mocha'; import * as sinon from 'sinon'; -import { type ClientSession, type Collection, type MongoClient } from '../../mongodb'; +import { + type ClientSession, + type Collection, + type MongoClient +} from '../../mongodb_runtime-testing'; import { configureFailPoint, type FailCommandFailPoint, measureDuration } from '../../tools/utils'; const failCommand: FailCommandFailPoint = { diff --git a/test/integration/transactions/transactions.prose.test.ts b/test/integration/transactions/transactions.prose.test.ts index 89b1e574fa..ce95e084f8 100644 --- a/test/integration/transactions/transactions.prose.test.ts +++ b/test/integration/transactions/transactions.prose.test.ts @@ -1,7 +1,7 @@ import { type ObjectId } from 'bson'; import { expect } from 'chai'; -import { type MongoClient } from '../../mongodb'; +import { type MongoClient } from '../../mongodb_runtime-testing'; const metadata: MongoDBMetadataUI = { requires: { diff --git a/test/integration/transactions/transactions.test.ts b/test/integration/transactions/transactions.test.ts index eb5406ea9e..597f355532 100644 --- a/test/integration/transactions/transactions.test.ts +++ b/test/integration/transactions/transactions.test.ts @@ -8,7 +8,7 @@ import { MongoInvalidArgumentError, MongoNetworkError, type ServerSessionPool -} from '../../mongodb'; +} from '../../mongodb_runtime-testing'; import { type FailCommandFailPoint } from '../../tools/utils'; describe('Transactions', function () { diff --git a/test/integration/uri-options/uri.test.ts b/test/integration/uri-options/uri.test.ts index ba531ff785..0ca7bc6a53 100644 --- a/test/integration/uri-options/uri.test.ts +++ b/test/integration/uri-options/uri.test.ts @@ -3,7 +3,7 @@ import * as os from 'os'; import * as process from 'process'; import * as sinon from 'sinon'; -import { Topology } from '../../mongodb'; +import { Topology } from '../../mongodb_runtime-testing'; describe('URI', function () { let client; diff --git a/test/mongodb_bundled.ts b/test/mongodb_bundled.ts index f6ae438176..3df4af6e51 100644 --- a/test/mongodb_bundled.ts +++ b/test/mongodb_bundled.ts @@ -11,72 +11,304 @@ try { } // Export public API from the contextified module +// Hint: This list isn't automatically alphabetized, but VSCode's "Sort Lines Ascending" command can be used to keep it organized export const { + abortable, + applySession, + AUTH_MECHS_AUTH_SRC_EXTERNAL, + AuthMechanism, aws4Sign, + BufferPool, + ChangeStreamCursor, + checkParentDomainMatch, + ClientSession, Collection, + COMMAND_FAILED, + COMMAND_STARTED, + COMMAND_SUCCEEDED, CommandFailedEvent, CommandStartedEvent, CommandSucceededEvent, + compareObjectId, + compress, + Compressor, + CONNECTION_CHECK_OUT_FAILED, + CONNECTION_CHECK_OUT_STARTED, + CONNECTION_CHECKED_IN, + CONNECTION_CHECKED_OUT, + CONNECTION_CLOSED, + CONNECTION_CREATED, + CONNECTION_POOL_CLEARED, + CONNECTION_POOL_CLOSED, + CONNECTION_POOL_CREATED, + CONNECTION_POOL_READY, + CONNECTION_READY, + COSMOS_DB_MSG, + createStdioLogger, CSOTTimeoutContext, Db, + decorateWithExplain, + DEFAULT_ALLOWED_HOSTS, + DEFAULT_MAX_DOCUMENT_LENGTH, + DeprioritizedServers, + DOCUMENT_DB_MSG, Double, + Explain, + ExplainVerbosity, + filterOutOptions, + FindCursor, + hasAtomicOperators, HostAddress, + hostMatchesWildcards, isHello, + isResumableError, + isRetryableReadError, + isStateChangeError, + isUint8Array, + LEGACY_HELLO_COMMAND, + LEGACY_NOT_PRIMARY_OR_SECONDARY_ERROR_MESSAGE, + LEGACY_NOT_WRITABLE_PRIMARY_ERROR_MESSAGE, LegacyTimeoutContext, + List, Long, MongoAPIError, MongoBulkWriteError, MongoClient, MongoCredentials, + MONGODB_ERROR_CODES, + MongoDBCollectionNamespace, + MongoDBNamespace, + MongoDriverError, + MongoError, + MongoErrorLabel, MongoInvalidArgumentError, MongoLoggableComponent, MongoLogger, + MongoMissingDependencyError, + MongoNetworkError, + MongoNetworkTimeoutError, + MongoOperationTimeoutError, MongoParseError, - MongoServerError, MongoRuntimeError, + MongoServerError, + MongoSystemError, + MongoWriteConcernError, + needsRetryableWriteLabel, + NODE_IS_RECOVERING_ERROR_MESSAGE, + ns, ObjectId, + OP_MSG, + OP_QUERY, + OpCompressedRequest, + OpMsgRequest, + OpQueryRequest, parseOptions, + parseSeverityFromString, + PoolClosedError, + processTimeMS, ReadConcern, ReadPreference, + resolveRuntimeAdapters, resolveSRVRecord, ReturnDocument, + RunCommandOperation, ServerApiVersion, + ServerSession, + ServerSessionPool, + setDifference, SeverityLevel, + shuffle, + SrvPoller, + StateMachine, + stringifyWithMaxLen, Timeout, TimeoutContext, TimeoutError, + Topology, TopologyType, - WriteConcern + Transaction, + uncompressibleCommands, + WaitQueueTimeoutError, + WriteConcern, + + AggregateOperation, + CountOperation, + CreateCollectionOperation, + CreateIndexesOperation, + CreateSearchIndexesOperation, + DbStatsOperation, + DeleteManyOperation, + DeleteOneOperation, + DeleteOperation, + DistinctOperation, + DropCollectionOperation, + DropDatabaseOperation, + DropIndexOperation, + DropSearchIndexOperation, + EstimatedDocumentCountOperation, + FindAndModifyOperation, + FindOneAndDeleteOperation, + FindOneAndReplaceOperation, + FindOneAndUpdateOperation, + FindOperation, + GetMoreOperation, + InsertOneOperation, + InsertOperation, + KillCursorsOperation, + ListCollectionsOperation, + ListDatabasesOperation, + ListIndexesOperation, + ProfilingLevelOperation, + RemoveUserOperation, + RenameOperation, + ReplaceOneOperation, + UpdateManyOperation, + UpdateOneOperation, + UpdateOperation, + UpdateSearchIndexOperation, + ValidateCollectionOperation, + SetProfilingLevelOperation, + MongoBatchReExecutionError, + MongoClientBulkWriteError, + CursorTimeoutContext, + MongoCursorExhaustedError, + promiseWithResolvers, + Code, + CursorResponse, + Binary, + BSONSymbol, + DBRef, + MaxKey, + MinKey, + noop, + Timestamp, + formatSort, + MongoClientClosedError, + ServerType, + ScramSHA256, + AWSSDKCredentialProvider, + MongoAWSError, + MongoDBAWS, + MongoMissingCredentialsError, + refreshKMSCredentials, + Decimal128, + ClientEncryption, + BSON, + fetchAzureKMSToken, + MongoCryptAzureKMSRequestError, + MongoCryptCreateEncryptedCollectionError, + MongoCryptError, + Int32, + MongoServerSelectionError, + MongoCryptCreateDataKeyError, + resolveTimeoutOptions, + GridFSBucket, + squashError, + CursorTimeoutMode, + BSONType, + MongoNotConnectedError, + ProfilingLevel, + MongoCryptInvalidArgumentError, + EJSON, + ServerDescription, + enumToString, + BSONRegExp, + BSONError, + deserialize, + OpMsgResponse, + ReadConcernLevel, + PoolClearedError, + SERVER_HEARTBEAT_FAILED, + SERVER_HEARTBEAT_SUCCEEDED, + getTopology, + connect, + makeClientMetadata, + MongoClientAuthProviders, + MongoDBResponse, + ServerHeartbeatStartedEvent, + Connection } = exportSource; // Export types from the contextified module export type { - AuthMechanism, + AbstractCursor, + AbstractOperation, + Admin, + AnyClientBulkWriteModel, + AWSCredentials, + ChangeStream, + ChangeStreamDocument, + ChangeStreamOptions, + ClientBulkWriteModel, + CollectionInfo, + CommandOptions, CompressorName, + ConnectionCheckOutFailedEvent, + ConnectionCreatedEvent, + ConnectionOptions, + ConnectionPool, + ConnectionPoolClearedEvent, + ConnectOptions, + DataKey, + DbOptions, + Document, + KMSProviders, + Log, + MongoChangeStreamError, MongoClientOptions, + MongoDBLogWritable, + MongoDBResponseConstructor, + MongoLoggerOptions, + MongoOptions, + ResumeToken, + Runtime, + Server, ServerApi, + ServerHeartbeatSucceededEvent, + TopologyDescription, + TopologyOptions, + UUID, + WithId, WriteConcernSettings } from './tools/runner/bundle/types/index'; // Export "clashing" types from the contextified module. // These are types that clash with the objects of the same name (eg Collection), so we need to export them separately to avoid type errors. import type { - Collection as _CollectionType, - CommandFailedEvent as _CommandFailedEventType, - CommandStartedEvent as _CommandStartedEventType, - CommandSucceededEvent as _CommandSucceededEventType, - CSOTTimeoutContext as _CSOTTimeoutContextType, - HostAddress as _HostAddressType, - MongoClient as _MongoClientType, - Timeout as _TimeoutType, + AuthMechanism as _AuthMechanism, + Collection as _Collection, + CommandFailedEvent as _CommandFailedEvent, + CommandStartedEvent as _CommandStartedEvent, + CommandSucceededEvent as _CommandSucceededEvent, + Connection as _Connection, + CSOTTimeoutContext as _CSOTTimeoutContext, + Db as _Db, + HostAddress as _HostAddress, + MongoClient as _MongoClient, + Timeout as _Timeout, + Topology as _Topology, TopologyType as _TopologyType } from './tools/runner/bundle/types/index'; -export type Collection = _CollectionType; -export type CommandFailedEvent = _CommandFailedEventType; -export type CommandStartedEvent = _CommandStartedEventType; -export type CommandSucceededEvent = _CommandSucceededEventType; -export type CSOTTimeoutContext = _CSOTTimeoutContextType; -export type HostAddress = _HostAddressType; -export type MongoClient = _MongoClientType; -export type Timeout = _TimeoutType; +export type AuthMechanism = _AuthMechanism; +export type Collection = _Collection; +export type Connection = _Connection; +export type CommandFailedEvent = _CommandFailedEvent; +export type CommandStartedEvent = _CommandStartedEvent; +export type CommandSucceededEvent = _CommandSucceededEvent; +export type CSOTTimeoutContext = _CSOTTimeoutContext; +export type Db = _Db; +export type HostAddress = _HostAddress; +export type MongoClient = _MongoClient; +export type Timeout = _Timeout; +export type Topology = _Topology; export type TopologyType = _TopologyType; + +// Export specific types from other files in the contextified module +export type { AzureKMSRequestOptions } from './tools/runner/bundle/types/client-side-encryption/providers/azure'; +export type { AwsSigv4Options } from './tools/runner/bundle/types/cmap/auth/aws4'; +export type { + MongoDBOIDC, + OIDCCallbackFunction, + OIDCCallbackParams, + OIDCResponse +} from './tools/runner/bundle/types/cmap/auth/mongodb_oidc'; diff --git a/test/tools/runner/vm_context_helper.ts b/test/tools/runner/vm_context_helper.ts index c19b7cd16c..aee34cedbc 100644 --- a/test/tools/runner/vm_context_helper.ts +++ b/test/tools/runner/vm_context_helper.ts @@ -5,20 +5,36 @@ import { isBuiltin } from 'node:module'; import * as path from 'node:path'; import * as vm from 'node:vm'; +const repoRoot = path.resolve(__dirname, '../../..'); + /** * Creates a require function that blocks access to specified core modules */ function createRestrictedRequire() { const blockedModules = new Set(['os']); + const allowedRequesterToModuleMapping: Record = { + 'src/runtime_adapters.ts': ['os'] + }; return function restrictedRequire(moduleName: string) { // Block core modules if (isBuiltin(moduleName) && blockedModules.has(moduleName)) { - const sourceFile = new Error().stack.split('\n')[2]?.replace('at', '').trim(); - const source = sourceFile ? `from ${sourceFile}` : 'from an unknown source'; - throw new Error( - `Access to core module '${moduleName}' (${source}) is restricted in this context` - ); + let sourceFile = new Error().stack.split('\n')[2]?.replace('at', '').trim() || ''; + sourceFile = + sourceFile.indexOf('(') !== -1 ? sourceFile.split('(')[1].slice(0, -1) : sourceFile; // Extract file path if present + sourceFile = sourceFile.indexOf(':') !== -1 ? sourceFile.split(':')[0] : sourceFile; // Remove line number if present + const srcRelativePath = path.relative(repoRoot, sourceFile); + const isAllowed = allowedRequesterToModuleMapping[srcRelativePath]?.includes(moduleName); + + if (isAllowed) { + // Allow access to the module if the requester is in the allowlist + console.log(`Allowing access to core module '${moduleName}' for ${srcRelativePath}`); + } else { + console.log(`Blocking access to core module '${moduleName}' from ${srcRelativePath}`); + throw new Error( + `Access to core module '${moduleName}' from ${srcRelativePath} is restricted in this context` + ); + } } return require(moduleName); diff --git a/test/tools/utils.ts b/test/tools/utils.ts index cb26f844ad..8ca41d62a1 100644 --- a/test/tools/utils.ts +++ b/test/tools/utils.ts @@ -24,7 +24,7 @@ import { type ServerApiVersion, Topology, type TopologyOptions -} from '../mongodb'; +} from '../mongodb_runtime-testing'; import { type TestConfiguration } from './runner/config'; import { isTLSEnabled } from './runner/filters/tls_filter'; @@ -32,9 +32,10 @@ export function ensureCalledWith(stub: any, args: any[]) { args.forEach((m: any) => expect(stub).to.have.been.calledWith(m)); } -export function ensureTypeByName(obj: any, typeName: string) { - const isType = obj != null && obj.constructor != null && obj.constructor.name === typeName; - return isType; +export function ensureTypeByName(obj: any, typeName: string): void { + expect(obj).to.be.an('object'); + expect(obj.constructor).to.be.an('function'); + expect(obj.constructor.name).to.equal(typeName); } export class EventCollector { From 5756424af702293f80bd9141626ecadefcde20c3 Mon Sep 17 00:00:00 2001 From: Pavel Safronov Date: Mon, 23 Feb 2026 09:29:54 -0800 Subject: [PATCH 17/36] readme updates --- test/readme.md | 30 ++++++++---------------------- 1 file changed, 8 insertions(+), 22 deletions(-) diff --git a/test/readme.md b/test/readme.md index 503ba1a9f6..811ebbaade 100644 --- a/test/readme.md +++ b/test/readme.md @@ -47,7 +47,6 @@ about the types of tests and how to run them. - [Design](#design) - [Adding tests to be tested with Node-less Runtime](#adding-tests-to-be-tested-with-node-less-runtime) - [Running tests in Node-less Runtime](#running-tests-in-node-less-runtime) - - [Running tests manually in Node-less Runtime](#running-tests-manually-in-node-less-runtime) - [GCP](#gcp) - [Azure](#azure) - [AWS](#aws) @@ -750,9 +749,13 @@ Here are a few of the relevant components of this system: #### Adding tests to be tested with Node-less Runtime Change the test's import from - `} from '../../mongodb';` + `} from '../mongodb';` to - `} from '../../mongodb_runtime-testing';` + `} from '../mongodb_runtime-testing';` + +Then run the tests. + +If any are failing because of a missing export, you will need to export those types in [test/mongodb_bundled.ts](test/mongodb_bundled.ts). #### Running tests in Node-less Runtime @@ -767,26 +770,9 @@ Either command will: 1. Create a bundle from `test/mongodb.ts` 2. Regenerate the barrel file to export from the generated bundle 3. Run unit or integ tests -4. Regenerate the barrel file to export from the test entry point - -#### Running tests manually in Node-less Runtime - -Call the following command to regenerate the barrel file to import from the bundle: - `npm run switch:to-bundled` - -Call the following command to rebuild the bundle: - `npm run build:bundle` - -You can now run the unit or integ tests locally and they will be importing from the patched bundle. - `npm run check:unit` -or - `npm run check:test` -or through an IDE. - -Note that you don't need to run `*-bundled` scripts after switching. -To revert the barrel file changes, run: - `npm run switch:to-unbundled` +Note: the barrel file will point to the bundle after either script is used. +You can either revert that change, or run `npm run switch:to-unbundled` to use the unbundled imports. ## GCP From 5c3fcfa1957bd505f31c147eb32ee2a1180ee49e Mon Sep 17 00:00:00 2001 From: Pavel Safronov Date: Mon, 23 Feb 2026 11:55:26 -0800 Subject: [PATCH 18/36] more exports and fixes for integ tests --- src/sdam/topology.ts | 2 +- .../causal_consistency.prose.test.js | 2 +- test/integration/crud/misc_cursors.test.ts | 4 +- .../max-staleness/max_staleness.test.js | 4 +- test/mongodb_bundled.ts | 219 ++++++++++-------- test/tools/utils.ts | 4 +- 6 files changed, 128 insertions(+), 107 deletions(-) diff --git a/src/sdam/topology.ts b/src/sdam/topology.ts index 0c4ad62133..2a158525fa 100644 --- a/src/sdam/topology.ts +++ b/src/sdam/topology.ts @@ -272,7 +272,7 @@ export class Topology extends TypedEventEmitter { for (const seed of seeds) { if (typeof seed === 'string') { seedlist.push(HostAddress.fromString(seed)); - } else if (seed instanceof HostAddress || (seed as any).constructor.name === 'HostAddress') { + } else if (seed instanceof HostAddress) { seedlist.push(seed); } else { // FIXME(NODE-3483): May need to be a MongoParseError diff --git a/test/integration/causal-consistency/causal_consistency.prose.test.js b/test/integration/causal-consistency/causal_consistency.prose.test.js index 9f333ff781..f072c7d9b2 100644 --- a/test/integration/causal-consistency/causal_consistency.prose.test.js +++ b/test/integration/causal-consistency/causal_consistency.prose.test.js @@ -1,6 +1,6 @@ 'use strict'; -const { LEGACY_HELLO_COMMAND } = require('../../mongodb'); +const { LEGACY_HELLO_COMMAND } = require('../../mongodb_runtime-testing'); const { setupDatabase } = require('../shared'); const { expect } = require('chai'); diff --git a/test/integration/crud/misc_cursors.test.ts b/test/integration/crud/misc_cursors.test.ts index da8a43564e..b15f913caa 100644 --- a/test/integration/crud/misc_cursors.test.ts +++ b/test/integration/crud/misc_cursors.test.ts @@ -8,7 +8,7 @@ import { ReadPreference, ServerType } from '../../mongodb_runtime-testing'; -import { runLater, sleep } from '../../tools/utils'; +import { ensureTypeByName, runLater, sleep } from '../../tools/utils'; import { assert as test, filterForCommands, setupDatabase } from '../shared'; describe('Cursor', function () { @@ -1529,7 +1529,7 @@ describe('Cursor', function () { const promise = cursor.forEach(() => { // do nothing }); - expect(promise).to.exist.and.to.be.an.instanceof(Promise); + ensureTypeByName(promise, 'Promise'); return promise; }); }); diff --git a/test/integration/max-staleness/max_staleness.test.js b/test/integration/max-staleness/max_staleness.test.js index b555eb16ce..cb876c2dd8 100644 --- a/test/integration/max-staleness/max_staleness.test.js +++ b/test/integration/max-staleness/max_staleness.test.js @@ -2,8 +2,8 @@ const { Long } = require('bson'); const { expect } = require('chai'); const mock = require('../../tools/mongodb-mock/index'); -const { ReadPreference } = require('../../mongodb'); -const { isHello } = require('../../mongodb'); +const { ReadPreference } = require('../../mongodb_runtime-testing'); +const { isHello } = require('../../mongodb_runtime-testing'); const test = {}; // TODO (NODE-3799): convert these to run against a real server diff --git a/test/mongodb_bundled.ts b/test/mongodb_bundled.ts index 3df4af6e51..75cce183b1 100644 --- a/test/mongodb_bundled.ts +++ b/test/mongodb_bundled.ts @@ -14,14 +14,27 @@ try { // Hint: This list isn't automatically alphabetized, but VSCode's "Sort Lines Ascending" command can be used to keep it organized export const { abortable, + AbstractCursor, + AggregateOperation, + AggregationCursor, + ListCollectionsCursor, applySession, AUTH_MECHS_AUTH_SRC_EXTERNAL, AuthMechanism, aws4Sign, + AWSSDKCredentialProvider, + Binary, + BSON, + BSONError, + BSONRegExp, + BSONSymbol, + BSONType, BufferPool, ChangeStreamCursor, checkParentDomainMatch, + ClientEncryption, ClientSession, + Code, Collection, COMMAND_FAILED, COMMAND_STARTED, @@ -32,6 +45,7 @@ export const { compareObjectId, compress, Compressor, + connect, CONNECTION_CHECK_OUT_FAILED, CONNECTION_CHECK_OUT_STARTED, CONNECTION_CHECKED_IN, @@ -43,195 +57,187 @@ export const { CONNECTION_POOL_CREATED, CONNECTION_POOL_READY, CONNECTION_READY, + Connection, + ConnectionPool, COSMOS_DB_MSG, + CountOperation, + CreateCollectionOperation, + CreateIndexesOperation, + CreateSearchIndexesOperation, createStdioLogger, CSOTTimeoutContext, + CursorResponse, + CursorTimeoutContext, + CursorTimeoutMode, Db, + DBRef, + DbStatsOperation, + Decimal128, decorateWithExplain, DEFAULT_ALLOWED_HOSTS, DEFAULT_MAX_DOCUMENT_LENGTH, + DeleteManyOperation, + DeleteOneOperation, + DeleteOperation, DeprioritizedServers, + deserialize, + DistinctOperation, DOCUMENT_DB_MSG, Double, + DropCollectionOperation, + DropDatabaseOperation, + DropIndexOperation, + DropSearchIndexOperation, + EJSON, + enumToString, + EstimatedDocumentCountOperation, Explain, ExplainVerbosity, + fetchAzureKMSToken, filterOutOptions, + FindAndModifyOperation, FindCursor, + FindOneAndDeleteOperation, + FindOneAndReplaceOperation, + FindOneAndUpdateOperation, + FindOperation, + formatSort, + GetMoreOperation, + getTopology, + GridFSBucket, hasAtomicOperators, HostAddress, hostMatchesWildcards, + InsertOneOperation, + InsertOperation, + Int32, isHello, isResumableError, isRetryableReadError, isStateChangeError, isUint8Array, + KillCursorsOperation, LEGACY_HELLO_COMMAND, LEGACY_NOT_PRIMARY_OR_SECONDARY_ERROR_MESSAGE, LEGACY_NOT_WRITABLE_PRIMARY_ERROR_MESSAGE, LegacyTimeoutContext, List, + ListCollectionsOperation, + ListDatabasesOperation, + ListIndexesOperation, Long, + makeClientMetadata, + MaxKey, + MinKey, MongoAPIError, + MongoAWSError, + MongoBatchReExecutionError, MongoBulkWriteError, MongoClient, + MongoClientAuthProviders, + MongoClientBulkWriteError, + MongoClientClosedError, MongoCredentials, + MongoCryptAzureKMSRequestError, + MongoCryptCreateDataKeyError, + MongoCryptCreateEncryptedCollectionError, + MongoCryptError, + MongoCryptInvalidArgumentError, + MongoCursorExhaustedError, MONGODB_ERROR_CODES, + MongoDBAWS, MongoDBCollectionNamespace, MongoDBNamespace, + MongoDBResponse, MongoDriverError, MongoError, MongoErrorLabel, MongoInvalidArgumentError, MongoLoggableComponent, MongoLogger, + MongoMissingCredentialsError, MongoMissingDependencyError, MongoNetworkError, MongoNetworkTimeoutError, + MongoNotConnectedError, MongoOperationTimeoutError, MongoParseError, MongoRuntimeError, MongoServerError, + MongoServerSelectionError, MongoSystemError, MongoWriteConcernError, needsRetryableWriteLabel, NODE_IS_RECOVERING_ERROR_MESSAGE, + noop, ns, ObjectId, OP_MSG, OP_QUERY, OpCompressedRequest, OpMsgRequest, + OpMsgResponse, OpQueryRequest, parseOptions, parseSeverityFromString, + PoolClearedError, PoolClosedError, processTimeMS, + ProfilingLevel, + ProfilingLevelOperation, + promiseWithResolvers, ReadConcern, + ReadConcernLevel, ReadPreference, + refreshKMSCredentials, + RemoveUserOperation, + RenameOperation, + ReplaceOneOperation, resolveRuntimeAdapters, resolveSRVRecord, + resolveTimeoutOptions, ReturnDocument, RunCommandOperation, + ScramSHA256, + SERVER_HEARTBEAT_FAILED, + SERVER_HEARTBEAT_SUCCEEDED, ServerApiVersion, + ServerDescription, + ServerHeartbeatStartedEvent, ServerSession, ServerSessionPool, + ServerType, setDifference, + SetProfilingLevelOperation, SeverityLevel, shuffle, + squashError, SrvPoller, StateMachine, stringifyWithMaxLen, Timeout, TimeoutContext, TimeoutError, + Timestamp, Topology, TopologyType, Transaction, uncompressibleCommands, - WaitQueueTimeoutError, - WriteConcern, - - AggregateOperation, - CountOperation, - CreateCollectionOperation, - CreateIndexesOperation, - CreateSearchIndexesOperation, - DbStatsOperation, - DeleteManyOperation, - DeleteOneOperation, - DeleteOperation, - DistinctOperation, - DropCollectionOperation, - DropDatabaseOperation, - DropIndexOperation, - DropSearchIndexOperation, - EstimatedDocumentCountOperation, - FindAndModifyOperation, - FindOneAndDeleteOperation, - FindOneAndReplaceOperation, - FindOneAndUpdateOperation, - FindOperation, - GetMoreOperation, - InsertOneOperation, - InsertOperation, - KillCursorsOperation, - ListCollectionsOperation, - ListDatabasesOperation, - ListIndexesOperation, - ProfilingLevelOperation, - RemoveUserOperation, - RenameOperation, - ReplaceOneOperation, UpdateManyOperation, UpdateOneOperation, UpdateOperation, UpdateSearchIndexOperation, ValidateCollectionOperation, - SetProfilingLevelOperation, - MongoBatchReExecutionError, - MongoClientBulkWriteError, - CursorTimeoutContext, - MongoCursorExhaustedError, - promiseWithResolvers, - Code, - CursorResponse, - Binary, - BSONSymbol, - DBRef, - MaxKey, - MinKey, - noop, - Timestamp, - formatSort, - MongoClientClosedError, - ServerType, - ScramSHA256, - AWSSDKCredentialProvider, - MongoAWSError, - MongoDBAWS, - MongoMissingCredentialsError, - refreshKMSCredentials, - Decimal128, - ClientEncryption, - BSON, - fetchAzureKMSToken, - MongoCryptAzureKMSRequestError, - MongoCryptCreateEncryptedCollectionError, - MongoCryptError, - Int32, - MongoServerSelectionError, - MongoCryptCreateDataKeyError, - resolveTimeoutOptions, - GridFSBucket, - squashError, - CursorTimeoutMode, - BSONType, - MongoNotConnectedError, - ProfilingLevel, - MongoCryptInvalidArgumentError, - EJSON, - ServerDescription, - enumToString, - BSONRegExp, - BSONError, - deserialize, - OpMsgResponse, - ReadConcernLevel, - PoolClearedError, - SERVER_HEARTBEAT_FAILED, - SERVER_HEARTBEAT_SUCCEEDED, - getTopology, - connect, - makeClientMetadata, - MongoClientAuthProviders, - MongoDBResponse, - ServerHeartbeatStartedEvent, - Connection + WaitQueueTimeoutError, + WriteConcern, + getFAASEnv, + isDriverInfoEqual, + Server, + UUID } = exportSource; // Export types from the contextified module export type { - AbstractCursor, AbstractOperation, Admin, AnyClientBulkWriteModel, @@ -240,18 +246,19 @@ export type { ChangeStreamDocument, ChangeStreamOptions, ClientBulkWriteModel, + ClientMetadata, CollectionInfo, CommandOptions, CompressorName, ConnectionCheckOutFailedEvent, ConnectionCreatedEvent, ConnectionOptions, - ConnectionPool, ConnectionPoolClearedEvent, ConnectOptions, DataKey, DbOptions, Document, + DriverInfo, KMSProviders, Log, MongoChangeStreamError, @@ -262,12 +269,10 @@ export type { MongoOptions, ResumeToken, Runtime, - Server, ServerApi, ServerHeartbeatSucceededEvent, TopologyDescription, TopologyOptions, - UUID, WithId, WriteConcernSettings } from './tools/runner/bundle/types/index'; @@ -275,33 +280,49 @@ export type { // Export "clashing" types from the contextified module. // These are types that clash with the objects of the same name (eg Collection), so we need to export them separately to avoid type errors. import type { + AbstractCursor as _AbstractCursor, AuthMechanism as _AuthMechanism, + ClientEncryption as _ClientEncryption, Collection as _Collection, CommandFailedEvent as _CommandFailedEvent, CommandStartedEvent as _CommandStartedEvent, CommandSucceededEvent as _CommandSucceededEvent, Connection as _Connection, + ConnectionPool as _ConnectionPool, CSOTTimeoutContext as _CSOTTimeoutContext, + CursorTimeoutContext as _CursorTimeoutContext, Db as _Db, + FindCursor as _FindCursor, HostAddress as _HostAddress, MongoClient as _MongoClient, + Server as _Server, Timeout as _Timeout, + TimeoutContext as _TimeoutContext, Topology as _Topology, - TopologyType as _TopologyType + TopologyType as _TopologyType, + UUID as _UUID } from './tools/runner/bundle/types/index'; +export type AbstractCursor = _AbstractCursor; export type AuthMechanism = _AuthMechanism; +export type ClientEncryption = _ClientEncryption; export type Collection = _Collection; export type Connection = _Connection; export type CommandFailedEvent = _CommandFailedEvent; export type CommandStartedEvent = _CommandStartedEvent; export type CommandSucceededEvent = _CommandSucceededEvent; +export type ConnectionPool = _ConnectionPool; +export type CursorTimeoutContext = _CursorTimeoutContext; +export type FindCursor = _FindCursor; export type CSOTTimeoutContext = _CSOTTimeoutContext; export type Db = _Db; export type HostAddress = _HostAddress; export type MongoClient = _MongoClient; +export type Server = _Server; export type Timeout = _Timeout; +export type TimeoutContext = _TimeoutContext; export type Topology = _Topology; export type TopologyType = _TopologyType; +export type UUID = _UUID; // Export specific types from other files in the contextified module export type { AzureKMSRequestOptions } from './tools/runner/bundle/types/client-side-encryption/providers/azure'; diff --git a/test/tools/utils.ts b/test/tools/utils.ts index 8ca41d62a1..32038d207d 100644 --- a/test/tools/utils.ts +++ b/test/tools/utils.ts @@ -33,8 +33,8 @@ export function ensureCalledWith(stub: any, args: any[]) { } export function ensureTypeByName(obj: any, typeName: string): void { - expect(obj).to.be.an('object'); - expect(obj.constructor).to.be.an('function'); + expect(obj).to.be.not.null; + expect(obj.constructor).to.be.not.null; expect(obj.constructor.name).to.equal(typeName); } From 1d0bb600e14f58f76ad28003d7bd676354b55471 Mon Sep 17 00:00:00 2001 From: Pavel Safronov Date: Mon, 23 Feb 2026 12:12:15 -0800 Subject: [PATCH 19/36] remove logging from vm context, remove runNodelessTests --- etc/build-runtime-barrel.mjs | 1 - test/integration/crud/crud_api.test.ts | 55 ++++++++------------------ test/mongodb_runtime-testing.ts | 1 - test/tools/runner/vm_context_helper.ts | 2 - 4 files changed, 17 insertions(+), 42 deletions(-) diff --git a/etc/build-runtime-barrel.mjs b/etc/build-runtime-barrel.mjs index afb34360a9..a37c918e78 100644 --- a/etc/build-runtime-barrel.mjs +++ b/etc/build-runtime-barrel.mjs @@ -13,7 +13,6 @@ const source = useBundled ? './mongodb_bundled' : './mongodb'; const contents = `// This file is auto-generated. Do not edit.\n` + `// Run 'npm run build:runtime-barrel' to regenerate.\n` + - `export const runNodelessTests = ${useBundled};\n` + `export * from '${source}';\n`; await fs.writeFile(outputBarrelFile, contents); diff --git a/test/integration/crud/crud_api.test.ts b/test/integration/crud/crud_api.test.ts index 8d0952a65a..7c8ec31d07 100644 --- a/test/integration/crud/crud_api.test.ts +++ b/test/integration/crud/crud_api.test.ts @@ -13,15 +13,14 @@ import { type MongoClient, MongoServerError, ObjectId, - ReturnDocument, - runNodelessTests + ReturnDocument } from '../../mongodb_runtime-testing'; import { ensureTypeByName, type FailCommandFailPoint } from '../../tools/utils'; import { assert as test } from '../shared'; const DB_NAME = 'crud_api_tests'; -describe('CRUD API', function () { +describe.only('CRUD API', function () { let client: MongoClient; beforeEach(async function () { @@ -104,13 +103,9 @@ describe('CRUD API', function () { const spy = sinon.spy(Collection.prototype, 'find'); const result = await collection.findOne({}); expect(result).to.deep.equal({ _id: 1 }); - if (runNodelessTests) { - ensureTypeByName(events.at(0), 'CommandSucceededEvent'); - } else { - expect(events.at(0)).to.be.instanceOf(CommandSucceededEvent); - expect(spy.returnValues.at(0)).to.have.property('closed', true); - expect(spy.returnValues.at(0)).to.have.nested.property('session.hasEnded', true); - } + expect(events.at(0)).to.be.instanceOf(CommandSucceededEvent); + expect(spy.returnValues.at(0)).to.have.property('closed', true); + expect(spy.returnValues.at(0)).to.have.nested.property('session.hasEnded', true); }); }); @@ -140,14 +135,10 @@ describe('CRUD API', function () { it('the cursor for findOne is closed', async function () { const spy = sinon.spy(Collection.prototype, 'find'); const error = await collection.findOne({}).catch(error => error); - if (runNodelessTests) { - ensureTypeByName(error, 'MongoServerError'); - } else { - expect(error).to.be.instanceOf(MongoServerError); - expect(events.at(0)).to.be.instanceOf(CommandFailedEvent); - expect(spy.returnValues.at(0)).to.have.property('closed', true); - expect(spy.returnValues.at(0)).to.have.nested.property('session.hasEnded', true); - } + expect(error).to.be.instanceOf(MongoServerError); + expect(events.at(0)).to.be.instanceOf(CommandFailedEvent); + expect(spy.returnValues.at(0)).to.have.property('closed', true); + expect(spy.returnValues.at(0)).to.have.nested.property('session.hasEnded', true); }); }); }); @@ -182,13 +173,9 @@ describe('CRUD API', function () { const spy = sinon.spy(Collection.prototype, 'aggregate'); const result = await collection.countDocuments({}); expect(result).to.deep.equal(2); - if (runNodelessTests) { - ensureTypeByName(events[0], 'CommandSucceededEvent'); - } else { - expect(events[0]).to.be.instanceOf(CommandSucceededEvent); - expect(spy.returnValues[0]).to.have.property('closed', true); - expect(spy.returnValues[0]).to.have.nested.property('session.hasEnded', true); - } + expect(events[0]).to.be.instanceOf(CommandSucceededEvent); + expect(spy.returnValues[0]).to.have.property('closed', true); + expect(spy.returnValues[0]).to.have.nested.property('session.hasEnded', true); }); }); @@ -218,14 +205,10 @@ describe('CRUD API', function () { it('the cursor for countDocuments is closed', async function () { const spy = sinon.spy(Collection.prototype, 'aggregate'); const error = await collection.countDocuments({}).catch(error => error); - if (runNodelessTests) { - ensureTypeByName(error, 'MongoServerError'); - } else { - expect(error).to.be.instanceOf(MongoServerError); - expect(events.at(0)).to.be.instanceOf(CommandFailedEvent); - expect(spy.returnValues.at(0)).to.have.property('closed', true); - expect(spy.returnValues.at(0)).to.have.nested.property('session.hasEnded', true); - } + expect(error).to.be.instanceOf(MongoServerError); + expect(events.at(0)).to.be.instanceOf(CommandFailedEvent); + expect(spy.returnValues.at(0)).to.have.property('closed', true); + expect(spy.returnValues.at(0)).to.have.nested.property('session.hasEnded', true); }); }); }); @@ -802,11 +785,7 @@ describe('CRUD API', function () { .bulkWrite(ops, { ordered: false, writeConcern: { w: 1 } }) .catch(error => error); - if (runNodelessTests) { - ensureTypeByName(error, 'MongoBulkWriteError'); - } else { - expect(error).to.be.instanceOf(MongoBulkWriteError); - } + expect(error).to.be.instanceOf(MongoBulkWriteError); // 1004 because one of them is duplicate key // but since it is unordered we continued to write expect(error).to.have.property('insertedCount', 1004); diff --git a/test/mongodb_runtime-testing.ts b/test/mongodb_runtime-testing.ts index d0b07fef47..9bbf99258e 100644 --- a/test/mongodb_runtime-testing.ts +++ b/test/mongodb_runtime-testing.ts @@ -1,4 +1,3 @@ // This file is auto-generated. Do not edit. // Run 'npm run build:runtime-barrel' to regenerate. -export const runNodelessTests = false; export * from './mongodb'; diff --git a/test/tools/runner/vm_context_helper.ts b/test/tools/runner/vm_context_helper.ts index aee34cedbc..90c19baf53 100644 --- a/test/tools/runner/vm_context_helper.ts +++ b/test/tools/runner/vm_context_helper.ts @@ -28,9 +28,7 @@ function createRestrictedRequire() { if (isAllowed) { // Allow access to the module if the requester is in the allowlist - console.log(`Allowing access to core module '${moduleName}' for ${srcRelativePath}`); } else { - console.log(`Blocking access to core module '${moduleName}' from ${srcRelativePath}`); throw new Error( `Access to core module '${moduleName}' from ${srcRelativePath} is restricted in this context` ); From 06ee01aca8c68bac9a7fca70dc64e2d998b4c639 Mon Sep 17 00:00:00 2001 From: Pavel Safronov Date: Mon, 23 Feb 2026 12:14:58 -0800 Subject: [PATCH 20/36] log more info about require error --- test/tools/runner/vm_context_helper.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/tools/runner/vm_context_helper.ts b/test/tools/runner/vm_context_helper.ts index 90c19baf53..61f50c4d29 100644 --- a/test/tools/runner/vm_context_helper.ts +++ b/test/tools/runner/vm_context_helper.ts @@ -19,7 +19,8 @@ function createRestrictedRequire() { return function restrictedRequire(moduleName: string) { // Block core modules if (isBuiltin(moduleName) && blockedModules.has(moduleName)) { - let sourceFile = new Error().stack.split('\n')[2]?.replace('at', '').trim() || ''; + const callStack = new Error().stack; + let sourceFile = callStack.split('\n')[2]?.replace('at', '').trim() || ''; // Get the caller's source file from the stack trace sourceFile = sourceFile.indexOf('(') !== -1 ? sourceFile.split('(')[1].slice(0, -1) : sourceFile; // Extract file path if present sourceFile = sourceFile.indexOf(':') !== -1 ? sourceFile.split(':')[0] : sourceFile; // Remove line number if present @@ -30,7 +31,7 @@ function createRestrictedRequire() { // Allow access to the module if the requester is in the allowlist } else { throw new Error( - `Access to core module '${moduleName}' from ${srcRelativePath} is restricted in this context` + `Access to core module '${moduleName}' from ${srcRelativePath} is restricted in this context (callStack: ${callStack}, sourceFile: ${sourceFile}, srcRelativePath: ${srcRelativePath})` ); } } From d6a56b8db368f8908832728329013565cc5a53fd Mon Sep 17 00:00:00 2001 From: Pavel Safronov Date: Mon, 23 Feb 2026 12:39:43 -0800 Subject: [PATCH 21/36] add console log when require is blocked --- test/tools/runner/vm_context_helper.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/tools/runner/vm_context_helper.ts b/test/tools/runner/vm_context_helper.ts index 61f50c4d29..e244b7f041 100644 --- a/test/tools/runner/vm_context_helper.ts +++ b/test/tools/runner/vm_context_helper.ts @@ -30,6 +30,9 @@ function createRestrictedRequire() { if (isAllowed) { // Allow access to the module if the requester is in the allowlist } else { + console.log( + `Access to core module '${moduleName}' from ${srcRelativePath} is restricted in this context (callStack: ${callStack}, sourceFile: ${sourceFile}, srcRelativePath: ${srcRelativePath})` + ); throw new Error( `Access to core module '${moduleName}' from ${srcRelativePath} is restricted in this context (callStack: ${callStack}, sourceFile: ${sourceFile}, srcRelativePath: ${srcRelativePath})` ); From 7cb3e5d289f716b364751975a6ac3ecd64b8ade6 Mon Sep 17 00:00:00 2001 From: Pavel Safronov Date: Mon, 23 Feb 2026 12:49:46 -0800 Subject: [PATCH 22/36] remove .only --- test/integration/crud/crud_api.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/integration/crud/crud_api.test.ts b/test/integration/crud/crud_api.test.ts index 7c8ec31d07..c00f0f4c7c 100644 --- a/test/integration/crud/crud_api.test.ts +++ b/test/integration/crud/crud_api.test.ts @@ -20,7 +20,7 @@ import { assert as test } from '../shared'; const DB_NAME = 'crud_api_tests'; -describe.only('CRUD API', function () { +describe('CRUD API', function () { let client: MongoClient; beforeEach(async function () { From 35563554b457ecc2c2d0b99dc4cb577a6ad918f2 Mon Sep 17 00:00:00 2001 From: Pavel Safronov Date: Mon, 23 Feb 2026 13:38:16 -0800 Subject: [PATCH 23/36] change how we block require calls, log more info --- test/tools/runner/vm_context_helper.ts | 43 +++++++++++++++++++------- 1 file changed, 32 insertions(+), 11 deletions(-) diff --git a/test/tools/runner/vm_context_helper.ts b/test/tools/runner/vm_context_helper.ts index e244b7f041..be9fbc830c 100644 --- a/test/tools/runner/vm_context_helper.ts +++ b/test/tools/runner/vm_context_helper.ts @@ -12,27 +12,48 @@ const repoRoot = path.resolve(__dirname, '../../..'); */ function createRestrictedRequire() { const blockedModules = new Set(['os']); - const allowedRequesterToModuleMapping: Record = { - 'src/runtime_adapters.ts': ['os'] - }; + const allowedRequesters = [ + { + file: 'src/runtime_adapters.ts', + method: 'resolveRuntimeAdapters', + module: 'os' + } + ]; return function restrictedRequire(moduleName: string) { // Block core modules if (isBuiltin(moduleName) && blockedModules.has(moduleName)) { const callStack = new Error().stack; - let sourceFile = callStack.split('\n')[2]?.replace('at', '').trim() || ''; // Get the caller's source file from the stack trace - sourceFile = - sourceFile.indexOf('(') !== -1 ? sourceFile.split('(')[1].slice(0, -1) : sourceFile; // Extract file path if present - sourceFile = sourceFile.indexOf(':') !== -1 ? sourceFile.split(':')[0] : sourceFile; // Remove line number if present + const methodAndFile = callStack.split('\n')[2]; + const match = methodAndFile.match(/at (.*) \((.*)\)/); + const method = match ? match[1] : null; + const sourceFileAndLineNumbers = match ? match[2] : null; + const sourceFile = + sourceFileAndLineNumbers.indexOf(':') !== -1 + ? sourceFileAndLineNumbers.split(':')[0] + : sourceFileAndLineNumbers; const srcRelativePath = path.relative(repoRoot, sourceFile); - const isAllowed = allowedRequesterToModuleMapping[srcRelativePath]?.includes(moduleName); + const isAllowed = allowedRequesters.some( + requester => + requester.file === srcRelativePath && + requester.method === method && + requester.module === moduleName + ); if (isAllowed) { // Allow access to the module if the requester is in the allowlist } else { - console.log( - `Access to core module '${moduleName}' from ${srcRelativePath} is restricted in this context (callStack: ${callStack}, sourceFile: ${sourceFile}, srcRelativePath: ${srcRelativePath})` - ); + console.log({ + message: `Blocked access to core module '${moduleName}' from ${srcRelativePath}`, + callStack, + methodAndFile, + match, + method, + sourceFileAndLineNumbers, + sourceFile, + srcRelativePath, + allowedRequesters + }); throw new Error( `Access to core module '${moduleName}' from ${srcRelativePath} is restricted in this context (callStack: ${callStack}, sourceFile: ${sourceFile}, srcRelativePath: ${srcRelativePath})` ); From 3ebd9ddfca6c224f00abde0c9236baaf9fc9c054 Mon Sep 17 00:00:00 2001 From: Pavel Safronov Date: Mon, 23 Feb 2026 14:54:45 -0800 Subject: [PATCH 24/36] simplified path logic for the require check --- test/tools/runner/vm_context_helper.ts | 27 ++++++++------------------ 1 file changed, 8 insertions(+), 19 deletions(-) diff --git a/test/tools/runner/vm_context_helper.ts b/test/tools/runner/vm_context_helper.ts index be9fbc830c..c28f77f8ad 100644 --- a/test/tools/runner/vm_context_helper.ts +++ b/test/tools/runner/vm_context_helper.ts @@ -2,11 +2,10 @@ import * as fs from 'node:fs'; import { isBuiltin } from 'node:module'; +import { platform } from 'node:os'; import * as path from 'node:path'; import * as vm from 'node:vm'; -const repoRoot = path.resolve(__dirname, '../../..'); - /** * Creates a require function that blocks access to specified core modules */ @@ -14,7 +13,7 @@ function createRestrictedRequire() { const blockedModules = new Set(['os']); const allowedRequesters = [ { - file: 'src/runtime_adapters.ts', + file: 'runtime_adapters.ts', method: 'resolveRuntimeAdapters', module: 'os' } @@ -24,18 +23,19 @@ function createRestrictedRequire() { // Block core modules if (isBuiltin(moduleName) && blockedModules.has(moduleName)) { const callStack = new Error().stack; + const correctPath = platform() === 'win32' ? path.win32 : path.posix; const methodAndFile = callStack.split('\n')[2]; const match = methodAndFile.match(/at (.*) \((.*)\)/); const method = match ? match[1] : null; const sourceFileAndLineNumbers = match ? match[2] : null; const sourceFile = - sourceFileAndLineNumbers.indexOf(':') !== -1 - ? sourceFileAndLineNumbers.split(':')[0] + sourceFileAndLineNumbers.indexOf('.ts:') !== -1 + ? sourceFileAndLineNumbers.substring(0, sourceFileAndLineNumbers.lastIndexOf('.ts:') + 3) : sourceFileAndLineNumbers; - const srcRelativePath = path.relative(repoRoot, sourceFile); + const sourceFileName = correctPath.basename(sourceFile); const isAllowed = allowedRequesters.some( requester => - requester.file === srcRelativePath && + requester.file === sourceFileName && requester.method === method && requester.module === moduleName ); @@ -43,19 +43,8 @@ function createRestrictedRequire() { if (isAllowed) { // Allow access to the module if the requester is in the allowlist } else { - console.log({ - message: `Blocked access to core module '${moduleName}' from ${srcRelativePath}`, - callStack, - methodAndFile, - match, - method, - sourceFileAndLineNumbers, - sourceFile, - srcRelativePath, - allowedRequesters - }); throw new Error( - `Access to core module '${moduleName}' from ${srcRelativePath} is restricted in this context (callStack: ${callStack}, sourceFile: ${sourceFile}, srcRelativePath: ${srcRelativePath})` + `Access to core module '${moduleName}' from ${sourceFileName} is restricted in this context` ); } } From 551c70dc2c2ca32132d8844361f5507e274dbaa2 Mon Sep 17 00:00:00 2001 From: Pavel Safronov Date: Mon, 23 Feb 2026 16:20:44 -0800 Subject: [PATCH 25/36] update a few more test imports, skip a v8 test in nodeless testing, and export a few more relevant types --- etc/build-runtime-barrel.mjs | 1 + test/action/dependency.test.ts | 2 +- .../node-specific/resource_clean_up.test.ts | 3 +- test/manual/atlas_connectivity.test.ts | 2 +- test/manual/kerberos.test.ts | 2 +- test/manual/ldap.test.ts | 2 +- .../search-index-management.prose.test.ts | 2 +- test/manual/socks5.test.ts | 2 +- test/manual/tls_support.test.ts | 2 +- test/manual/x509_auth.test.ts | 2 +- test/mongodb_bundled.ts | 83 +++++++++++++++++-- test/mongodb_runtime-testing.ts | 1 + test/spec/index.ts | 2 +- test/tools/cmap_spec_runner.ts | 2 +- test/tools/common.js | 4 +- test/tools/mongodb-mock/index.js | 2 +- test/tools/runner/config.ts | 9 -- .../runner/filters/api_version_filter.ts | 2 +- .../filters/client_encryption_filter.ts | 2 +- .../runner/filters/crypt_shared_filter.ts | 2 +- test/tools/runner/filters/filter.ts | 2 +- .../runner/filters/mongodb_topology_filter.ts | 2 +- .../runner/filters/mongodb_version_filter.ts | 2 +- test/tools/runner/filters/tls_filter.ts | 2 +- test/tools/runner/hooks/configuration.ts | 2 +- test/tools/runner/hooks/leak_checker.ts | 2 +- test/tools/spec-runner/context.js | 2 +- test/tools/spec-runner/index.js | 4 +- test/tools/unified-spec-runner/entities.ts | 2 +- .../entity_event_registry.ts | 2 +- test/tools/unified-spec-runner/match.ts | 2 +- test/tools/unified-spec-runner/operations.ts | 2 +- test/tools/unified-spec-runner/runner.ts | 2 +- test/tools/unified-spec-runner/schema.ts | 2 +- .../unified-spec-runner/unified-utils.ts | 2 +- test/tools/uri_spec_runner.ts | 2 +- 36 files changed, 111 insertions(+), 52 deletions(-) diff --git a/etc/build-runtime-barrel.mjs b/etc/build-runtime-barrel.mjs index a37c918e78..afb34360a9 100644 --- a/etc/build-runtime-barrel.mjs +++ b/etc/build-runtime-barrel.mjs @@ -13,6 +13,7 @@ const source = useBundled ? './mongodb_bundled' : './mongodb'; const contents = `// This file is auto-generated. Do not edit.\n` + `// Run 'npm run build:runtime-barrel' to regenerate.\n` + + `export const runNodelessTests = ${useBundled};\n` + `export * from '${source}';\n`; await fs.writeFile(outputBarrelFile, contents); diff --git a/test/action/dependency.test.ts b/test/action/dependency.test.ts index dc3aa7294f..e623f94cad 100644 --- a/test/action/dependency.test.ts +++ b/test/action/dependency.test.ts @@ -5,7 +5,7 @@ import * as path from 'node:path'; import { expect } from 'chai'; import { dependencies, peerDependencies, peerDependenciesMeta } from '../../package.json'; -import { setDifference } from '../mongodb'; +import { setDifference } from '../mongodb_runtime-testing'; import { alphabetically, itInNodeProcess, sorted } from '../tools/utils'; const EXPECTED_DEPENDENCIES = sorted( diff --git a/test/integration/node-specific/resource_clean_up.test.ts b/test/integration/node-specific/resource_clean_up.test.ts index db74ced8b0..44de9302d1 100644 --- a/test/integration/node-specific/resource_clean_up.test.ts +++ b/test/integration/node-specific/resource_clean_up.test.ts @@ -2,6 +2,7 @@ import * as v8 from 'node:v8'; import { expect } from 'chai'; +import { runNodelessTests } from '../../mongodb_runtime-testing'; import { isTLSEnabled } from '../../tools/runner/filters/tls_filter'; import { sleep } from '../../tools/utils'; import { runScriptAndReturnHeapInfo } from './resource_tracking_script_builder'; @@ -91,7 +92,7 @@ describe('Driver Resources', () => { context('when 100s of operations are executed and complete', () => { beforeEach(function () { - if (this.currentTest && typeof v8.queryObjects !== 'function') { + if ((this.currentTest && typeof v8.queryObjects !== 'function') || runNodelessTests) { this.currentTest.skipReason = 'Test requires v8.queryObjects API to count Promises'; this.currentTest?.skip(); } diff --git a/test/manual/atlas_connectivity.test.ts b/test/manual/atlas_connectivity.test.ts index 15fd2d91b3..db5ed6f90c 100644 --- a/test/manual/atlas_connectivity.test.ts +++ b/test/manual/atlas_connectivity.test.ts @@ -1,6 +1,6 @@ import * as process from 'process'; -import { LEGACY_HELLO_COMMAND, MongoClient } from '../mongodb'; +import { LEGACY_HELLO_COMMAND, MongoClient } from '../mongodb_runtime-testing'; /** * ATLAS_CONNECTIVITY env variable is JSON * Here's some typescript describing the shape: diff --git a/test/manual/kerberos.test.ts b/test/manual/kerberos.test.ts index ff6352e7c9..dfc2586321 100644 --- a/test/manual/kerberos.test.ts +++ b/test/manual/kerberos.test.ts @@ -4,7 +4,7 @@ import * as os from 'os'; import * as process from 'process'; import * as sinon from 'sinon'; -import { MongoClient } from '../mongodb'; +import { MongoClient } from '../mongodb_runtime-testing'; const expect = chai.expect; diff --git a/test/manual/ldap.test.ts b/test/manual/ldap.test.ts index e110b91058..ad36131368 100644 --- a/test/manual/ldap.test.ts +++ b/test/manual/ldap.test.ts @@ -1,7 +1,7 @@ import { expect } from 'chai'; import * as process from 'process'; -import { MongoClient } from '../mongodb'; +import { MongoClient } from '../mongodb_runtime-testing'; describe('LDAP', function () { const { SASL_USER, SASL_PASS, SASL_HOST } = process.env; diff --git a/test/manual/search-index-management.prose.test.ts b/test/manual/search-index-management.prose.test.ts index fd2f2f63a7..66bc0f3a75 100644 --- a/test/manual/search-index-management.prose.test.ts +++ b/test/manual/search-index-management.prose.test.ts @@ -11,7 +11,7 @@ import { type MongoClient, ObjectId, ReadConcern -} from '../mongodb'; +} from '../mongodb_runtime-testing'; class TimeoutController extends AbortController { timeoutId: NodeJS.Timeout; diff --git a/test/manual/socks5.test.ts b/test/manual/socks5.test.ts index 34e4f57ef8..94d2b2902c 100644 --- a/test/manual/socks5.test.ts +++ b/test/manual/socks5.test.ts @@ -2,7 +2,7 @@ import { expect } from 'chai'; import ConnectionString from 'mongodb-connection-string-url'; import * as process from 'process'; -import { LEGACY_HELLO_COMMAND, MongoClient, MongoParseError } from '../mongodb'; +import { LEGACY_HELLO_COMMAND, MongoClient, MongoParseError } from '../mongodb_runtime-testing'; /** * The SOCKS5_CONFIG environment variable is either a JSON 4-tuple * [host, port, username, password] or just [host, port]. diff --git a/test/manual/tls_support.test.ts b/test/manual/tls_support.test.ts index c576c05a2c..029b6359ff 100644 --- a/test/manual/tls_support.test.ts +++ b/test/manual/tls_support.test.ts @@ -12,7 +12,7 @@ import { MongoClient, type MongoClientOptions, MongoServerSelectionError -} from '../mongodb'; +} from '../mongodb_runtime-testing'; const REQUIRED_ENV = ['MONGODB_URI', 'TLS_KEY_FILE', 'TLS_CA_FILE', 'TLS_CRL_FILE']; describe('TLS Support', function () { diff --git a/test/manual/x509_auth.test.ts b/test/manual/x509_auth.test.ts index d6e7a10e17..b8ec8b636b 100644 --- a/test/manual/x509_auth.test.ts +++ b/test/manual/x509_auth.test.ts @@ -7,7 +7,7 @@ import { type MongoClientOptions, MongoServerError, MongoServerSelectionError -} from '../mongodb'; +} from '../mongodb_runtime-testing'; // eslint-disable-next-line @typescript-eslint/no-non-null-assertion const connectionString = new ConnectionString(process.env.MONGODB_URI!); diff --git a/test/mongodb_bundled.ts b/test/mongodb_bundled.ts index 75cce183b1..11e6673afc 100644 --- a/test/mongodb_bundled.ts +++ b/test/mongodb_bundled.ts @@ -17,7 +17,6 @@ export const { AbstractCursor, AggregateOperation, AggregationCursor, - ListCollectionsCursor, applySession, AUTH_MECHS_AUTH_SRC_EXTERNAL, AuthMechanism, @@ -34,6 +33,7 @@ export const { checkParentDomainMatch, ClientEncryption, ClientSession, + CMAP_EVENTS, Code, Collection, COMMAND_FAILED, @@ -102,15 +102,19 @@ export const { FindOneAndUpdateOperation, FindOperation, formatSort, + getFAASEnv, + getMongoDBClientEncryption, GetMoreOperation, getTopology, GridFSBucket, hasAtomicOperators, + HEARTBEAT_EVENTS, HostAddress, hostMatchesWildcards, InsertOneOperation, InsertOperation, Int32, + isDriverInfoEqual, isHello, isResumableError, isRetryableReadError, @@ -122,6 +126,7 @@ export const { LEGACY_NOT_WRITABLE_PRIMARY_ERROR_MESSAGE, LegacyTimeoutContext, List, + ListCollectionsCursor, ListCollectionsOperation, ListDatabasesOperation, ListIndexesOperation, @@ -199,8 +204,11 @@ export const { ReturnDocument, RunCommandOperation, ScramSHA256, + SENSITIVE_COMMANDS, + SERVER_DESCRIPTION_CHANGED, SERVER_HEARTBEAT_FAILED, SERVER_HEARTBEAT_SUCCEEDED, + Server, ServerApiVersion, ServerDescription, ServerHeartbeatStartedEvent, @@ -219,6 +227,7 @@ export const { TimeoutContext, TimeoutError, Timestamp, + TOPOLOGY_EVENTS, Topology, TopologyType, Transaction, @@ -227,13 +236,10 @@ export const { UpdateOneOperation, UpdateOperation, UpdateSearchIndexOperation, + UUID, ValidateCollectionOperation, WaitQueueTimeoutError, - WriteConcern, - getFAASEnv, - isDriverInfoEqual, - Server, - UUID + WriteConcern } = exportSource; // Export types from the contextified module @@ -241,24 +247,66 @@ export type { AbstractOperation, Admin, AnyClientBulkWriteModel, + AutoEncrypter, + AutoEncryptionOptions, AWSCredentials, + BSONSerializeOptions, + BSONTypeAlias, ChangeStream, + ChangeStreamCollModDocument, + ChangeStreamCreateDocument, + ChangeStreamCreateIndexDocument, + ChangeStreamDeleteDocument, ChangeStreamDocument, + ChangeStreamDocumentCommon, + ChangeStreamDocumentKey, + ChangeStreamDropDatabaseDocument, + ChangeStreamDropDocument, + ChangeStreamDropIndexDocument, + ChangeStreamInsertDocument, + ChangeStreamInvalidateDocument, + ChangeStreamNameSpace, ChangeStreamOptions, + ChangeStreamRefineCollectionShardKeyDocument, + ChangeStreamRenameDocument, + ChangeStreamReplaceDocument, + ChangeStreamReshardCollectionDocument, + ChangeStreamShardCollectionDocument, + ChangeStreamUpdateDocument, ClientBulkWriteModel, + ClientDeleteManyModel, + ClientDeleteOneModel, + ClientEncryptionDataKeyProvider, + ClientInsertOneModel, ClientMetadata, + ClientReplaceOneModel, + ClientUpdateManyModel, + ClientUpdateOneModel, + ClusterTime, CollectionInfo, + CollectionOptions, CommandOptions, CompressorName, + ConnectionCheckedInEvent, + ConnectionCheckedOutEvent, ConnectionCheckOutFailedEvent, + ConnectionCheckOutStartedEvent, + ConnectionClosedEvent, ConnectionCreatedEvent, ConnectionOptions, ConnectionPoolClearedEvent, + ConnectionPoolClosedEvent, + ConnectionPoolCreatedEvent, + ConnectionPoolOptions, + ConnectionPoolReadyEvent, + ConnectionReadyEvent, ConnectOptions, DataKey, DbOptions, Document, DriverInfo, + Filter, + InferIdType, KMSProviders, Log, MongoChangeStreamError, @@ -267,13 +315,30 @@ export type { MongoDBResponseConstructor, MongoLoggerOptions, MongoOptions, + OneOrMore, + OptionalId, + ReadPreferenceMode, ResumeToken, Runtime, ServerApi, + ServerClosedEvent, + ServerDescriptionChangedEvent, + ServerHeartbeatFailedEvent, ServerHeartbeatSucceededEvent, + ServerOpeningEvent, + ServerSessionId, + TagSet, + TopologyClosedEvent, TopologyDescription, + TopologyDescriptionChangedEvent, + TopologyOpeningEvent, TopologyOptions, + TransactionOptions, + UpdateDescription, + UpdateFilter, + W, WithId, + WithoutId, WriteConcernSettings } from './tools/runner/bundle/types/index'; @@ -306,15 +371,15 @@ export type AbstractCursor = _AbstractCursor; export type AuthMechanism = _AuthMechanism; export type ClientEncryption = _ClientEncryption; export type Collection = _Collection; -export type Connection = _Connection; export type CommandFailedEvent = _CommandFailedEvent; export type CommandStartedEvent = _CommandStartedEvent; export type CommandSucceededEvent = _CommandSucceededEvent; +export type Connection = _Connection; export type ConnectionPool = _ConnectionPool; -export type CursorTimeoutContext = _CursorTimeoutContext; -export type FindCursor = _FindCursor; export type CSOTTimeoutContext = _CSOTTimeoutContext; +export type CursorTimeoutContext = _CursorTimeoutContext; export type Db = _Db; +export type FindCursor = _FindCursor; export type HostAddress = _HostAddress; export type MongoClient = _MongoClient; export type Server = _Server; diff --git a/test/mongodb_runtime-testing.ts b/test/mongodb_runtime-testing.ts index 9bbf99258e..d0b07fef47 100644 --- a/test/mongodb_runtime-testing.ts +++ b/test/mongodb_runtime-testing.ts @@ -1,3 +1,4 @@ // This file is auto-generated. Do not edit. // Run 'npm run build:runtime-barrel' to regenerate. +export const runNodelessTests = false; export * from './mongodb'; diff --git a/test/spec/index.ts b/test/spec/index.ts index 221d667189..fdc3c03d77 100644 --- a/test/spec/index.ts +++ b/test/spec/index.ts @@ -1,7 +1,7 @@ import * as fs from 'fs'; import * as path from 'path'; -import { EJSON } from '../mongodb'; +import { EJSON } from '../mongodb_runtime-testing'; function hasDuplicates(testArray) { const testNames = testArray.map(test => test.description); diff --git a/test/tools/cmap_spec_runner.ts b/test/tools/cmap_spec_runner.ts index 9bdf85bee8..7c9b5b3373 100644 --- a/test/tools/cmap_spec_runner.ts +++ b/test/tools/cmap_spec_runner.ts @@ -15,7 +15,7 @@ import { type Server, shuffle, TimeoutContext -} from '../mongodb'; +} from '../mongodb_runtime-testing'; import { isAnyRequirementSatisfied } from './unified-spec-runner/unified-utils'; import { type FailCommandFailPoint, sleep } from './utils'; diff --git a/test/tools/common.js b/test/tools/common.js index 30732d247c..0982197c3d 100644 --- a/test/tools/common.js +++ b/test/tools/common.js @@ -1,8 +1,8 @@ 'use strict'; const mock = require('./mongodb-mock/index'); -const { ObjectId, Timestamp, Long, Binary } = require('../mongodb'); -const { LEGACY_HELLO_COMMAND, isHello } = require('../mongodb'); +const { ObjectId, Timestamp, Long, Binary } = require('../mongodb_runtime-testing'); +const { LEGACY_HELLO_COMMAND, isHello } = require('../mongodb_runtime-testing'); class ReplSetFixture { constructor() { diff --git a/test/tools/mongodb-mock/index.js b/test/tools/mongodb-mock/index.js index 11427450f7..1a363faecf 100644 --- a/test/tools/mongodb-mock/index.js +++ b/test/tools/mongodb-mock/index.js @@ -1,5 +1,5 @@ const fs = require('fs'); -const { LEGACY_HELLO_COMMAND } = require('../../mongodb'); +const { LEGACY_HELLO_COMMAND } = require('../../mongodb_runtime-testing'); const { MockServer } = require('./src/server'); const process = require('node:process'); diff --git a/test/tools/runner/config.ts b/test/tools/runner/config.ts index 265be7a926..1dd4b4f3fd 100644 --- a/test/tools/runner/config.ts +++ b/test/tools/runner/config.ts @@ -17,7 +17,6 @@ import { MongoClient, type MongoClientOptions, ObjectId, - runNodelessTests, type ServerApi, TopologyType, type WriteConcernSettings @@ -232,14 +231,6 @@ export class TestConfiguration { : {}; serverOptions = Object.assign(baseOptions, getEnvironmentalOptions(), serverOptions); - // If using contextified mongodb, inject Node.js runtime adapters - if (runNodelessTests) { - serverOptions.runtimeAdapters = { - // eslint-disable-next-line @typescript-eslint/no-require-imports - os: require('os'), - ...serverOptions.runtimeAdapters - }; - } if (this.loggingEnabled && !Object.hasOwn(serverOptions, 'mongodbLogPath')) { serverOptions = this.setupLogging(serverOptions); diff --git a/test/tools/runner/filters/api_version_filter.ts b/test/tools/runner/filters/api_version_filter.ts index ce7df6f1fe..41f719f300 100755 --- a/test/tools/runner/filters/api_version_filter.ts +++ b/test/tools/runner/filters/api_version_filter.ts @@ -1,6 +1,6 @@ import * as process from 'process'; -import { type MongoClient } from '../../../mongodb'; +import { type MongoClient } from '../../../mongodb_runtime-testing'; import { Filter } from './filter'; /** diff --git a/test/tools/runner/filters/client_encryption_filter.ts b/test/tools/runner/filters/client_encryption_filter.ts index 5789552574..88e6f5ab5c 100644 --- a/test/tools/runner/filters/client_encryption_filter.ts +++ b/test/tools/runner/filters/client_encryption_filter.ts @@ -5,7 +5,7 @@ import * as process from 'process'; import { satisfies } from 'semver'; import { kmsCredentialsPresent } from '../../../csfle-kms-providers'; -import { type MongoClient } from '../../../mongodb'; +import { type MongoClient } from '../../../mongodb_runtime-testing'; import { Filter } from './filter'; /** diff --git a/test/tools/runner/filters/crypt_shared_filter.ts b/test/tools/runner/filters/crypt_shared_filter.ts index bf82435708..6ed7f21d4d 100644 --- a/test/tools/runner/filters/crypt_shared_filter.ts +++ b/test/tools/runner/filters/crypt_shared_filter.ts @@ -1,4 +1,4 @@ -import { type AutoEncrypter, MongoClient } from '../../../mongodb'; +import { type AutoEncrypter, MongoClient } from '../../../mongodb_runtime-testing'; import { getEncryptExtraOptions } from '../../utils'; import { Filter } from './filter'; diff --git a/test/tools/runner/filters/filter.ts b/test/tools/runner/filters/filter.ts index 6251cf44c8..0fbbcae46c 100644 --- a/test/tools/runner/filters/filter.ts +++ b/test/tools/runner/filters/filter.ts @@ -1,4 +1,4 @@ -import { type MongoClient } from '../../../mongodb'; +import { type MongoClient } from '../../../mongodb_runtime-testing'; export abstract class Filter { async initializeFilter(_client: MongoClient, _context: Record): Promise { diff --git a/test/tools/runner/filters/mongodb_topology_filter.ts b/test/tools/runner/filters/mongodb_topology_filter.ts index 429b028b8b..6c8abff35c 100755 --- a/test/tools/runner/filters/mongodb_topology_filter.ts +++ b/test/tools/runner/filters/mongodb_topology_filter.ts @@ -1,4 +1,4 @@ -import { type MongoClient, TopologyType } from '../../../mongodb'; +import { type MongoClient, TopologyType } from '../../../mongodb_runtime-testing'; import { Filter } from './filter'; /** diff --git a/test/tools/runner/filters/mongodb_version_filter.ts b/test/tools/runner/filters/mongodb_version_filter.ts index 8d1eb6307f..a649b69d5f 100755 --- a/test/tools/runner/filters/mongodb_version_filter.ts +++ b/test/tools/runner/filters/mongodb_version_filter.ts @@ -1,6 +1,6 @@ import * as semver from 'semver'; -import { type MongoClient } from '../../../mongodb'; +import { type MongoClient } from '../../../mongodb_runtime-testing'; import { Filter } from './filter'; /** diff --git a/test/tools/runner/filters/tls_filter.ts b/test/tools/runner/filters/tls_filter.ts index b08b03a0a7..04f5a9f5a3 100644 --- a/test/tools/runner/filters/tls_filter.ts +++ b/test/tools/runner/filters/tls_filter.ts @@ -1,6 +1,6 @@ import * as process from 'process'; -import { type MongoClient } from '../../../mongodb'; +import { type MongoClient } from '../../../mongodb_runtime-testing'; import { Filter } from './filter'; export const isTLSEnabled = process.env.SSL === 'ssl'; diff --git a/test/tools/runner/hooks/configuration.ts b/test/tools/runner/hooks/configuration.ts index 0220d81fb9..9ff870c9a4 100644 --- a/test/tools/runner/hooks/configuration.ts +++ b/test/tools/runner/hooks/configuration.ts @@ -8,7 +8,7 @@ require('source-map-support').install({ import * as process from 'process'; import * as os from 'os'; -import { MongoClient } from '../../../mongodb'; +import { MongoClient } from '../../../mongodb_runtime-testing'; import { AlpineTestConfiguration, AstrolabeTestConfiguration, TestConfiguration } from '../config'; import { getEnvironmentalOptions } from '../../utils'; import * as mock from '../../mongodb-mock/index'; diff --git a/test/tools/runner/hooks/leak_checker.ts b/test/tools/runner/hooks/leak_checker.ts index fab12158fc..069dd8dac5 100644 --- a/test/tools/runner/hooks/leak_checker.ts +++ b/test/tools/runner/hooks/leak_checker.ts @@ -5,7 +5,7 @@ import * as chalk from 'chalk'; import * as net from 'net'; import * as process from 'process'; -import { MongoClient, ServerSessionPool } from '../../../mongodb'; +import { MongoClient, ServerSessionPool } from '../../../mongodb_runtime-testing'; class LeakChecker { static originalAcquire: typeof ServerSessionPool.prototype.acquire; static originalRelease: typeof ServerSessionPool.prototype.release; diff --git a/test/tools/spec-runner/context.js b/test/tools/spec-runner/context.js index 22871c707d..0d650024ce 100644 --- a/test/tools/spec-runner/context.js +++ b/test/tools/spec-runner/context.js @@ -2,7 +2,7 @@ const { expect } = require('chai'); const { setTimeout } = require('timers'); const { resolveConnectionString } = require('./utils'); -const { ns } = require('../../mongodb'); +const { ns } = require('../../mongodb_runtime-testing'); const { extractAuthFromConnectionString } = require('../utils'); const process = require('node:process'); diff --git a/test/tools/spec-runner/index.js b/test/tools/spec-runner/index.js index 2043ba395a..029994cf47 100644 --- a/test/tools/spec-runner/index.js +++ b/test/tools/spec-runner/index.js @@ -6,7 +6,7 @@ const process = require('node:process'); const expect = chai.expect; const { EJSON } = require('bson'); -const { isRecord } = require('../../mongodb'); +const { isRecord } = require('../../mongodb_runtime-testing'); const TestRunnerContext = require('./context').TestRunnerContext; const resolveConnectionString = require('./utils').resolveConnectionString; const { @@ -14,7 +14,7 @@ const { CMAP_EVENTS: SOURCE_CMAP_EVENTS, TOPOLOGY_EVENTS, HEARTBEAT_EVENTS -} = require('../../mongodb'); +} = require('../../mongodb_runtime-testing'); const { isAnyRequirementSatisfied } = require('../unified-spec-runner/unified-utils'); const { getCSFLEKMSProviders } = require('../../csfle-kms-providers'); diff --git a/test/tools/unified-spec-runner/entities.ts b/test/tools/unified-spec-runner/entities.ts index 2c4f257b15..793b9c3a0e 100644 --- a/test/tools/unified-spec-runner/entities.ts +++ b/test/tools/unified-spec-runner/entities.ts @@ -49,7 +49,7 @@ import { type TopologyDescriptionChangedEvent, type TopologyOpeningEvent, WriteConcern -} from '../../mongodb'; +} from '../../mongodb_runtime-testing'; import { getEncryptExtraOptions, getEnvironmentalOptions } from '../../tools/utils'; import { AlpineTestConfiguration, type TestConfiguration } from '../runner/config'; import { EntityEventRegistry } from './entity_event_registry'; diff --git a/test/tools/unified-spec-runner/entity_event_registry.ts b/test/tools/unified-spec-runner/entity_event_registry.ts index d62e106988..c995c288dc 100644 --- a/test/tools/unified-spec-runner/entity_event_registry.ts +++ b/test/tools/unified-spec-runner/entity_event_registry.ts @@ -15,7 +15,7 @@ import { CONNECTION_POOL_CREATED, CONNECTION_POOL_READY, CONNECTION_READY -} from '../../mongodb'; +} from '../../mongodb_runtime-testing'; import { type EntitiesMap, type UnifiedMongoClient } from './entities'; import { type ClientEntity } from './schema'; diff --git a/test/tools/unified-spec-runner/match.ts b/test/tools/unified-spec-runner/match.ts index 112748a10a..b3cc263092 100644 --- a/test/tools/unified-spec-runner/match.ts +++ b/test/tools/unified-spec-runner/match.ts @@ -38,7 +38,7 @@ import { TopologyClosedEvent, TopologyDescriptionChangedEvent, TopologyOpeningEvent -} from '../../mongodb'; +} from '../../mongodb_runtime-testing'; import { ejson } from '../utils'; import { type CmapEvent, type CommandEvent, type EntitiesMap, type SdamEvent } from './entities'; import { diff --git a/test/tools/unified-spec-runner/operations.ts b/test/tools/unified-spec-runner/operations.ts index d0bf5969e7..b9dc1c0eb8 100644 --- a/test/tools/unified-spec-runner/operations.ts +++ b/test/tools/unified-spec-runner/operations.ts @@ -23,7 +23,7 @@ import { type TopologyType, type TransactionOptions, WriteConcern -} from '../../mongodb'; +} from '../../mongodb_runtime-testing'; import { sleep } from '../../tools/utils'; import { type TestConfiguration } from '../runner/config'; import { EntitiesMap } from './entities'; diff --git a/test/tools/unified-spec-runner/runner.ts b/test/tools/unified-spec-runner/runner.ts index f58d01f98b..d72d10c2db 100644 --- a/test/tools/unified-spec-runner/runner.ts +++ b/test/tools/unified-spec-runner/runner.ts @@ -11,7 +11,7 @@ import { ns, ReadPreference, TopologyType -} from '../../mongodb'; +} from '../../mongodb_runtime-testing'; import { ejson } from '../utils'; import { AstrolabeResultsWriter } from './astrolabe_results_writer'; import { EntitiesMap, type UnifiedMongoClient } from './entities'; diff --git a/test/tools/unified-spec-runner/schema.ts b/test/tools/unified-spec-runner/schema.ts index 0f7e048b17..efb529b98f 100644 --- a/test/tools/unified-spec-runner/schema.ts +++ b/test/tools/unified-spec-runner/schema.ts @@ -10,7 +10,7 @@ import type { TagSet, TopologyType, W -} from '../../mongodb'; +} from '../../mongodb_runtime-testing'; import { type TestConfiguration } from '../runner/config'; import { type UnifiedThread } from './entities'; diff --git a/test/tools/unified-spec-runner/unified-utils.ts b/test/tools/unified-spec-runner/unified-utils.ts index 1d4973734a..f69a293339 100644 --- a/test/tools/unified-spec-runner/unified-utils.ts +++ b/test/tools/unified-spec-runner/unified-utils.ts @@ -14,7 +14,7 @@ import { getMongoDBClientEncryption, type MongoClient, ReturnDocument -} from '../../mongodb'; +} from '../../mongodb_runtime-testing'; import type { CmapEvent, CommandEvent, EntitiesMap, SdamEvent } from './entities'; import { matchesEvents } from './match'; import { MalformedOperationError } from './operations'; diff --git a/test/tools/uri_spec_runner.ts b/test/tools/uri_spec_runner.ts index bb6f44459a..6934b23e7f 100644 --- a/test/tools/uri_spec_runner.ts +++ b/test/tools/uri_spec_runner.ts @@ -6,7 +6,7 @@ import { MongoInvalidArgumentError, MongoParseError, MongoRuntimeError -} from '../mongodb'; +} from '../mongodb_runtime-testing'; type HostObject = { type: 'ipv4' | 'ip_literal' | 'hostname' | 'unix'; From d2fbe57c708c12b6f6274f2e6eab2e7724e61931 Mon Sep 17 00:00:00 2001 From: Pavel Safronov Date: Tue, 24 Feb 2026 07:18:51 -0800 Subject: [PATCH 26/36] add a few more exports --- test/mongodb_bundled.ts | 56 ++++++++++++++++++++++++++--------------- 1 file changed, 36 insertions(+), 20 deletions(-) diff --git a/test/mongodb_bundled.ts b/test/mongodb_bundled.ts index 11e6673afc..34c5db13c2 100644 --- a/test/mongodb_bundled.ts +++ b/test/mongodb_bundled.ts @@ -29,6 +29,7 @@ export const { BSONSymbol, BSONType, BufferPool, + ChangeStream, ChangeStreamCursor, checkParentDomainMatch, ClientEncryption, @@ -58,7 +59,18 @@ export const { CONNECTION_POOL_READY, CONNECTION_READY, Connection, + ConnectionCheckedInEvent, + ConnectionCheckedOutEvent, + ConnectionCheckOutFailedEvent, + ConnectionCheckOutStartedEvent, + ConnectionClosedEvent, + ConnectionCreatedEvent, ConnectionPool, + ConnectionPoolClearedEvent, + ConnectionPoolClosedEvent, + ConnectionPoolCreatedEvent, + ConnectionPoolReadyEvent, + ConnectionReadyEvent, COSMOS_DB_MSG, CountOperation, CreateCollectionOperation, @@ -210,8 +222,13 @@ export const { SERVER_HEARTBEAT_SUCCEEDED, Server, ServerApiVersion, + ServerClosedEvent, ServerDescription, + ServerDescriptionChangedEvent, + ServerHeartbeatFailedEvent, ServerHeartbeatStartedEvent, + ServerHeartbeatSucceededEvent, + ServerOpeningEvent, ServerSession, ServerSessionPool, ServerType, @@ -229,6 +246,9 @@ export const { Timestamp, TOPOLOGY_EVENTS, Topology, + TopologyClosedEvent, + TopologyDescriptionChangedEvent, + TopologyOpeningEvent, TopologyType, Transaction, uncompressibleCommands, @@ -252,7 +272,6 @@ export type { AWSCredentials, BSONSerializeOptions, BSONTypeAlias, - ChangeStream, ChangeStreamCollModDocument, ChangeStreamCreateDocument, ChangeStreamCreateIndexDocument, @@ -287,19 +306,8 @@ export type { CollectionOptions, CommandOptions, CompressorName, - ConnectionCheckedInEvent, - ConnectionCheckedOutEvent, - ConnectionCheckOutFailedEvent, - ConnectionCheckOutStartedEvent, - ConnectionClosedEvent, - ConnectionCreatedEvent, ConnectionOptions, - ConnectionPoolClearedEvent, - ConnectionPoolClosedEvent, - ConnectionPoolCreatedEvent, ConnectionPoolOptions, - ConnectionPoolReadyEvent, - ConnectionReadyEvent, ConnectOptions, DataKey, DbOptions, @@ -321,17 +329,9 @@ export type { ResumeToken, Runtime, ServerApi, - ServerClosedEvent, - ServerDescriptionChangedEvent, - ServerHeartbeatFailedEvent, - ServerHeartbeatSucceededEvent, - ServerOpeningEvent, ServerSessionId, TagSet, - TopologyClosedEvent, TopologyDescription, - TopologyDescriptionChangedEvent, - TopologyOpeningEvent, TopologyOptions, TransactionOptions, UpdateDescription, @@ -347,45 +347,61 @@ export type { import type { AbstractCursor as _AbstractCursor, AuthMechanism as _AuthMechanism, + ChangeStream as _ChangeStream, ClientEncryption as _ClientEncryption, + ClientSession as _ClientSession, Collection as _Collection, CommandFailedEvent as _CommandFailedEvent, CommandStartedEvent as _CommandStartedEvent, CommandSucceededEvent as _CommandSucceededEvent, Connection as _Connection, + ConnectionClosedEvent as _ConnectionClosedEvent, ConnectionPool as _ConnectionPool, + ConnectionPoolClearedEvent as _ConnectionPoolClearedEvent, CSOTTimeoutContext as _CSOTTimeoutContext, CursorTimeoutContext as _CursorTimeoutContext, Db as _Db, FindCursor as _FindCursor, + GridFSBucket as _GridFSBucket, HostAddress as _HostAddress, MongoClient as _MongoClient, + MongoError as _MongoError, Server as _Server, + ServerDescriptionChangedEvent as _ServerDescriptionChangedEvent, Timeout as _Timeout, TimeoutContext as _TimeoutContext, Topology as _Topology, + TopologyDescriptionChangedEvent as _TopologyDescriptionChangedEvent, TopologyType as _TopologyType, UUID as _UUID } from './tools/runner/bundle/types/index'; export type AbstractCursor = _AbstractCursor; export type AuthMechanism = _AuthMechanism; +export type ChangeStream = _ChangeStream; export type ClientEncryption = _ClientEncryption; +export type ClientSession = _ClientSession; export type Collection = _Collection; export type CommandFailedEvent = _CommandFailedEvent; export type CommandStartedEvent = _CommandStartedEvent; export type CommandSucceededEvent = _CommandSucceededEvent; export type Connection = _Connection; +export type ConnectionClosedEvent = _ConnectionClosedEvent; export type ConnectionPool = _ConnectionPool; +export type ConnectionPoolClearedEvent = _ConnectionPoolClearedEvent; export type CSOTTimeoutContext = _CSOTTimeoutContext; export type CursorTimeoutContext = _CursorTimeoutContext; export type Db = _Db; export type FindCursor = _FindCursor; +export type GridFSBucket = _GridFSBucket; export type HostAddress = _HostAddress; export type MongoClient = _MongoClient; +export type MongoError = _MongoError; export type Server = _Server; +export type ServerDescriptionChangedEvent = _ServerDescriptionChangedEvent; export type Timeout = _Timeout; export type TimeoutContext = _TimeoutContext; export type Topology = _Topology; +export type TopologyDescriptionChangedEvent = _TopologyDescriptionChangedEvent; export type TopologyType = _TopologyType; export type UUID = _UUID; From 7a2fda51fc512c374d98518bf0f82c52eec5e46e Mon Sep 17 00:00:00 2001 From: Pavel Safronov Date: Tue, 24 Feb 2026 08:18:40 -0800 Subject: [PATCH 27/36] add missing export --- test/mongodb_bundled.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/test/mongodb_bundled.ts b/test/mongodb_bundled.ts index 34c5db13c2..bb76c6aaa0 100644 --- a/test/mongodb_bundled.ts +++ b/test/mongodb_bundled.ts @@ -128,6 +128,7 @@ export const { Int32, isDriverInfoEqual, isHello, + isRecord, isResumableError, isRetryableReadError, isStateChangeError, From f454070f437ca4b5b75e0b53c30f4bf7c762157e Mon Sep 17 00:00:00 2001 From: Pavel Safronov Date: Tue, 24 Feb 2026 10:27:59 -0800 Subject: [PATCH 28/36] fix prose test, add unit test for nodeless --- test/csfle-kms-providers.ts | 2 +- ...ose.21.automatic_data_encryption_keys.test.ts | 3 ++- test/unit/nodeless.test.ts | 16 ++++++++++++++++ 3 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 test/unit/nodeless.test.ts diff --git a/test/csfle-kms-providers.ts b/test/csfle-kms-providers.ts index f18ac70de9..431be83f21 100644 --- a/test/csfle-kms-providers.ts +++ b/test/csfle-kms-providers.ts @@ -1,6 +1,6 @@ import * as process from 'process'; -import { type KMSProviders } from './mongodb'; +import { type KMSProviders } from './mongodb_runtime-testing'; const csfleKMSProviders = { aws: { diff --git a/test/integration/client-side-encryption/client_side_encryption.prose.21.automatic_data_encryption_keys.test.ts b/test/integration/client-side-encryption/client_side_encryption.prose.21.automatic_data_encryption_keys.test.ts index e4244518ca..d24ec289c7 100644 --- a/test/integration/client-side-encryption/client_side_encryption.prose.21.automatic_data_encryption_keys.test.ts +++ b/test/integration/client-side-encryption/client_side_encryption.prose.21.automatic_data_encryption_keys.test.ts @@ -12,6 +12,7 @@ import { MongoCryptCreateEncryptedCollectionError, MongoServerError } from '../../mongodb_runtime-testing'; +import { ensureTypeByName } from '../../tools/utils'; const metadata: MongoDBMetadataUI = { requires: { clientSideEncryption: true, @@ -94,7 +95,7 @@ describe('21. Automatic Data Encryption Keys', () => { }) .catch(error => error); - expect(result).to.be.instanceOf(TypeError); + ensureTypeByName(result, 'TypeError'); }); it('Case 3: Invalid keyId', metadata, async () => { diff --git a/test/unit/nodeless.test.ts b/test/unit/nodeless.test.ts new file mode 100644 index 0000000000..de665064ba --- /dev/null +++ b/test/unit/nodeless.test.ts @@ -0,0 +1,16 @@ +import { expect } from 'chai'; +import { env } from 'process'; + +import { runNodelessTests } from '../mongodb_runtime-testing'; + +describe('Nodeless tests', function () { + it('runNodelessTests variable should match env vars', function () { + const nodelessEnv = env.NODELESS; + const expectedNodeless = nodelessEnv === 'true'; + const actualNodeless = runNodelessTests; + expect(actualNodeless).to.equal( + expectedNodeless, + "runNodelessTests variable does not match NODELESS env var, run 'npm run build:runtime-barrel' to update the barrel file" + ); + }); +}); From 7bd8b9aac391649260c9dccd19c2475acb4e1c7c Mon Sep 17 00:00:00 2001 From: Pavel Safronov Date: Tue, 24 Feb 2026 15:47:27 -0800 Subject: [PATCH 29/36] swapped files to remove all import changes, got most non-integ tests passing, in addition to all integ tests --- etc/build-runtime-barrel.mjs | 4 +- etc/bundle-driver.mjs | 2 +- src/client-side-encryption/providers/azure.ts | 5 +- .../client_bulk_write/command_builder.ts | 2 +- test/action/dependency.test.ts | 2 +- test/csfle-kms-providers.ts | 2 +- test/integration/auth/auth.prose.test.ts | 7 +- .../auth/mongodb_aws.prose.test.ts | 6 +- test/integration/auth/mongodb_aws.test.ts | 2 +- .../auth/mongodb_oidc.prose.test.ts | 2 +- .../bson-decimal128/decimal128.test.ts | 2 +- .../causal_consistency.prose.test.js | 2 +- .../change-streams/change_stream.test.ts | 2 +- .../change_streams.prose.test.ts | 2 +- ...nt_side_encryption.prose.06.corpus.test.ts | 2 +- ...t_side_encryption.prose.10.kms_tls.test.ts | 2 +- ..._side_encryption.prose.12.deadlock.test.ts | 2 +- ...ryption.prose.14.decryption_events.test.ts | 2 +- ..._encryption.prose.17.on_demand_gcp.test.ts | 2 +- ...ion.prose.18.azure_kms_mock_server.test.ts | 2 +- ...ncryption.prose.19.on_demand_azure.test.ts | 6 +- ...yption.prose.20.mongocryptd_client.test.ts | 2 +- ....21.automatic_data_encryption_keys.test.ts | 2 +- ...prose.22.range_explicit_encryption.test.ts | 2 +- ...prose.23.range_encryption_defaults.test.ts | 2 +- ...nt_side_encryption.prose.25.lookup.test.ts | 2 +- ...26.custom_aws_credential_providers.test.ts | 7 +- ...e_encryption.prose.27.text_queries.test.ts | 6 +- .../client_side_encryption.prose.test.ts | 2 +- .../client-side-encryption/driver.test.ts | 2 +- ...ient_side_operations_timeout.prose.test.ts | 2 +- ...lient_side_operations_timeout.unit.test.ts | 2 +- .../node_csot.test.ts | 2 +- .../collection-management/collection.test.ts | 7 +- .../collection_db_management.test.ts | 2 +- .../collection-management/view.test.ts | 2 +- ...mmand_logging_and_monitoring.prose.test.ts | 2 +- .../command_monitoring.test.ts | 2 +- .../connection.test.ts | 2 +- .../connection_pool.test.ts | 2 +- .../rtt_pinger.test.ts | 2 +- ...onnections_survive_step_down.prose.test.ts | 2 +- .../crud/abstract_operation.test.ts | 2 +- test/integration/crud/aggregation.test.ts | 6 +- test/integration/crud/bulk.test.ts | 2 +- .../crud/client_bulk_write.test.ts | 2 +- test/integration/crud/crud.prose.test.ts | 2 +- test/integration/crud/crud_api.test.ts | 2 +- .../crud/document_validation.test.ts | 6 +- test/integration/crud/explain.test.ts | 2 +- test/integration/crud/find.test.ts | 2 +- test/integration/crud/find_and_modify.test.ts | 2 +- .../crud/find_cursor_methods.test.ts | 2 +- test/integration/crud/insert.test.ts | 2 +- test/integration/crud/maxTimeMS.test.ts | 2 +- test/integration/crud/misc_cursors.test.ts | 2 +- test/integration/crud/remove.test.ts | 2 +- test/integration/crud/server_errors.test.ts | 2 +- test/integration/crud/stats.test.ts | 2 +- test/integration/crud/unicode.test.ts | 2 +- .../enumerate_databases.prose.test.ts | 2 +- test/integration/enumerate_databases.test.ts | 2 +- test/integration/gridfs/gridfs.test.ts | 2 +- test/integration/gridfs/gridfs_stream.test.ts | 8 +- .../search-index-management.test.ts | 6 +- .../dns_seedlist.test.ts | 2 +- ...itial_dns_seedlist_discovery.prose.test.ts | 8 +- ...nitial_dns_seedlist_discovery.spec.test.ts | 2 +- .../max-staleness/max_staleness.test.js | 4 +- .../mongodb-handshake.prose.test.ts | 2 +- .../mongodb-handshake.test.ts | 2 +- .../node-specific/abort_signal.test.ts | 2 +- .../node-specific/abstract_cursor.test.ts | 2 +- .../node-specific/async_dispose.test.ts | 2 +- .../node-specific/auto_connect.test.ts | 2 +- .../node-specific/auto_encrypter.test.ts | 2 +- .../bson-options/bsonRegExp.test.ts | 2 +- .../bson-options/ignore_undefined.test.ts | 2 +- .../bson-options/promote_values.test.ts | 2 +- .../node-specific/bson-options/raw.test.ts | 2 +- .../bson-options/use_bigint_64.test.ts | 2 +- .../bson-options/utf8_validation.test.ts | 2 +- .../node-specific/client_close.test.ts | 2 +- .../node-specific/client_encryption.test.ts | 2 +- .../comment_with_falsy_values.test.ts | 7 +- .../convert_socket_errors.test.ts | 2 +- .../node-specific/crypt_shared_lib.test.ts | 2 +- .../node-specific/cursor_stream.test.ts | 2 +- test/integration/node-specific/db.test.ts | 2 +- test/integration/node-specific/errors.test.ts | 6 +- test/integration/node-specific/ipv6.test.ts | 2 +- .../node-specific/mongo_client.test.ts | 2 +- .../node-specific/operation_examples.test.ts | 2 +- .../node-specific/resource_clean_up.test.ts | 2 +- .../resource_tracking_script_builder.ts | 2 +- .../node-specific/topology.test.ts | 2 +- .../node-specific/validate_collection.test.ts | 2 +- test/integration/objectid.test.ts | 2 +- .../read-write-concern/readconcern.test.ts | 2 +- .../read-write-concern/write_concern.test.ts | 2 +- .../retryable_reads.spec.prose.test.ts | 2 +- .../non-server-retryable_writes.test.ts | 2 +- .../retryable_writes.spec.prose.test.ts | 2 +- .../run-command/run_command.test.ts | 2 +- .../run-command/run_cursor_command.test.ts | 2 +- .../server_description.test.ts | 2 +- .../server_discover_and_monitoring.test.ts | 2 +- ...ver_discovery_and_monitoring.prose.test.ts | 2 +- .../topology_description.test.ts | 2 +- .../server-selection/operation_count.test.ts | 2 +- .../server-selection/readpreference.test.ts | 2 +- ...er_selection.prose.operation_count.test.ts | 2 +- ...tion.prose.sharded_retryable_reads.test.ts | 2 +- ...ion.prose.sharded_retryable_writes.test.ts | 2 +- .../sessions/sessions.prose.test.ts | 2 +- test/integration/sessions/sessions.test.ts | 2 +- .../transactions-convenient-api.prose.test.ts | 6 +- .../transactions/transactions.prose.test.ts | 2 +- .../transactions/transactions.test.ts | 2 +- test/integration/uri-options/uri.test.ts | 2 +- test/manual/atlas_connectivity.test.ts | 2 +- test/manual/kerberos.test.ts | 2 +- test/manual/ldap.test.ts | 2 +- .../search-index-management.prose.test.ts | 2 +- test/manual/socks5.test.ts | 2 +- test/manual/tls_support.test.ts | 2 +- test/manual/x509_auth.test.ts | 2 +- test/mongodb.ts | 148 +----------------- test/mongodb_all.ts | 144 +++++++++++++++++ test/mongodb_bundled.ts | 87 +++++++++- test/mongodb_runtime-testing.ts | 4 - test/readme.md | 20 +-- test/spec/index.ts | 2 +- test/tools/cmap_spec_runner.ts | 2 +- test/tools/common.js | 4 +- test/tools/mongodb-mock/index.js | 2 +- test/tools/runner/config.ts | 2 +- .../runner/filters/api_version_filter.ts | 2 +- .../filters/client_encryption_filter.ts | 2 +- .../runner/filters/crypt_shared_filter.ts | 2 +- test/tools/runner/filters/filter.ts | 2 +- .../runner/filters/mongodb_topology_filter.ts | 2 +- .../runner/filters/mongodb_version_filter.ts | 2 +- test/tools/runner/filters/tls_filter.ts | 2 +- test/tools/runner/hooks/configuration.ts | 2 +- test/tools/runner/hooks/leak_checker.ts | 2 +- test/tools/spec-runner/context.js | 2 +- test/tools/spec-runner/index.js | 4 +- test/tools/unified-spec-runner/entities.ts | 2 +- .../entity_event_registry.ts | 2 +- test/tools/unified-spec-runner/match.ts | 2 +- test/tools/unified-spec-runner/operations.ts | 2 +- test/tools/unified-spec-runner/runner.ts | 2 +- test/tools/unified-spec-runner/schema.ts | 2 +- .../unified-spec-runner/unified-utils.ts | 2 +- test/tools/uri_spec_runner.ts | 2 +- test/tools/utils.ts | 9 +- ...rver_discovery_and_monitoring.spec.test.ts | 34 +++- .../assorted/server_selection_spec_helper.js | 6 +- .../client_encryption.test.ts | 25 +-- .../providers/credentialsProvider.test.ts | 9 +- test/unit/cmap/commands.test.ts | 4 +- .../cmap/handshake/client_metadata.test.ts | 9 +- test/unit/commands.test.ts | 7 + test/unit/mongo_client.test.ts | 4 +- test/unit/nodeless.test.ts | 7 +- test/unit/sdam/monitor.test.ts | 7 + test/unit/timeout.test.ts | 4 +- test/unit/utils.test.ts | 5 +- 169 files changed, 491 insertions(+), 419 deletions(-) create mode 100644 test/mongodb_all.ts delete mode 100644 test/mongodb_runtime-testing.ts diff --git a/etc/build-runtime-barrel.mjs b/etc/build-runtime-barrel.mjs index afb34360a9..68a7595e85 100644 --- a/etc/build-runtime-barrel.mjs +++ b/etc/build-runtime-barrel.mjs @@ -7,8 +7,8 @@ const useBundled = process.env.MONGODB_BUNDLED === 'true'; const __dirname = path.dirname(fileURLToPath(import.meta.url)); const rootDir = path.join(__dirname, '..'); -const outputBarrelFile = path.join(rootDir, 'test/mongodb_runtime-testing.ts'); -const source = useBundled ? './mongodb_bundled' : './mongodb'; +const outputBarrelFile = path.join(rootDir, 'test/mongodb.ts'); +const source = useBundled ? './mongodb_bundled' : './mongodb_all'; const contents = `// This file is auto-generated. Do not edit.\n` + diff --git a/etc/bundle-driver.mjs b/etc/bundle-driver.mjs index f007d00f06..e57558f484 100755 --- a/etc/bundle-driver.mjs +++ b/etc/bundle-driver.mjs @@ -14,7 +14,7 @@ await fs.rm(outdir, { recursive: true, force: true }); const outputBundleFile = path.join(outdir, 'driver-bundle.js'); await esbuild.build({ - entryPoints: [path.join(rootDir, 'test/mongodb.ts')], + entryPoints: [path.join(rootDir, 'test/mongodb_all.ts')], bundle: true, outfile: outputBundleFile, platform: 'node', diff --git a/src/client-side-encryption/providers/azure.ts b/src/client-side-encryption/providers/azure.ts index 97a2665ee9..5dcb9c4f15 100644 --- a/src/client-side-encryption/providers/azure.ts +++ b/src/client-side-encryption/providers/azure.ts @@ -163,7 +163,10 @@ export async function fetchAzureKMSToken( const response = await get(url, { headers }); return await parseResponse(response); } catch (error) { - if (error instanceof MongoNetworkTimeoutError) { + if ( + error instanceof MongoNetworkTimeoutError || + (error && error.constructor && error.constructor.name === 'MongoNetworkTimeoutError') + ) { throw new MongoCryptAzureKMSRequestError(`[Azure KMS] ${error.message}`); } throw error; diff --git a/src/operations/client_bulk_write/command_builder.ts b/src/operations/client_bulk_write/command_builder.ts index 6e937f058c..dee80facca 100644 --- a/src/operations/client_bulk_write/command_builder.ts +++ b/src/operations/client_bulk_write/command_builder.ts @@ -242,7 +242,7 @@ function validateBufferSize(name: string, buffer: Uint8Array, maxBsonObjectSize: } /** @internal */ -interface ClientInsertOperation { +export interface ClientInsertOperation { insert: number; document: OptionalId; } diff --git a/test/action/dependency.test.ts b/test/action/dependency.test.ts index e623f94cad..dc3aa7294f 100644 --- a/test/action/dependency.test.ts +++ b/test/action/dependency.test.ts @@ -5,7 +5,7 @@ import * as path from 'node:path'; import { expect } from 'chai'; import { dependencies, peerDependencies, peerDependenciesMeta } from '../../package.json'; -import { setDifference } from '../mongodb_runtime-testing'; +import { setDifference } from '../mongodb'; import { alphabetically, itInNodeProcess, sorted } from '../tools/utils'; const EXPECTED_DEPENDENCIES = sorted( diff --git a/test/csfle-kms-providers.ts b/test/csfle-kms-providers.ts index 431be83f21..ed4cfd7e79 100644 --- a/test/csfle-kms-providers.ts +++ b/test/csfle-kms-providers.ts @@ -1,6 +1,6 @@ import * as process from 'process'; -import { type KMSProviders } from './mongodb_runtime-testing'; +import { type KMSProviders } from './mongodb_all'; const csfleKMSProviders = { aws: { diff --git a/test/integration/auth/auth.prose.test.ts b/test/integration/auth/auth.prose.test.ts index 0c9dccddff..1b2dfc2633 100644 --- a/test/integration/auth/auth.prose.test.ts +++ b/test/integration/auth/auth.prose.test.ts @@ -2,12 +2,7 @@ import { expect } from 'chai'; import * as process from 'process'; import * as sinon from 'sinon'; -import { - Connection, - LEGACY_HELLO_COMMAND, - type MongoClient, - ScramSHA256 -} from '../../mongodb_runtime-testing'; +import { Connection, LEGACY_HELLO_COMMAND, type MongoClient, ScramSHA256 } from '../../mongodb'; import { type TestConfiguration } from '../../tools/runner/config'; function makeConnectionString(config, username, password) { diff --git a/test/integration/auth/mongodb_aws.prose.test.ts b/test/integration/auth/mongodb_aws.prose.test.ts index b15e54aa46..33e8502a3e 100644 --- a/test/integration/auth/mongodb_aws.prose.test.ts +++ b/test/integration/auth/mongodb_aws.prose.test.ts @@ -1,11 +1,7 @@ import { expect } from 'chai'; import * as process from 'process'; -import { - AWSSDKCredentialProvider, - type MongoClient, - MongoServerError -} from '../../mongodb_runtime-testing'; +import { AWSSDKCredentialProvider, type MongoClient, MongoServerError } from '../../mongodb'; const isMongoDBAWSAuthEnvironment = (process.env.MONGODB_URI ?? '').includes('MONGODB-AWS'); describe('MONGODB-AWS Prose Tests', function () { diff --git a/test/integration/auth/mongodb_aws.test.ts b/test/integration/auth/mongodb_aws.test.ts index 02aeef047d..95b792e864 100644 --- a/test/integration/auth/mongodb_aws.test.ts +++ b/test/integration/auth/mongodb_aws.test.ts @@ -21,7 +21,7 @@ import { MongoServerError, refreshKMSCredentials, setDifference -} from '../../mongodb_runtime-testing'; +} from '../../mongodb'; const isMongoDBAWSAuthEnvironment = (process.env.MONGODB_URI ?? '').includes('MONGODB-AWS'); describe('MONGODB-AWS', function () { diff --git a/test/integration/auth/mongodb_oidc.prose.test.ts b/test/integration/auth/mongodb_oidc.prose.test.ts index 06db99a52c..a7e89876a6 100644 --- a/test/integration/auth/mongodb_oidc.prose.test.ts +++ b/test/integration/auth/mongodb_oidc.prose.test.ts @@ -14,7 +14,7 @@ import { type OIDCCallbackFunction, type OIDCCallbackParams, type OIDCResponse -} from '../../mongodb_runtime-testing'; +} from '../../mongodb'; const createCallback = (tokenFile = 'test_user1', expiresInSeconds?: number, extraFields?: any) => { return async (params: OIDCCallbackParams) => { const token = await readFile(path.join(process.env.OIDC_TOKEN_DIR, tokenFile), { diff --git a/test/integration/bson-decimal128/decimal128.test.ts b/test/integration/bson-decimal128/decimal128.test.ts index 4dca2f6831..9797ce6206 100644 --- a/test/integration/bson-decimal128/decimal128.test.ts +++ b/test/integration/bson-decimal128/decimal128.test.ts @@ -1,6 +1,6 @@ import { expect } from 'chai'; -import { type Collection, Decimal128, type MongoClient } from '../../mongodb_runtime-testing'; +import { type Collection, Decimal128, type MongoClient } from '../../mongodb'; describe('Decimal128', function () { let client: MongoClient; diff --git a/test/integration/causal-consistency/causal_consistency.prose.test.js b/test/integration/causal-consistency/causal_consistency.prose.test.js index f072c7d9b2..9f333ff781 100644 --- a/test/integration/causal-consistency/causal_consistency.prose.test.js +++ b/test/integration/causal-consistency/causal_consistency.prose.test.js @@ -1,6 +1,6 @@ 'use strict'; -const { LEGACY_HELLO_COMMAND } = require('../../mongodb_runtime-testing'); +const { LEGACY_HELLO_COMMAND } = require('../../mongodb'); const { setupDatabase } = require('../shared'); const { expect } = require('chai'); diff --git a/test/integration/change-streams/change_stream.test.ts b/test/integration/change-streams/change_stream.test.ts index 2ed1891c2d..fbdc5e4561 100644 --- a/test/integration/change-streams/change_stream.test.ts +++ b/test/integration/change-streams/change_stream.test.ts @@ -22,7 +22,7 @@ import { MongoServerError, ReadPreference, type ResumeToken -} from '../../mongodb_runtime-testing'; +} from '../../mongodb'; import * as mock from '../../tools/mongodb-mock/index'; import { TestBuilder, UnifiedTestSuiteBuilder } from '../../tools/unified_suite_builder'; import { type FailCommandFailPoint, sleep } from '../../tools/utils'; diff --git a/test/integration/change-streams/change_streams.prose.test.ts b/test/integration/change-streams/change_streams.prose.test.ts index e4802da438..d655036b70 100644 --- a/test/integration/change-streams/change_streams.prose.test.ts +++ b/test/integration/change-streams/change_streams.prose.test.ts @@ -16,7 +16,7 @@ import { MongoNetworkError, ObjectId, Timestamp -} from '../../mongodb_runtime-testing'; +} from '../../mongodb'; import * as mock from '../../tools/mongodb-mock/index'; import { setupDatabase } from '../shared'; diff --git a/test/integration/client-side-encryption/client_side_encryption.prose.06.corpus.test.ts b/test/integration/client-side-encryption/client_side_encryption.prose.06.corpus.test.ts index e3b6486e75..357acc49bb 100644 --- a/test/integration/client-side-encryption/client_side_encryption.prose.06.corpus.test.ts +++ b/test/integration/client-side-encryption/client_side_encryption.prose.06.corpus.test.ts @@ -7,7 +7,7 @@ import * as path from 'path'; import * as process from 'process'; import { getCSFLEKMSProviders } from '../../csfle-kms-providers'; -import { ClientEncryption, type MongoClient, WriteConcern } from '../../mongodb_runtime-testing'; +import { ClientEncryption, type MongoClient, WriteConcern } from '../../mongodb'; import { getEncryptExtraOptions } from '../../tools/utils'; describe('Client Side Encryption Prose Corpus Test', function () { diff --git a/test/integration/client-side-encryption/client_side_encryption.prose.10.kms_tls.test.ts b/test/integration/client-side-encryption/client_side_encryption.prose.10.kms_tls.test.ts index 746269c701..c6121eedf3 100644 --- a/test/integration/client-side-encryption/client_side_encryption.prose.10.kms_tls.test.ts +++ b/test/integration/client-side-encryption/client_side_encryption.prose.10.kms_tls.test.ts @@ -3,7 +3,7 @@ import * as process from 'process'; import { satisfies } from 'semver'; import { getCSFLEKMSProviders } from '../../csfle-kms-providers'; -import { ClientEncryption, type MongoClient } from '../../mongodb_runtime-testing'; +import { ClientEncryption, type MongoClient } from '../../mongodb'; const metadata: MongoDBMetadataUI = { requires: { diff --git a/test/integration/client-side-encryption/client_side_encryption.prose.12.deadlock.test.ts b/test/integration/client-side-encryption/client_side_encryption.prose.12.deadlock.test.ts index caab1755ce..2009a787d4 100644 --- a/test/integration/client-side-encryption/client_side_encryption.prose.12.deadlock.test.ts +++ b/test/integration/client-side-encryption/client_side_encryption.prose.12.deadlock.test.ts @@ -9,7 +9,7 @@ import { type CommandStartedEvent, type MongoClient, type MongoClientOptions -} from '../../mongodb_runtime-testing'; +} from '../../mongodb'; import { type TestConfiguration } from '../../tools/runner/config'; import { getEncryptExtraOptions } from '../../tools/utils'; import { dropCollection } from '../shared'; diff --git a/test/integration/client-side-encryption/client_side_encryption.prose.14.decryption_events.test.ts b/test/integration/client-side-encryption/client_side_encryption.prose.14.decryption_events.test.ts index 0c25f5c866..7f4563ff3a 100644 --- a/test/integration/client-side-encryption/client_side_encryption.prose.14.decryption_events.test.ts +++ b/test/integration/client-side-encryption/client_side_encryption.prose.14.decryption_events.test.ts @@ -8,7 +8,7 @@ import { type CommandSucceededEvent, type MongoClient, MongoNetworkError -} from '../../mongodb_runtime-testing'; +} from '../../mongodb'; import { getEncryptExtraOptions } from '../../tools/utils'; const metadata: MongoDBMetadataUI = { diff --git a/test/integration/client-side-encryption/client_side_encryption.prose.17.on_demand_gcp.test.ts b/test/integration/client-side-encryption/client_side_encryption.prose.17.on_demand_gcp.test.ts index e0ab6d2f73..c319b20b89 100644 --- a/test/integration/client-side-encryption/client_side_encryption.prose.17.on_demand_gcp.test.ts +++ b/test/integration/client-side-encryption/client_side_encryption.prose.17.on_demand_gcp.test.ts @@ -1,7 +1,7 @@ import { expect } from 'chai'; import { env } from 'process'; -import { Binary, ClientEncryption } from '../../mongodb_runtime-testing'; +import { Binary, ClientEncryption } from '../../mongodb'; const dataKeyOptions = { masterKey: { projectId: 'devprod-drivers', diff --git a/test/integration/client-side-encryption/client_side_encryption.prose.18.azure_kms_mock_server.test.ts b/test/integration/client-side-encryption/client_side_encryption.prose.18.azure_kms_mock_server.test.ts index bd23b52005..3ceb767922 100644 --- a/test/integration/client-side-encryption/client_side_encryption.prose.18.azure_kms_mock_server.test.ts +++ b/test/integration/client-side-encryption/client_side_encryption.prose.18.azure_kms_mock_server.test.ts @@ -5,7 +5,7 @@ import { type Document, fetchAzureKMSToken, MongoCryptAzureKMSRequestError -} from '../../mongodb_runtime-testing'; +} from '../../mongodb'; const BASE_URL = new URL(`http://127.0.0.1:8080/metadata/identity/oauth2/token`); class KMSRequestOptions implements AzureKMSRequestOptions { url: URL = BASE_URL; diff --git a/test/integration/client-side-encryption/client_side_encryption.prose.19.on_demand_azure.test.ts b/test/integration/client-side-encryption/client_side_encryption.prose.19.on_demand_azure.test.ts index 14dd42a2e7..2c5492739f 100644 --- a/test/integration/client-side-encryption/client_side_encryption.prose.19.on_demand_azure.test.ts +++ b/test/integration/client-side-encryption/client_side_encryption.prose.19.on_demand_azure.test.ts @@ -1,11 +1,7 @@ import { expect } from 'chai'; import { env } from 'process'; -import { - Binary, - ClientEncryption, - MongoCryptAzureKMSRequestError -} from '../../mongodb_runtime-testing'; +import { Binary, ClientEncryption, MongoCryptAzureKMSRequestError } from '../../mongodb'; const dataKeyOptions = { masterKey: { keyVaultEndpoint: 'https://drivers-2411-keyvault.vault.azure.net/', diff --git a/test/integration/client-side-encryption/client_side_encryption.prose.20.mongocryptd_client.test.ts b/test/integration/client-side-encryption/client_side_encryption.prose.20.mongocryptd_client.test.ts index d7e49cfb91..98bd88a9bd 100644 --- a/test/integration/client-side-encryption/client_side_encryption.prose.20.mongocryptd_client.test.ts +++ b/test/integration/client-side-encryption/client_side_encryption.prose.20.mongocryptd_client.test.ts @@ -3,7 +3,7 @@ import { once } from 'events'; import { createServer, type Server } from 'net'; import { getCSFLEKMSProviders } from '../../csfle-kms-providers'; -import { type MongoClient } from '../../mongodb_runtime-testing'; +import { type MongoClient } from '../../mongodb'; import { getEncryptExtraOptions } from '../../tools/utils'; describe('20. Bypass creating mongocryptd client when shared library is loaded', function () { diff --git a/test/integration/client-side-encryption/client_side_encryption.prose.21.automatic_data_encryption_keys.test.ts b/test/integration/client-side-encryption/client_side_encryption.prose.21.automatic_data_encryption_keys.test.ts index d24ec289c7..d7d49d3341 100644 --- a/test/integration/client-side-encryption/client_side_encryption.prose.21.automatic_data_encryption_keys.test.ts +++ b/test/integration/client-side-encryption/client_side_encryption.prose.21.automatic_data_encryption_keys.test.ts @@ -11,7 +11,7 @@ import { type Db, MongoCryptCreateEncryptedCollectionError, MongoServerError -} from '../../mongodb_runtime-testing'; +} from '../../mongodb'; import { ensureTypeByName } from '../../tools/utils'; const metadata: MongoDBMetadataUI = { requires: { diff --git a/test/integration/client-side-encryption/client_side_encryption.prose.22.range_explicit_encryption.test.ts b/test/integration/client-side-encryption/client_side_encryption.prose.22.range_explicit_encryption.test.ts index 8b998d3dbc..6257039008 100644 --- a/test/integration/client-side-encryption/client_side_encryption.prose.22.range_explicit_encryption.test.ts +++ b/test/integration/client-side-encryption/client_side_encryption.prose.22.range_explicit_encryption.test.ts @@ -12,7 +12,7 @@ import { Long, type MongoClient, MongoCryptError -} from '../../mongodb_runtime-testing'; +} from '../../mongodb'; const getKmsProviders = () => { const result = getCSFLEKMSProviders(); diff --git a/test/integration/client-side-encryption/client_side_encryption.prose.23.range_encryption_defaults.test.ts b/test/integration/client-side-encryption/client_side_encryption.prose.23.range_encryption_defaults.test.ts index 309214f4df..97f81e5e33 100644 --- a/test/integration/client-side-encryption/client_side_encryption.prose.23.range_encryption_defaults.test.ts +++ b/test/integration/client-side-encryption/client_side_encryption.prose.23.range_encryption_defaults.test.ts @@ -1,7 +1,7 @@ import { expect } from 'chai'; import { getCSFLEKMSProviders } from '../../csfle-kms-providers'; -import { type Binary, ClientEncryption, Int32, Long } from '../../mongodb_runtime-testing'; +import { type Binary, ClientEncryption, Int32, Long } from '../../mongodb'; const metaData: MongoDBMetadataUI = { requires: { clientSideEncryption: '>=6.1.0', diff --git a/test/integration/client-side-encryption/client_side_encryption.prose.25.lookup.test.ts b/test/integration/client-side-encryption/client_side_encryption.prose.25.lookup.test.ts index 0f9b4154d3..0c873ee1cc 100644 --- a/test/integration/client-side-encryption/client_side_encryption.prose.25.lookup.test.ts +++ b/test/integration/client-side-encryption/client_side_encryption.prose.25.lookup.test.ts @@ -4,7 +4,7 @@ import * as path from 'node:path'; import { expect } from 'chai'; import { getCSFLEKMSProviders } from '../../csfle-kms-providers'; -import { BSON, type Document, type MongoClient } from '../../mongodb_runtime-testing'; +import { BSON, type Document, type MongoClient } from '../../mongodb'; import { type TestConfiguration } from '../../tools/runner/config'; import { getEncryptExtraOptions } from '../../tools/utils'; diff --git a/test/integration/client-side-encryption/client_side_encryption.prose.26.custom_aws_credential_providers.test.ts b/test/integration/client-side-encryption/client_side_encryption.prose.26.custom_aws_credential_providers.test.ts index bc14888827..0a77a06c77 100644 --- a/test/integration/client-side-encryption/client_side_encryption.prose.26.custom_aws_credential_providers.test.ts +++ b/test/integration/client-side-encryption/client_side_encryption.prose.26.custom_aws_credential_providers.test.ts @@ -1,12 +1,7 @@ import { expect } from 'chai'; import * as process from 'process'; -import { - AWSSDKCredentialProvider, - Binary, - ClientEncryption, - MongoClient -} from '../../mongodb_runtime-testing'; +import { AWSSDKCredentialProvider, Binary, ClientEncryption, MongoClient } from '../../mongodb'; import { getEncryptExtraOptions } from '../../tools/utils'; const metadata: MongoDBMetadataUI = { diff --git a/test/integration/client-side-encryption/client_side_encryption.prose.27.text_queries.test.ts b/test/integration/client-side-encryption/client_side_encryption.prose.27.text_queries.test.ts index 9f4107dcda..1159b3360d 100644 --- a/test/integration/client-side-encryption/client_side_encryption.prose.27.text_queries.test.ts +++ b/test/integration/client-side-encryption/client_side_encryption.prose.27.text_queries.test.ts @@ -5,11 +5,7 @@ import { type Binary, type Document, EJSON } from 'bson'; import { expect } from 'chai'; import { getCSFLEKMSProviders } from '../../csfle-kms-providers'; -import { - ClientEncryption, - type MongoClient, - MongoDBCollectionNamespace -} from '../../mongodb_runtime-testing'; +import { ClientEncryption, type MongoClient, MongoDBCollectionNamespace } from '../../mongodb'; const metadata: MongoDBMetadataUI = { requires: { clientSideEncryption: '>=6.4.0', diff --git a/test/integration/client-side-encryption/client_side_encryption.prose.test.ts b/test/integration/client-side-encryption/client_side_encryption.prose.test.ts index c6f541529d..42ed8dcfe0 100644 --- a/test/integration/client-side-encryption/client_side_encryption.prose.test.ts +++ b/test/integration/client-side-encryption/client_side_encryption.prose.test.ts @@ -14,7 +14,7 @@ import { MongoRuntimeError, MongoServerError, MongoServerSelectionError -} from '../../mongodb_runtime-testing'; +} from '../../mongodb'; import { AlpineTestConfiguration } from '../../tools/runner/config'; import { getEncryptExtraOptions } from '../../tools/utils'; import { APMEventCollector, dropCollection } from '../shared'; diff --git a/test/integration/client-side-encryption/driver.test.ts b/test/integration/client-side-encryption/driver.test.ts index a761022cba..65592e9f37 100644 --- a/test/integration/client-side-encryption/driver.test.ts +++ b/test/integration/client-side-encryption/driver.test.ts @@ -22,7 +22,7 @@ import { resolveTimeoutOptions, StateMachine, TimeoutContext -} from '../../mongodb_runtime-testing'; +} from '../../mongodb'; import { clearFailPoint, configureFailPoint, diff --git a/test/integration/client-side-operations-timeout/client_side_operations_timeout.prose.test.ts b/test/integration/client-side-operations-timeout/client_side_operations_timeout.prose.test.ts index c3dbde8127..a00601a0f2 100644 --- a/test/integration/client-side-operations-timeout/client_side_operations_timeout.prose.test.ts +++ b/test/integration/client-side-operations-timeout/client_side_operations_timeout.prose.test.ts @@ -20,7 +20,7 @@ import { ObjectId, processTimeMS, squashError -} from '../../mongodb_runtime-testing'; +} from '../../mongodb'; import { clearFailPoint, configureFailPoint, diff --git a/test/integration/client-side-operations-timeout/client_side_operations_timeout.unit.test.ts b/test/integration/client-side-operations-timeout/client_side_operations_timeout.unit.test.ts index c9c314416b..10ecbe3629 100644 --- a/test/integration/client-side-operations-timeout/client_side_operations_timeout.unit.test.ts +++ b/test/integration/client-side-operations-timeout/client_side_operations_timeout.unit.test.ts @@ -21,7 +21,7 @@ import { Timeout, TimeoutContext, Topology -} from '../../mongodb_runtime-testing'; +} from '../../mongodb'; import { measureDuration, sleep } from '../../tools/utils'; import { createTimerSandbox } from '../../unit/timer_sandbox'; diff --git a/test/integration/client-side-operations-timeout/node_csot.test.ts b/test/integration/client-side-operations-timeout/node_csot.test.ts index 613084f114..7aad267083 100644 --- a/test/integration/client-side-operations-timeout/node_csot.test.ts +++ b/test/integration/client-side-operations-timeout/node_csot.test.ts @@ -30,7 +30,7 @@ import { ObjectId, promiseWithResolvers, TopologyType -} from '../../mongodb_runtime-testing'; +} from '../../mongodb'; import { type FailCommandFailPoint, type FailPoint, waitUntilPoolsFilled } from '../../tools/utils'; const metadata = { requires: { mongodb: '>=4.4' } }; diff --git a/test/integration/collection-management/collection.test.ts b/test/integration/collection-management/collection.test.ts index 4eb8d01247..4a4b4b532d 100644 --- a/test/integration/collection-management/collection.test.ts +++ b/test/integration/collection-management/collection.test.ts @@ -1,11 +1,6 @@ import { expect } from 'chai'; -import { - Collection, - type Db, - type MongoClient, - MongoServerError -} from '../../mongodb_runtime-testing'; +import { Collection, type Db, type MongoClient, MongoServerError } from '../../mongodb'; import { type TestConfiguration } from '../../tools/runner/config'; import { type FailCommandFailPoint } from '../../tools/utils'; import { setupDatabase } from '../shared'; diff --git a/test/integration/collection-management/collection_db_management.test.ts b/test/integration/collection-management/collection_db_management.test.ts index 6c03d8850d..327c7f4113 100644 --- a/test/integration/collection-management/collection_db_management.test.ts +++ b/test/integration/collection-management/collection_db_management.test.ts @@ -1,6 +1,6 @@ import { expect } from 'chai'; -import { Collection, type Db, type MongoClient, ObjectId } from '../../mongodb_runtime-testing'; +import { Collection, type Db, type MongoClient, ObjectId } from '../../mongodb'; describe('Collection Management and Db Management', function () { let client: MongoClient; diff --git a/test/integration/collection-management/view.test.ts b/test/integration/collection-management/view.test.ts index ab4029356b..88b30d03f3 100644 --- a/test/integration/collection-management/view.test.ts +++ b/test/integration/collection-management/view.test.ts @@ -1,6 +1,6 @@ import { expect } from 'chai'; -import { type CollectionInfo, type Db, type MongoClient } from '../../mongodb_runtime-testing'; +import { type CollectionInfo, type Db, type MongoClient } from '../../mongodb'; describe('Views', function () { let client: MongoClient; diff --git a/test/integration/command-logging-and-monitoring/command_logging_and_monitoring.prose.test.ts b/test/integration/command-logging-and-monitoring/command_logging_and_monitoring.prose.test.ts index 0e3f8600ed..5417a51688 100644 --- a/test/integration/command-logging-and-monitoring/command_logging_and_monitoring.prose.test.ts +++ b/test/integration/command-logging-and-monitoring/command_logging_and_monitoring.prose.test.ts @@ -1,6 +1,6 @@ import { expect } from 'chai'; -import { DEFAULT_MAX_DOCUMENT_LENGTH, type Document } from '../../mongodb_runtime-testing'; +import { DEFAULT_MAX_DOCUMENT_LENGTH, type Document } from '../../mongodb'; describe('Command Logging and Monitoring Prose Tests', function () { const ELLIPSES_LENGTH = 3; let client; diff --git a/test/integration/command-logging-and-monitoring/command_monitoring.test.ts b/test/integration/command-logging-and-monitoring/command_monitoring.test.ts index 6d383d447a..9242770d46 100644 --- a/test/integration/command-logging-and-monitoring/command_monitoring.test.ts +++ b/test/integration/command-logging-and-monitoring/command_monitoring.test.ts @@ -1,6 +1,6 @@ import { expect } from 'chai'; -import { type MongoClient, ObjectId, ReadPreference } from '../../mongodb_runtime-testing'; +import { type MongoClient, ObjectId, ReadPreference } from '../../mongodb'; import { filterForCommands, setupDatabase } from '../shared'; describe('Command Monitoring', function () { diff --git a/test/integration/connection-monitoring-and-pooling/connection.test.ts b/test/integration/connection-monitoring-and-pooling/connection.test.ts index ae89bfe7d1..0a1dc572bc 100644 --- a/test/integration/connection-monitoring-and-pooling/connection.test.ts +++ b/test/integration/connection-monitoring-and-pooling/connection.test.ts @@ -21,7 +21,7 @@ import { ns, ServerHeartbeatStartedEvent, Topology -} from '../../mongodb_runtime-testing'; +} from '../../mongodb'; import * as mock from '../../tools/mongodb-mock/index'; import { processTick, runtime, sleep } from '../../tools/utils'; import { assert as test, setupDatabase } from '../shared'; diff --git a/test/integration/connection-monitoring-and-pooling/connection_pool.test.ts b/test/integration/connection-monitoring-and-pooling/connection_pool.test.ts index c377abdebf..d073b5a112 100644 --- a/test/integration/connection-monitoring-and-pooling/connection_pool.test.ts +++ b/test/integration/connection-monitoring-and-pooling/connection_pool.test.ts @@ -8,7 +8,7 @@ import { type Db, type MongoClient, type Server -} from '../../mongodb_runtime-testing'; +} from '../../mongodb'; import { clearFailPoint, configureFailPoint, sleep } from '../../tools/utils'; describe('Connection Pool', function () { diff --git a/test/integration/connection-monitoring-and-pooling/rtt_pinger.test.ts b/test/integration/connection-monitoring-and-pooling/rtt_pinger.test.ts index 7acce6b6a1..5b659290ef 100644 --- a/test/integration/connection-monitoring-and-pooling/rtt_pinger.test.ts +++ b/test/integration/connection-monitoring-and-pooling/rtt_pinger.test.ts @@ -7,7 +7,7 @@ import { LEGACY_HELLO_COMMAND, type MongoClient, type RTTPinger -} from '../../mongodb_runtime-testing'; +} from '../../mongodb'; import { sleep } from '../../tools/utils'; /** diff --git a/test/integration/connections-survive-step-down/connections_survive_step_down.prose.test.ts b/test/integration/connections-survive-step-down/connections_survive_step_down.prose.test.ts index 70801d9d73..3ba24d9587 100644 --- a/test/integration/connections-survive-step-down/connections_survive_step_down.prose.test.ts +++ b/test/integration/connections-survive-step-down/connections_survive_step_down.prose.test.ts @@ -8,7 +8,7 @@ import { MONGODB_ERROR_CODES, MongoServerError, ReadPreference -} from '../../mongodb_runtime-testing'; +} from '../../mongodb'; import { type FailCommandFailPoint } from '../../tools/utils'; describe('Connections Survive Primary Step Down - prose', function () { diff --git a/test/integration/crud/abstract_operation.test.ts b/test/integration/crud/abstract_operation.test.ts index 6f2c1e975f..777e2a38fc 100644 --- a/test/integration/crud/abstract_operation.test.ts +++ b/test/integration/crud/abstract_operation.test.ts @@ -48,7 +48,7 @@ import { UpdateOperation, UpdateSearchIndexOperation, ValidateCollectionOperation -} from '../../mongodb_runtime-testing'; +} from '../../mongodb'; describe('abstract operation', function () { describe('command name getter', function () { diff --git a/test/integration/crud/aggregation.test.ts b/test/integration/crud/aggregation.test.ts index eafeffd565..915d9c9de3 100644 --- a/test/integration/crud/aggregation.test.ts +++ b/test/integration/crud/aggregation.test.ts @@ -1,10 +1,6 @@ import { expect } from 'chai'; -import { - type MongoClient, - MongoInvalidArgumentError, - MongoServerError -} from '../../mongodb_runtime-testing'; +import { type MongoClient, MongoInvalidArgumentError, MongoServerError } from '../../mongodb'; import { filterForCommands } from '../shared'; describe('Aggregation', function () { diff --git a/test/integration/crud/bulk.test.ts b/test/integration/crud/bulk.test.ts index 9a13e6aab2..0f8ae3ae60 100644 --- a/test/integration/crud/bulk.test.ts +++ b/test/integration/crud/bulk.test.ts @@ -11,7 +11,7 @@ import { type MongoClient, MongoDriverError, MongoInvalidArgumentError -} from '../../mongodb_runtime-testing'; +} from '../../mongodb'; import { assert as test } from '../shared'; const MAX_BSON_SIZE = 16777216; diff --git a/test/integration/crud/client_bulk_write.test.ts b/test/integration/crud/client_bulk_write.test.ts index b288e529f7..acb05b2e01 100644 --- a/test/integration/crud/client_bulk_write.test.ts +++ b/test/integration/crud/client_bulk_write.test.ts @@ -9,7 +9,7 @@ import { MongoOperationTimeoutError, processTimeMS, TimeoutContext -} from '../../mongodb_runtime-testing'; +} from '../../mongodb'; import { clearFailPoint, configureFailPoint, diff --git a/test/integration/crud/crud.prose.test.ts b/test/integration/crud/crud.prose.test.ts index f018381d87..302abeb247 100644 --- a/test/integration/crud/crud.prose.test.ts +++ b/test/integration/crud/crud.prose.test.ts @@ -12,7 +12,7 @@ import { MongoClientBulkWriteError, MongoInvalidArgumentError, MongoServerError -} from '../../mongodb_runtime-testing'; +} from '../../mongodb'; import { getEncryptExtraOptions } from '../../tools/utils'; import { filterForCommands } from '../shared'; diff --git a/test/integration/crud/crud_api.test.ts b/test/integration/crud/crud_api.test.ts index c00f0f4c7c..b174a5b660 100644 --- a/test/integration/crud/crud_api.test.ts +++ b/test/integration/crud/crud_api.test.ts @@ -14,7 +14,7 @@ import { MongoServerError, ObjectId, ReturnDocument -} from '../../mongodb_runtime-testing'; +} from '../../mongodb'; import { ensureTypeByName, type FailCommandFailPoint } from '../../tools/utils'; import { assert as test } from '../shared'; diff --git a/test/integration/crud/document_validation.test.ts b/test/integration/crud/document_validation.test.ts index 75da7b91df..4ef0f8e946 100644 --- a/test/integration/crud/document_validation.test.ts +++ b/test/integration/crud/document_validation.test.ts @@ -1,10 +1,6 @@ import { expect } from 'chai'; -import { - MongoBulkWriteError, - type MongoClient, - MongoServerError -} from '../../mongodb_runtime-testing'; +import { MongoBulkWriteError, type MongoClient, MongoServerError } from '../../mongodb'; import { setupDatabase } from '../shared'; describe('Document Validation', function () { diff --git a/test/integration/crud/explain.test.ts b/test/integration/crud/explain.test.ts index 4ac6f0bde9..8236cbf00e 100644 --- a/test/integration/crud/explain.test.ts +++ b/test/integration/crud/explain.test.ts @@ -9,7 +9,7 @@ import { type MongoClient, MongoOperationTimeoutError, MongoServerError -} from '../../mongodb_runtime-testing'; +} from '../../mongodb'; import { clearFailPoint, configureFailPoint, measureDuration } from '../../tools/utils'; import { filterForCommands } from '../shared'; diff --git a/test/integration/crud/find.test.ts b/test/integration/crud/find.test.ts index 36f565e09b..bb6fc2146e 100644 --- a/test/integration/crud/find.test.ts +++ b/test/integration/crud/find.test.ts @@ -9,7 +9,7 @@ import { MongoServerError, ObjectId, ReturnDocument -} from '../../mongodb_runtime-testing'; +} from '../../mongodb'; import { assert as test, filterForCommands } from '../shared'; describe('Find', function () { diff --git a/test/integration/crud/find_and_modify.test.ts b/test/integration/crud/find_and_modify.test.ts index c437849e6d..524ad7b06a 100644 --- a/test/integration/crud/find_and_modify.test.ts +++ b/test/integration/crud/find_and_modify.test.ts @@ -6,7 +6,7 @@ import { type MongoClient, MongoServerError, ObjectId -} from '../../mongodb_runtime-testing'; +} from '../../mongodb'; import { setupDatabase } from '../shared'; describe('Collection (#findOneAnd...)', function () { diff --git a/test/integration/crud/find_cursor_methods.test.ts b/test/integration/crud/find_cursor_methods.test.ts index 566ef09c01..fd2b66f679 100644 --- a/test/integration/crud/find_cursor_methods.test.ts +++ b/test/integration/crud/find_cursor_methods.test.ts @@ -9,7 +9,7 @@ import { MongoCursorExhaustedError, promiseWithResolvers, TimeoutContext -} from '../../mongodb_runtime-testing'; +} from '../../mongodb'; import { filterForCommands } from '../shared'; describe('Find Cursor', function () { diff --git a/test/integration/crud/insert.test.ts b/test/integration/crud/insert.test.ts index b16e5fa2e2..b649d6a5b5 100644 --- a/test/integration/crud/insert.test.ts +++ b/test/integration/crud/insert.test.ts @@ -23,7 +23,7 @@ import { ObjectId, ReturnDocument, Timestamp -} from '../../mongodb_runtime-testing'; +} from '../../mongodb'; import { assert as test, setupDatabase } from '../shared'; describe('crud - insert', function () { diff --git a/test/integration/crud/maxTimeMS.test.ts b/test/integration/crud/maxTimeMS.test.ts index b681068bd5..f4d83ddc2f 100644 --- a/test/integration/crud/maxTimeMS.test.ts +++ b/test/integration/crud/maxTimeMS.test.ts @@ -8,7 +8,7 @@ import { type MongoClient, MongoCursorExhaustedError, MongoServerError -} from '../../mongodb_runtime-testing'; +} from '../../mongodb'; describe('MaxTimeMS', function () { let client: MongoClient; diff --git a/test/integration/crud/misc_cursors.test.ts b/test/integration/crud/misc_cursors.test.ts index b15f913caa..0fb7539774 100644 --- a/test/integration/crud/misc_cursors.test.ts +++ b/test/integration/crud/misc_cursors.test.ts @@ -7,7 +7,7 @@ import { MongoClientClosedError, ReadPreference, ServerType -} from '../../mongodb_runtime-testing'; +} from '../../mongodb'; import { ensureTypeByName, runLater, sleep } from '../../tools/utils'; import { assert as test, filterForCommands, setupDatabase } from '../shared'; diff --git a/test/integration/crud/remove.test.ts b/test/integration/crud/remove.test.ts index fc7bca60fe..6e5ea8b41d 100644 --- a/test/integration/crud/remove.test.ts +++ b/test/integration/crud/remove.test.ts @@ -1,6 +1,6 @@ import { expect } from 'chai'; -import { type MongoClient } from '../../mongodb_runtime-testing'; +import { type MongoClient } from '../../mongodb'; describe('Remove', function () { let client: MongoClient; diff --git a/test/integration/crud/server_errors.test.ts b/test/integration/crud/server_errors.test.ts index dcf5859e40..b3f0191e07 100644 --- a/test/integration/crud/server_errors.test.ts +++ b/test/integration/crud/server_errors.test.ts @@ -1,6 +1,6 @@ import { expect } from 'chai'; -import { type MongoClient, MongoServerError } from '../../mongodb_runtime-testing'; +import { type MongoClient, MongoServerError } from '../../mongodb'; import { setupDatabase } from '../shared'; describe('Errors', function () { diff --git a/test/integration/crud/stats.test.ts b/test/integration/crud/stats.test.ts index a1fa060736..aadb9dedac 100644 --- a/test/integration/crud/stats.test.ts +++ b/test/integration/crud/stats.test.ts @@ -1,6 +1,6 @@ import { expect } from 'chai'; -import { type MongoClient } from '../../mongodb_runtime-testing'; +import { type MongoClient } from '../../mongodb'; describe('stats', function () { let client: MongoClient; diff --git a/test/integration/crud/unicode.test.ts b/test/integration/crud/unicode.test.ts index 671c63e542..8d4e898f2a 100644 --- a/test/integration/crud/unicode.test.ts +++ b/test/integration/crud/unicode.test.ts @@ -2,7 +2,7 @@ import { expect } from 'chai'; import * as process from 'process'; import { satisfies } from 'semver'; -import type { MongoClient } from '../../mongodb_runtime-testing'; +import type { MongoClient } from '../../mongodb'; import { assert as test, setupDatabase } from '../shared'; describe('Unicode', function () { diff --git a/test/integration/enumerate_databases.prose.test.ts b/test/integration/enumerate_databases.prose.test.ts index 154eb26079..9528d68fad 100644 --- a/test/integration/enumerate_databases.prose.test.ts +++ b/test/integration/enumerate_databases.prose.test.ts @@ -1,6 +1,6 @@ import { expect } from 'chai'; -import type { MongoClient } from '../mongodb_runtime-testing'; +import type { MongoClient } from '../mongodb'; const REQUIRED_DBS = ['admin', 'local', 'config']; const DB_NAME = 'listDatabasesTest'; diff --git a/test/integration/enumerate_databases.test.ts b/test/integration/enumerate_databases.test.ts index f6d8311edb..0b52ade130 100644 --- a/test/integration/enumerate_databases.test.ts +++ b/test/integration/enumerate_databases.test.ts @@ -1,7 +1,7 @@ import { expect } from 'chai'; import { once } from 'events'; -import { type MongoClient, MongoServerError } from '../mongodb_runtime-testing'; +import { type MongoClient, MongoServerError } from '../mongodb'; import { TestBuilder, UnifiedTestSuiteBuilder } from '../tools/unified_suite_builder'; const metadata: MongoDBMetadataUI = { diff --git a/test/integration/gridfs/gridfs.test.ts b/test/integration/gridfs/gridfs.test.ts index a03e25a891..20ac793e80 100644 --- a/test/integration/gridfs/gridfs.test.ts +++ b/test/integration/gridfs/gridfs.test.ts @@ -8,7 +8,7 @@ import { GridFSBucket, type MongoClient, ObjectId -} from '../../mongodb_runtime-testing'; +} from '../../mongodb'; import { sleep } from '../../tools/utils'; describe('GridFS', () => { diff --git a/test/integration/gridfs/gridfs_stream.test.ts b/test/integration/gridfs/gridfs_stream.test.ts index 5174d74def..df34a239a6 100644 --- a/test/integration/gridfs/gridfs_stream.test.ts +++ b/test/integration/gridfs/gridfs_stream.test.ts @@ -7,13 +7,7 @@ import { promisify } from 'node:util'; import { expect } from 'chai'; import * as sinon from 'sinon'; -import { - type Db, - GridFSBucket, - MongoAPIError, - type MongoClient, - ObjectId -} from '../../mongodb_runtime-testing'; +import { type Db, GridFSBucket, MongoAPIError, type MongoClient, ObjectId } from '../../mongodb'; describe('GridFS Stream', function () { let client: MongoClient; diff --git a/test/integration/index-management/search-index-management.test.ts b/test/integration/index-management/search-index-management.test.ts index e85422e065..39d17f2281 100644 --- a/test/integration/index-management/search-index-management.test.ts +++ b/test/integration/index-management/search-index-management.test.ts @@ -1,10 +1,6 @@ import { expect } from 'chai'; -import { - type Collection, - type CommandStartedEvent, - type MongoClient -} from '../../mongodb_runtime-testing'; +import { type Collection, type CommandStartedEvent, type MongoClient } from '../../mongodb'; describe('Search Index Management Integration Tests', function () { describe('read concern and write concern ', function () { diff --git a/test/integration/initial-dns-seedlist-discovery/dns_seedlist.test.ts b/test/integration/initial-dns-seedlist-discovery/dns_seedlist.test.ts index 97e649e4b2..a27172c574 100644 --- a/test/integration/initial-dns-seedlist-discovery/dns_seedlist.test.ts +++ b/test/integration/initial-dns-seedlist-discovery/dns_seedlist.test.ts @@ -2,7 +2,7 @@ import { expect } from 'chai'; import * as dns from 'dns'; import * as sinon from 'sinon'; -import { MongoClient } from '../../mongodb_runtime-testing'; +import { MongoClient } from '../../mongodb'; const metadata: MongoDBMetadataUI = { requires: { topology: '!single', tls: 'disabled' } }; diff --git a/test/integration/initial-dns-seedlist-discovery/initial_dns_seedlist_discovery.prose.test.ts b/test/integration/initial-dns-seedlist-discovery/initial_dns_seedlist_discovery.prose.test.ts index 185f111f77..3f931c019c 100644 --- a/test/integration/initial-dns-seedlist-discovery/initial_dns_seedlist_discovery.prose.test.ts +++ b/test/integration/initial-dns-seedlist-discovery/initial_dns_seedlist_discovery.prose.test.ts @@ -2,13 +2,7 @@ import { expect } from 'chai'; import * as dns from 'dns'; import * as sinon from 'sinon'; -import { - ConnectionPool, - MongoAPIError, - Server, - ServerDescription, - Topology -} from '../../mongodb_runtime-testing'; +import { ConnectionPool, MongoAPIError, Server, ServerDescription, Topology } from '../../mongodb'; import { topologyWithPlaceholderClient } from '../../tools/utils'; describe('Initial DNS Seedlist Discovery (Prose Tests)', () => { diff --git a/test/integration/initial-dns-seedlist-discovery/initial_dns_seedlist_discovery.spec.test.ts b/test/integration/initial-dns-seedlist-discovery/initial_dns_seedlist_discovery.spec.test.ts index 9fa8510852..141c5d6fe5 100644 --- a/test/integration/initial-dns-seedlist-discovery/initial_dns_seedlist_discovery.spec.test.ts +++ b/test/integration/initial-dns-seedlist-discovery/initial_dns_seedlist_discovery.spec.test.ts @@ -4,7 +4,7 @@ import * as fs from 'fs'; import * as path from 'path'; import { promisify } from 'util'; -import { HostAddress, MongoClient } from '../../mongodb_runtime-testing'; +import { HostAddress, MongoClient } from '../../mongodb'; function makeTest(test, topology) { let client; diff --git a/test/integration/max-staleness/max_staleness.test.js b/test/integration/max-staleness/max_staleness.test.js index cb876c2dd8..b555eb16ce 100644 --- a/test/integration/max-staleness/max_staleness.test.js +++ b/test/integration/max-staleness/max_staleness.test.js @@ -2,8 +2,8 @@ const { Long } = require('bson'); const { expect } = require('chai'); const mock = require('../../tools/mongodb-mock/index'); -const { ReadPreference } = require('../../mongodb_runtime-testing'); -const { isHello } = require('../../mongodb_runtime-testing'); +const { ReadPreference } = require('../../mongodb'); +const { isHello } = require('../../mongodb'); const test = {}; // TODO (NODE-3799): convert these to run against a real server diff --git a/test/integration/mongodb-handshake/mongodb-handshake.prose.test.ts b/test/integration/mongodb-handshake/mongodb-handshake.prose.test.ts index b643c64c76..6b9dad6099 100644 --- a/test/integration/mongodb-handshake/mongodb-handshake.prose.test.ts +++ b/test/integration/mongodb-handshake/mongodb-handshake.prose.test.ts @@ -11,7 +11,7 @@ import { isDriverInfoEqual, LEGACY_HELLO_COMMAND, type MongoClient -} from '../../mongodb_runtime-testing'; +} from '../../mongodb'; import { sleep } from '../../tools/utils'; type EnvironmentVariables = Array<[string, string]>; diff --git a/test/integration/mongodb-handshake/mongodb-handshake.test.ts b/test/integration/mongodb-handshake/mongodb-handshake.test.ts index a7b162f4c0..528fb0d1c4 100644 --- a/test/integration/mongodb-handshake/mongodb-handshake.test.ts +++ b/test/integration/mongodb-handshake/mongodb-handshake.test.ts @@ -9,7 +9,7 @@ import { OpMsgRequest, OpQueryRequest, ServerApiVersion -} from '../../mongodb_runtime-testing'; +} from '../../mongodb'; describe('MongoDB Handshake', () => { let client; diff --git a/test/integration/node-specific/abort_signal.test.ts b/test/integration/node-specific/abort_signal.test.ts index 85bdf4762f..6cec61ec39 100644 --- a/test/integration/node-specific/abort_signal.test.ts +++ b/test/integration/node-specific/abort_signal.test.ts @@ -22,7 +22,7 @@ import { ReadPreference, setDifference, StateMachine -} from '../../mongodb_runtime-testing'; +} from '../../mongodb'; import { clearFailPoint, configureFailPoint, diff --git a/test/integration/node-specific/abstract_cursor.test.ts b/test/integration/node-specific/abstract_cursor.test.ts index 8da033447a..3a39cfe03e 100644 --- a/test/integration/node-specific/abstract_cursor.test.ts +++ b/test/integration/node-specific/abstract_cursor.test.ts @@ -16,7 +16,7 @@ import { MongoCursorExhaustedError, MongoOperationTimeoutError, TimeoutContext -} from '../../mongodb_runtime-testing'; +} from '../../mongodb'; import { clearFailPoint, configureFailPoint } from '../../tools/utils'; import { filterForCommands } from '../shared'; diff --git a/test/integration/node-specific/async_dispose.test.ts b/test/integration/node-specific/async_dispose.test.ts index 223df65dbd..729b665455 100644 --- a/test/integration/node-specific/async_dispose.test.ts +++ b/test/integration/node-specific/async_dispose.test.ts @@ -1,7 +1,7 @@ import { expect } from 'chai'; import * as sinon from 'sinon'; -import { type MongoClient } from '../../mongodb_runtime-testing'; +import { type MongoClient } from '../../mongodb'; describe('Symbol.asyncDispose implementation tests', function () { let client: MongoClient; diff --git a/test/integration/node-specific/auto_connect.test.ts b/test/integration/node-specific/auto_connect.test.ts index c92a3d46e2..f085004963 100644 --- a/test/integration/node-specific/auto_connect.test.ts +++ b/test/integration/node-specific/auto_connect.test.ts @@ -12,7 +12,7 @@ import { ProfilingLevel, Topology, TopologyType -} from '../../mongodb_runtime-testing'; +} from '../../mongodb'; import { sleep } from '../../tools/utils'; describe('When executing an operation for the first time', () => { diff --git a/test/integration/node-specific/auto_encrypter.test.ts b/test/integration/node-specific/auto_encrypter.test.ts index 2d28acb90d..1f29951e1b 100644 --- a/test/integration/node-specific/auto_encrypter.test.ts +++ b/test/integration/node-specific/auto_encrypter.test.ts @@ -9,7 +9,7 @@ import { MongoRuntimeError, StateMachine, type UUID -} from '../../mongodb_runtime-testing'; +} from '../../mongodb'; describe('mongocryptd auto spawn', function () { let client: MongoClient; const kmsProviders: KMSProviders = { diff --git a/test/integration/node-specific/bson-options/bsonRegExp.test.ts b/test/integration/node-specific/bson-options/bsonRegExp.test.ts index bd9636dc58..d1c06f538c 100644 --- a/test/integration/node-specific/bson-options/bsonRegExp.test.ts +++ b/test/integration/node-specific/bson-options/bsonRegExp.test.ts @@ -1,6 +1,6 @@ import { expect } from 'chai'; -import { BSONRegExp, type MongoClient } from '../../../mongodb_runtime-testing'; +import { BSONRegExp, type MongoClient } from '../../../mongodb'; describe('BSONRegExp', () => { describe('bsonRegExp option', () => { diff --git a/test/integration/node-specific/bson-options/ignore_undefined.test.ts b/test/integration/node-specific/bson-options/ignore_undefined.test.ts index 83fe2b0972..0cbcf43b9c 100644 --- a/test/integration/node-specific/bson-options/ignore_undefined.test.ts +++ b/test/integration/node-specific/bson-options/ignore_undefined.test.ts @@ -1,6 +1,6 @@ import { expect } from 'chai'; -import { type MongoClient, ObjectId } from '../../../mongodb_runtime-testing'; +import { type MongoClient, ObjectId } from '../../../mongodb'; import { assert as test, setupDatabase } from '../../shared'; describe('Ignore Undefined', function () { diff --git a/test/integration/node-specific/bson-options/promote_values.test.ts b/test/integration/node-specific/bson-options/promote_values.test.ts index fa2d4d98cb..6be7e9960c 100644 --- a/test/integration/node-specific/bson-options/promote_values.test.ts +++ b/test/integration/node-specific/bson-options/promote_values.test.ts @@ -1,6 +1,6 @@ import { expect } from 'chai'; -import { Double, Int32, Long } from '../../../mongodb_runtime-testing'; +import { Double, Int32, Long } from '../../../mongodb'; import { assert as test, setupDatabase } from '../../shared'; describe('Promote Values', function () { diff --git a/test/integration/node-specific/bson-options/raw.test.ts b/test/integration/node-specific/bson-options/raw.test.ts index 85b740f2ba..455344f9a9 100644 --- a/test/integration/node-specific/bson-options/raw.test.ts +++ b/test/integration/node-specific/bson-options/raw.test.ts @@ -1,6 +1,6 @@ import { expect } from 'chai'; -import { type Collection, type MongoClient, ObjectId } from '../../../mongodb_runtime-testing'; +import { type Collection, type MongoClient, ObjectId } from '../../../mongodb'; describe('raw bson support', () => { describe('raw', () => { diff --git a/test/integration/node-specific/bson-options/use_bigint_64.test.ts b/test/integration/node-specific/bson-options/use_bigint_64.test.ts index 78070ebe0f..8adec9807d 100644 --- a/test/integration/node-specific/bson-options/use_bigint_64.test.ts +++ b/test/integration/node-specific/bson-options/use_bigint_64.test.ts @@ -9,7 +9,7 @@ import { MongoAPIError, type MongoClient, type WithId -} from '../../../mongodb_runtime-testing'; +} from '../../../mongodb'; describe('useBigInt64 option', function () { let client: MongoClient; let db: Db; diff --git a/test/integration/node-specific/bson-options/utf8_validation.test.ts b/test/integration/node-specific/bson-options/utf8_validation.test.ts index 31d5af7c49..e9920834bd 100644 --- a/test/integration/node-specific/bson-options/utf8_validation.test.ts +++ b/test/integration/node-specific/bson-options/utf8_validation.test.ts @@ -10,7 +10,7 @@ import { type MongoClient, MongoServerError, OpMsgResponse -} from '../../../mongodb_runtime-testing'; +} from '../../../mongodb'; describe('class MongoDBResponse', () => { let client; diff --git a/test/integration/node-specific/client_close.test.ts b/test/integration/node-specific/client_close.test.ts index 887f724ae6..98053aa0af 100644 --- a/test/integration/node-specific/client_close.test.ts +++ b/test/integration/node-specific/client_close.test.ts @@ -9,7 +9,7 @@ import { type CommandStartedEvent, type FindCursor, type MongoClient -} from '../../mongodb_runtime-testing'; +} from '../../mongodb'; import { configureMongocryptdSpawnHooks } from '../../tools/utils'; import { filterForCommands } from '../shared'; import { runScriptAndGetProcessInfo } from './resource_tracking_script_builder'; diff --git a/test/integration/node-specific/client_encryption.test.ts b/test/integration/node-specific/client_encryption.test.ts index c171f17f93..033b27e08f 100644 --- a/test/integration/node-specific/client_encryption.test.ts +++ b/test/integration/node-specific/client_encryption.test.ts @@ -14,7 +14,7 @@ import { MongoCryptInvalidArgumentError, StateMachine, UUID -} from '../../mongodb_runtime-testing'; +} from '../../mongodb'; function readHttpResponse(path) { let data = readFileSync(path, 'utf8').toString(); data = data.split('\n').join('\r\n'); diff --git a/test/integration/node-specific/comment_with_falsy_values.test.ts b/test/integration/node-specific/comment_with_falsy_values.test.ts index 74d6e9a1aa..6d0819fd33 100644 --- a/test/integration/node-specific/comment_with_falsy_values.test.ts +++ b/test/integration/node-specific/comment_with_falsy_values.test.ts @@ -1,11 +1,6 @@ import { expect } from 'chai'; -import { - type Collection, - type CommandStartedEvent, - Long, - type MongoClient -} from '../../mongodb_runtime-testing'; +import { type Collection, type CommandStartedEvent, Long, type MongoClient } from '../../mongodb'; import { TestBuilder, UnifiedTestSuiteBuilder } from '../../tools/unified_suite_builder'; const falsyValues = [0, false, '', Long.ZERO, null, NaN] as const; diff --git a/test/integration/node-specific/convert_socket_errors.test.ts b/test/integration/node-specific/convert_socket_errors.test.ts index 4b2772af8f..e13a216711 100644 --- a/test/integration/node-specific/convert_socket_errors.test.ts +++ b/test/integration/node-specific/convert_socket_errors.test.ts @@ -10,7 +10,7 @@ import { type MongoClient, MongoNetworkError, ns -} from '../../mongodb_runtime-testing'; +} from '../../mongodb'; import { clearFailPoint, configureFailPoint } from '../../tools/utils'; import { filterForCommands } from '../shared'; diff --git a/test/integration/node-specific/crypt_shared_lib.test.ts b/test/integration/node-specific/crypt_shared_lib.test.ts index 28bdbcaba9..5020e8579d 100644 --- a/test/integration/node-specific/crypt_shared_lib.test.ts +++ b/test/integration/node-specific/crypt_shared_lib.test.ts @@ -3,7 +3,7 @@ import { spawnSync } from 'child_process'; import { dirname } from 'path'; import * as process from 'process'; -import { EJSON } from '../../mongodb_runtime-testing'; +import { EJSON } from '../../mongodb'; import { getEncryptExtraOptions } from '../../tools/utils'; describe('crypt shared library', () => { diff --git a/test/integration/node-specific/cursor_stream.test.ts b/test/integration/node-specific/cursor_stream.test.ts index cc6eb0ec9c..4181b1c025 100644 --- a/test/integration/node-specific/cursor_stream.test.ts +++ b/test/integration/node-specific/cursor_stream.test.ts @@ -10,7 +10,7 @@ import { type Db, type MongoClient, MongoServerError -} from '../../mongodb_runtime-testing'; +} from '../../mongodb'; import { sleep } from '../../tools/utils'; describe('Cursor Streams', function () { diff --git a/test/integration/node-specific/db.test.ts b/test/integration/node-specific/db.test.ts index 7ac960353a..6b8541667e 100644 --- a/test/integration/node-specific/db.test.ts +++ b/test/integration/node-specific/db.test.ts @@ -6,7 +6,7 @@ import { MongoClient, MongoInvalidArgumentError, MongoServerError -} from '../../mongodb_runtime-testing'; +} from '../../mongodb'; import { setupDatabase } from '../shared'; describe('Db', function () { diff --git a/test/integration/node-specific/errors.test.ts b/test/integration/node-specific/errors.test.ts index abeecf5365..ff00db6564 100644 --- a/test/integration/node-specific/errors.test.ts +++ b/test/integration/node-specific/errors.test.ts @@ -1,10 +1,6 @@ import { expect } from 'chai'; -import { - MongoClient, - MongoServerSelectionError, - ReadPreference -} from '../../mongodb_runtime-testing'; +import { MongoClient, MongoServerSelectionError, ReadPreference } from '../../mongodb'; describe('Error (Integration)', function () { it('NODE-5296: handles aggregate errors from dns lookup', async function () { diff --git a/test/integration/node-specific/ipv6.test.ts b/test/integration/node-specific/ipv6.test.ts index 253fcb8957..1353415817 100644 --- a/test/integration/node-specific/ipv6.test.ts +++ b/test/integration/node-specific/ipv6.test.ts @@ -8,7 +8,7 @@ import { type MongoClient, ReadPreference, TopologyType -} from '../../mongodb_runtime-testing'; +} from '../../mongodb'; describe('IPv6 Addresses', () => { let client: MongoClient; diff --git a/test/integration/node-specific/mongo_client.test.ts b/test/integration/node-specific/mongo_client.test.ts index 9e3de614f0..65eeb73ad2 100644 --- a/test/integration/node-specific/mongo_client.test.ts +++ b/test/integration/node-specific/mongo_client.test.ts @@ -17,7 +17,7 @@ import { ReadPreference, ServerDescription, Topology -} from '../../mongodb_runtime-testing'; +} from '../../mongodb'; import { clearFailPoint, configureFailPoint } from '../../tools/utils'; import { setupDatabase } from '../shared'; diff --git a/test/integration/node-specific/operation_examples.test.ts b/test/integration/node-specific/operation_examples.test.ts index 8f72dba3af..4573198f62 100644 --- a/test/integration/node-specific/operation_examples.test.ts +++ b/test/integration/node-specific/operation_examples.test.ts @@ -7,7 +7,7 @@ import { type MongoClient, ProfilingLevel, ReturnDocument -} from '../../mongodb_runtime-testing'; +} from '../../mongodb'; import { sleep as delay } from '../../tools/utils'; import { setupDatabase } from '../shared'; diff --git a/test/integration/node-specific/resource_clean_up.test.ts b/test/integration/node-specific/resource_clean_up.test.ts index 44de9302d1..1b9709ec54 100644 --- a/test/integration/node-specific/resource_clean_up.test.ts +++ b/test/integration/node-specific/resource_clean_up.test.ts @@ -2,7 +2,7 @@ import * as v8 from 'node:v8'; import { expect } from 'chai'; -import { runNodelessTests } from '../../mongodb_runtime-testing'; +import { runNodelessTests } from '../../mongodb'; import { isTLSEnabled } from '../../tools/runner/filters/tls_filter'; import { sleep } from '../../tools/utils'; import { runScriptAndReturnHeapInfo } from './resource_tracking_script_builder'; diff --git a/test/integration/node-specific/resource_tracking_script_builder.ts b/test/integration/node-specific/resource_tracking_script_builder.ts index d2fb31bd93..fd835611c0 100644 --- a/test/integration/node-specific/resource_tracking_script_builder.ts +++ b/test/integration/node-specific/resource_tracking_script_builder.ts @@ -9,7 +9,7 @@ import { AssertionError, expect } from 'chai'; import * as process from 'process'; import type * as timers from 'timers'; -import type * as mongodb from '../../mongodb_runtime-testing'; +import type * as mongodb from '../../mongodb'; import { type TestConfiguration } from '../../tools/runner/config'; import { type sleep } from '../../tools/utils'; diff --git a/test/integration/node-specific/topology.test.ts b/test/integration/node-specific/topology.test.ts index 0e4e2999bc..4d2a223ff6 100644 --- a/test/integration/node-specific/topology.test.ts +++ b/test/integration/node-specific/topology.test.ts @@ -1,6 +1,6 @@ import { expect } from 'chai'; -import { MongoClient, type MongoClientOptions, type Topology } from '../../mongodb_runtime-testing'; +import { MongoClient, type MongoClientOptions, type Topology } from '../../mongodb'; describe('Topology', function () { it('should correctly track states of a topology', { diff --git a/test/integration/node-specific/validate_collection.test.ts b/test/integration/node-specific/validate_collection.test.ts index 34aa7d5f4c..b19f19e708 100644 --- a/test/integration/node-specific/validate_collection.test.ts +++ b/test/integration/node-specific/validate_collection.test.ts @@ -1,6 +1,6 @@ import { expect } from 'chai'; -import { ValidateCollectionOperation } from '../../mongodb_runtime-testing'; +import { ValidateCollectionOperation } from '../../mongodb'; describe('ValidateCollectionOperation', function () { let client; diff --git a/test/integration/objectid.test.ts b/test/integration/objectid.test.ts index 6be14706fa..e1b61b8b4e 100644 --- a/test/integration/objectid.test.ts +++ b/test/integration/objectid.test.ts @@ -1,6 +1,6 @@ import { expect } from 'chai'; -import { type Collection, type Db, type MongoClient, ObjectId } from '../mongodb_runtime-testing'; +import { type Collection, type Db, type MongoClient, ObjectId } from '../mongodb'; import { sleep } from '../tools/utils'; // TODO(NODE-4989): Improve these tests, likely can be made unit tests, or migrated to CRUD coverage (find oid range) diff --git a/test/integration/read-write-concern/readconcern.test.ts b/test/integration/read-write-concern/readconcern.test.ts index 11c9947fe2..06348eaf4e 100644 --- a/test/integration/read-write-concern/readconcern.test.ts +++ b/test/integration/read-write-concern/readconcern.test.ts @@ -1,6 +1,6 @@ import { expect } from 'chai'; -import { type MongoClient, ReadConcernLevel } from '../../mongodb_runtime-testing'; +import { type MongoClient, ReadConcernLevel } from '../../mongodb'; import { filterForCommands, setupDatabase } from '../shared'; describe('ReadConcern', function () { diff --git a/test/integration/read-write-concern/write_concern.test.ts b/test/integration/read-write-concern/write_concern.test.ts index 728466d25f..44dfe658c2 100644 --- a/test/integration/read-write-concern/write_concern.test.ts +++ b/test/integration/read-write-concern/write_concern.test.ts @@ -11,7 +11,7 @@ import { LEGACY_HELLO_COMMAND, MongoClient, OpMsgRequest -} from '../../mongodb_runtime-testing'; +} from '../../mongodb'; import * as mock from '../../tools/mongodb-mock/index'; import { filterForCommands } from '../shared'; diff --git a/test/integration/retryable-reads/retryable_reads.spec.prose.test.ts b/test/integration/retryable-reads/retryable_reads.spec.prose.test.ts index f99ec40fd0..ca0576d218 100644 --- a/test/integration/retryable-reads/retryable_reads.spec.prose.test.ts +++ b/test/integration/retryable-reads/retryable_reads.spec.prose.test.ts @@ -1,7 +1,7 @@ /* eslint-disable @typescript-eslint/no-non-null-assertion */ import { expect } from 'chai'; -import { type Collection, type MongoClient } from '../../mongodb_runtime-testing'; +import { type Collection, type MongoClient } from '../../mongodb'; describe('Retryable Reads Spec Prose', () => { let client: MongoClient, failPointName; diff --git a/test/integration/retryable-writes/non-server-retryable_writes.test.ts b/test/integration/retryable-writes/non-server-retryable_writes.test.ts index 8065e47896..0e2a06c7cf 100644 --- a/test/integration/retryable-writes/non-server-retryable_writes.test.ts +++ b/test/integration/retryable-writes/non-server-retryable_writes.test.ts @@ -7,7 +7,7 @@ import { MongoWriteConcernError, PoolClearedError, Server -} from '../../mongodb_runtime-testing'; +} from '../../mongodb'; describe('Non Server Retryable Writes', function () { let client: MongoClient; let collection: Collection<{ _id: 1 }>; diff --git a/test/integration/retryable-writes/retryable_writes.spec.prose.test.ts b/test/integration/retryable-writes/retryable_writes.spec.prose.test.ts index 52118230b8..22f475978d 100644 --- a/test/integration/retryable-writes/retryable_writes.spec.prose.test.ts +++ b/test/integration/retryable-writes/retryable_writes.spec.prose.test.ts @@ -11,7 +11,7 @@ import { MongoServerError, MongoWriteConcernError, Server -} from '../../mongodb_runtime-testing'; +} from '../../mongodb'; import { sleep } from '../../tools/utils'; describe('Retryable Writes Spec Prose', () => { diff --git a/test/integration/run-command/run_command.test.ts b/test/integration/run-command/run_command.test.ts index 64100a331b..e71d3887bf 100644 --- a/test/integration/run-command/run_command.test.ts +++ b/test/integration/run-command/run_command.test.ts @@ -7,7 +7,7 @@ import { ReadConcern, ReadPreference, WriteConcern -} from '../../mongodb_runtime-testing'; +} from '../../mongodb'; describe('RunCommand API', () => { let client: MongoClient; diff --git a/test/integration/run-command/run_cursor_command.test.ts b/test/integration/run-command/run_cursor_command.test.ts index 9fc86bda88..8b88c313f7 100644 --- a/test/integration/run-command/run_cursor_command.test.ts +++ b/test/integration/run-command/run_cursor_command.test.ts @@ -1,6 +1,6 @@ import { expect } from 'chai'; -import { type Db, type MongoClient } from '../../mongodb_runtime-testing'; +import { type Db, type MongoClient } from '../../mongodb'; describe('runCursorCommand API', () => { let client: MongoClient; diff --git a/test/integration/server-discovery-and-monitoring/server_description.test.ts b/test/integration/server-discovery-and-monitoring/server_description.test.ts index 071298c083..0bc9112c4b 100644 --- a/test/integration/server-discovery-and-monitoring/server_description.test.ts +++ b/test/integration/server-discovery-and-monitoring/server_description.test.ts @@ -1,6 +1,6 @@ import { expect } from 'chai'; -import { MongoClient } from '../../mongodb_runtime-testing'; +import { MongoClient } from '../../mongodb'; import { configureMongocryptdSpawnHooks } from '../../tools/utils'; describe('class ServerDescription', function () { diff --git a/test/integration/server-discovery-and-monitoring/server_discover_and_monitoring.test.ts b/test/integration/server-discovery-and-monitoring/server_discover_and_monitoring.test.ts index 06fe64c6aa..282d081b45 100644 --- a/test/integration/server-discovery-and-monitoring/server_discover_and_monitoring.test.ts +++ b/test/integration/server-discovery-and-monitoring/server_discover_and_monitoring.test.ts @@ -8,7 +8,7 @@ import { type MongoClient, promiseWithResolvers, type ServerHeartbeatSucceededEvent -} from '../../mongodb_runtime-testing'; +} from '../../mongodb'; import { loadSpecTests } from '../../spec'; import { runUnifiedSuite } from '../../tools/unified-spec-runner/runner'; diff --git a/test/integration/server-discovery-and-monitoring/server_discovery_and_monitoring.prose.test.ts b/test/integration/server-discovery-and-monitoring/server_discovery_and_monitoring.prose.test.ts index 59be8de218..1f4cec0057 100644 --- a/test/integration/server-discovery-and-monitoring/server_discovery_and_monitoring.prose.test.ts +++ b/test/integration/server-discovery-and-monitoring/server_discovery_and_monitoring.prose.test.ts @@ -9,7 +9,7 @@ import { type MongoClient, SERVER_HEARTBEAT_FAILED, SERVER_HEARTBEAT_SUCCEEDED -} from '../../mongodb_runtime-testing'; +} from '../../mongodb'; import { sleep } from '../../tools/utils'; describe('Server Discovery and Monitoring Prose Tests', function () { diff --git a/test/integration/server-discovery-and-monitoring/topology_description.test.ts b/test/integration/server-discovery-and-monitoring/topology_description.test.ts index 2a2dcb22d9..18a6824d1d 100644 --- a/test/integration/server-discovery-and-monitoring/topology_description.test.ts +++ b/test/integration/server-discovery-and-monitoring/topology_description.test.ts @@ -5,7 +5,7 @@ import { type MongoClient, type MongoClientOptions, TopologyType -} from '../../mongodb_runtime-testing'; +} from '../../mongodb'; describe('TopologyDescription (integration tests)', function () { let client: MongoClient; diff --git a/test/integration/server-selection/operation_count.test.ts b/test/integration/server-selection/operation_count.test.ts index 8e953a32ef..6f6a68f10a 100644 --- a/test/integration/server-selection/operation_count.test.ts +++ b/test/integration/server-selection/operation_count.test.ts @@ -6,7 +6,7 @@ import { type Collection, ConnectionPool, type MongoClient -} from '../../mongodb_runtime-testing'; +} from '../../mongodb'; import { type FailCommandFailPoint } from '../../tools/utils'; const testMetadata: MongoDBMetadataUI = { diff --git a/test/integration/server-selection/readpreference.test.ts b/test/integration/server-selection/readpreference.test.ts index 90410e7714..e3ff9e47a8 100644 --- a/test/integration/server-selection/readpreference.test.ts +++ b/test/integration/server-selection/readpreference.test.ts @@ -5,7 +5,7 @@ import { type MongoClient, ReadPreference, Topology -} from '../../mongodb_runtime-testing'; +} from '../../mongodb'; import { assert as test, filterForCommands, setupDatabase } from '../shared'; describe('ReadPreference', function () { diff --git a/test/integration/server-selection/server_selection.prose.operation_count.test.ts b/test/integration/server-selection/server_selection.prose.operation_count.test.ts index c596eeaf5a..b4a7d9bf47 100644 --- a/test/integration/server-selection/server_selection.prose.operation_count.test.ts +++ b/test/integration/server-selection/server_selection.prose.operation_count.test.ts @@ -5,7 +5,7 @@ import { type CommandStartedEvent, HostAddress, type MongoClient -} from '../../mongodb_runtime-testing'; +} from '../../mongodb'; import { waitUntilPoolsFilled } from '../../tools/utils'; const failPoint = { diff --git a/test/integration/server-selection/server_selection.prose.sharded_retryable_reads.test.ts b/test/integration/server-selection/server_selection.prose.sharded_retryable_reads.test.ts index 449926a614..3b72fe93eb 100644 --- a/test/integration/server-selection/server_selection.prose.sharded_retryable_reads.test.ts +++ b/test/integration/server-selection/server_selection.prose.sharded_retryable_reads.test.ts @@ -1,6 +1,6 @@ import { expect } from 'chai'; -import type { CommandFailedEvent, CommandSucceededEvent } from '../../mongodb_runtime-testing'; +import type { CommandFailedEvent, CommandSucceededEvent } from '../../mongodb'; const TEST_METADATA = { requires: { mongodb: '>=4.2.9', topology: 'sharded' } }; const FAIL_COMMAND = { diff --git a/test/integration/server-selection/server_selection.prose.sharded_retryable_writes.test.ts b/test/integration/server-selection/server_selection.prose.sharded_retryable_writes.test.ts index 86f03a8c1e..29cb5d11dd 100644 --- a/test/integration/server-selection/server_selection.prose.sharded_retryable_writes.test.ts +++ b/test/integration/server-selection/server_selection.prose.sharded_retryable_writes.test.ts @@ -1,6 +1,6 @@ import { expect } from 'chai'; -import type { CommandFailedEvent, CommandSucceededEvent } from '../../mongodb_runtime-testing'; +import type { CommandFailedEvent, CommandSucceededEvent } from '../../mongodb'; const TEST_METADATA = { requires: { mongodb: '>=4.3.1', topology: 'sharded' } }; const FAIL_COMMAND = { diff --git a/test/integration/sessions/sessions.prose.test.ts b/test/integration/sessions/sessions.prose.test.ts index 8da6dafe23..b6be8d763e 100644 --- a/test/integration/sessions/sessions.prose.test.ts +++ b/test/integration/sessions/sessions.prose.test.ts @@ -7,7 +7,7 @@ import { MongoClient, MongoDriverError, MongoInvalidArgumentError -} from '../../mongodb_runtime-testing'; +} from '../../mongodb'; import { configureMongocryptdSpawnHooks, sleep } from '../../tools/utils'; describe('Sessions Prose Tests', () => { diff --git a/test/integration/sessions/sessions.test.ts b/test/integration/sessions/sessions.test.ts index 0047b89ed4..a4b292ca9d 100644 --- a/test/integration/sessions/sessions.test.ts +++ b/test/integration/sessions/sessions.test.ts @@ -6,7 +6,7 @@ import { LEGACY_HELLO_COMMAND, type MongoClient, MongoServerError -} from '../../mongodb_runtime-testing'; +} from '../../mongodb'; import type { TestConfiguration } from '../../tools/runner/config'; import { setupDatabase } from '../shared'; diff --git a/test/integration/transactions-convenient-api/transactions-convenient-api.prose.test.ts b/test/integration/transactions-convenient-api/transactions-convenient-api.prose.test.ts index e32bf59bec..1f4e67687d 100644 --- a/test/integration/transactions-convenient-api/transactions-convenient-api.prose.test.ts +++ b/test/integration/transactions-convenient-api/transactions-convenient-api.prose.test.ts @@ -2,11 +2,7 @@ import { expect } from 'chai'; import { test } from 'mocha'; import * as sinon from 'sinon'; -import { - type ClientSession, - type Collection, - type MongoClient -} from '../../mongodb_runtime-testing'; +import { type ClientSession, type Collection, type MongoClient } from '../../mongodb'; import { configureFailPoint, type FailCommandFailPoint, measureDuration } from '../../tools/utils'; const failCommand: FailCommandFailPoint = { diff --git a/test/integration/transactions/transactions.prose.test.ts b/test/integration/transactions/transactions.prose.test.ts index ce95e084f8..89b1e574fa 100644 --- a/test/integration/transactions/transactions.prose.test.ts +++ b/test/integration/transactions/transactions.prose.test.ts @@ -1,7 +1,7 @@ import { type ObjectId } from 'bson'; import { expect } from 'chai'; -import { type MongoClient } from '../../mongodb_runtime-testing'; +import { type MongoClient } from '../../mongodb'; const metadata: MongoDBMetadataUI = { requires: { diff --git a/test/integration/transactions/transactions.test.ts b/test/integration/transactions/transactions.test.ts index 597f355532..eb5406ea9e 100644 --- a/test/integration/transactions/transactions.test.ts +++ b/test/integration/transactions/transactions.test.ts @@ -8,7 +8,7 @@ import { MongoInvalidArgumentError, MongoNetworkError, type ServerSessionPool -} from '../../mongodb_runtime-testing'; +} from '../../mongodb'; import { type FailCommandFailPoint } from '../../tools/utils'; describe('Transactions', function () { diff --git a/test/integration/uri-options/uri.test.ts b/test/integration/uri-options/uri.test.ts index 0ca7bc6a53..ba531ff785 100644 --- a/test/integration/uri-options/uri.test.ts +++ b/test/integration/uri-options/uri.test.ts @@ -3,7 +3,7 @@ import * as os from 'os'; import * as process from 'process'; import * as sinon from 'sinon'; -import { Topology } from '../../mongodb_runtime-testing'; +import { Topology } from '../../mongodb'; describe('URI', function () { let client; diff --git a/test/manual/atlas_connectivity.test.ts b/test/manual/atlas_connectivity.test.ts index db5ed6f90c..15fd2d91b3 100644 --- a/test/manual/atlas_connectivity.test.ts +++ b/test/manual/atlas_connectivity.test.ts @@ -1,6 +1,6 @@ import * as process from 'process'; -import { LEGACY_HELLO_COMMAND, MongoClient } from '../mongodb_runtime-testing'; +import { LEGACY_HELLO_COMMAND, MongoClient } from '../mongodb'; /** * ATLAS_CONNECTIVITY env variable is JSON * Here's some typescript describing the shape: diff --git a/test/manual/kerberos.test.ts b/test/manual/kerberos.test.ts index dfc2586321..ff6352e7c9 100644 --- a/test/manual/kerberos.test.ts +++ b/test/manual/kerberos.test.ts @@ -4,7 +4,7 @@ import * as os from 'os'; import * as process from 'process'; import * as sinon from 'sinon'; -import { MongoClient } from '../mongodb_runtime-testing'; +import { MongoClient } from '../mongodb'; const expect = chai.expect; diff --git a/test/manual/ldap.test.ts b/test/manual/ldap.test.ts index ad36131368..e110b91058 100644 --- a/test/manual/ldap.test.ts +++ b/test/manual/ldap.test.ts @@ -1,7 +1,7 @@ import { expect } from 'chai'; import * as process from 'process'; -import { MongoClient } from '../mongodb_runtime-testing'; +import { MongoClient } from '../mongodb'; describe('LDAP', function () { const { SASL_USER, SASL_PASS, SASL_HOST } = process.env; diff --git a/test/manual/search-index-management.prose.test.ts b/test/manual/search-index-management.prose.test.ts index 66bc0f3a75..fd2f2f63a7 100644 --- a/test/manual/search-index-management.prose.test.ts +++ b/test/manual/search-index-management.prose.test.ts @@ -11,7 +11,7 @@ import { type MongoClient, ObjectId, ReadConcern -} from '../mongodb_runtime-testing'; +} from '../mongodb'; class TimeoutController extends AbortController { timeoutId: NodeJS.Timeout; diff --git a/test/manual/socks5.test.ts b/test/manual/socks5.test.ts index 94d2b2902c..34e4f57ef8 100644 --- a/test/manual/socks5.test.ts +++ b/test/manual/socks5.test.ts @@ -2,7 +2,7 @@ import { expect } from 'chai'; import ConnectionString from 'mongodb-connection-string-url'; import * as process from 'process'; -import { LEGACY_HELLO_COMMAND, MongoClient, MongoParseError } from '../mongodb_runtime-testing'; +import { LEGACY_HELLO_COMMAND, MongoClient, MongoParseError } from '../mongodb'; /** * The SOCKS5_CONFIG environment variable is either a JSON 4-tuple * [host, port, username, password] or just [host, port]. diff --git a/test/manual/tls_support.test.ts b/test/manual/tls_support.test.ts index 029b6359ff..c576c05a2c 100644 --- a/test/manual/tls_support.test.ts +++ b/test/manual/tls_support.test.ts @@ -12,7 +12,7 @@ import { MongoClient, type MongoClientOptions, MongoServerSelectionError -} from '../mongodb_runtime-testing'; +} from '../mongodb'; const REQUIRED_ENV = ['MONGODB_URI', 'TLS_KEY_FILE', 'TLS_CA_FILE', 'TLS_CRL_FILE']; describe('TLS Support', function () { diff --git a/test/manual/x509_auth.test.ts b/test/manual/x509_auth.test.ts index b8ec8b636b..d6e7a10e17 100644 --- a/test/manual/x509_auth.test.ts +++ b/test/manual/x509_auth.test.ts @@ -7,7 +7,7 @@ import { type MongoClientOptions, MongoServerError, MongoServerSelectionError -} from '../mongodb_runtime-testing'; +} from '../mongodb'; // eslint-disable-next-line @typescript-eslint/no-non-null-assertion const connectionString = new ConnectionString(process.env.MONGODB_URI!); diff --git a/test/mongodb.ts b/test/mongodb.ts index 9c3234acd7..f1a8e2160e 100644 --- a/test/mongodb.ts +++ b/test/mongodb.ts @@ -1,144 +1,4 @@ -// As the centralized import for all src code for tests, we intentionally import from `src` in this file. -/* eslint-disable @typescript-eslint/no-restricted-imports */ - -export * from '../src/admin'; -export * from '../src/bson'; -export * from '../src/bulk/common'; -export * from '../src/bulk/ordered'; -export * from '../src/bulk/unordered'; -export * from '../src/change_stream'; -export * from '../src/client-side-encryption/auto_encrypter'; -export * from '../src/client-side-encryption/client_encryption'; -export * from '../src/client-side-encryption/errors'; -export * from '../src/client-side-encryption/mongocryptd_manager'; -export * from '../src/client-side-encryption/providers/aws'; -export * from '../src/client-side-encryption/providers/azure'; -export * from '../src/client-side-encryption/providers/gcp'; -export * from '../src/client-side-encryption/providers/index'; -export * from '../src/client-side-encryption/state_machine'; -export * from '../src/cmap/auth/auth_provider'; -export * from '../src/cmap/auth/aws_temporary_credentials'; -export * from '../src/cmap/auth/aws4'; -export * from '../src/cmap/auth/gssapi'; -export * from '../src/cmap/auth/mongo_credentials'; -export * from '../src/cmap/auth/mongodb_aws'; -export * from '../src/cmap/auth/mongodb_oidc'; -export * from '../src/cmap/auth/mongodb_oidc/automated_callback_workflow'; -export * from '../src/cmap/auth/mongodb_oidc/azure_machine_workflow'; -export * from '../src/cmap/auth/mongodb_oidc/callback_workflow'; -export * from '../src/cmap/auth/mongodb_oidc/command_builders'; -export * from '../src/cmap/auth/mongodb_oidc/gcp_machine_workflow'; -export * from '../src/cmap/auth/mongodb_oidc/human_callback_workflow'; -export * from '../src/cmap/auth/mongodb_oidc/k8s_machine_workflow'; -export * from '../src/cmap/auth/mongodb_oidc/token_cache'; -export * from '../src/cmap/auth/mongodb_oidc/token_machine_workflow'; -export * from '../src/cmap/auth/plain'; -export * from '../src/cmap/auth/providers'; -export * from '../src/cmap/auth/scram'; -export * from '../src/cmap/auth/x509'; -export * from '../src/cmap/command_monitoring_events'; -export * from '../src/cmap/commands'; -export * from '../src/cmap/connect'; -export * from '../src/cmap/connection'; -export * from '../src/cmap/connection_pool'; -export * from '../src/cmap/connection_pool_events'; -export * from '../src/cmap/errors'; -export * from '../src/cmap/handshake/client_metadata'; -export * from '../src/cmap/metrics'; -export * from '../src/cmap/stream_description'; -export * from '../src/cmap/wire_protocol/compression'; -export * from '../src/cmap/wire_protocol/constants'; -export * from '../src/cmap/wire_protocol/on_data'; -export * from '../src/cmap/wire_protocol/on_demand/document'; -export * from '../src/cmap/wire_protocol/responses'; -export * from '../src/cmap/wire_protocol/shared'; -export * from '../src/collection'; -export * from '../src/connection_string'; -export * from '../src/constants'; -export * from '../src/cursor/abstract_cursor'; -export * from '../src/cursor/aggregation_cursor'; -export * from '../src/cursor/change_stream_cursor'; -export * from '../src/cursor/client_bulk_write_cursor'; -export * from '../src/cursor/explainable_cursor'; -export * from '../src/cursor/find_cursor'; -export * from '../src/cursor/find_cursor'; -export * from '../src/cursor/list_collections_cursor'; -export * from '../src/cursor/list_collections_cursor'; -export * from '../src/cursor/list_indexes_cursor'; -export * from '../src/cursor/list_indexes_cursor'; -export * from '../src/cursor/list_search_indexes_cursor'; -export * from '../src/cursor/run_command_cursor'; -export * from '../src/db'; -export * from '../src/deps'; -export * from '../src/encrypter'; -export * from '../src/error'; -export * from '../src/explain'; -export * from '../src/gridfs/download'; -export * from '../src/gridfs/index'; -export * from '../src/gridfs/upload'; -export * from '../src/mongo_client'; -export * from '../src/mongo_client_auth_providers'; -export * from '../src/mongo_logger'; -export * from '../src/mongo_logger'; -export * from '../src/mongo_types'; -export * from '../src/mongo_types'; -export * from '../src/operations/aggregate'; -export * from '../src/operations/aggregate'; -export * from '../src/operations/client_bulk_write/client_bulk_write'; -export * from '../src/operations/client_bulk_write/command_builder'; -export * from '../src/operations/client_bulk_write/command_builder'; -export * from '../src/operations/client_bulk_write/common'; -export * from '../src/operations/client_bulk_write/common'; -export * from '../src/operations/client_bulk_write/executor'; -export * from '../src/operations/client_bulk_write/results_merger'; -export * from '../src/operations/command'; -export * from '../src/operations/count'; -export * from '../src/operations/create_collection'; -export * from '../src/operations/delete'; -export * from '../src/operations/distinct'; -export * from '../src/operations/drop'; -export * from '../src/operations/end_sessions'; -export * from '../src/operations/estimated_document_count'; -export * from '../src/operations/execute_operation'; -export * from '../src/operations/find'; -export * from '../src/operations/find_and_modify'; -export * from '../src/operations/get_more'; -export * from '../src/operations/indexes'; -export * from '../src/operations/insert'; -export * from '../src/operations/kill_cursors'; -export * from '../src/operations/list_collections'; -export * from '../src/operations/list_databases'; -export * from '../src/operations/operation'; -export * from '../src/operations/profiling_level'; -export * from '../src/operations/remove_user'; -export * from '../src/operations/rename'; -export * from '../src/operations/run_command'; -export * from '../src/operations/search_indexes/create'; -export * from '../src/operations/search_indexes/drop'; -export * from '../src/operations/search_indexes/update'; -export * from '../src/operations/set_profiling_level'; -export * from '../src/operations/stats'; -export * from '../src/operations/update'; -export * from '../src/operations/validate_collection'; -export * from '../src/read_concern'; -export * from '../src/read_preference'; -export * from '../src/runtime_adapters'; -export * from '../src/sdam/common'; -export * from '../src/sdam/events'; -export * from '../src/sdam/monitor'; -export * from '../src/sdam/server'; -export * from '../src/sdam/server_description'; -export * from '../src/sdam/server_selection'; -export * from '../src/sdam/server_selection_events'; -export * from '../src/sdam/srv_polling'; -export * from '../src/sdam/topology'; -export * from '../src/sdam/topology_description'; -export * from '../src/sessions'; -export * from '../src/sort'; -export * from '../src/timeout'; -export * from '../src/transactions'; -export * from '../src/utils'; -export * from '../src/write_concern'; - -// Must be last for precedence -export * from '../src/index'; +// This file is auto-generated. Do not edit. +// Run 'npm run build:runtime-barrel' to regenerate. +export const runNodelessTests = false; +export * from './mongodb_all'; diff --git a/test/mongodb_all.ts b/test/mongodb_all.ts new file mode 100644 index 0000000000..9c3234acd7 --- /dev/null +++ b/test/mongodb_all.ts @@ -0,0 +1,144 @@ +// As the centralized import for all src code for tests, we intentionally import from `src` in this file. +/* eslint-disable @typescript-eslint/no-restricted-imports */ + +export * from '../src/admin'; +export * from '../src/bson'; +export * from '../src/bulk/common'; +export * from '../src/bulk/ordered'; +export * from '../src/bulk/unordered'; +export * from '../src/change_stream'; +export * from '../src/client-side-encryption/auto_encrypter'; +export * from '../src/client-side-encryption/client_encryption'; +export * from '../src/client-side-encryption/errors'; +export * from '../src/client-side-encryption/mongocryptd_manager'; +export * from '../src/client-side-encryption/providers/aws'; +export * from '../src/client-side-encryption/providers/azure'; +export * from '../src/client-side-encryption/providers/gcp'; +export * from '../src/client-side-encryption/providers/index'; +export * from '../src/client-side-encryption/state_machine'; +export * from '../src/cmap/auth/auth_provider'; +export * from '../src/cmap/auth/aws_temporary_credentials'; +export * from '../src/cmap/auth/aws4'; +export * from '../src/cmap/auth/gssapi'; +export * from '../src/cmap/auth/mongo_credentials'; +export * from '../src/cmap/auth/mongodb_aws'; +export * from '../src/cmap/auth/mongodb_oidc'; +export * from '../src/cmap/auth/mongodb_oidc/automated_callback_workflow'; +export * from '../src/cmap/auth/mongodb_oidc/azure_machine_workflow'; +export * from '../src/cmap/auth/mongodb_oidc/callback_workflow'; +export * from '../src/cmap/auth/mongodb_oidc/command_builders'; +export * from '../src/cmap/auth/mongodb_oidc/gcp_machine_workflow'; +export * from '../src/cmap/auth/mongodb_oidc/human_callback_workflow'; +export * from '../src/cmap/auth/mongodb_oidc/k8s_machine_workflow'; +export * from '../src/cmap/auth/mongodb_oidc/token_cache'; +export * from '../src/cmap/auth/mongodb_oidc/token_machine_workflow'; +export * from '../src/cmap/auth/plain'; +export * from '../src/cmap/auth/providers'; +export * from '../src/cmap/auth/scram'; +export * from '../src/cmap/auth/x509'; +export * from '../src/cmap/command_monitoring_events'; +export * from '../src/cmap/commands'; +export * from '../src/cmap/connect'; +export * from '../src/cmap/connection'; +export * from '../src/cmap/connection_pool'; +export * from '../src/cmap/connection_pool_events'; +export * from '../src/cmap/errors'; +export * from '../src/cmap/handshake/client_metadata'; +export * from '../src/cmap/metrics'; +export * from '../src/cmap/stream_description'; +export * from '../src/cmap/wire_protocol/compression'; +export * from '../src/cmap/wire_protocol/constants'; +export * from '../src/cmap/wire_protocol/on_data'; +export * from '../src/cmap/wire_protocol/on_demand/document'; +export * from '../src/cmap/wire_protocol/responses'; +export * from '../src/cmap/wire_protocol/shared'; +export * from '../src/collection'; +export * from '../src/connection_string'; +export * from '../src/constants'; +export * from '../src/cursor/abstract_cursor'; +export * from '../src/cursor/aggregation_cursor'; +export * from '../src/cursor/change_stream_cursor'; +export * from '../src/cursor/client_bulk_write_cursor'; +export * from '../src/cursor/explainable_cursor'; +export * from '../src/cursor/find_cursor'; +export * from '../src/cursor/find_cursor'; +export * from '../src/cursor/list_collections_cursor'; +export * from '../src/cursor/list_collections_cursor'; +export * from '../src/cursor/list_indexes_cursor'; +export * from '../src/cursor/list_indexes_cursor'; +export * from '../src/cursor/list_search_indexes_cursor'; +export * from '../src/cursor/run_command_cursor'; +export * from '../src/db'; +export * from '../src/deps'; +export * from '../src/encrypter'; +export * from '../src/error'; +export * from '../src/explain'; +export * from '../src/gridfs/download'; +export * from '../src/gridfs/index'; +export * from '../src/gridfs/upload'; +export * from '../src/mongo_client'; +export * from '../src/mongo_client_auth_providers'; +export * from '../src/mongo_logger'; +export * from '../src/mongo_logger'; +export * from '../src/mongo_types'; +export * from '../src/mongo_types'; +export * from '../src/operations/aggregate'; +export * from '../src/operations/aggregate'; +export * from '../src/operations/client_bulk_write/client_bulk_write'; +export * from '../src/operations/client_bulk_write/command_builder'; +export * from '../src/operations/client_bulk_write/command_builder'; +export * from '../src/operations/client_bulk_write/common'; +export * from '../src/operations/client_bulk_write/common'; +export * from '../src/operations/client_bulk_write/executor'; +export * from '../src/operations/client_bulk_write/results_merger'; +export * from '../src/operations/command'; +export * from '../src/operations/count'; +export * from '../src/operations/create_collection'; +export * from '../src/operations/delete'; +export * from '../src/operations/distinct'; +export * from '../src/operations/drop'; +export * from '../src/operations/end_sessions'; +export * from '../src/operations/estimated_document_count'; +export * from '../src/operations/execute_operation'; +export * from '../src/operations/find'; +export * from '../src/operations/find_and_modify'; +export * from '../src/operations/get_more'; +export * from '../src/operations/indexes'; +export * from '../src/operations/insert'; +export * from '../src/operations/kill_cursors'; +export * from '../src/operations/list_collections'; +export * from '../src/operations/list_databases'; +export * from '../src/operations/operation'; +export * from '../src/operations/profiling_level'; +export * from '../src/operations/remove_user'; +export * from '../src/operations/rename'; +export * from '../src/operations/run_command'; +export * from '../src/operations/search_indexes/create'; +export * from '../src/operations/search_indexes/drop'; +export * from '../src/operations/search_indexes/update'; +export * from '../src/operations/set_profiling_level'; +export * from '../src/operations/stats'; +export * from '../src/operations/update'; +export * from '../src/operations/validate_collection'; +export * from '../src/read_concern'; +export * from '../src/read_preference'; +export * from '../src/runtime_adapters'; +export * from '../src/sdam/common'; +export * from '../src/sdam/events'; +export * from '../src/sdam/monitor'; +export * from '../src/sdam/server'; +export * from '../src/sdam/server_description'; +export * from '../src/sdam/server_selection'; +export * from '../src/sdam/server_selection_events'; +export * from '../src/sdam/srv_polling'; +export * from '../src/sdam/topology'; +export * from '../src/sdam/topology_description'; +export * from '../src/sessions'; +export * from '../src/sort'; +export * from '../src/timeout'; +export * from '../src/transactions'; +export * from '../src/utils'; +export * from '../src/write_concern'; + +// Must be last for precedence +export * from '../src/index'; diff --git a/test/mongodb_bundled.ts b/test/mongodb_bundled.ts index bb76c6aaa0..8454307fd3 100644 --- a/test/mongodb_bundled.ts +++ b/test/mongodb_bundled.ts @@ -1,6 +1,6 @@ import { loadContextifiedMongoDBModule } from './tools/runner/vm_context_helper'; -type all = typeof import('./mongodb'); +type all = typeof import('./mongodb_all'); let exportSource: all; try { exportSource = loadContextifiedMongoDBModule() as all; @@ -18,10 +18,16 @@ export const { AggregateOperation, AggregationCursor, applySession, + Aspect, AUTH_MECHS_AUTH_SRC_EXTERNAL, + AuthContext, AuthMechanism, + AuthProvider, + AutoEncrypter, + AutomatedCallbackWorkflow, aws4Sign, AWSSDKCredentialProvider, + azureCallback, Binary, BSON, BSONError, @@ -29,9 +35,20 @@ export const { BSONSymbol, BSONType, BufferPool, + buildDeleteManyOperation, + buildDeleteOneOperation, + buildInsertOneOperation, + buildReplaceOneOperation, + buildUpdateManyOperation, + buildUpdateOneOperation, + CallbackWorkflow, + CancellationToken, ChangeStream, ChangeStreamCursor, checkParentDomainMatch, + ClientBulkWriteCommandBuilder, + ClientBulkWriteCursorResponse, + ClientBulkWriteResultsMerger, ClientEncryption, ClientSession, CMAP_EVENTS, @@ -44,6 +61,7 @@ export const { CommandStartedEvent, CommandSucceededEvent, compareObjectId, + compareTopologyVersion, compress, Compressor, connect, @@ -69,6 +87,7 @@ export const { ConnectionPoolClearedEvent, ConnectionPoolClosedEvent, ConnectionPoolCreatedEvent, + ConnectionPoolMetrics, ConnectionPoolReadyEvent, ConnectionReadyEvent, COSMOS_DB_MSG, @@ -77,6 +96,7 @@ export const { CreateIndexesOperation, CreateSearchIndexesOperation, createStdioLogger, + CryptoConnection, CSOTTimeoutContext, CursorResponse, CursorTimeoutContext, @@ -85,9 +105,11 @@ export const { DBRef, DbStatsOperation, Decimal128, + decompress, decorateWithExplain, DEFAULT_ALLOWED_HOSTS, DEFAULT_MAX_DOCUMENT_LENGTH, + DEFAULT_PK_FACTORY, DeleteManyOperation, DeleteOneOperation, DeleteOperation, @@ -95,6 +117,7 @@ export const { deserialize, DistinctOperation, DOCUMENT_DB_MSG, + DocumentSequence, Double, DropCollectionOperation, DropDatabaseOperation, @@ -114,11 +137,16 @@ export const { FindOneAndUpdateOperation, FindOperation, formatSort, + gcpCallback, + getAwsCredentialProvider, getFAASEnv, + getGcpMetadata, getMongoDBClientEncryption, GetMoreOperation, getTopology, GridFSBucket, + GSSAPI, + GSSAPICanonicalizationValue, hasAtomicOperators, HEARTBEAT_EVENTS, HostAddress, @@ -127,6 +155,7 @@ export const { InsertOperation, Int32, isDriverInfoEqual, + isEmptyCredentials, isHello, isRecord, isResumableError, @@ -138,6 +167,7 @@ export const { LEGACY_NOT_PRIMARY_OR_SECONDARY_ERROR_MESSAGE, LEGACY_NOT_WRITABLE_PRIMARY_ERROR_MESSAGE, LegacyTimeoutContext, + LimitedSizeDocument, List, ListCollectionsCursor, ListCollectionsOperation, @@ -145,7 +175,12 @@ export const { ListIndexesOperation, Long, makeClientMetadata, + MAX_SUPPORTED_SERVER_VERSION, + MAX_SUPPORTED_WIRE_VERSION, MaxKey, + MIN_SECONDARY_WRITE_WIRE_VERSION, + MIN_SUPPORTED_SERVER_VERSION, + MIN_SUPPORTED_WIRE_VERSION, MinKey, MongoAPIError, MongoAWSError, @@ -155,10 +190,12 @@ export const { MongoClientAuthProviders, MongoClientBulkWriteError, MongoClientClosedError, + MongoCompatibilityError, MongoCredentials, MongoCryptAzureKMSRequestError, MongoCryptCreateDataKeyError, MongoCryptCreateEncryptedCollectionError, + MongocryptdManager, MongoCryptError, MongoCryptInvalidArgumentError, MongoCursorExhaustedError, @@ -184,22 +221,30 @@ export const { MongoServerError, MongoServerSelectionError, MongoSystemError, + MongoUnexpectedServerResponseError, MongoWriteConcernError, + Monitor, + MonitorInterval, needsRetryableWriteLabel, NODE_IS_RECOVERING_ERROR_MESSAGE, noop, ns, ObjectId, + OIDC_VERSION, + OnDemandDocument, OP_MSG, OP_QUERY, OpCompressedRequest, OpMsgRequest, OpMsgResponse, OpQueryRequest, + OpReply, parseOptions, parseSeverityFromString, + performGSSAPICanonicalizeHostName, PoolClearedError, PoolClosedError, + prepareHandshakeDocument, processTimeMS, ProfilingLevel, ProfilingLevelOperation, @@ -207,20 +252,30 @@ export const { ReadConcern, ReadConcernLevel, ReadPreference, + readPreferenceServerSelector, refreshKMSCredentials, RemoveUserOperation, RenameOperation, ReplaceOneOperation, + resolveCname, resolveRuntimeAdapters, resolveSRVRecord, resolveTimeoutOptions, ReturnDocument, + RTTSampler, RunCommandOperation, + RunCursorCommandOperation, + sameServerSelector, ScramSHA256, + secondaryWritableServerSelector, SENSITIVE_COMMANDS, + serialize, + SERVER_CLOSED, SERVER_DESCRIPTION_CHANGED, SERVER_HEARTBEAT_FAILED, + SERVER_HEARTBEAT_STARTED, SERVER_HEARTBEAT_SUCCEEDED, + SERVER_OPENING, Server, ServerApiVersion, ServerClosedEvent, @@ -230,6 +285,7 @@ export const { ServerHeartbeatStartedEvent, ServerHeartbeatSucceededEvent, ServerOpeningEvent, + ServerSelectionEvent, ServerSession, ServerSessionPool, ServerType, @@ -237,17 +293,27 @@ export const { SetProfilingLevelOperation, SeverityLevel, shuffle, + SizedMessageTransform, squashError, SrvPoller, + SrvPollingEvent, StateMachine, + StreamDescription, stringifyWithMaxLen, Timeout, TimeoutContext, TimeoutError, Timestamp, + tokenCache, + TokenCache, + tokenMachineCallback, + TOPOLOGY_CLOSED, + TOPOLOGY_DESCRIPTION_CHANGED, TOPOLOGY_EVENTS, + TOPOLOGY_OPENING, Topology, TopologyClosedEvent, + TopologyDescription, TopologyDescriptionChangedEvent, TopologyOpeningEvent, TopologyType, @@ -260,15 +326,16 @@ export const { UUID, ValidateCollectionOperation, WaitQueueTimeoutError, + writableServerSelector, WriteConcern } = exportSource; // Export types from the contextified module +// Hint: This list IS automatically alphabetized, so add new types anywhere in the list and it will stay organized export type { AbstractOperation, Admin, AnyClientBulkWriteModel, - AutoEncrypter, AutoEncryptionOptions, AWSCredentials, BSONSerializeOptions, @@ -294,6 +361,7 @@ export type { ChangeStreamShardCollectionDocument, ChangeStreamUpdateDocument, ClientBulkWriteModel, + ClientBulkWriteResult, ClientDeleteManyModel, ClientDeleteOneModel, ClientEncryptionDataKeyProvider, @@ -332,8 +400,8 @@ export type { ServerApi, ServerSessionId, TagSet, - TopologyDescription, TopologyOptions, + TopologyVersion, TransactionOptions, UpdateDescription, UpdateFilter, @@ -345,6 +413,7 @@ export type { // Export "clashing" types from the contextified module. // These are types that clash with the objects of the same name (eg Collection), so we need to export them separately to avoid type errors. +// Hint: This list IS automatically alphabetized, so add new types anywhere in the list and it will stay organized import type { AbstractCursor as _AbstractCursor, AuthMechanism as _AuthMechanism, @@ -367,15 +436,21 @@ import type { HostAddress as _HostAddress, MongoClient as _MongoClient, MongoError as _MongoError, + OnDemandDocument as _OnDemandDocument, Server as _Server, + ServerDescription as _ServerDescription, ServerDescriptionChangedEvent as _ServerDescriptionChangedEvent, Timeout as _Timeout, TimeoutContext as _TimeoutContext, Topology as _Topology, + TopologyDescription as _TopologyDescription, TopologyDescriptionChangedEvent as _TopologyDescriptionChangedEvent, TopologyType as _TopologyType, UUID as _UUID } from './tools/runner/bundle/types/index'; + +// Export "clashing" types from the contextified module +// Hint: This list IS NOT automatically alphabetized, but VSCode's "Sort Lines Ascending" command can be used to keep it organized export type AbstractCursor = _AbstractCursor; export type AuthMechanism = _AuthMechanism; export type ChangeStream = _ChangeStream; @@ -397,16 +472,20 @@ export type GridFSBucket = _GridFSBucket; export type HostAddress = _HostAddress; export type MongoClient = _MongoClient; export type MongoError = _MongoError; +export type OnDemandDocument = _OnDemandDocument; export type Server = _Server; +export type ServerDescription = _ServerDescription; export type ServerDescriptionChangedEvent = _ServerDescriptionChangedEvent; export type Timeout = _Timeout; export type TimeoutContext = _TimeoutContext; export type Topology = _Topology; +export type TopologyDescription = _TopologyDescription; export type TopologyDescriptionChangedEvent = _TopologyDescriptionChangedEvent; export type TopologyType = _TopologyType; export type UUID = _UUID; // Export specific types from other files in the contextified module +// Hint: This list IS automatically alphabetized, so add new types anywhere in the list and it will stay organized export type { AzureKMSRequestOptions } from './tools/runner/bundle/types/client-side-encryption/providers/azure'; export type { AwsSigv4Options } from './tools/runner/bundle/types/cmap/auth/aws4'; export type { @@ -415,3 +494,5 @@ export type { OIDCCallbackParams, OIDCResponse } from './tools/runner/bundle/types/cmap/auth/mongodb_oidc'; +import type { ClientBulkWriteCursorResponse as _ClientBulkWriteCursorResponse } from './tools/runner/bundle/types/cmap/wire_protocol/responses'; +export type ClientBulkWriteCursorResponse = _ClientBulkWriteCursorResponse; diff --git a/test/mongodb_runtime-testing.ts b/test/mongodb_runtime-testing.ts deleted file mode 100644 index d0b07fef47..0000000000 --- a/test/mongodb_runtime-testing.ts +++ /dev/null @@ -1,4 +0,0 @@ -// This file is auto-generated. Do not edit. -// Run 'npm run build:runtime-barrel' to regenerate. -export const runNodelessTests = false; -export * from './mongodb'; diff --git a/test/readme.md b/test/readme.md index 811ebbaade..eadd83a90b 100644 --- a/test/readme.md +++ b/test/readme.md @@ -45,7 +45,6 @@ about the types of tests and how to run them. - [Container Tests](#container-tests) - [Node-less Runtime Testing](#node-less-runtime-testing) - [Design](#design) - - [Adding tests to be tested with Node-less Runtime](#adding-tests-to-be-tested-with-node-less-runtime) - [Running tests in Node-less Runtime](#running-tests-in-node-less-runtime) - [GCP](#gcp) - [Azure](#azure) @@ -732,30 +731,19 @@ The approach we are taking is to modify our unit and integration tests to run ag Here are a few of the relevant components of this system: -1. [test/mongodb.ts](test/mongodb.ts) +1. [test/mongodb_all.ts](test/mongodb.ts) - Test entrypoint that exports Driver and all internal types. 2. [etc/bundle-driver.mjs](etc/bundle-driver.mjs) - - Creates a CommonJS bundle (Driver and all internal types) from `test/mongodb.ts`. + - Creates a CommonJS bundle (Driver and all internal types) from `test/mongodb_all.ts`. 3. [test/tools/runner/vm_context_helper.ts](./tools/runner/vm_context_helper.ts) - Special VM that blocks specific `require` calls. 4. [test/mongodb_bundled.ts](./mongodb_bundled.ts) - Exports MongoDB from CommonJS bundle created by `etc/bundle-driver.mjs`, using `vm_context_helper.ts` to detect usages of blocked `require` calls. - This file is currently maintained by hand and needs to export types explicitly. We may want to generate this file as well. -5. [test/mongodb_runtime-testing.ts](./mongodb_runtime-testing.ts) +5. [test/mongodb.ts](./mongodb.ts) - Generated "barrel file". It exports either `test/mongodb.ts` (Driver + all internal types) or `test/mongodb_bundled.ts` (Driver + all internal types, loaded from bundle, and using `vm_context_helper.ts` to block `require` calls.) 6. [etc/build-runtime-barrel.mjs](./etc/build-runtime-barrel.mjs) - - Generates the barrel file `test/mongodb_runtime-testing.ts` based on `MONGODB_BUNDLED` env var. - -#### Adding tests to be tested with Node-less Runtime - -Change the test's import from - `} from '../mongodb';` -to - `} from '../mongodb_runtime-testing';` - -Then run the tests. - -If any are failing because of a missing export, you will need to export those types in [test/mongodb_bundled.ts](test/mongodb_bundled.ts). + - Generates the barrel file `test/mongodb.ts` based on `MONGODB_BUNDLED` env var. #### Running tests in Node-less Runtime diff --git a/test/spec/index.ts b/test/spec/index.ts index fdc3c03d77..221d667189 100644 --- a/test/spec/index.ts +++ b/test/spec/index.ts @@ -1,7 +1,7 @@ import * as fs from 'fs'; import * as path from 'path'; -import { EJSON } from '../mongodb_runtime-testing'; +import { EJSON } from '../mongodb'; function hasDuplicates(testArray) { const testNames = testArray.map(test => test.description); diff --git a/test/tools/cmap_spec_runner.ts b/test/tools/cmap_spec_runner.ts index 7c9b5b3373..9bdf85bee8 100644 --- a/test/tools/cmap_spec_runner.ts +++ b/test/tools/cmap_spec_runner.ts @@ -15,7 +15,7 @@ import { type Server, shuffle, TimeoutContext -} from '../mongodb_runtime-testing'; +} from '../mongodb'; import { isAnyRequirementSatisfied } from './unified-spec-runner/unified-utils'; import { type FailCommandFailPoint, sleep } from './utils'; diff --git a/test/tools/common.js b/test/tools/common.js index 0982197c3d..30732d247c 100644 --- a/test/tools/common.js +++ b/test/tools/common.js @@ -1,8 +1,8 @@ 'use strict'; const mock = require('./mongodb-mock/index'); -const { ObjectId, Timestamp, Long, Binary } = require('../mongodb_runtime-testing'); -const { LEGACY_HELLO_COMMAND, isHello } = require('../mongodb_runtime-testing'); +const { ObjectId, Timestamp, Long, Binary } = require('../mongodb'); +const { LEGACY_HELLO_COMMAND, isHello } = require('../mongodb'); class ReplSetFixture { constructor() { diff --git a/test/tools/mongodb-mock/index.js b/test/tools/mongodb-mock/index.js index 1a363faecf..11427450f7 100644 --- a/test/tools/mongodb-mock/index.js +++ b/test/tools/mongodb-mock/index.js @@ -1,5 +1,5 @@ const fs = require('fs'); -const { LEGACY_HELLO_COMMAND } = require('../../mongodb_runtime-testing'); +const { LEGACY_HELLO_COMMAND } = require('../../mongodb'); const { MockServer } = require('./src/server'); const process = require('node:process'); diff --git a/test/tools/runner/config.ts b/test/tools/runner/config.ts index 1dd4b4f3fd..8f6078b79c 100644 --- a/test/tools/runner/config.ts +++ b/test/tools/runner/config.ts @@ -20,7 +20,7 @@ import { type ServerApi, TopologyType, type WriteConcernSettings -} from '../../mongodb_runtime-testing'; +} from '../../mongodb'; import { getEnvironmentalOptions } from '../utils'; import { type Filter } from './filters/filter'; import { flakyTests } from './flaky'; diff --git a/test/tools/runner/filters/api_version_filter.ts b/test/tools/runner/filters/api_version_filter.ts index 41f719f300..ce7df6f1fe 100755 --- a/test/tools/runner/filters/api_version_filter.ts +++ b/test/tools/runner/filters/api_version_filter.ts @@ -1,6 +1,6 @@ import * as process from 'process'; -import { type MongoClient } from '../../../mongodb_runtime-testing'; +import { type MongoClient } from '../../../mongodb'; import { Filter } from './filter'; /** diff --git a/test/tools/runner/filters/client_encryption_filter.ts b/test/tools/runner/filters/client_encryption_filter.ts index 88e6f5ab5c..5789552574 100644 --- a/test/tools/runner/filters/client_encryption_filter.ts +++ b/test/tools/runner/filters/client_encryption_filter.ts @@ -5,7 +5,7 @@ import * as process from 'process'; import { satisfies } from 'semver'; import { kmsCredentialsPresent } from '../../../csfle-kms-providers'; -import { type MongoClient } from '../../../mongodb_runtime-testing'; +import { type MongoClient } from '../../../mongodb'; import { Filter } from './filter'; /** diff --git a/test/tools/runner/filters/crypt_shared_filter.ts b/test/tools/runner/filters/crypt_shared_filter.ts index 6ed7f21d4d..bf82435708 100644 --- a/test/tools/runner/filters/crypt_shared_filter.ts +++ b/test/tools/runner/filters/crypt_shared_filter.ts @@ -1,4 +1,4 @@ -import { type AutoEncrypter, MongoClient } from '../../../mongodb_runtime-testing'; +import { type AutoEncrypter, MongoClient } from '../../../mongodb'; import { getEncryptExtraOptions } from '../../utils'; import { Filter } from './filter'; diff --git a/test/tools/runner/filters/filter.ts b/test/tools/runner/filters/filter.ts index 0fbbcae46c..6251cf44c8 100644 --- a/test/tools/runner/filters/filter.ts +++ b/test/tools/runner/filters/filter.ts @@ -1,4 +1,4 @@ -import { type MongoClient } from '../../../mongodb_runtime-testing'; +import { type MongoClient } from '../../../mongodb'; export abstract class Filter { async initializeFilter(_client: MongoClient, _context: Record): Promise { diff --git a/test/tools/runner/filters/mongodb_topology_filter.ts b/test/tools/runner/filters/mongodb_topology_filter.ts index 6c8abff35c..429b028b8b 100755 --- a/test/tools/runner/filters/mongodb_topology_filter.ts +++ b/test/tools/runner/filters/mongodb_topology_filter.ts @@ -1,4 +1,4 @@ -import { type MongoClient, TopologyType } from '../../../mongodb_runtime-testing'; +import { type MongoClient, TopologyType } from '../../../mongodb'; import { Filter } from './filter'; /** diff --git a/test/tools/runner/filters/mongodb_version_filter.ts b/test/tools/runner/filters/mongodb_version_filter.ts index a649b69d5f..8d1eb6307f 100755 --- a/test/tools/runner/filters/mongodb_version_filter.ts +++ b/test/tools/runner/filters/mongodb_version_filter.ts @@ -1,6 +1,6 @@ import * as semver from 'semver'; -import { type MongoClient } from '../../../mongodb_runtime-testing'; +import { type MongoClient } from '../../../mongodb'; import { Filter } from './filter'; /** diff --git a/test/tools/runner/filters/tls_filter.ts b/test/tools/runner/filters/tls_filter.ts index 04f5a9f5a3..b08b03a0a7 100644 --- a/test/tools/runner/filters/tls_filter.ts +++ b/test/tools/runner/filters/tls_filter.ts @@ -1,6 +1,6 @@ import * as process from 'process'; -import { type MongoClient } from '../../../mongodb_runtime-testing'; +import { type MongoClient } from '../../../mongodb'; import { Filter } from './filter'; export const isTLSEnabled = process.env.SSL === 'ssl'; diff --git a/test/tools/runner/hooks/configuration.ts b/test/tools/runner/hooks/configuration.ts index 9ff870c9a4..0220d81fb9 100644 --- a/test/tools/runner/hooks/configuration.ts +++ b/test/tools/runner/hooks/configuration.ts @@ -8,7 +8,7 @@ require('source-map-support').install({ import * as process from 'process'; import * as os from 'os'; -import { MongoClient } from '../../../mongodb_runtime-testing'; +import { MongoClient } from '../../../mongodb'; import { AlpineTestConfiguration, AstrolabeTestConfiguration, TestConfiguration } from '../config'; import { getEnvironmentalOptions } from '../../utils'; import * as mock from '../../mongodb-mock/index'; diff --git a/test/tools/runner/hooks/leak_checker.ts b/test/tools/runner/hooks/leak_checker.ts index 069dd8dac5..fab12158fc 100644 --- a/test/tools/runner/hooks/leak_checker.ts +++ b/test/tools/runner/hooks/leak_checker.ts @@ -5,7 +5,7 @@ import * as chalk from 'chalk'; import * as net from 'net'; import * as process from 'process'; -import { MongoClient, ServerSessionPool } from '../../../mongodb_runtime-testing'; +import { MongoClient, ServerSessionPool } from '../../../mongodb'; class LeakChecker { static originalAcquire: typeof ServerSessionPool.prototype.acquire; static originalRelease: typeof ServerSessionPool.prototype.release; diff --git a/test/tools/spec-runner/context.js b/test/tools/spec-runner/context.js index 0d650024ce..22871c707d 100644 --- a/test/tools/spec-runner/context.js +++ b/test/tools/spec-runner/context.js @@ -2,7 +2,7 @@ const { expect } = require('chai'); const { setTimeout } = require('timers'); const { resolveConnectionString } = require('./utils'); -const { ns } = require('../../mongodb_runtime-testing'); +const { ns } = require('../../mongodb'); const { extractAuthFromConnectionString } = require('../utils'); const process = require('node:process'); diff --git a/test/tools/spec-runner/index.js b/test/tools/spec-runner/index.js index 029994cf47..2043ba395a 100644 --- a/test/tools/spec-runner/index.js +++ b/test/tools/spec-runner/index.js @@ -6,7 +6,7 @@ const process = require('node:process'); const expect = chai.expect; const { EJSON } = require('bson'); -const { isRecord } = require('../../mongodb_runtime-testing'); +const { isRecord } = require('../../mongodb'); const TestRunnerContext = require('./context').TestRunnerContext; const resolveConnectionString = require('./utils').resolveConnectionString; const { @@ -14,7 +14,7 @@ const { CMAP_EVENTS: SOURCE_CMAP_EVENTS, TOPOLOGY_EVENTS, HEARTBEAT_EVENTS -} = require('../../mongodb_runtime-testing'); +} = require('../../mongodb'); const { isAnyRequirementSatisfied } = require('../unified-spec-runner/unified-utils'); const { getCSFLEKMSProviders } = require('../../csfle-kms-providers'); diff --git a/test/tools/unified-spec-runner/entities.ts b/test/tools/unified-spec-runner/entities.ts index 793b9c3a0e..2c4f257b15 100644 --- a/test/tools/unified-spec-runner/entities.ts +++ b/test/tools/unified-spec-runner/entities.ts @@ -49,7 +49,7 @@ import { type TopologyDescriptionChangedEvent, type TopologyOpeningEvent, WriteConcern -} from '../../mongodb_runtime-testing'; +} from '../../mongodb'; import { getEncryptExtraOptions, getEnvironmentalOptions } from '../../tools/utils'; import { AlpineTestConfiguration, type TestConfiguration } from '../runner/config'; import { EntityEventRegistry } from './entity_event_registry'; diff --git a/test/tools/unified-spec-runner/entity_event_registry.ts b/test/tools/unified-spec-runner/entity_event_registry.ts index c995c288dc..d62e106988 100644 --- a/test/tools/unified-spec-runner/entity_event_registry.ts +++ b/test/tools/unified-spec-runner/entity_event_registry.ts @@ -15,7 +15,7 @@ import { CONNECTION_POOL_CREATED, CONNECTION_POOL_READY, CONNECTION_READY -} from '../../mongodb_runtime-testing'; +} from '../../mongodb'; import { type EntitiesMap, type UnifiedMongoClient } from './entities'; import { type ClientEntity } from './schema'; diff --git a/test/tools/unified-spec-runner/match.ts b/test/tools/unified-spec-runner/match.ts index b3cc263092..112748a10a 100644 --- a/test/tools/unified-spec-runner/match.ts +++ b/test/tools/unified-spec-runner/match.ts @@ -38,7 +38,7 @@ import { TopologyClosedEvent, TopologyDescriptionChangedEvent, TopologyOpeningEvent -} from '../../mongodb_runtime-testing'; +} from '../../mongodb'; import { ejson } from '../utils'; import { type CmapEvent, type CommandEvent, type EntitiesMap, type SdamEvent } from './entities'; import { diff --git a/test/tools/unified-spec-runner/operations.ts b/test/tools/unified-spec-runner/operations.ts index b9dc1c0eb8..d0bf5969e7 100644 --- a/test/tools/unified-spec-runner/operations.ts +++ b/test/tools/unified-spec-runner/operations.ts @@ -23,7 +23,7 @@ import { type TopologyType, type TransactionOptions, WriteConcern -} from '../../mongodb_runtime-testing'; +} from '../../mongodb'; import { sleep } from '../../tools/utils'; import { type TestConfiguration } from '../runner/config'; import { EntitiesMap } from './entities'; diff --git a/test/tools/unified-spec-runner/runner.ts b/test/tools/unified-spec-runner/runner.ts index d72d10c2db..f58d01f98b 100644 --- a/test/tools/unified-spec-runner/runner.ts +++ b/test/tools/unified-spec-runner/runner.ts @@ -11,7 +11,7 @@ import { ns, ReadPreference, TopologyType -} from '../../mongodb_runtime-testing'; +} from '../../mongodb'; import { ejson } from '../utils'; import { AstrolabeResultsWriter } from './astrolabe_results_writer'; import { EntitiesMap, type UnifiedMongoClient } from './entities'; diff --git a/test/tools/unified-spec-runner/schema.ts b/test/tools/unified-spec-runner/schema.ts index efb529b98f..0f7e048b17 100644 --- a/test/tools/unified-spec-runner/schema.ts +++ b/test/tools/unified-spec-runner/schema.ts @@ -10,7 +10,7 @@ import type { TagSet, TopologyType, W -} from '../../mongodb_runtime-testing'; +} from '../../mongodb'; import { type TestConfiguration } from '../runner/config'; import { type UnifiedThread } from './entities'; diff --git a/test/tools/unified-spec-runner/unified-utils.ts b/test/tools/unified-spec-runner/unified-utils.ts index f69a293339..1d4973734a 100644 --- a/test/tools/unified-spec-runner/unified-utils.ts +++ b/test/tools/unified-spec-runner/unified-utils.ts @@ -14,7 +14,7 @@ import { getMongoDBClientEncryption, type MongoClient, ReturnDocument -} from '../../mongodb_runtime-testing'; +} from '../../mongodb'; import type { CmapEvent, CommandEvent, EntitiesMap, SdamEvent } from './entities'; import { matchesEvents } from './match'; import { MalformedOperationError } from './operations'; diff --git a/test/tools/uri_spec_runner.ts b/test/tools/uri_spec_runner.ts index 6934b23e7f..bb6f44459a 100644 --- a/test/tools/uri_spec_runner.ts +++ b/test/tools/uri_spec_runner.ts @@ -6,7 +6,7 @@ import { MongoInvalidArgumentError, MongoParseError, MongoRuntimeError -} from '../mongodb_runtime-testing'; +} from '../mongodb'; type HostObject = { type: 'ipv4' | 'ip_literal' | 'hostname' | 'unix'; diff --git a/test/tools/utils.ts b/test/tools/utils.ts index 32038d207d..3c0d8eb88a 100644 --- a/test/tools/utils.ts +++ b/test/tools/utils.ts @@ -24,7 +24,7 @@ import { type ServerApiVersion, Topology, type TopologyOptions -} from '../mongodb_runtime-testing'; +} from '../mongodb'; import { type TestConfiguration } from './runner/config'; import { isTLSEnabled } from './runner/filters/tls_filter'; @@ -32,6 +32,13 @@ export function ensureCalledWith(stub: any, args: any[]) { args.forEach((m: any) => expect(stub).to.have.been.calledWith(m)); } +export function checkTypeByName(obj: any, typeName: string): boolean { + console.log(`pavel >>> checking obj: ${obj} for type ${typeName}`); + if (obj !== null && obj.constructor != null && obj.constructor.name === typeName) { + return true; + } + return false; +} export function ensureTypeByName(obj: any, typeName: string): void { expect(obj).to.be.not.null; expect(obj.constructor).to.be.not.null; diff --git a/test/unit/assorted/server_discovery_and_monitoring.spec.test.ts b/test/unit/assorted/server_discovery_and_monitoring.spec.test.ts index 7012836395..562c5b308b 100644 --- a/test/unit/assorted/server_discovery_and_monitoring.spec.test.ts +++ b/test/unit/assorted/server_discovery_and_monitoring.spec.test.ts @@ -18,6 +18,7 @@ import { MongoServerError, ns, RunCommandOperation, + runNodelessTests, Server, SERVER_CLOSED, SERVER_DESCRIPTION_CHANGED, @@ -40,7 +41,7 @@ import { TopologyOpeningEvent, type TopologyVersion } from '../../mongodb'; -import { ejson, fakeServer } from '../../tools/utils'; +import { checkTypeByName, ejson, fakeServer } from '../../tools/utils'; const SDAM_EVENT_CLASSES = { ServerDescriptionChangedEvent, @@ -193,7 +194,11 @@ function assertMonitoringOutcome(outcome: any): asserts outcome is MonitoringOut describe('Server Discovery and Monitoring (spec)', function () { let serverConnect: sinon.SinonStub; - before(() => { + before(function () { + if (runNodelessTests) { + this.skip(); + } + serverConnect = sinon.stub(Server.prototype, 'connect').callsFake(function () { this.s.state = 'connected'; this.emit('connect'); @@ -201,6 +206,10 @@ describe('Server Discovery and Monitoring (spec)', function () { }); after(() => { + if (runNodelessTests) { + return; + } + serverConnect.restore(); }); @@ -455,16 +464,25 @@ async function executeSDAMTest(testData: SDAMTest) { const isApplicationError = error => { // These errors all come from the withConnection stub - return ( - error instanceof MongoNetworkError || - error instanceof MongoNetworkTimeoutError || - error instanceof MongoServerError - ); + const result = + checkTypeByName(error, 'MongoNetworkError') || + checkTypeByName(error, 'MongoNetworkTimeoutError') || + checkTypeByName(error, 'MongoServerError'); + console.log(`pavel >>> checking error: ${error.name}, result: ${result}`); + return result; }; expect( thrownError, `expected the error thrown to be one of MongoNetworkError, MongoNetworkTimeoutError or MongoServerError (referred to in the spec as an "Application Error") got ${thrownError.name} ${thrownError.stack}` - ).to.satisfy(isApplicationError); + ).to.satisfy(e => { + const result = isApplicationError(e); + if (!result) { + console.error( + `pavel >>> unexpected error thrown from SDAM test: ${e.name} ${e.stack}` + ); + } + return result; + }); } } else if (phase.outcome != null && Object.keys(phase).length === 1) { // Load Balancer SDAM tests have no "work" to be done for the phase diff --git a/test/unit/assorted/server_selection_spec_helper.js b/test/unit/assorted/server_selection_spec_helper.js index 573788c9e7..0510573574 100644 --- a/test/unit/assorted/server_selection_spec_helper.js +++ b/test/unit/assorted/server_selection_spec_helper.js @@ -1,6 +1,8 @@ 'use strict'; const { + writableServerSelector, + readPreferenceServerSelector, MongoServerSelectionError, ReadPreference, ServerType, @@ -119,11 +121,11 @@ export async function executeServerSelectionTest(testDefinition) { let selector; if (testDefinition.operation === 'write') { - selector = ServerSelectors.writableServerSelector(); + selector = writableServerSelector(); } else if (testDefinition.operation === 'read' || testDefinition.read_preference) { try { const readPreference = readPreferenceFromDefinition(testDefinition.read_preference); - selector = ServerSelectors.readPreferenceServerSelector(readPreference); + selector = readPreferenceServerSelector(readPreference); } catch (e) { if (testDefinition.error) return topology.close(); throw e; diff --git a/test/unit/client-side-encryption/client_encryption.test.ts b/test/unit/client-side-encryption/client_encryption.test.ts index 7914c6ae32..1e81df434e 100644 --- a/test/unit/client-side-encryption/client_encryption.test.ts +++ b/test/unit/client-side-encryption/client_encryption.test.ts @@ -8,6 +8,7 @@ import { MongoCryptCreateDataKeyError, MongoCryptCreateEncryptedCollectionError } from '../../mongodb'; +import { ensureTypeByName } from '../../tools/utils'; class MockClient { options: any; s: { options: any }; @@ -99,27 +100,33 @@ describe('ClientEncryption', function () { const error = await clientEncryption .createEncryptedCollection(db, collectionName) .catch(error => error); - expect(error) - .to.be.instanceOf(TypeError) - .to.match(/provider/); + // expect(error) + // .to.be.instanceOf(TypeError) + // .to.match(/provider/); + ensureTypeByName(error, 'TypeError'); + expect(error.message).to.match(/provider/); }); it('throws TypeError if options.createCollectionOptions are omitted', async () => { const error = await clientEncryption .createEncryptedCollection(db, collectionName, {}) .catch(error => error); - expect(error) - .to.be.instanceOf(TypeError) - .to.match(/encryptedFields/); + // expect(error) + // .to.be.instanceOf(TypeError) + // .to.match(/encryptedFields/); + ensureTypeByName(error, 'TypeError'); + expect(error.message).to.match(/encryptedFields/); }); it('throws TypeError if options.createCollectionOptions.encryptedFields are omitted', async () => { const error = await clientEncryption .createEncryptedCollection(db, collectionName, { createCollectionOptions: {} }) .catch(error => error); - expect(error) - .to.be.instanceOf(TypeError) - .to.match(/Cannot read properties/); + // expect(error) + // .to.be.instanceOf(TypeError) + // .to.match(/Cannot read properties/); + ensureTypeByName(error, 'TypeError'); + expect(error.message).to.match(/Cannot read properties/); }); }); diff --git a/test/unit/client-side-encryption/providers/credentialsProvider.test.ts b/test/unit/client-side-encryption/providers/credentialsProvider.test.ts index 7e8ce19ebb..cf18014c04 100644 --- a/test/unit/client-side-encryption/providers/credentialsProvider.test.ts +++ b/test/unit/client-side-encryption/providers/credentialsProvider.test.ts @@ -6,6 +6,7 @@ import * as sinon from 'sinon'; // Intentionally import from src, because we need to stub the `get()` function. // eslint-disable-next-line @typescript-eslint/no-restricted-imports import * as utils from '../../../../src/utils'; +import { runNodelessTests } from '../../../mongodb'; import { AWSSDKCredentialProvider, fetchAzureKMSToken, @@ -15,7 +16,7 @@ import { MongoNetworkTimeoutError, refreshKMSCredentials, tokenCache -} from '../../../mongodb'; +} from '../../../mongodb_all'; // continue to import from mongodb_all, skipping these tests for nodeless import * as requirements from '../requirements.helper'; const originalAccessKeyId = process.env.AWS_ACCESS_KEY_ID; @@ -23,6 +24,12 @@ const originalSecretAccessKey = process.env.AWS_SECRET_ACCESS_KEY; const originalSessionToken = process.env.AWS_SESSION_TOKEN; describe('#refreshKMSCredentials', function () { + before(function () { + if (runNodelessTests) { + this.skip(); + } + }); + context('isEmptyCredentials()', () => { it('returns true for an empty object', () => { expect(isEmptyCredentials('aws', { aws: {} })).to.be.true; diff --git a/test/unit/cmap/commands.test.ts b/test/unit/cmap/commands.test.ts index 5725f5b249..3bd13de98f 100644 --- a/test/unit/cmap/commands.test.ts +++ b/test/unit/cmap/commands.test.ts @@ -123,7 +123,7 @@ describe('commands', function () { it('throws an exception', function () { const response = new OpReply(message, header, body); - expect(() => response.parse()).to.throw(RangeError, /outside buffer bounds/); + expect(() => response.parse()).to.throw(/outside buffer bounds/); }); }); @@ -140,7 +140,7 @@ describe('commands', function () { it('throws an exception', function () { const response = new OpReply(message, header, body); - expect(() => response.parse()).to.throw(RangeError, /Invalid array length/i); + expect(() => response.parse()).to.throw(/Invalid array length/i); }); }); }); diff --git a/test/unit/cmap/handshake/client_metadata.test.ts b/test/unit/cmap/handshake/client_metadata.test.ts index 0915f2e2bd..6900ecf1e0 100644 --- a/test/unit/cmap/handshake/client_metadata.test.ts +++ b/test/unit/cmap/handshake/client_metadata.test.ts @@ -10,7 +10,8 @@ import { getFAASEnv, LimitedSizeDocument, makeClientMetadata, - MongoInvalidArgumentError + MongoInvalidArgumentError, + runNodelessTests } from '../../../mongodb'; import { runtime } from '../../../tools/utils'; describe('client metadata module', () => { @@ -315,6 +316,12 @@ describe('client metadata module', () => { }); context('when globalThis indicates alternative runtime', () => { + beforeEach(function () { + if (runNodelessTests) { + this.skip(); // these tests are meant to run in node and will fail in nodeless environments due to the presence of globalThis.Bun or globalThis.Deno + } + }); + context('deno', () => { afterEach(() => { expect(delete globalThis.Deno, 'failed to delete Deno global').to.be.true; diff --git a/test/unit/commands.test.ts b/test/unit/commands.test.ts index 3f601c678c..ae8dbaf7d8 100644 --- a/test/unit/commands.test.ts +++ b/test/unit/commands.test.ts @@ -11,10 +11,17 @@ import { OpCompressedRequest, OpMsgRequest, OpQueryRequest, + runNodelessTests, uncompressibleCommands } from '../mongodb'; describe('class OpCompressedRequest', () => { + before(function () { + if (runNodelessTests) { + this.skip(); + } + }); + context('canCompress()', () => { for (const command of uncompressibleCommands) { it(`returns true when the command is ${command}`, () => { diff --git a/test/unit/mongo_client.test.ts b/test/unit/mongo_client.test.ts index 80e53450dd..327efec3d3 100644 --- a/test/unit/mongo_client.test.ts +++ b/test/unit/mongo_client.test.ts @@ -23,6 +23,7 @@ import { SeverityLevel, WriteConcern } from '../mongodb'; +import { ensureTypeByName } from '../tools/utils'; describe('MongoClient', function () { it('programmatic options should override URI options', function () { @@ -1207,7 +1208,8 @@ describe('MongoClient', function () { it('when client.close is pending, client.closeLock is set', () => { client.close(); - expect(client.closeLock).to.be.instanceOf(Promise); + // expect(client.closeLock).to.be.instanceOf(Promise); + ensureTypeByName(client.closeLock, 'Promise'); }); it('when client.close is not pending, client.closeLock is not set', async () => { diff --git a/test/unit/nodeless.test.ts b/test/unit/nodeless.test.ts index de665064ba..655c65cdd7 100644 --- a/test/unit/nodeless.test.ts +++ b/test/unit/nodeless.test.ts @@ -1,16 +1,17 @@ import { expect } from 'chai'; import { env } from 'process'; -import { runNodelessTests } from '../mongodb_runtime-testing'; +import { runNodelessTests } from '../mongodb'; describe('Nodeless tests', function () { it('runNodelessTests variable should match env vars', function () { - const nodelessEnv = env.NODELESS; + const nodelessEnv = env.MONGODB_BUNDLED; const expectedNodeless = nodelessEnv === 'true'; const actualNodeless = runNodelessTests; expect(actualNodeless).to.equal( expectedNodeless, - "runNodelessTests variable does not match NODELESS env var, run 'npm run build:runtime-barrel' to update the barrel file" + `runNodelessTests (${actualNodeless}) does not match MONGODB_BUNDLED env var (${nodelessEnv})` + + " run 'npm run build:runtime-barrel' to update the barrel file" ); }); }); diff --git a/test/unit/sdam/monitor.test.ts b/test/unit/sdam/monitor.test.ts index 03edc95361..54ccef9393 100644 --- a/test/unit/sdam/monitor.test.ts +++ b/test/unit/sdam/monitor.test.ts @@ -16,6 +16,7 @@ import { Monitor, MonitorInterval, RTTSampler, + runNodelessTests, ServerDescription, type ServerHeartbeatFailedEvent, type ServerHeartbeatStartedEvent, @@ -51,6 +52,12 @@ class MockServer { describe('monitoring', function () { let mockServer; + before(function () { + if (runNodelessTests) { + this.skip(); + } + }); + beforeEach(function () { // eslint-disable-next-line @typescript-eslint/no-non-null-assertion const test = this.currentTest!; diff --git a/test/unit/timeout.test.ts b/test/unit/timeout.test.ts index 5fbdf0c7a5..b4783d7881 100644 --- a/test/unit/timeout.test.ts +++ b/test/unit/timeout.test.ts @@ -8,9 +8,9 @@ import { Timeout, TimeoutContext, TimeoutError -} from '../mongodb_runtime-testing'; +} from '../mongodb'; -describe('Timeout', function () { +describe.only('Timeout', function () { let timeout: Timeout; beforeEach(() => { diff --git a/test/unit/utils.test.ts b/test/unit/utils.test.ts index e0783eb530..003d5fabc7 100644 --- a/test/unit/utils.test.ts +++ b/test/unit/utils.test.ts @@ -24,7 +24,7 @@ import { MongoRuntimeError, shuffle } from '../mongodb'; -import { sleep } from '../tools/utils'; +import { ensureTypeByName, sleep } from '../tools/utils'; describe('driver utils', function () { describe('.hasAtomicOperators', function () { @@ -463,8 +463,7 @@ describe('driver utils', function () { describe('*[Symbol.iterator]()', () => { it('should be instanceof GeneratorFunction', () => { const list = new List(); - // eslint-disable-next-line @typescript-eslint/no-empty-function - expect(list[Symbol.iterator]).to.be.instanceOf(function* () {}.constructor); + ensureTypeByName(list[Symbol.iterator], 'GeneratorFunction'); }); it('should only run generator for the number of items in the list', () => { From 837f71a38910d18c3b55bfd11fc5288462caac0c Mon Sep 17 00:00:00 2001 From: Pavel Safronov Date: Tue, 24 Feb 2026 15:54:55 -0800 Subject: [PATCH 30/36] remove incorrect import --- test/integration/index_management.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/integration/index_management.test.ts b/test/integration/index_management.test.ts index 0316c07ab4..d824dea7d7 100644 --- a/test/integration/index_management.test.ts +++ b/test/integration/index_management.test.ts @@ -7,7 +7,7 @@ import { type Db, type MongoClient, MongoServerError -} from '../mongodb_runtime-testing'; +} from '../mongodb'; import { type FailCommandFailPoint } from '../tools/utils'; import { assert as test, filterForCommands, setupDatabase } from './shared'; From e1877694ec93341558cbb31a59d4887dc6d7422c Mon Sep 17 00:00:00 2001 From: Pavel Safronov Date: Tue, 24 Feb 2026 15:57:35 -0800 Subject: [PATCH 31/36] remove debug calls --- test/tools/utils.ts | 1 - .../server_discovery_and_monitoring.spec.test.ts | 11 +---------- 2 files changed, 1 insertion(+), 11 deletions(-) diff --git a/test/tools/utils.ts b/test/tools/utils.ts index 3c0d8eb88a..300beeb10d 100644 --- a/test/tools/utils.ts +++ b/test/tools/utils.ts @@ -33,7 +33,6 @@ export function ensureCalledWith(stub: any, args: any[]) { } export function checkTypeByName(obj: any, typeName: string): boolean { - console.log(`pavel >>> checking obj: ${obj} for type ${typeName}`); if (obj !== null && obj.constructor != null && obj.constructor.name === typeName) { return true; } diff --git a/test/unit/assorted/server_discovery_and_monitoring.spec.test.ts b/test/unit/assorted/server_discovery_and_monitoring.spec.test.ts index 562c5b308b..bd1d197db7 100644 --- a/test/unit/assorted/server_discovery_and_monitoring.spec.test.ts +++ b/test/unit/assorted/server_discovery_and_monitoring.spec.test.ts @@ -468,21 +468,12 @@ async function executeSDAMTest(testData: SDAMTest) { checkTypeByName(error, 'MongoNetworkError') || checkTypeByName(error, 'MongoNetworkTimeoutError') || checkTypeByName(error, 'MongoServerError'); - console.log(`pavel >>> checking error: ${error.name}, result: ${result}`); return result; }; expect( thrownError, `expected the error thrown to be one of MongoNetworkError, MongoNetworkTimeoutError or MongoServerError (referred to in the spec as an "Application Error") got ${thrownError.name} ${thrownError.stack}` - ).to.satisfy(e => { - const result = isApplicationError(e); - if (!result) { - console.error( - `pavel >>> unexpected error thrown from SDAM test: ${e.name} ${e.stack}` - ); - } - return result; - }); + ).to.satisfy(isApplicationError); } } else if (phase.outcome != null && Object.keys(phase).length === 1) { // Load Balancer SDAM tests have no "work" to be done for the phase From 670f69e814a0118d44e95da6e477c80a47c5ede8 Mon Sep 17 00:00:00 2001 From: Pavel Safronov Date: Tue, 24 Feb 2026 16:00:51 -0800 Subject: [PATCH 32/36] minor fixes --- .../client-side-encryption/client_encryption.test.ts | 9 --------- test/unit/mongo_client.test.ts | 1 - test/unit/timeout.test.ts | 2 +- 3 files changed, 1 insertion(+), 11 deletions(-) diff --git a/test/unit/client-side-encryption/client_encryption.test.ts b/test/unit/client-side-encryption/client_encryption.test.ts index 1e81df434e..c5e26cc39a 100644 --- a/test/unit/client-side-encryption/client_encryption.test.ts +++ b/test/unit/client-side-encryption/client_encryption.test.ts @@ -100,9 +100,6 @@ describe('ClientEncryption', function () { const error = await clientEncryption .createEncryptedCollection(db, collectionName) .catch(error => error); - // expect(error) - // .to.be.instanceOf(TypeError) - // .to.match(/provider/); ensureTypeByName(error, 'TypeError'); expect(error.message).to.match(/provider/); }); @@ -111,9 +108,6 @@ describe('ClientEncryption', function () { const error = await clientEncryption .createEncryptedCollection(db, collectionName, {}) .catch(error => error); - // expect(error) - // .to.be.instanceOf(TypeError) - // .to.match(/encryptedFields/); ensureTypeByName(error, 'TypeError'); expect(error.message).to.match(/encryptedFields/); }); @@ -122,9 +116,6 @@ describe('ClientEncryption', function () { const error = await clientEncryption .createEncryptedCollection(db, collectionName, { createCollectionOptions: {} }) .catch(error => error); - // expect(error) - // .to.be.instanceOf(TypeError) - // .to.match(/Cannot read properties/); ensureTypeByName(error, 'TypeError'); expect(error.message).to.match(/Cannot read properties/); }); diff --git a/test/unit/mongo_client.test.ts b/test/unit/mongo_client.test.ts index 327efec3d3..7365095089 100644 --- a/test/unit/mongo_client.test.ts +++ b/test/unit/mongo_client.test.ts @@ -1208,7 +1208,6 @@ describe('MongoClient', function () { it('when client.close is pending, client.closeLock is set', () => { client.close(); - // expect(client.closeLock).to.be.instanceOf(Promise); ensureTypeByName(client.closeLock, 'Promise'); }); diff --git a/test/unit/timeout.test.ts b/test/unit/timeout.test.ts index b4783d7881..1dd7e83feb 100644 --- a/test/unit/timeout.test.ts +++ b/test/unit/timeout.test.ts @@ -10,7 +10,7 @@ import { TimeoutError } from '../mongodb'; -describe.only('Timeout', function () { +describe('Timeout', function () { let timeout: Timeout; beforeEach(() => { From 4d537b2addc2d0897e91970f8236712a1ada9c73 Mon Sep 17 00:00:00 2001 From: Pavel Safronov Date: Wed, 25 Feb 2026 08:52:56 -0800 Subject: [PATCH 33/36] pr feedback: remove duplicates --- test/mongodb_all.ts | 8 -------- 1 file changed, 8 deletions(-) diff --git a/test/mongodb_all.ts b/test/mongodb_all.ts index 9c3234acd7..d98518f6f3 100644 --- a/test/mongodb_all.ts +++ b/test/mongodb_all.ts @@ -61,11 +61,8 @@ export * from '../src/cursor/change_stream_cursor'; export * from '../src/cursor/client_bulk_write_cursor'; export * from '../src/cursor/explainable_cursor'; export * from '../src/cursor/find_cursor'; -export * from '../src/cursor/find_cursor'; -export * from '../src/cursor/list_collections_cursor'; export * from '../src/cursor/list_collections_cursor'; export * from '../src/cursor/list_indexes_cursor'; -export * from '../src/cursor/list_indexes_cursor'; export * from '../src/cursor/list_search_indexes_cursor'; export * from '../src/cursor/run_command_cursor'; export * from '../src/db'; @@ -79,15 +76,10 @@ export * from '../src/gridfs/upload'; export * from '../src/mongo_client'; export * from '../src/mongo_client_auth_providers'; export * from '../src/mongo_logger'; -export * from '../src/mongo_logger'; export * from '../src/mongo_types'; -export * from '../src/mongo_types'; -export * from '../src/operations/aggregate'; export * from '../src/operations/aggregate'; export * from '../src/operations/client_bulk_write/client_bulk_write'; export * from '../src/operations/client_bulk_write/command_builder'; -export * from '../src/operations/client_bulk_write/command_builder'; -export * from '../src/operations/client_bulk_write/common'; export * from '../src/operations/client_bulk_write/common'; export * from '../src/operations/client_bulk_write/executor'; export * from '../src/operations/client_bulk_write/results_merger'; From e3703f03e923dc3197d1647f187437d0baca3f7e Mon Sep 17 00:00:00 2001 From: Pavel Safronov Date: Wed, 25 Feb 2026 13:20:11 -0800 Subject: [PATCH 34/36] script and eslint updated --- .eslintrc.json | 5 ++- .evergreen/run-azure-kms-tests.sh | 2 ++ .evergreen/run-gcp-kms-tests.sh | 2 ++ .evergreen/run-mongosh-scope-test.sh | 2 ++ package.json | 33 +++++++++-------- test/mongodb_bundled.ts | 50 ++++++++++++++++++++++++-- test/tools/runner/vm_context_helper.ts | 12 +++---- test/tools/utils.ts | 1 + 8 files changed, 80 insertions(+), 27 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 404f9cffdd..a1fad4ea22 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1,6 +1,9 @@ { "root": true, "parser": "@typescript-eslint/parser", + "ignorePatterns": [ + "test/tools/runner/bundle/**" + ], "parserOptions": { "ecmaVersion": 2023 }, @@ -346,4 +349,4 @@ } } ] -} \ No newline at end of file +} diff --git a/.evergreen/run-azure-kms-tests.sh b/.evergreen/run-azure-kms-tests.sh index c8818962d4..c0d56c9259 100644 --- a/.evergreen/run-azure-kms-tests.sh +++ b/.evergreen/run-azure-kms-tests.sh @@ -18,4 +18,6 @@ export MONGODB_URI="mongodb://localhost:27017" export EXPECTED_AZUREKMS_OUTCOME=${EXPECTED_AZUREKMS_OUTCOME:-omitted} export TEST_CSFLE=true +npm run build:bundle + npx mocha --config test/mocha_mongodb.js test/integration/client-side-encryption/client_side_encryption.prose.19.on_demand_azure.test.ts diff --git a/.evergreen/run-gcp-kms-tests.sh b/.evergreen/run-gcp-kms-tests.sh index ecc88e535e..f18ed9c069 100644 --- a/.evergreen/run-gcp-kms-tests.sh +++ b/.evergreen/run-gcp-kms-tests.sh @@ -20,4 +20,6 @@ export MONGODB_URI="mongodb://localhost:27017" export EXPECTED_GCPKMS_OUTCOME=${EXPECTED_GCPKMS_OUTCOME:-omitted} export TEST_CSFLE=true +npm run build:bundle + npx mocha --config test/mocha_mongodb.js test/integration/client-side-encryption/client_side_encryption.prose.17.on_demand_gcp.test.ts diff --git a/.evergreen/run-mongosh-scope-test.sh b/.evergreen/run-mongosh-scope-test.sh index e2477dda4c..d9d5451f15 100644 --- a/.evergreen/run-mongosh-scope-test.sh +++ b/.evergreen/run-mongosh-scope-test.sh @@ -13,4 +13,6 @@ export SCOPES=$(./node_modules/lerna/cli.js ls --all --json) cd - +npm run build:bundle + npx mocha --config test/manual/mocharc.json test/manual/mongosh_scopes.test.ts diff --git a/package.json b/package.json index 506979984d..706dc6b536 100644 --- a/package.json +++ b/package.json @@ -132,32 +132,31 @@ "check:bench": "npm --prefix test/benchmarks/driver_bench start", "check:coverage": "nyc npm run test:all", "check:integration-coverage": "nyc npm run check:test", - "check:lambda": "nyc mocha --config test/mocha_lambda.js test/integration/node-specific/examples/handler.test.js", - "check:lambda:aws": "nyc mocha --config test/mocha_lambda.js test/integration/node-specific/examples/aws_handler.test.js", + "check:lambda": "npm run build:bundle && nyc mocha --config test/mocha_lambda.js test/integration/node-specific/examples/handler.test.js", + "check:lambda:aws": "npm run build:bundle && nyc mocha --config test/mocha_lambda.js test/integration/node-specific/examples/aws_handler.test.js", "check:lint": "npm run build:dts && npm run check:dts && npm run check:eslint && npm run check:tsd", "check:eslint": "npm run build:dts && ESLINT_USE_FLAT_CONFIG=false eslint -v && ESLINT_USE_FLAT_CONFIG=false eslint --max-warnings=0 --ext '.js,.ts' src test", "check:tsd": "tsd --version && tsd", - "check:dependencies": "mocha test/action/dependency.test.ts", + "check:dependencies": "npm run build:bundle && mocha test/action/dependency.test.ts", "check:dts": "node ./node_modules/typescript/bin/tsc --target es2023 --module commonjs --noEmit mongodb.d.ts && tsd", - "check:search-indexes": "nyc mocha --config test/mocha_mongodb.js test/manual/search-index-management.prose.test.ts", + "check:search-indexes": "npm run build:bundle && nyc mocha --config test/mocha_mongodb.js test/manual/search-index-management.prose.test.ts", "check:test": "npm run build:bundle && nyc mocha --config test/mocha_mongodb.js test/integration", "check:test-bundled": "MONGODB_BUNDLED=true npm run check:test", "check:unit": "npm run build:bundle && nyc mocha test/unit", "check:unit-bundled": "MONGODB_BUNDLED=true npm run check:unit", "check:ts": "node ./node_modules/typescript/bin/tsc -v && node ./node_modules/typescript/bin/tsc --noEmit", - "check:atlas": "nyc mocha --config test/manual/mocharc.js test/manual/atlas_connectivity.test.ts", - "check:drivers-atlas-testing": "nyc mocha --config test/mocha_mongodb.js test/atlas/drivers_atlas_testing.test.ts", - "check:aws": "nyc mocha --config test/mocha_mongodb.js test/integration/auth/mongodb_aws.test.ts test/integration/auth/mongodb_aws.prose.test.ts", - "check:oidc-auth": "nyc mocha --config test/mocha_mongodb.js test/integration/auth/auth.spec.test.ts", - "check:oidc-test": "nyc mocha --config test/mocha_mongodb.js test/integration/auth/mongodb_oidc.prose.test.ts", - "check:kerberos": "nyc mocha --config test/manual/mocharc.js test/manual/kerberos.test.ts", - "check:tls": "nyc mocha --config test/manual/mocharc.js test/manual/tls_support.test.ts", - "check:ldap": "nyc mocha --config test/manual/mocharc.js test/manual/ldap.test.ts", - "check:socks5": "nyc mocha --config test/manual/mocharc.js test/manual/socks5.test.ts", - "check:csfle": "nyc mocha --config test/mocha_mongodb.js test/integration/client-side-encryption", - "check:snappy": "nyc mocha test/unit/assorted/snappy.test.js", - "check:x509": "nyc mocha test/manual/x509_auth.test.ts", - "check:runtime-independence": "ts-node test/tools/runner/vm_context_helper.ts test/integration/change-streams/change_stream.test.ts", + "check:atlas": "npm run build:bundle && nyc mocha --config test/manual/mocharc.js test/manual/atlas_connectivity.test.ts", + "check:drivers-atlas-testing": "npm run build:bundle && nyc mocha --config test/mocha_mongodb.js test/atlas/drivers_atlas_testing.test.ts", + "check:aws": "npm run build:bundle && nyc mocha --config test/mocha_mongodb.js test/integration/auth/mongodb_aws.test.ts test/integration/auth/mongodb_aws.prose.test.ts", + "check:oidc-auth": "npm run build:bundle && nyc mocha --config test/mocha_mongodb.js test/integration/auth/auth.spec.test.ts", + "check:oidc-test": "npm run build:bundle && nyc mocha --config test/mocha_mongodb.js test/integration/auth/mongodb_oidc.prose.test.ts", + "check:kerberos": "npm run build:bundle && nyc mocha --config test/manual/mocharc.js test/manual/kerberos.test.ts", + "check:tls": "npm run build:bundle && nyc mocha --config test/manual/mocharc.js test/manual/tls_support.test.ts", + "check:ldap": "npm run build:bundle && nyc mocha --config test/manual/mocharc.js test/manual/ldap.test.ts", + "check:socks5": "npm run build:bundle && nyc mocha --config test/manual/mocharc.js test/manual/socks5.test.ts", + "check:csfle": "npm run build:bundle && nyc mocha --config test/mocha_mongodb.js test/integration/client-side-encryption", + "check:snappy": "npm run build:bundle && nyc mocha test/unit/assorted/snappy.test.js", + "check:x509": "npm run build:bundle && nyc mocha test/manual/x509_auth.test.ts", "build:bundle": "npm run bundle:driver && npm run bundle:types && npm run build:runtime-barrel", "build:runtime-barrel": "node etc/build-runtime-barrel.mjs", "bundle:driver": "node etc/bundle-driver.mjs", diff --git a/test/mongodb_bundled.ts b/test/mongodb_bundled.ts index 8454307fd3..1874d040fd 100644 --- a/test/mongodb_bundled.ts +++ b/test/mongodb_bundled.ts @@ -11,7 +11,8 @@ try { } // Export public API from the contextified module -// Hint: This list isn't automatically alphabetized, but VSCode's "Sort Lines Ascending" command can be used to keep it organized +// Hint: This list IS NOT automatically alphabetized +// To re-sort: Highlight the list and use VSCode's "Sort Lines Ascending" command export const { abortable, AbstractCursor, @@ -378,11 +379,13 @@ export type { ConnectionOptions, ConnectionPoolOptions, ConnectOptions, + CreateIndexesOptions, DataKey, DbOptions, Document, DriverInfo, Filter, + IndexDirection, InferIdType, KMSProviders, Log, @@ -399,8 +402,8 @@ export type { Runtime, ServerApi, ServerSessionId, + Sort, TagSet, - TopologyOptions, TopologyVersion, TransactionOptions, UpdateDescription, @@ -425,9 +428,18 @@ import type { CommandStartedEvent as _CommandStartedEvent, CommandSucceededEvent as _CommandSucceededEvent, Connection as _Connection, + ConnectionCheckedInEvent as _ConnectionCheckedInEvent, + ConnectionCheckedOutEvent as _ConnectionCheckedOutEvent, + ConnectionCheckOutFailedEvent as _ConnectionCheckOutFailedEvent, + ConnectionCheckOutStartedEvent as _ConnectionCheckOutStartedEvent, ConnectionClosedEvent as _ConnectionClosedEvent, + ConnectionCreatedEvent as _ConnectionCreatedEvent, ConnectionPool as _ConnectionPool, ConnectionPoolClearedEvent as _ConnectionPoolClearedEvent, + ConnectionPoolClosedEvent as _ConnectionPoolClosedEvent, + ConnectionPoolCreatedEvent as _ConnectionPoolCreatedEvent, + ConnectionPoolReadyEvent as _ConnectionPoolReadyEvent, + ConnectionReadyEvent as _ConnectionReadyEvent, CSOTTimeoutContext as _CSOTTimeoutContext, CursorTimeoutContext as _CursorTimeoutContext, Db as _Db, @@ -435,22 +447,34 @@ import type { GridFSBucket as _GridFSBucket, HostAddress as _HostAddress, MongoClient as _MongoClient, + MongoCredentials as _MongoCredentials, MongoError as _MongoError, OnDemandDocument as _OnDemandDocument, Server as _Server, + ServerApiVersion as _ServerApiVersion, + ServerClosedEvent as _ServerClosedEvent, ServerDescription as _ServerDescription, ServerDescriptionChangedEvent as _ServerDescriptionChangedEvent, + ServerHeartbeatFailedEvent as _ServerHeartbeatFailedEvent, + ServerHeartbeatStartedEvent as _ServerHeartbeatStartedEvent, + ServerHeartbeatSucceededEvent as _ServerHeartbeatSucceededEvent, + ServerOpeningEvent as _ServerOpeningEvent, + ServerSessionPool as _ServerSessionPool, Timeout as _Timeout, TimeoutContext as _TimeoutContext, Topology as _Topology, + TopologyClosedEvent as _TopologyClosedEvent, TopologyDescription as _TopologyDescription, TopologyDescriptionChangedEvent as _TopologyDescriptionChangedEvent, + TopologyOpeningEvent as _TopologyOpeningEvent, + TopologyOptions as _TopologyOptions, TopologyType as _TopologyType, UUID as _UUID } from './tools/runner/bundle/types/index'; // Export "clashing" types from the contextified module -// Hint: This list IS NOT automatically alphabetized, but VSCode's "Sort Lines Ascending" command can be used to keep it organized +// Hint: This list IS NOT automatically alphabetized +// To re-sort: Highlight the list and use VSCode's "Sort Lines Ascending" command export type AbstractCursor = _AbstractCursor; export type AuthMechanism = _AuthMechanism; export type ChangeStream = _ChangeStream; @@ -461,9 +485,18 @@ export type CommandFailedEvent = _CommandFailedEvent; export type CommandStartedEvent = _CommandStartedEvent; export type CommandSucceededEvent = _CommandSucceededEvent; export type Connection = _Connection; +export type ConnectionCheckedInEvent = _ConnectionCheckedInEvent; +export type ConnectionCheckedOutEvent = _ConnectionCheckedOutEvent; +export type ConnectionCheckOutFailedEvent = _ConnectionCheckOutFailedEvent; +export type ConnectionCheckOutStartedEvent = _ConnectionCheckOutStartedEvent; export type ConnectionClosedEvent = _ConnectionClosedEvent; +export type ConnectionCreatedEvent = _ConnectionCreatedEvent; export type ConnectionPool = _ConnectionPool; export type ConnectionPoolClearedEvent = _ConnectionPoolClearedEvent; +export type ConnectionPoolClosedEvent = _ConnectionPoolClosedEvent; +export type ConnectionPoolCreatedEvent = _ConnectionPoolCreatedEvent; +export type ConnectionPoolReadyEvent = _ConnectionPoolReadyEvent; +export type ConnectionReadyEvent = _ConnectionReadyEvent; export type CSOTTimeoutContext = _CSOTTimeoutContext; export type CursorTimeoutContext = _CursorTimeoutContext; export type Db = _Db; @@ -471,16 +504,27 @@ export type FindCursor = _FindCursor; export type GridFSBucket = _GridFSBucket; export type HostAddress = _HostAddress; export type MongoClient = _MongoClient; +export type MongoCredentials = _MongoCredentials; export type MongoError = _MongoError; export type OnDemandDocument = _OnDemandDocument; export type Server = _Server; +export type ServerApiVersion = _ServerApiVersion; +export type ServerClosedEvent = _ServerClosedEvent; export type ServerDescription = _ServerDescription; export type ServerDescriptionChangedEvent = _ServerDescriptionChangedEvent; +export type ServerHeartbeatFailedEvent = _ServerHeartbeatFailedEvent; +export type ServerHeartbeatStartedEvent = _ServerHeartbeatStartedEvent; +export type ServerHeartbeatSucceededEvent = _ServerHeartbeatSucceededEvent; +export type ServerOpeningEvent = _ServerOpeningEvent; +export type ServerSessionPool = _ServerSessionPool; export type Timeout = _Timeout; export type TimeoutContext = _TimeoutContext; export type Topology = _Topology; +export type TopologyClosedEvent = _TopologyClosedEvent; export type TopologyDescription = _TopologyDescription; export type TopologyDescriptionChangedEvent = _TopologyDescriptionChangedEvent; +export type TopologyOpeningEvent = _TopologyOpeningEvent; +export type TopologyOptions = _TopologyOptions; export type TopologyType = _TopologyType; export type UUID = _UUID; diff --git a/test/tools/runner/vm_context_helper.ts b/test/tools/runner/vm_context_helper.ts index c28f77f8ad..a25a72e16e 100644 --- a/test/tools/runner/vm_context_helper.ts +++ b/test/tools/runner/vm_context_helper.ts @@ -27,11 +27,11 @@ function createRestrictedRequire() { const methodAndFile = callStack.split('\n')[2]; const match = methodAndFile.match(/at (.*) \((.*)\)/); const method = match ? match[1] : null; - const sourceFileAndLineNumbers = match ? match[2] : null; + const sourceFileAndLineNumbers = match ? match[2] : 'unknown'; const sourceFile = - sourceFileAndLineNumbers.indexOf('.ts:') !== -1 - ? sourceFileAndLineNumbers.substring(0, sourceFileAndLineNumbers.lastIndexOf('.ts:') + 3) - : sourceFileAndLineNumbers; + sourceFileAndLineNumbers.indexOf('.ts:') === -1 + ? sourceFileAndLineNumbers + : sourceFileAndLineNumbers.substring(0, sourceFileAndLineNumbers.lastIndexOf('.ts:') + 3); const sourceFileName = correctPath.basename(sourceFile); const isAllowed = allowedRequesters.some( requester => @@ -145,8 +145,8 @@ export function loadContextifiedMongoDBModule() { const bundleCode = fs.readFileSync(bundlePath, 'utf8'); - const exportsContainer = {}; - const moduleContainer = { exports: exportsContainer }; + const exportsContainer = { __proto__: null }; + const moduleContainer = { __proto__: null, exports: exportsContainer }; // Wrap the bundle in a CommonJS-style wrapper const wrapper = `(function(exports, module, require) {${bundleCode}})`; diff --git a/test/tools/utils.ts b/test/tools/utils.ts index 300beeb10d..7a77b82a73 100644 --- a/test/tools/utils.ts +++ b/test/tools/utils.ts @@ -14,6 +14,7 @@ import { inspect, promisify } from 'util'; import { type AnyClientBulkWriteModel, type Document, + EJSON, type HostAddress, MongoClient, type MongoClientOptions, From 9183a647f6c2017606cd96f8ac67d8febb112af8 Mon Sep 17 00:00:00 2001 From: Pavel Safronov Date: Thu, 26 Feb 2026 13:28:20 -0800 Subject: [PATCH 35/36] pr feedback: - change how we allow or block modules - change how allowed imports are handled - exported more types - added build step to a script --- package.json | 2 +- src/runtime_adapters.ts | 6 +- test/mongodb_bundled.ts | 3 + test/tools/runner/vm_context_helper.ts | 101 +++++++------------------ 4 files changed, 37 insertions(+), 75 deletions(-) diff --git a/package.json b/package.json index 706dc6b536..f57814f082 100644 --- a/package.json +++ b/package.json @@ -138,7 +138,7 @@ "check:eslint": "npm run build:dts && ESLINT_USE_FLAT_CONFIG=false eslint -v && ESLINT_USE_FLAT_CONFIG=false eslint --max-warnings=0 --ext '.js,.ts' src test", "check:tsd": "tsd --version && tsd", "check:dependencies": "npm run build:bundle && mocha test/action/dependency.test.ts", - "check:dts": "node ./node_modules/typescript/bin/tsc --target es2023 --module commonjs --noEmit mongodb.d.ts && tsd", + "check:dts": "npm run build:bundle && node ./node_modules/typescript/bin/tsc --target es2023 --module commonjs --noEmit mongodb.d.ts && tsd", "check:search-indexes": "npm run build:bundle && nyc mocha --config test/mocha_mongodb.js test/manual/search-index-management.prose.test.ts", "check:test": "npm run build:bundle && nyc mocha --config test/mocha_mongodb.js test/integration", "check:test-bundled": "MONGODB_BUNDLED=true npm run check:test", diff --git a/src/runtime_adapters.ts b/src/runtime_adapters.ts index bb998d4bd0..e0a3e91569 100644 --- a/src/runtime_adapters.ts +++ b/src/runtime_adapters.ts @@ -1,4 +1,4 @@ -/* eslint-disable no-restricted-imports, @typescript-eslint/no-require-imports */ +/* eslint-disable no-restricted-imports*/ // We squash the restricted import errors here because we are using type-only imports, which // do not impact the driver's actual runtime dependencies. @@ -43,7 +43,9 @@ export interface Runtime { * not provided by in `options`, and returns a `Runtime`. */ export function resolveRuntimeAdapters(options: MongoClientOptions): Runtime { + const correctRequire = (globalThis as any).__driver_require || require; + return { - os: options.runtimeAdapters?.os ?? require('os') + os: options.runtimeAdapters?.os ?? correctRequire('os') }; } diff --git a/test/mongodb_bundled.ts b/test/mongodb_bundled.ts index 1874d040fd..90120ded08 100644 --- a/test/mongodb_bundled.ts +++ b/test/mongodb_bundled.ts @@ -385,6 +385,7 @@ export type { Document, DriverInfo, Filter, + FindOptions, IndexDirection, InferIdType, KMSProviders, @@ -449,6 +450,7 @@ import type { MongoClient as _MongoClient, MongoCredentials as _MongoCredentials, MongoError as _MongoError, + ObjectId as _ObjectId, OnDemandDocument as _OnDemandDocument, Server as _Server, ServerApiVersion as _ServerApiVersion, @@ -506,6 +508,7 @@ export type HostAddress = _HostAddress; export type MongoClient = _MongoClient; export type MongoCredentials = _MongoCredentials; export type MongoError = _MongoError; +export type ObjectId = _ObjectId; export type OnDemandDocument = _OnDemandDocument; export type Server = _Server; export type ServerApiVersion = _ServerApiVersion; diff --git a/test/tools/runner/vm_context_helper.ts b/test/tools/runner/vm_context_helper.ts index a25a72e16e..e2b0b3634e 100644 --- a/test/tools/runner/vm_context_helper.ts +++ b/test/tools/runner/vm_context_helper.ts @@ -2,53 +2,37 @@ import * as fs from 'node:fs'; import { isBuiltin } from 'node:module'; -import { platform } from 'node:os'; import * as path from 'node:path'; import * as vm from 'node:vm'; +const allowedModules = new Set([ + '@aws-sdk/credential-providers', + '@mongodb-js/saslprep', + '@mongodb-js/zstd', + 'bson', + 'gcp-metadata', + 'kerberos', + 'mongodb-client-encryption', + 'mongodb-connection-string-url', + 'path', + 'snappy' +]); +const blockedModules = new Set(['os']); + /** * Creates a require function that blocks access to specified core modules */ function createRestrictedRequire() { - const blockedModules = new Set(['os']); - const allowedRequesters = [ - { - file: 'runtime_adapters.ts', - method: 'resolveRuntimeAdapters', - module: 'os' - } - ]; - return function restrictedRequire(moduleName: string) { - // Block core modules - if (isBuiltin(moduleName) && blockedModules.has(moduleName)) { - const callStack = new Error().stack; - const correctPath = platform() === 'win32' ? path.win32 : path.posix; - const methodAndFile = callStack.split('\n')[2]; - const match = methodAndFile.match(/at (.*) \((.*)\)/); - const method = match ? match[1] : null; - const sourceFileAndLineNumbers = match ? match[2] : 'unknown'; - const sourceFile = - sourceFileAndLineNumbers.indexOf('.ts:') === -1 - ? sourceFileAndLineNumbers - : sourceFileAndLineNumbers.substring(0, sourceFileAndLineNumbers.lastIndexOf('.ts:') + 3); - const sourceFileName = correctPath.basename(sourceFile); - const isAllowed = allowedRequesters.some( - requester => - requester.file === sourceFileName && - requester.method === method && - requester.module === moduleName - ); - - if (isAllowed) { - // Allow access to the module if the requester is in the allowlist - } else { - throw new Error( - `Access to core module '${moduleName}' from ${sourceFileName} is restricted in this context` - ); - } + const isModuleBuiltin = isBuiltin(moduleName); + const isModuleAllowed = allowedModules.has(moduleName); + const isModuleBlocked = blockedModules.has(moduleName); + const shouldAllow = isModuleAllowed || isModuleBuiltin; + const shouldBlock = isModuleBlocked || !shouldAllow; + + if (shouldBlock) { + throw new Error(`Access to core module '${moduleName}' is restricted in this context`); } - return require(moduleName); } as NodeRequire; } @@ -77,52 +61,25 @@ const sandbox = vm.createContext({ // Process process: process, + // TODO: NODE-7460 - Remove Error and other unnecessary exports + // Global objects needed for runtime Buffer: Buffer, Headers: global.Headers, - Promise: Promise, Map: Map, - Set: Set, - WeakMap: WeakMap, - WeakSet: WeakSet, - ArrayBuffer: ArrayBuffer, - SharedArrayBuffer: SharedArrayBuffer, - Atomics: Atomics, - DataView: DataView, - Int8Array: Int8Array, - Uint8Array: Uint8Array, - Uint8ClampedArray: Uint8ClampedArray, - Int16Array: Int16Array, - Uint16Array: Uint16Array, - Int32Array: Int32Array, - Uint32Array: Uint32Array, - Float32Array: Float32Array, - Float64Array: Float64Array, - BigInt64Array: BigInt64Array, - BigUint64Array: BigUint64Array, - - // Other necessary globals + Promise: Promise, + Math: Math, TextEncoder: global.TextEncoder, TextDecoder: global.TextDecoder, BigInt: global.BigInt, - Symbol: Symbol, - Proxy: Proxy, - Reflect: Reflect, - Object: Object, - Array: Array, - Function: Function, - String: String, - Number: Number, - Boolean: Boolean, - RegExp: RegExp, - Math: Math, - JSON: JSON, - Intl: global.Intl, crypto: global.crypto, // Custom require that blocks core modules require: createRestrictedRequire(), + // Driver require + __driver_require: require, + // Needed for some modules global: undefined as any, globalThis: undefined as any From 76634cbc9ff166a6672ad8954e1a81756258ef0a Mon Sep 17 00:00:00 2001 From: Pavel Safronov Date: Fri, 27 Feb 2026 14:38:30 -0800 Subject: [PATCH 36/36] pr feedback: - removed unnecessary test checks - added more export types - made suggested fixes - added comments to tests being skipped --- etc/build-runtime-barrel.mjs | 4 +- etc/bundle-driver.mjs | 13 +-- src/client-side-encryption/providers/azure.ts | 5 +- test/mongodb_all.ts | 1 + test/mongodb_bundled.ts | 9 +- test/tools/runner/vm_context_helper.ts | 90 ++++++++++--------- ...rver_discovery_and_monitoring.spec.test.ts | 16 ++-- .../providers/credentialsProvider.test.ts | 7 -- .../cmap/handshake/client_metadata.test.ts | 4 +- test/unit/commands.test.ts | 38 ++++---- test/unit/sdam/monitor.test.ts | 16 ++-- 11 files changed, 109 insertions(+), 94 deletions(-) diff --git a/etc/build-runtime-barrel.mjs b/etc/build-runtime-barrel.mjs index 68a7595e85..3f89b79168 100644 --- a/etc/build-runtime-barrel.mjs +++ b/etc/build-runtime-barrel.mjs @@ -1,12 +1,10 @@ import fs from 'node:fs/promises'; import path from 'node:path'; -import { fileURLToPath } from 'node:url'; // eslint-disable-next-line no-restricted-globals const useBundled = process.env.MONGODB_BUNDLED === 'true'; -const __dirname = path.dirname(fileURLToPath(import.meta.url)); -const rootDir = path.join(__dirname, '..'); +const rootDir = path.join(import.meta.dirname, '..'); const outputBarrelFile = path.join(rootDir, 'test/mongodb.ts'); const source = useBundled ? './mongodb_bundled' : './mongodb_all'; diff --git a/etc/bundle-driver.mjs b/etc/bundle-driver.mjs index e57558f484..f9c4c5dd1b 100755 --- a/etc/bundle-driver.mjs +++ b/etc/bundle-driver.mjs @@ -21,16 +21,17 @@ await esbuild.build({ format: 'cjs', target: 'node20', external: [ - 'bson', - 'mongodb-connection-string-url', + '@aws-sdk/credential-providers', '@mongodb-js/saslprep', '@mongodb-js/zstd', - 'mongodb-client-encryption', - 'snappy', '@napi-rs/snappy*', - 'kerberos', + 'bson', 'gcp-metadata', - '@aws-sdk/credential-providers' + 'kerberos', + 'mongodb-client-encryption', + 'mongodb-connection-string-url', + 'snappy', + 'socks' ], plugins: [ { diff --git a/src/client-side-encryption/providers/azure.ts b/src/client-side-encryption/providers/azure.ts index 5dcb9c4f15..97a2665ee9 100644 --- a/src/client-side-encryption/providers/azure.ts +++ b/src/client-side-encryption/providers/azure.ts @@ -163,10 +163,7 @@ export async function fetchAzureKMSToken( const response = await get(url, { headers }); return await parseResponse(response); } catch (error) { - if ( - error instanceof MongoNetworkTimeoutError || - (error && error.constructor && error.constructor.name === 'MongoNetworkTimeoutError') - ) { + if (error instanceof MongoNetworkTimeoutError) { throw new MongoCryptAzureKMSRequestError(`[Azure KMS] ${error.message}`); } throw error; diff --git a/test/mongodb_all.ts b/test/mongodb_all.ts index d98518f6f3..16beb26c90 100644 --- a/test/mongodb_all.ts +++ b/test/mongodb_all.ts @@ -128,6 +128,7 @@ export * from '../src/sdam/topology_description'; export * from '../src/sessions'; export * from '../src/sort'; export * from '../src/timeout'; +export * from '../src/token_bucket'; export * from '../src/transactions'; export * from '../src/utils'; export * from '../src/write_concern'; diff --git a/test/mongodb_bundled.ts b/test/mongodb_bundled.ts index 90120ded08..a932265376 100644 --- a/test/mongodb_bundled.ts +++ b/test/mongodb_bundled.ts @@ -3,7 +3,7 @@ import { loadContextifiedMongoDBModule } from './tools/runner/vm_context_helper' type all = typeof import('./mongodb_all'); let exportSource: all; try { - exportSource = loadContextifiedMongoDBModule() as all; + exportSource = loadContextifiedMongoDBModule(); } catch (error) { throw new Error( `Failed to load contextified MongoDB module: ${error instanceof Error ? error.message : String(error)}` @@ -152,6 +152,7 @@ export const { HEARTBEAT_EVENTS, HostAddress, hostMatchesWildcards, + INITIAL_TOKEN_BUCKET_SIZE, InsertOneOperation, InsertOperation, Int32, @@ -450,8 +451,11 @@ import type { MongoClient as _MongoClient, MongoCredentials as _MongoCredentials, MongoError as _MongoError, + Monitor as _Monitor, + MonitorInterval as _MonitorInterval, ObjectId as _ObjectId, OnDemandDocument as _OnDemandDocument, + RTTSampler as _RTTSampler, Server as _Server, ServerApiVersion as _ServerApiVersion, ServerClosedEvent as _ServerClosedEvent, @@ -508,8 +512,11 @@ export type HostAddress = _HostAddress; export type MongoClient = _MongoClient; export type MongoCredentials = _MongoCredentials; export type MongoError = _MongoError; +export type Monitor = _Monitor; +export type MonitorInterval = _MonitorInterval; export type ObjectId = _ObjectId; export type OnDemandDocument = _OnDemandDocument; +export type RTTSampler = _RTTSampler; export type Server = _Server; export type ServerApiVersion = _ServerApiVersion; export type ServerClosedEvent = _ServerClosedEvent; diff --git a/test/tools/runner/vm_context_helper.ts b/test/tools/runner/vm_context_helper.ts index e2b0b3634e..64e3e5be9d 100644 --- a/test/tools/runner/vm_context_helper.ts +++ b/test/tools/runner/vm_context_helper.ts @@ -1,4 +1,4 @@ -/* eslint-disable no-restricted-globals, @typescript-eslint/no-require-imports */ +/* eslint-disable @typescript-eslint/no-require-imports */ import * as fs from 'node:fs'; import { isBuiltin } from 'node:module'; @@ -15,10 +15,42 @@ const allowedModules = new Set([ 'mongodb-client-encryption', 'mongodb-connection-string-url', 'path', - 'snappy' + 'snappy', + 'socks' ]); const blockedModules = new Set(['os']); +// TODO: NODE-7460 - Remove Error and other unnecessary exports +const exposedGlobals = new Set([ + 'AbortController', + 'AbortSignal', + 'BigInt', + 'Buffer', + 'Date', + 'Error', + 'Headers', + 'Map', + 'Math', + 'Promise', + 'TextDecoder', + 'TextEncoder', + 'URL', + 'URLSearchParams', + + 'console', + 'crypto', + 'performance', + 'process', + + 'clearImmediate', + 'clearInterval', + 'clearTimeout', + 'setImmediate', + 'setInterval', + 'setTimeout', + 'queueMicrotask' +]); + /** * Creates a require function that blocks access to specified core modules */ @@ -34,46 +66,12 @@ function createRestrictedRequire() { throw new Error(`Access to core module '${moduleName}' is restricted in this context`); } return require(moduleName); - } as NodeRequire; + } as NodeJS.Require; } -// Create a sandbox context with necessary globals -const sandbox = vm.createContext({ +const context = { __proto__: null, - // Console and timing - console: console, - AbortController: AbortController, - AbortSignal: AbortSignal, - Date: global.Date, - Error: global.Error, - URL: global.URL, - URLSearchParams: global.URLSearchParams, - queueMicrotask: queueMicrotask, - performance: global.performance, - setTimeout: global.setTimeout, - clearTimeout: global.clearTimeout, - setInterval: global.setInterval, - clearInterval: global.clearInterval, - setImmediate: global.setImmediate, - clearImmediate: global.clearImmediate, - - // Process - process: process, - - // TODO: NODE-7460 - Remove Error and other unnecessary exports - - // Global objects needed for runtime - Buffer: Buffer, - Headers: global.Headers, - Map: Map, - Promise: Promise, - Math: Math, - TextEncoder: global.TextEncoder, - TextDecoder: global.TextDecoder, - BigInt: global.BigInt, - crypto: global.crypto, - // Custom require that blocks core modules require: createRestrictedRequire(), @@ -83,7 +81,17 @@ const sandbox = vm.createContext({ // Needed for some modules global: undefined as any, globalThis: undefined as any -}); +}; + +// Expose allowed globals in the context +for (const globalName of exposedGlobals) { + if (globalName in global) { + context[globalName] = (global as any)[globalName]; + } +} + +// Create a sandbox context with necessary globals +const sandbox = vm.createContext(context); // Make global and globalThis point to the sandbox sandbox.global = sandbox; @@ -93,7 +101,7 @@ sandbox.globalThis = sandbox; * Load the bundled MongoDB driver module in a VM context * This allows us to control the globals that the driver has access to */ -export function loadContextifiedMongoDBModule() { +export function loadContextifiedMongoDBModule(): typeof import('../../mongodb_all') { const bundlePath = path.join(__dirname, 'bundle/driver-bundle.js'); if (!fs.existsSync(bundlePath)) { @@ -114,5 +122,5 @@ export function loadContextifiedMongoDBModule() { // Execute the bundle with the restricted require from the sandbox fn(moduleContainer.exports, moduleContainer, sandbox.require); - return moduleContainer.exports; + return moduleContainer.exports as unknown as typeof import('../../mongodb_all'); } diff --git a/test/unit/assorted/server_discovery_and_monitoring.spec.test.ts b/test/unit/assorted/server_discovery_and_monitoring.spec.test.ts index bd1d197db7..c9abe0e5a4 100644 --- a/test/unit/assorted/server_discovery_and_monitoring.spec.test.ts +++ b/test/unit/assorted/server_discovery_and_monitoring.spec.test.ts @@ -195,22 +195,22 @@ describe('Server Discovery and Monitoring (spec)', function () { let serverConnect: sinon.SinonStub; before(function () { - if (runNodelessTests) { - this.skip(); - } - serverConnect = sinon.stub(Server.prototype, 'connect').callsFake(function () { this.s.state = 'connected'; this.emit('connect'); }); }); - after(() => { + after(function () { + serverConnect.restore(); + }); + + beforeEach(function () { if (runNodelessTests) { - return; + this.currentTest.skipReason = + 'SDAM spec tests rely heavily on stubbing Connection behavior, which is not currently possible in nodeless environments'; + this.currentTest.skip(); } - - serverConnect.restore(); }); const specTests = collectTests(); diff --git a/test/unit/client-side-encryption/providers/credentialsProvider.test.ts b/test/unit/client-side-encryption/providers/credentialsProvider.test.ts index cf18014c04..6dd66db2e9 100644 --- a/test/unit/client-side-encryption/providers/credentialsProvider.test.ts +++ b/test/unit/client-side-encryption/providers/credentialsProvider.test.ts @@ -6,7 +6,6 @@ import * as sinon from 'sinon'; // Intentionally import from src, because we need to stub the `get()` function. // eslint-disable-next-line @typescript-eslint/no-restricted-imports import * as utils from '../../../../src/utils'; -import { runNodelessTests } from '../../../mongodb'; import { AWSSDKCredentialProvider, fetchAzureKMSToken, @@ -24,12 +23,6 @@ const originalSecretAccessKey = process.env.AWS_SECRET_ACCESS_KEY; const originalSessionToken = process.env.AWS_SESSION_TOKEN; describe('#refreshKMSCredentials', function () { - before(function () { - if (runNodelessTests) { - this.skip(); - } - }); - context('isEmptyCredentials()', () => { it('returns true for an empty object', () => { expect(isEmptyCredentials('aws', { aws: {} })).to.be.true; diff --git a/test/unit/cmap/handshake/client_metadata.test.ts b/test/unit/cmap/handshake/client_metadata.test.ts index 6900ecf1e0..be8e2c2ca2 100644 --- a/test/unit/cmap/handshake/client_metadata.test.ts +++ b/test/unit/cmap/handshake/client_metadata.test.ts @@ -318,7 +318,9 @@ describe('client metadata module', () => { context('when globalThis indicates alternative runtime', () => { beforeEach(function () { if (runNodelessTests) { - this.skip(); // these tests are meant to run in node and will fail in nodeless environments due to the presence of globalThis.Bun or globalThis.Deno + this.currentTest.skipReason = + 'These tests are meant to run in node and will fail in nodeless environments'; + this.currentTest.skip(); } }); diff --git a/test/unit/commands.test.ts b/test/unit/commands.test.ts index ae8dbaf7d8..4bda290ac3 100644 --- a/test/unit/commands.test.ts +++ b/test/unit/commands.test.ts @@ -16,12 +16,6 @@ import { } from '../mongodb'; describe('class OpCompressedRequest', () => { - before(function () { - if (runNodelessTests) { - this.skip(); - } - }); - context('canCompress()', () => { for (const command of uncompressibleCommands) { it(`returns true when the command is ${command}`, () => { @@ -96,20 +90,30 @@ describe('class OpCompressedRequest', () => { expect(compressedMessage).to.deep.equal(expectedCompressedCommand); }); - it('respects the zlib compression level', async () => { - const spy = sinon.spy(compression, 'compress'); - const [messageHeader] = await new OpCompressedRequest(msg, { - agreedCompressor: 'snappy', - zlibCompressionLevel: 3 - }).toBin(); + describe('zlib compression', function () { + before(function () { + if (runNodelessTests) { + this.currentTest.skipReason = + 'This test relies on sinon spying on the compress() function, which is not currently possible in nodeless environments'; + this.currentTest.skip(); + } + }); - expect(messageHeader.readInt32LE(12), 'opcode is not OP_COMPRESSED').to.equal(2012); + it('respects the zlib compression level', async function () { + const spy = sinon.spy(compression, 'compress'); + const [messageHeader] = await new OpCompressedRequest(msg, { + agreedCompressor: 'snappy', + zlibCompressionLevel: 3 + }).toBin(); - expect(spy).to.have.been.called; + expect(messageHeader.readInt32LE(12), 'opcode is not OP_COMPRESSED').to.equal(2012); - expect(spy.args[0][0]).to.deep.equal({ - agreedCompressor: 'snappy', - zlibCompressionLevel: 3 + expect(spy).to.have.been.called; + + expect(spy.args[0][0]).to.deep.equal({ + agreedCompressor: 'snappy', + zlibCompressionLevel: 3 + }); }); }); }); diff --git a/test/unit/sdam/monitor.test.ts b/test/unit/sdam/monitor.test.ts index 54ccef9393..81af145096 100644 --- a/test/unit/sdam/monitor.test.ts +++ b/test/unit/sdam/monitor.test.ts @@ -52,12 +52,6 @@ class MockServer { describe('monitoring', function () { let mockServer; - before(function () { - if (runNodelessTests) { - this.skip(); - } - }); - beforeEach(function () { // eslint-disable-next-line @typescript-eslint/no-non-null-assertion const test = this.currentTest!; @@ -369,6 +363,12 @@ describe('monitoring', function () { let timerSandbox, clock, executor, fnSpy; beforeEach(function () { + if (runNodelessTests) { + this.currentTest.skipReason = + 'sinon.useFakeTimers is not yet supported in a nodeless environment'; + this.skip(); + } + timerSandbox = createTimerSandbox(); clock = sinon.useFakeTimers(); fnSpy = sinon.spy(cb => { @@ -377,6 +377,10 @@ describe('monitoring', function () { }); afterEach(function () { + if (runNodelessTests) { + this.skip(); + } + if (executor) { executor.stop(); }