Skip to content

Commit d03a6bd

Browse files
chore(NODE-7123): fix flaky CSOT test (#4638)
1 parent 3469f86 commit d03a6bd

File tree

14 files changed

+113
-87
lines changed

14 files changed

+113
-87
lines changed

test/integration/change-streams/change_stream.test.ts

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import {
2424
} from '../../mongodb';
2525
import * as mock from '../../tools/mongodb-mock/index';
2626
import { TestBuilder, UnifiedTestSuiteBuilder } from '../../tools/unified_suite_builder';
27-
import { type FailPoint, sleep } from '../../tools/utils';
27+
import { type FailCommandFailPoint, sleep } from '../../tools/utils';
2828
import { delay, filterForCommands } from '../shared';
2929

3030
const initIteratorMode = async (cs: ChangeStream) => {
@@ -1097,7 +1097,7 @@ describe('Change Streams', function () {
10971097
failCommands: ['getMore'],
10981098
errorCode: unresumableErrorCode
10991099
}
1100-
} as FailPoint);
1100+
} as FailCommandFailPoint);
11011101

11021102
await collection.insertOne({ city: 'New York City' });
11031103
try {
@@ -1912,7 +1912,7 @@ describe('ChangeStream resumability', function () {
19121912
errorCode: code,
19131913
errmsg: message
19141914
}
1915-
} as FailPoint);
1915+
} as FailCommandFailPoint);
19161916

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

@@ -1940,7 +1940,7 @@ describe('ChangeStream resumability', function () {
19401940
errorCode: code,
19411941
errmsg: message
19421942
}
1943-
} as FailPoint);
1943+
} as FailCommandFailPoint);
19441944

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

19841984
expect(changeStream.cursor)
19851985
.to.have.property('changeStreamCursorOptions')
@@ -2009,7 +2009,7 @@ describe('ChangeStream resumability', function () {
20092009
failCommands: ['getMore'],
20102010
errorCode: unresumableErrorCode
20112011
}
2012-
} as FailPoint);
2012+
} as FailCommandFailPoint);
20132013

20142014
await initIteratorMode(changeStream);
20152015

@@ -2032,7 +2032,7 @@ describe('ChangeStream resumability', function () {
20322032
failCommands: ['aggregate'],
20332033
errorCode: resumableErrorCode
20342034
}
2035-
} as FailPoint);
2035+
} as FailCommandFailPoint);
20362036

20372037
changeStream = collection.watch([]);
20382038

@@ -2066,7 +2066,7 @@ describe('ChangeStream resumability', function () {
20662066
errorCode: code,
20672067
errmsg: message
20682068
}
2069-
} as FailPoint);
2069+
} as FailCommandFailPoint);
20702070

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

@@ -2094,7 +2094,7 @@ describe('ChangeStream resumability', function () {
20942094
errorCode: code,
20952095
errmsg: message
20962096
}
2097-
} as FailPoint);
2097+
} as FailCommandFailPoint);
20982098

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

21382138
expect(changeStream.cursor)
21392139
.to.have.property('changeStreamCursorOptions')
@@ -2163,7 +2163,7 @@ describe('ChangeStream resumability', function () {
21632163
failCommands: ['getMore'],
21642164
errorCode: unresumableErrorCode
21652165
}
2166-
} as FailPoint);
2166+
} as FailCommandFailPoint);
21672167

21682168
await initIteratorMode(changeStream);
21692169

@@ -2186,7 +2186,7 @@ describe('ChangeStream resumability', function () {
21862186
failCommands: ['aggregate'],
21872187
errorCode: resumableErrorCode
21882188
}
2189-
} as FailPoint);
2189+
} as FailCommandFailPoint);
21902190

21912191
changeStream = collection.watch([]);
21922192

@@ -2220,7 +2220,7 @@ describe('ChangeStream resumability', function () {
22202220
errorCode: code,
22212221
errmsg: message
22222222
}
2223-
} as FailPoint);
2223+
} as FailCommandFailPoint);
22242224

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

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

22992299
expect(changeStream.cursor)
23002300
.to.have.property('changeStreamCursorOptions')
@@ -2324,7 +2324,7 @@ describe('ChangeStream resumability', function () {
23242324
failCommands: ['getMore'],
23252325
errorCode: unresumableErrorCode
23262326
}
2327-
} as FailPoint);
2327+
} as FailCommandFailPoint);
23282328

