Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 27 additions & 27 deletions test/integration/change-streams/change_stream.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import {
} from '../../mongodb';
import * as mock from '../../tools/mongodb-mock/index';
import { TestBuilder, UnifiedTestSuiteBuilder } from '../../tools/unified_suite_builder';
import { type FailPoint, sleep } from '../../tools/utils';
import { type FailCommandFailPoint, sleep } from '../../tools/utils';
import { delay, filterForCommands } from '../shared';

const initIteratorMode = async (cs: ChangeStream) => {
Expand Down Expand Up @@ -1097,7 +1097,7 @@ describe('Change Streams', function () {
failCommands: ['getMore'],
errorCode: unresumableErrorCode
}
} as FailPoint);
} as FailCommandFailPoint);

await collection.insertOne({ city: 'New York City' });
try {
Expand Down Expand Up @@ -1912,7 +1912,7 @@ describe('ChangeStream resumability', function () {
errorCode: code,
errmsg: message
}
} as FailPoint);
} as FailCommandFailPoint);

await collection.insertOne({ name: 'bailey' });

Expand Down Expand Up @@ -1940,7 +1940,7 @@ describe('ChangeStream resumability', function () {
errorCode: code,
errmsg: message
}
} as FailPoint);
} as FailCommandFailPoint);

// There's an inherent race condition here because we need to make sure that the `aggregates` that succeed when
// resuming a change stream don't return the change event. So we defer the insert until a period of time
Expand Down Expand Up @@ -1979,7 +1979,7 @@ describe('ChangeStream resumability', function () {
errorCode: resumableErrorCodes[0].code,
errmsg: resumableErrorCodes[0].message
}
} as FailPoint);
} as FailCommandFailPoint);

expect(changeStream.cursor)
.to.have.property('changeStreamCursorOptions')
Expand Down Expand Up @@ -2009,7 +2009,7 @@ describe('ChangeStream resumability', function () {
failCommands: ['getMore'],
errorCode: unresumableErrorCode
}
} as FailPoint);
} as FailCommandFailPoint);

await initIteratorMode(changeStream);

Expand All @@ -2032,7 +2032,7 @@ describe('ChangeStream resumability', function () {
failCommands: ['aggregate'],
errorCode: resumableErrorCode
}
} as FailPoint);
} as FailCommandFailPoint);

changeStream = collection.watch([]);

Expand Down Expand Up @@ -2066,7 +2066,7 @@ describe('ChangeStream resumability', function () {
errorCode: code,
errmsg: message
}
} as FailPoint);
} as FailCommandFailPoint);

await collection.insertOne({ name: 'bailey' });

Expand Down Expand Up @@ -2094,7 +2094,7 @@ describe('ChangeStream resumability', function () {
errorCode: code,
errmsg: message
}
} as FailPoint);
} as FailCommandFailPoint);

// There's an inherent race condition here because we need to make sure that the `aggregates` that succeed when
// resuming a change stream don't return the change event. So we defer the insert until a period of time
Expand Down Expand Up @@ -2133,7 +2133,7 @@ describe('ChangeStream resumability', function () {
errorCode: resumableErrorCodes[0].code,
errmsg: resumableErrorCodes[0].message
}
} as FailPoint);
} as FailCommandFailPoint);

expect(changeStream.cursor)
.to.have.property('changeStreamCursorOptions')
Expand Down Expand Up @@ -2163,7 +2163,7 @@ describe('ChangeStream resumability', function () {
failCommands: ['getMore'],
errorCode: unresumableErrorCode
}
} as FailPoint);
} as FailCommandFailPoint);

await initIteratorMode(changeStream);

Expand All @@ -2186,7 +2186,7 @@ describe('ChangeStream resumability', function () {
failCommands: ['aggregate'],
errorCode: resumableErrorCode
}
} as FailPoint);
} as FailCommandFailPoint);

changeStream = collection.watch([]);

Expand Down Expand Up @@ -2220,7 +2220,7 @@ describe('ChangeStream resumability', function () {
errorCode: code,
errmsg: message
}
} as FailPoint);
} as FailCommandFailPoint);

