Skip to content

Commit 20afd3e

Browse files
committed
prose tests WIP
1 parent bcee059 commit 20afd3e

File tree

1 file changed

+22
-16
lines changed

1 file changed

+22
-16
lines changed

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

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -240,8 +240,11 @@ describe('CSOT spec prose tests', function () {
240240
beforeEach(async function () {
241241
internalClient = this.configuration.newClient();
242242
await internalClient.db('db').dropCollection('coll');
243-
await internalClient.db('db').createCollection('coll', { capped: true, size: 1_000_000 });
244-
await internalClient.db('db').collection('coll').insertOne({ x: 1 });
243+
// Creating capped collection to be able to create tailable find cursor
244+
const coll = await internalClient
245+
.db('db')
246+
.createCollection('coll', { capped: true, size: 1_000_000 });
247+
await coll.insertOne({ x: 1 });
245248
await internalClient.db().admin().command(failpoint);
246249

247250
client = this.configuration.newClient(undefined, { timeoutMS: 20, monitorCommands: true });
@@ -287,14 +290,13 @@ describe('CSOT spec prose tests', function () {
287290
* 1. Verify that a `find` command and two `getMore` commands were executed against the `db.coll` collection during the test.
288291
*/
289292

290-
it('send correct number of finds and getMores', async function () {
293+
it.skip('send correct number of finds and getMores', async function () {
291294
const cursor = client
292295
.db('db')
293296
.collection('coll')
294-
.find({}, { tailable: true })
297+
.find({}, { tailable: true, awaitData: true })
295298
.project({ _id: 0 });
296299
const doc = await cursor.next();
297-
// FIXME: Account for object id
298300
expect(doc).to.deep.equal({ x: 1 });
299301
// Check that there are no getMores sent
300302
expect(commandStarted.filter(e => e.command.getMore != null)).to.have.lengthOf(0);
@@ -305,10 +307,11 @@ describe('CSOT spec prose tests', function () {
305307
);
306308

307309
expect(maybeError).to.be.instanceof(MongoOperationTimeoutError);
308-
expect(
309-
commandStarted.filter(e => e.command.find != null || e.command.getMore != null)
310-
).to.have.lengthOf(3);
311-
});
310+
// Expect 1 find
311+
expect(commandStarted.filter(e => e.command.find != null)).to.have.lengthOf(1);
312+
// Expect 2 getMore
313+
expect(commandStarted.filter(e => e.command.getMore != null)).to.have.lengthOf(2);
314+
}).skipReason = 'TODO(NODE-6305)';
312315
});
313316

314317
context('Change Streams', () => {
@@ -333,20 +336,23 @@ describe('CSOT spec prose tests', function () {
333336
* - Expect this to fail with a timeout error.
334337
* 1. Verify that an `aggregate` command and two `getMore` commands were executed against the `db.coll` collection during the test.
335338
*/
336-
it('sends correct number of aggregate and getMores', async function () {
339+
it.skip('sends correct number of aggregate and getMores', async function () {
337340
const changeStream = client.db('db').collection('coll').watch();
338341
const maybeError = await changeStream.next().then(
339342
() => null,
340343
e => e
341344
);
342345

343346
expect(maybeError).to.be.instanceof(MongoOperationTimeoutError);
344-
expect(
345-
commandStarted.filter(
346-
e => Object.hasOwn(e.command, 'aggregate') || Object.hasOwn(e.command, 'getMore')
347-
)
348-
).to.have.lengthOf(3);
349-
});
347+
const aggregates = commandStarted
348+
.filter(e => e.command.aggregate != null)
349+
.map(e => e.command);
350+
const getMores = commandStarted.filter(e => e.command.getMore != null).map(e => e.command);
351+
// Expect 1 aggregate
352+
expect(aggregates).to.have.lengthOf(1);
353+
// Expect 1 getMore
354+
expect(getMores).to.have.lengthOf(1);
355+
}).skipReason = 'TODO(NODE-6305)';
350356
});
351357
});
352358

0 commit comments

Comments
 (0)