Skip to content

Commit 048868c

Browse files
move prose test to to server only
1 parent 19ebaf0 commit 048868c

File tree

1 file changed

+23
-26
lines changed

1 file changed

+23
-26
lines changed

test/integration/client-side-operations-timeout/client_side_operations_timeout.prose.test.ts

Lines changed: 23 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { pipeline } from 'stream/promises';
88

99
import { type CommandStartedEvent } from '../../../mongodb';
1010
import {
11+
type AnyClientBulkWriteModel,
1112
type CommandSucceededEvent,
1213
GridFSBucket,
1314
MongoBulkWriteError,
@@ -19,6 +20,7 @@ import {
1920
promiseWithResolvers
2021
} from '../../mongodb';
2122
import { type FailPoint } from '../../tools/utils';
23+
import { filterForCommands } from '../shared';
2224

2325
// TODO(NODE-5824): Implement CSOT prose tests
2426
describe('CSOT spec prose tests', function () {
@@ -1106,7 +1108,7 @@ describe('CSOT spec prose tests', function () {
11061108

11071109
describe(
11081110
'11. Multi-batch bulkWrites',
1109-
{ requires: { mongodb: '>=8.0', serverless: 'forbid' } },
1111+
{ requires: { mongodb: '>=8.0', serverless: 'forbid', topology: 'single' } },
11101112
function () {
11111113
/**
11121114
* ### 11. Multi-batch bulkWrites
@@ -1154,47 +1156,42 @@ describe('CSOT spec prose tests', function () {
11541156
*
11551157
* 7. Verify that two `bulkWrite` commands were executed as part of the `MongoClient.bulkWrite` call.
11561158
*/
1157-
const failpoint: FailPoint = {
1158-
configureFailPoint: 'failCommand',
1159-
mode: {
1160-
times: 2
1161-
},
1162-
data: {
1163-
failCommands: ['bulkWrite'],
1164-
blockConnection: true,
1165-
blockTimeMS: 1010
1166-
}
1167-
};
11681159

1169-
let maxBsonObjectSize: number;
1170-
let maxMessageSizeBytes: number;
1160+
let models: AnyClientBulkWriteModel[];
1161+
const writes: CommandStartedEvent[] = [];
11711162

11721163
beforeEach(async function () {
11731164
await internalClient
11741165
.db('db')
11751166
.collection('coll')
11761167
.drop()
11771168
.catch(() => null);
1178-
await internalClient.db('admin').command(failpoint);
1179-
1180-
const hello = await internalClient.db('admin').command({ hello: 1 });
1181-
maxBsonObjectSize = hello.maxBsonObjectSize;
1182-
maxMessageSizeBytes = hello.maxMessageSizeBytes;
1183-
1184-
client = this.configuration.newClient({ timeoutMS: 2000, monitorCommands: true });
1185-
});
1169+
await internalClient.db('admin').command(<FailPoint>{
1170+
configureFailPoint: 'failCommand',
1171+
mode: {
1172+
times: 2
1173+
},
1174+
data: {
1175+
failCommands: ['bulkWrite'],
1176+
blockConnection: true,
1177+
blockTimeMS: 1010
1178+
}
1179+
});
11861180

1187-
it('performs two bulkWrites which fail to complete before 2000 ms', async function () {
1188-
const writes = [];
1189-
client.on('commandStarted', ev => writes.push(ev));
1181+
const { maxBsonObjectSize, maxMessageSizeBytes } = await this.configuration.hello();
11901182

11911183
const length = maxMessageSizeBytes / maxBsonObjectSize + 1;
1192-
const models = Array.from({ length }, () => ({
1184+
models = Array.from({ length }, () => ({
11931185
namespace: 'db.coll',
11941186
name: 'insertOne' as const,
11951187
document: { a: 'b'.repeat(maxBsonObjectSize - 500) }
11961188
}));
11971189

1190+
client = this.configuration.newClient({ timeoutMS: 2000, monitorCommands: true });
1191+
client.on('commandStarted', filterForCommands('bulkWrite', writes));
1192+
});
1193+
1194+
it('performs two bulkWrites which fail to complete before 2000 ms', async function () {
11981195
const error = await client.bulkWrite(models).catch(error => error);
11991196

12001197
expect(error, error.stack).to.be.instanceOf(MongoOperationTimeoutError);

0 commit comments

Comments
 (0)