23292329
await initIteratorMode(changeStream);
23302330

@@ -2345,7 +2345,7 @@ describe('ChangeStream resumability', function () {
23452345
failCommands: ['aggregate'],
23462346
errorCode: resumableErrorCode
23472347
}
2348-
} as FailPoint);
2348+
} as FailCommandFailPoint);
23492349

23502350
changeStream = collection.watch([]);
23512351

@@ -2382,7 +2382,7 @@ describe('ChangeStream resumability', function () {
23822382
errorCode: code,
23832383
errmsg: message
23842384
}
2385-
} as FailPoint);
2385+
} as FailCommandFailPoint);
23862386

23872387
for await (const change of changeStream) {
23882388
const { fullDocument } = change;
@@ -2417,7 +2417,7 @@ describe('ChangeStream resumability', function () {
24172417
errorCode: resumableErrorCodes[0].code,
24182418
errmsg: resumableErrorCodes[0].message
24192419
}
2420-
} as FailPoint);
2420+
} as FailCommandFailPoint);
24212421

24222422
expect(changeStream.cursor)
24232423
.to.have.property('changeStreamCursorOptions')
@@ -2450,7 +2450,7 @@ describe('ChangeStream resumability', function () {
24502450
failCommands: ['getMore'],
24512451
errorCode: unresumableErrorCode
24522452
}
2453-
} as FailPoint);
2453+
} as FailCommandFailPoint);
24542454

24552455
try {
24562456
// eslint-disable-next-line @typescript-eslint/no-unused-vars
@@ -2479,7 +2479,7 @@ describe('ChangeStream resumability', function () {
24792479
failCommands: ['aggregate'],
24802480
errorCode: resumableErrorCode
24812481
}
2482-
} as FailPoint);
2482+
} as FailCommandFailPoint);
24832483

24842484
try {
24852485
// eslint-disable-next-line @typescript-eslint/no-unused-vars
@@ -2515,7 +2515,7 @@ describe('ChangeStream resumability', function () {
25152515
errorCode: code,
25162516
errmsg: message
25172517
}
2518-
} as FailPoint);
2518+
} as FailCommandFailPoint);
25192519

25202520
const changes = once(changeStream, 'change');
25212521
await once(changeStream.cursor, 'init');
@@ -2545,7 +2545,7 @@ describe('ChangeStream resumability', function () {
25452545
errorCode: code,
25462546
errmsg: message
25472547
}
2548-
} as FailPoint);
2548+
} as FailCommandFailPoint);
25492549

25502550
const changes = once(changeStream, 'change');
25512551
await once(changeStream.cursor, 'init');
@@ -2585,7 +2585,7 @@ describe('ChangeStream resumability', function () {
25852585
errorCode: resumableErrorCodes[0].code,
25862586
errmsg: resumableErrorCodes[0].message
25872587
}
2588-
} as FailPoint);
2588+
} as FailCommandFailPoint);
25892589

25902590
expect(changeStream.cursor)
25912591
.to.have.property('changeStreamCursorOptions')
@@ -2618,7 +2618,7 @@ describe('ChangeStream resumability', function () {
26182618
failCommands: ['getMore'],
26192619
errorCode: unresumableErrorCode
26202620
}
2621-
} as FailPoint);
2621+
} as FailCommandFailPoint);
26222622

26232623
const willBeError = once(changeStream, 'change').catch(error => error);
26242624
await once(changeStream.cursor, 'init');
@@ -2646,7 +2646,7 @@ describe('ChangeStream resumability', function () {
26462646
errorCode: unresumableErrorCode,
26472647
errmsg: 'operation was interrupted'
26482648
}
2649-
} as FailPoint);
2649+
} as FailCommandFailPoint);
26502650

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

26762676
const willBeError = once(changeStream, 'change').catch(error => error);
26772677
await collection.insertOne({ name: 'bailey' });