try {
// tryNext is not blocking and on sharded clusters we don't have control of when
Expand Down Expand Up @@ -2255,7 +2255,7 @@ describe('ChangeStream resumability', function () {
errorCode: code,
errmsg: message
}
} as FailPoint);
} as FailCommandFailPoint);

try {
// tryNext is not blocking and on sharded clusters we don't have control of when
Expand Down Expand Up @@ -2294,7 +2294,7 @@ describe('ChangeStream resumability', function () {
errorCode: resumableErrorCodes[0].code,
errmsg: resumableErrorCodes[0].message
}
} as FailPoint);
} as FailCommandFailPoint);

expect(changeStream.cursor)
.to.have.property('changeStreamCursorOptions')
Expand Down Expand Up @@ -2324,7 +2324,7 @@ describe('ChangeStream resumability', function () {
failCommands: ['getMore'],
errorCode: unresumableErrorCode
}
} as FailPoint);
} as FailCommandFailPoint);

await initIteratorMode(changeStream);

Expand All @@ -2345,7 +2345,7 @@ describe('ChangeStream resumability', function () {
failCommands: ['aggregate'],
errorCode: resumableErrorCode
}
} as FailPoint);
} as FailCommandFailPoint);

changeStream = collection.watch([]);

Expand Down Expand Up @@ -2382,7 +2382,7 @@ describe('ChangeStream resumability', function () {
errorCode: code,
errmsg: message
}
} as FailPoint);
} as FailCommandFailPoint);

for await (const change of changeStream) {
const { fullDocument } = change;
Expand Down Expand Up @@ -2417,7 +2417,7 @@ describe('ChangeStream resumability', function () {
errorCode: resumableErrorCodes[0].code,
errmsg: resumableErrorCodes[0].message
}
} as FailPoint);
} as FailCommandFailPoint);

expect(changeStream.cursor)
.to.have.property('changeStreamCursorOptions')
Expand Down Expand Up @@ -2450,7 +2450,7 @@ describe('ChangeStream resumability', function () {
failCommands: ['getMore'],
errorCode: unresumableErrorCode
}
} as FailPoint);
} as FailCommandFailPoint);

try {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
Expand Down Expand Up @@ -2479,7 +2479,7 @@ describe('ChangeStream resumability', function () {
failCommands: ['aggregate'],
errorCode: resumableErrorCode
}
} as FailPoint);
} as FailCommandFailPoint);

try {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
Expand Down Expand Up @@ -2515,7 +2515,7 @@ describe('ChangeStream resumability', function () {
errorCode: code,
errmsg: message
}
} as FailPoint);
} as FailCommandFailPoint);

const changes = once(changeStream, 'change');
await once(changeStream.cursor, 'init');
Expand Down Expand Up @@ -2545,7 +2545,7 @@ describe('ChangeStream resumability', function () {
errorCode: code,
errmsg: message
}
} as FailPoint);
} as FailCommandFailPoint);

const changes = once(changeStream, 'change');
await once(changeStream.cursor, 'init');
Expand Down Expand Up @@ -2585,7 +2585,7 @@ describe('ChangeStream resumability', function () {
errorCode: resumableErrorCodes[0].code,
errmsg: resumableErrorCodes[0].message
}
} as FailPoint);
} as FailCommandFailPoint);

expect(changeStream.cursor)
.to.have.property('changeStreamCursorOptions')
Expand Down Expand Up @@ -2618,7 +2618,7 @@ describe('ChangeStream resumability', function () {
failCommands: ['getMore'],
errorCode: unresumableErrorCode
}
} as FailPoint);
} as FailCommandFailPoint);

const willBeError = once(changeStream, 'change').catch(error => error);
await once(changeStream.cursor, 'init');
Expand Down Expand Up @@ -2646,7 +2646,7 @@ describe('ChangeStream resumability', function () {
errorCode: unresumableErrorCode,
errmsg: 'operation was interrupted'
}
} as FailPoint);
} as FailCommandFailPoint);

const willBeError = once(changeStream, 'change').catch(error => error);
await once(changeStream.cursor, 'init');
Expand All @@ -2671,7 +2671,7 @@ describe('ChangeStream resumability', function () {
failCommands: ['aggregate'],
errorCode: resumableErrorCode
}
} as FailPoint);
} as FailCommandFailPoint);

