diff --git a/packages/data-service/src/connect-mongo-client.spec.ts b/packages/data-service/src/connect-mongo-client.spec.ts index 9a4ba568356..e725553ea6a 100644 --- a/packages/data-service/src/connect-mongo-client.spec.ts +++ b/packages/data-service/src/connect-mongo-client.spec.ts @@ -1,7 +1,7 @@ import assert from 'assert'; import asyncHooks from 'async_hooks'; import { expect } from 'chai'; -import type { MongoClientOptions, CommandStartedEvent } from 'mongodb'; +import type { MongoClientOptions } from 'mongodb'; import { connectMongoClientDataService as connectMongoClient, @@ -170,42 +170,6 @@ describe('connectMongoClient', function () { ]); }); - it('should at least try to run a ping command to verify connectivity', async function () { - try { - await connectMongoClient({ - connectionOptions: { - connectionString: 'mongodb://localhost:1/?loadBalanced=true', - }, - setupListeners, - }); - expect.fail('missed exception'); - } catch (err: any) { - expect(err.name).to.equal('MongoNetworkError'); - } - }); - - it('should not run the ping command with the specified ReadPreference', async function () { - const connectionString = clusterConnectionStringURL.clone(); - connectionString - .typedSearchParams() - .set('readPreference', 'secondaryPreferred'); - const commands: CommandStartedEvent[] = []; - const [metadataClient, crudClient, , state] = await connectMongoClient({ - connectionOptions: { - connectionString: connectionString.toString(), - }, - setupListeners: (client) => - client.on('commandStarted', (ev) => commands.push(ev)), - }); - expect(commands).to.have.lengthOf(1); - expect(commands[0].commandName).to.equal('ping'); - expect(commands[0].command.$readPreference).to.equal(undefined); - - for (const closeLater of [metadataClient, crudClient, state]) { - toBeClosed.add(closeLater); - } - }); - describe('ssh tunnel failures', function () { // Use async_hooks to track the state of the internal network server used // for SSH tunneling diff --git a/packages/data-service/src/connect-mongo-client.ts b/packages/data-service/src/connect-mongo-client.ts index 3b1097eca76..20b684e0836 100644 --- a/packages/data-service/src/connect-mongo-client.ts +++ b/packages/data-service/src/connect-mongo-client.ts @@ -21,7 +21,6 @@ import _ from 'lodash'; import { redactConnectionOptions, redactConnectionString } from './redact'; import type { ConnectionOptions } from './connection-options'; import { getTunnelOptions, waitForTunnelError } from './ssh-tunnel-helpers'; -import { runCommand } from './run-command'; import type { UnboundDataServiceImplLogger } from './logger'; import { debug as _debug } from './logger'; @@ -252,7 +251,7 @@ export async function connectMongoClientDataService({ connectLogger, CompassMongoClient ); - await runCommand(client.db('admin'), { ping: 1 }); + return { client: Object.assign(client, { async [createClonedClient]() {