test/integration/client-side-encryption/driver.test.ts

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import {
2626
import {
2727
clearFailPoint,
2828
configureFailPoint,
29-
type FailPoint,
29+
type FailCommandFailPoint,
3030
getEncryptExtraOptions,
3131
measureDuration,
3232
sleep
@@ -398,6 +398,10 @@ describe('Client Side Encryption Functional', function () {
398398

399399
function makeBlockingFailFor(command: string | string[], blockTimeMS: number) {
400400
beforeEach(async function () {
401+
await configureFailPoint(this.configuration, {
402+
configureFailPoint: 'maxTimeNeverTimeOut',
403+
mode: 'alwaysOn'
404+
});
401405
await configureFailPoint(this.configuration, {
402406
configureFailPoint: 'failCommand',
403407
mode: { times: 2 },
@@ -412,6 +416,7 @@ describe('Client Side Encryption Functional', function () {
412416

413417
afterEach(async function () {
414418
sinon.restore();
419+
await clearFailPoint(this.configuration, 'maxTimeNeverTimeOut');
415420
await clearFailPoint(this.configuration);
416421
});
417422
}
@@ -681,7 +686,7 @@ describe('CSOT', function () {
681686
blockConnection: true,
682687
blockTimeMS: 2000
683688
}
684-
} as FailPoint);
689+
} as FailCommandFailPoint);
685690
});
686691

687692
afterEach(async function () {
@@ -692,7 +697,7 @@ describe('CSOT', function () {
692697
.command({
693698
configureFailPoint: 'failCommand',
694699
mode: 'off'
695-
} as FailPoint);
700+
} as FailCommandFailPoint);
696701
await setupClient.close();
697702
});
698703

@@ -863,7 +868,7 @@ describe('CSOT', function () {
863868
blockConnection: true,
864869
blockTimeMS: 2000
865870
}
866-
} as FailPoint);
871+
} as FailCommandFailPoint);
867872
});
868873

869874
afterEach(async function () {
@@ -873,7 +878,7 @@ describe('CSOT', function () {
873878
.command({
874879
configureFailPoint: 'failCommand',
875880
mode: 'off'
876-
} as FailPoint);
881+
} as FailCommandFailPoint);
877882
await setupClient.close();
878883
});
879884

@@ -1004,7 +1009,7 @@ describe('CSOT', function () {
10041009
blockConnection: true,
10051010
blockTimeMS: 2000
10061011
}
1007-
} as FailPoint);
1012+
} as FailCommandFailPoint);
10081013
});
10091014

10101015
afterEach(async function () {
@@ -1014,7 +1019,7 @@ describe('CSOT', function () {
10141019
.command({
10151020
configureFailPoint: 'failCommand',
10161021
mode: 'off'
1017-
} as FailPoint);
1022+
} as FailCommandFailPoint);
10181023
await setupClient.close();
10191024
});
10201025

@@ -1116,7 +1121,7 @@ describe('CSOT', function () {
11161121
.command({
11171122
configureFailPoint: 'failCommand',
11181123
mode: 'off'
1119-
} as FailPoint);
1124+
} as FailCommandFailPoint);
11201125
await client
11211126
.db('db')
11221127
.collection('newnew')
@@ -1168,7 +1173,7 @@ describe('CSOT', function () {
11681173
blockConnection: true,
11691174
blockTimeMS: timeoutMS * 1.2
11701175
}
1171-
} as FailPoint);
1176+
} as FailCommandFailPoint);
11721177

11731178
const { duration, result: err } = await runCreateEncryptedCollection();
11741179
expect(err).to.be.instanceOf(MongoCryptCreateDataKeyError);
@@ -1199,7 +1204,7 @@ describe('CSOT', function () {
11991204
blockConnection: true,
12001205
blockTimeMS: timeoutMS * 1.2
12011206
}
1202-
} as FailPoint);
1207+
} as FailCommandFailPoint);
12031208

12041209
const { duration, result: err } = await runCreateEncryptedCollection();
12051210
expect(err).to.be.instanceOf(MongoCryptCreateEncryptedCollectionError);
@@ -1230,7 +1235,7 @@ describe('CSOT', function () {
12301235
blockConnection: true,
12311236
blockTimeMS: timeoutMS * 0.6
12321237
}
1233-
} as FailPoint);
1238+
} as FailCommandFailPoint);
12341239

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

0 commit comments

Comments
 (0)