const willBeError = once(changeStream, 'change').catch(error => error);
await collection.insertOne({ name: 'bailey' });
Expand Down
27 changes: 16 additions & 11 deletions test/integration/client-side-encryption/driver.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import {
import {
clearFailPoint,
configureFailPoint,
type FailPoint,
type FailCommandFailPoint,
getEncryptExtraOptions,
measureDuration,
sleep
Expand Down Expand Up @@ -398,6 +398,10 @@ describe('Client Side Encryption Functional', function () {

function makeBlockingFailFor(command: string | string[], blockTimeMS: number) {
beforeEach(async function () {
await configureFailPoint(this.configuration, {
configureFailPoint: 'maxTimeNeverTimeOut',
mode: 'alwaysOn'
});
await configureFailPoint(this.configuration, {
configureFailPoint: 'failCommand',
mode: { times: 2 },
Expand All @@ -412,6 +416,7 @@ describe('Client Side Encryption Functional', function () {

afterEach(async function () {
sinon.restore();
await clearFailPoint(this.configuration, 'maxTimeNeverTimeOut');
await clearFailPoint(this.configuration);
});
}
Expand Down Expand Up @@ -681,7 +686,7 @@ describe('CSOT', function () {
blockConnection: true,
blockTimeMS: 2000
}
} as FailPoint);
} as FailCommandFailPoint);
});

afterEach(async function () {
Expand All @@ -692,7 +697,7 @@ describe('CSOT', function () {
.command({
configureFailPoint: 'failCommand',
mode: 'off'
} as FailPoint);
} as FailCommandFailPoint);
await setupClient.close();
});

Expand Down Expand Up @@ -863,7 +868,7 @@ describe('CSOT', function () {
blockConnection: true,
blockTimeMS: 2000
}
} as FailPoint);
} as FailCommandFailPoint);
});

afterEach(async function () {
Expand All @@ -873,7 +878,7 @@ describe('CSOT', function () {
.command({
configureFailPoint: 'failCommand',
mode: 'off'
} as FailPoint);
} as FailCommandFailPoint);
await setupClient.close();
});

Expand Down Expand Up @@ -1004,7 +1009,7 @@ describe('CSOT', function () {
blockConnection: true,
blockTimeMS: 2000
}
} as FailPoint);
} as FailCommandFailPoint);
});

afterEach(async function () {
Expand All @@ -1014,7 +1019,7 @@ describe('CSOT', function () {
.command({
configureFailPoint: 'failCommand',
mode: 'off'
} as FailPoint);
} as FailCommandFailPoint);
await setupClient.close();
});

Expand Down Expand Up @@ -1116,7 +1121,7 @@ describe('CSOT', function () {
.command({
configureFailPoint: 'failCommand',
mode: 'off'
} as FailPoint);
} as FailCommandFailPoint);
await client
.db('db')
.collection('newnew')
Expand Down Expand Up @@ -1168,7 +1173,7 @@ describe('CSOT', function () {
blockConnection: true,
blockTimeMS: timeoutMS * 1.2
}
} as FailPoint);
} as FailCommandFailPoint);

const { duration, result: err } = await runCreateEncryptedCollection();
expect(err).to.be.instanceOf(MongoCryptCreateDataKeyError);
Expand Down Expand Up @@ -1199,7 +1204,7 @@ describe('CSOT', function () {
blockConnection: true,
blockTimeMS: timeoutMS * 1.2
}
} as FailPoint);
} as FailCommandFailPoint);

const { duration, result: err } = await runCreateEncryptedCollection();
expect(err).to.be.instanceOf(MongoCryptCreateEncryptedCollectionError);
Expand Down Expand Up @@ -1230,7 +1235,7 @@ describe('CSOT', function () {
blockConnection: true,
blockTimeMS: timeoutMS * 0.6
}
} as FailPoint);
} as FailCommandFailPoint);

const { duration, result: err } = await runCreateEncryptedCollection();
expect(err).to.be.instanceOf(MongoCryptCreateEncryptedCollectionError);
Expand Down
Loading