Skip to content

Commit

Permalink
temp2
Browse files Browse the repository at this point in the history
  • Loading branch information
aditi-khare-mongoDB committed Sep 16, 2024
1 parent f3b47c0 commit 0342d92
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 25 deletions.
3 changes: 3 additions & 0 deletions src/cmap/connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ export interface CommandOptions extends BSONSerializeOptions {
writeConcern?: WriteConcern;

directConnection?: boolean;

// Triggers fire-and-forget protocol for commands that don't support WriteConcern
moreToCome?: boolean;
}

/** @public */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,21 @@ describe('Connection', function () {
}
}
});

it('supports fire-and-forget messages', async function () {
const options: ConnectionOptions = {
...commonConnectOptions,
connectionType: Connection,
...this.configuration.options,
metadata: makeClientMetadata({ driverInfo: {} }),
extendedMetadata: addContainerMetadata(makeClientMetadata({ driverInfo: {} }))
};

const conn = await connect(options);
const readSpy = sinon.spy(conn, 'readMany');
await conn.command(ns('$admin.cmd'), { ping: 1 }, { moreToCome: true });
expect(readSpy).to.not.have.been.called;
});
});

describe('Connection - functional', function () {
Expand Down
2 changes: 1 addition & 1 deletion test/integration/read-write-concern/write_concern.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ describe('Write Concern', function () {
});
});

describe.only('fire-and-forget protocol', function () {
describe('fire-and-forget protocol', function () {
context('when writeConcern = 0 and OP_MSG is used', function () {
const writeOperations: { name: string; command: any; expectedReturnVal: any }[] = [
{
Expand Down
23 changes: 0 additions & 23 deletions test/unit/cmap/connection.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,29 +28,6 @@ describe('new Connection()', function () {

before(() => mock.createServer().then(s => (server = s)));

it.only('supports fire-and-forget messages', async function () {
server.setMessageHandler(request => {
const doc = request.document;
if (isHello(doc)) {
request.reply(mock.HELLO);
}

// black hole all other requests
});

const options = {
...connectionOptionsDefaults,
connectionType: Connection,
hostAddress: server.hostAddress(),
authProviders: new MongoClientAuthProviders()
};

const conn = await connect(options);
const readSpy = sinon.spy(conn, 'readMany');
await conn.command(ns('$admin.cmd'), { ping: 1 }, { moreToCome: true });
expect(readSpy).to.not.have.been.called;
});

it('destroys streams which time out', async function () {
server.setMessageHandler(request => {
const doc = request.document;
Expand Down
2 changes: 1 addition & 1 deletion test/unit/collection.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ describe('Collection', function () {
});

context('#createIndex', () => {
it.only('should error when createIndex fails', function (done) {
it('should error when createIndex fails', function (done) {
const ERROR_RESPONSE = {
ok: 0,
errmsg:
Expand Down

0 comments on commit 0342d92

Please sign in to comment.