Skip to content

Commit 8b4c6fe

Browse files
committed
add test metadata
1 parent eadcff3 commit 8b4c6fe

File tree

1 file changed

+49
-46
lines changed

1 file changed

+49
-46
lines changed

test/integration/client-side-operations-timeout/node_csot.test.ts

Lines changed: 49 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ describe('CSOT driver tests', metadata, () => {
3333
let db: Db;
3434
let coll: Collection;
3535

36-
beforeEach(async function () {
36+
beforeEach(async function() {
3737
client = this.configuration.newClient(undefined, { timeoutMS: 100, minPoolSize });
3838
db = client.db('test', { timeoutMS: 200 });
3939
});
@@ -110,15 +110,15 @@ describe('CSOT driver tests', metadata, () => {
110110
describe('autoconnect', () => {
111111
let client: MongoClient;
112112

113-
afterEach(async function () {
113+
afterEach(async function() {
114114
await client?.close();
115115
client = undefined;
116116
});
117117

118118
describe('when failing autoconnect with timeoutMS defined', () => {
119119
let configClient: MongoClient;
120120

121-
beforeEach(async function () {
121+
beforeEach(async function() {
122122
configClient = this.configuration.newClient();
123123
const result = await configClient
124124
.db()
@@ -135,7 +135,7 @@ describe('CSOT driver tests', metadata, () => {
135135
expect(result).to.have.property('ok', 1);
136136
});
137137

138-
afterEach(async function () {
138+
afterEach(async function() {
139139
const result = await configClient
140140
.db()
141141
.admin()
@@ -154,7 +154,7 @@ describe('CSOT driver tests', metadata, () => {
154154

155155
it('throws a MongoOperationTimeoutError', {
156156
metadata: { requires: { mongodb: '>=4.4', topology: '!load-balanced' } },
157-
test: async function () {
157+
test: async function() {
158158
const commandsStarted = [];
159159
client = this.configuration.newClient(undefined, { timeoutMS: 1, monitorCommands: true });
160160

@@ -183,7 +183,7 @@ describe('CSOT driver tests', metadata, () => {
183183
let commandsSucceeded: CommandSucceededEvent[];
184184
let commandsFailed: CommandFailedEvent[];
185185

186-
beforeEach(async function () {
186+
beforeEach(async function() {
187187
client = this.configuration.newClient({ timeoutMS: 500_000, monitorCommands: true });
188188
commandsSucceeded = [];
189189
commandsFailed = [];
@@ -194,7 +194,7 @@ describe('CSOT driver tests', metadata, () => {
194194
client.on('commandFailed', event => commandsFailed.push(event));
195195
});
196196

197-
afterEach(async function () {
197+
afterEach(async function() {
198198
await client
199199
.db()
200200
.collection('a')
@@ -216,7 +216,7 @@ describe('CSOT driver tests', metadata, () => {
216216
}
217217
};
218218

219-
beforeEach(async function () {
219+
beforeEach(async function() {
220220
if (semver.satisfies(this.configuration.version, '>=4.4'))
221221
await client.db('admin').command(failpoint);
222222
else {
@@ -225,7 +225,7 @@ describe('CSOT driver tests', metadata, () => {
225225
}
226226
});
227227

228-
afterEach(async function () {
228+
afterEach(async function() {
229229
if (semver.satisfies(this.configuration.version, '>=4.4'))
230230
await client.db('admin').command({ ...failpoint, mode: 'off' });
231231
});
@@ -266,7 +266,7 @@ describe('CSOT driver tests', metadata, () => {
266266
const readManyStub = sinon
267267
// @ts-expect-error: readMany is private
268268
.stub(Connection.prototype, 'readMany')
269-
.callsFake(async function* (...args) {
269+
.callsFake(async function*(...args) {
270270
const realIterator = readManyStub.wrappedMethod.call(this, ...args);
271271
const cmd = commandSpy.lastCall.args.at(1);
272272
if ('giveMeWriteErrors' in cmd) {
@@ -309,7 +309,7 @@ describe('CSOT driver tests', metadata, () => {
309309
}
310310
};
311311

312-
beforeEach(async function () {
312+
beforeEach(async function() {
313313
if (semver.satisfies(this.configuration.version, '>=4.4'))
314314
await client.db('admin').command(failpoint);
315315
else {
@@ -318,7 +318,7 @@ describe('CSOT driver tests', metadata, () => {
318318
}
319319
});
320320

321-
afterEach(async function () {
321+
afterEach(async function() {
322322
if (semver.satisfies(this.configuration.version, '>=4.4'))
323323
await client.db('admin').command({ ...failpoint, mode: 'off' });
324324
});
@@ -358,7 +358,7 @@ describe('CSOT driver tests', metadata, () => {
358358
}
359359
};
360360

361-
beforeEach(async function () {
361+
beforeEach(async function() {
362362
internalClient = this.configuration.newClient();
363363
await internalClient
364364
.db('db')
@@ -382,7 +382,7 @@ describe('CSOT driver tests', metadata, () => {
382382
client.on('commandSucceeded', ev => commandSucceeded.push(ev));
383383
});
384384

385-
afterEach(async function () {
385+
afterEach(async function() {
386386
await internalClient
387387
.db()
388388
.admin()
@@ -396,7 +396,7 @@ describe('CSOT driver tests', metadata, () => {
396396
it(
397397
'must apply the configured timeoutMS to the initial operation execution',
398398
metadata,
399-
async function () {
399+
async function() {
400400
const cursor = client
401401
.db('db')
402402
.collection('coll')
@@ -412,7 +412,7 @@ describe('CSOT driver tests', metadata, () => {
412412
}
413413
);
414414

415-
it('refreshes the timeout for any getMores', metadata, async function () {
415+
it('refreshes the timeout for any getMores', metadata, async function() {
416416
const cursor = client
417417
.db('db')
418418
.collection('coll')
@@ -434,7 +434,7 @@ describe('CSOT driver tests', metadata, () => {
434434
it(
435435
'does not append a maxTimeMS to the original command or getMores',
436436
metadata,
437-
async function () {
437+
async function() {
438438
const cursor = client
439439
.db('db')
440440
.collection('coll')
@@ -472,7 +472,7 @@ describe('CSOT driver tests', metadata, () => {
472472
}
473473
};
474474

475-
beforeEach(async function () {
475+
beforeEach(async function() {
476476
internalClient = this.configuration.newClient();
477477
await internalClient
478478
.db('db')
@@ -496,7 +496,7 @@ describe('CSOT driver tests', metadata, () => {
496496
client.on('commandSucceeded', ev => commandSucceeded.push(ev));
497497
});
498498

499-
afterEach(async function () {
499+
afterEach(async function() {
500500
await internalClient
501501
.db()
502502
.admin()
@@ -508,7 +508,7 @@ describe('CSOT driver tests', metadata, () => {
508508
context(
509509
'when there are documents available from previously retrieved batch and timeout has expired',
510510
() => {
511-
it('returns documents without error', metadata, async function () {
511+
it('returns documents without error', metadata, async function() {
512512
const cursor = client
513513
.db('db')
514514
.collection('coll')
@@ -531,7 +531,7 @@ describe('CSOT driver tests', metadata, () => {
531531
}
532532
);
533533
context('when a getMore is required and the timeout has expired', () => {
534-
it('throws a MongoOperationTimeoutError', metadata, async function () {
534+
it('throws a MongoOperationTimeoutError', metadata, async function() {
535535
const cursor = client
536536
.db('db')
537537
.collection('coll')
@@ -554,7 +554,7 @@ describe('CSOT driver tests', metadata, () => {
554554
});
555555
});
556556

557-
it('does not apply maxTimeMS to a getMore', metadata, async function () {
557+
it('does not apply maxTimeMS to a getMore', metadata, async function() {
558558
const cursor = client
559559
.db('db')
560560
.collection('coll')
@@ -578,10 +578,13 @@ describe('CSOT driver tests', metadata, () => {
578578
});
579579
});
580580

581-
describe('Tailable cursors', function () {
581+
describe('Tailable cursors', function() {
582582
let client: MongoClient;
583583
let internalClient: MongoClient;
584584
let commandStarted: CommandStartedEvent[];
585+
const metadata: MongoDBMetadataUI = {
586+
requires: { mongodb: '>=4.4' }
587+
};
585588

586589
const failpoint: FailPoint = {
587590
configureFailPoint: 'failCommand',
@@ -593,7 +596,7 @@ describe('CSOT driver tests', metadata, () => {
593596
}
594597
};
595598

596-
beforeEach(async function () {
599+
beforeEach(async function() {
597600
internalClient = this.configuration.newClient();
598601
await internalClient
599602
.db('db')
@@ -619,7 +622,7 @@ describe('CSOT driver tests', metadata, () => {
619622
await client.connect();
620623
});
621624

622-
afterEach(async function () {
625+
afterEach(async function() {
623626
await internalClient
624627
.db()
625628
.admin()
@@ -628,14 +631,14 @@ describe('CSOT driver tests', metadata, () => {
628631
await client.close();
629632
});
630633

631-
context('when in ITERATION mode', function () {
632-
context('awaitData cursors', function () {
634+
context('when in ITERATION mode', function() {
635+
context('awaitData cursors', function() {
633636
let cursor: FindCursor;
634-
afterEach(async function () {
637+
afterEach(async function() {
635638
if (cursor) await cursor.close();
636639
});
637640

638-
it('applies timeoutMS to initial command', async function () {
641+
it('applies timeoutMS to initial command', metadata, async function() {
639642
cursor = client
640643
.db('db')
641644
.collection('coll')
@@ -647,7 +650,7 @@ describe('CSOT driver tests', metadata, () => {
647650
expect(maybeError).to.be.instanceOf(MongoOperationTimeoutError);
648651
});
649652

650-
it('refreshes the timeout for subsequent getMores', async function () {
653+
it('refreshes the timeout for subsequent getMores', async function() {
651654
cursor = client
652655
.db('db')
653656
.collection('coll')
@@ -659,7 +662,7 @@ describe('CSOT driver tests', metadata, () => {
659662
}
660663
});
661664

662-
it('does not use timeoutMS to compute maxTimeMS for getMores', async function () {
665+
it('does not use timeoutMS to compute maxTimeMS for getMores', metadata, async function() {
663666
cursor = client
664667
.db('db')
665668
.collection('coll')
@@ -676,8 +679,8 @@ describe('CSOT driver tests', metadata, () => {
676679
expect(getMore).to.not.haveOwnProperty('maxTimeMS');
677680
});
678681

679-
context('when maxAwaitTimeMS is specified', function () {
680-
it('sets maxTimeMS to the configured maxAwaitTimeMS value on getMores', async function () {
682+
context('when maxAwaitTimeMS is specified', function() {
683+
it('sets maxTimeMS to the configured maxAwaitTimeMS value on getMores', metadata, async function() {
681684
cursor = client.db('db').collection('coll').find(
682685
{},
683686
{
@@ -703,14 +706,14 @@ describe('CSOT driver tests', metadata, () => {
703706
});
704707
});
705708

706-
context('non-awaitData cursors', function () {
709+
context('non-awaitData cursors', function() {
707710
let cursor: FindCursor;
708711

709-
afterEach(async function () {
712+
afterEach(async function() {
710713
if (cursor) await cursor.close();
711714
});
712715

713-
it('applies timeoutMS to initial command', async function () {
716+
it('applies timeoutMS to initial command', metadata, async function() {
714717
cursor = client
715718
.db('db')
716719
.collection('coll')
@@ -722,7 +725,7 @@ describe('CSOT driver tests', metadata, () => {
722725
expect(maybeError).to.be.instanceOf(MongoOperationTimeoutError);
723726
});
724727

725-
it('refreshes the timeout for subsequent getMores', async function () {
728+
it('refreshes the timeout for subsequent getMores', metadata, async function() {
726729
cursor = client
727730
.db('db')
728731
.collection('coll')
@@ -734,7 +737,7 @@ describe('CSOT driver tests', metadata, () => {
734737
}
735738
});
736739

737-
it('does not append a maxTimeMS field to original command', async function () {
740+
it('does not append a maxTimeMS field to original command', metadata, async function() {
738741
cursor = client
739742
.db('db')
740743
.collection('coll')
@@ -747,7 +750,7 @@ describe('CSOT driver tests', metadata, () => {
747750
expect(finds[0].command.find).to.exist;
748751
expect(finds[0].command.maxTimeMS).to.not.exist;
749752
});
750-
it('does not append a maxTimeMS field to subsequent getMores', async function () {
753+
it('does not append a maxTimeMS field to subsequent getMores', metadata, async function() {
751754
cursor = client
752755
.db('db')
753756
.collection('coll')
@@ -775,11 +778,11 @@ describe('CSOT driver tests', metadata, () => {
775778
describe('passing a timeoutMS and a session with a timeoutContext', () => {
776779
let client: MongoClient;
777780

778-
beforeEach(async function () {
781+
beforeEach(async function() {
779782
client = this.configuration.newClient({ timeoutMS: 123 });
780783
});
781784

782-
afterEach(async function () {
785+
afterEach(async function() {
783786
await client.close();
784787
});
785788

@@ -811,15 +814,15 @@ describe('CSOT driver tests', metadata, () => {
811814
describe('passing a timeoutMS and a session with an inherited timeoutMS', () => {
812815
let client: MongoClient;
813816

814-
beforeEach(async function () {
817+
beforeEach(async function() {
815818
client = this.configuration.newClient({ timeoutMS: 123 });
816819
await client
817820
.db('db')
818821
.dropCollection('coll')
819822
.catch(() => null);
820823
});
821824

822-
afterEach(async function () {
825+
afterEach(async function() {
823826
await client.close();
824827
});
825828

@@ -851,7 +854,7 @@ describe('CSOT driver tests', metadata, () => {
851854
}
852855
};
853856

854-
beforeEach(async function () {
857+
beforeEach(async function() {
855858
if (!semver.satisfies(this.configuration.version, '>=4.4')) {
856859
this.skipReason = 'Requires server version 4.4+';
857860
this.skip();
@@ -868,7 +871,7 @@ describe('CSOT driver tests', metadata, () => {
868871

869872
let client: MongoClient;
870873

871-
afterEach(async function () {
874+
afterEach(async function() {
872875
if (semver.satisfies(this.configuration.version, '>=4.4')) {
873876
const internalClient = this.configuration.newClient();
874877
await internalClient
@@ -882,7 +885,7 @@ describe('CSOT driver tests', metadata, () => {
882885
it(
883886
'timeoutMS is refreshed for abortTransaction and the timeout error is thrown from the operation',
884887
metadata,
885-
async function () {
888+
async function() {
886889
const commandsFailed = [];
887890
const commandsStarted = [];
888891

0 commit comments

Comments
 (0)