Skip to content

Commit

Permalink
fix failing 8.0 test
Browse files Browse the repository at this point in the history
  • Loading branch information
baileympearson committed Oct 7, 2024
1 parent 19ebaf0 commit d6b99ed
Showing 1 changed file with 21 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
ObjectId,
promiseWithResolvers
} from '../../mongodb';
import { type FailPoint } from '../../tools/utils';
import { type FailPoint, waitUntilPoolsFilled } from '../../tools/utils';

// TODO(NODE-5824): Implement CSOT prose tests
describe('CSOT spec prose tests', function () {
Expand Down Expand Up @@ -1154,34 +1154,37 @@ describe('CSOT spec prose tests', function () {
*
* 7. Verify that two `bulkWrite` commands were executed as part of the `MongoClient.bulkWrite` call.
*/
const failpoint: FailPoint = {
configureFailPoint: 'failCommand',
mode: {
times: 2
},
data: {
failCommands: ['bulkWrite'],
blockConnection: true,
blockTimeMS: 1010
}
};

let maxBsonObjectSize: number;
let maxMessageSizeBytes: number;

beforeEach(async function () {
await internalClient
.db('db')
.collection('coll')
.collection('coll_bulk_write')
.drop()
.catch(() => null);
await internalClient.db('admin').command(failpoint);
await internalClient.db('admin').command(<FailPoint>{
configureFailPoint: 'failCommand',
mode: {
times: 2
},
data: {
failCommands: ['bulkWrite'],
blockConnection: true,
blockTimeMS: 1000
}
});

const hello = await internalClient.db('admin').command({ hello: 1 });
const hello = await this.configuration.hello();
maxBsonObjectSize = hello.maxBsonObjectSize;
maxMessageSizeBytes = hello.maxMessageSizeBytes;

client = this.configuration.newClient({ timeoutMS: 2000, monitorCommands: true });
client = this.configuration.newClient(
{ timeoutMS: 4000, monitorCommands: true },
{ minPoolSize: 5 }
);

await waitUntilPoolsFilled(client, AbortSignal.timeout(30_000), 5);
});

it('performs two bulkWrites which fail to complete before 2000 ms', async function () {
Expand All @@ -1190,7 +1193,7 @@ describe('CSOT spec prose tests', function () {

const length = maxMessageSizeBytes / maxBsonObjectSize + 1;
const models = Array.from({ length }, () => ({
namespace: 'db.coll',
namespace: 'db.coll_bulk_write',
name: 'insertOne' as const,
document: { a: 'b'.repeat(maxBsonObjectSize - 500) }
}));
Expand Down

0 comments on commit d6b99ed

Please sign in to comment.