Skip to content

Commit 21bdda8

Browse files
debugs
1 parent 921778f commit 21bdda8

File tree

6 files changed

+68
-31
lines changed

6 files changed

+68
-31
lines changed

src/cmap/connect.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,19 @@ import {
3535
/** @public */
3636
export type Stream = Socket | TLSSocket;
3737

38+
export const log = (...args) => _log && console.error(...args);
39+
export let _log = false;
40+
export const enable = () => (_log = true);
41+
export const disable = () => (_log = false);
42+
3843
export async function connect(options: ConnectionOptions): Promise<Connection> {
44+
const start = performance.now();
3945
let connection: Connection | null = null;
4046
try {
4147
const socket = await makeSocket(options);
4248
connection = makeConnection(options, socket);
4349
await performInitialHandshake(connection, options);
50+
log('established: ', performance.now() - start);
4451
return connection;
4552
} catch (error) {
4653
connection?.destroy();

src/sdam/server.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import type { Document } from '../bson';
22
import { type AutoEncrypter } from '../client-side-encryption/auto_encrypter';
3+
import { log } from '../cmap/connect';
34
import { type CommandOptions, Connection } from '../cmap/connection';
45
import {
56
ConnectionPool,
@@ -48,6 +49,7 @@ import {
4849
maxWireVersion,
4950
type MongoDBNamespace,
5051
noop,
52+
now,
5153
squashError,
5254
supportsRetryableWrites
5355
} from '../utils';
@@ -320,7 +322,10 @@ export class Server extends TypedEventEmitter<ServerEvents> {
320322
this.incrementOperationCount();
321323
if (conn == null) {
322324
try {
325+
log('starting checkout, ', now());
323326
conn = await this.pool.checkOut(options);
327+
log('checked out', now());
328+
324329
if (this.loadBalanced && isPinnableCommand(cmd, session)) {
325330
session?.pin(conn);
326331
}

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

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,26 @@ const skippedTests = {
2121
'timeoutMS is refreshed for getMore if maxAwaitTimeMS is set': 'TODO(DRIVERS-3018)'
2222
};
2323

24-
describe('CSOT spec tests', function () {
25-
const specs = loadSpecTests('client-side-operations-timeout');
26-
for (const spec of specs) {
27-
for (const test of spec.tests) {
28-
if (skippedSpecs[spec.name] != null) {
29-
test.skipReason = skippedSpecs[spec.name];
30-
}
31-
if (skippedTests[test.description] != null) {
32-
test.skipReason = skippedTests[test.description];
33-
}
24+
const specs = loadSpecTests('client-side-operations-timeout');
25+
for (const spec of specs) {
26+
for (const test of spec.tests) {
27+
if (skippedSpecs[spec.name] != null) {
28+
test.skipReason = skippedSpecs[spec.name];
29+
}
30+
if (skippedTests[test.description] != null) {
31+
test.skipReason = skippedTests[test.description];
3432
}
3533
}
34+
}
3635

36+
describe('CSOT spec tests', function () {
3737
runUnifiedSuite(specs, (test, configuration) => {
38+
if (
39+
test.description !==
40+
'Non-tailable cursor lifetime remaining timeoutMS applied to getMore if timeoutMode is unset'
41+
) {
42+
return 'skipped for now';
43+
}
3844
const sessionCSOTTests = ['timeoutMS applied to withTransaction'];
3945
if (
4046
configuration.topologyType === 'LoadBalanced' &&

test/spec/client-side-operations-timeout/runCursorCommand.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@
149149
"getMore"
150150
],
151151
"blockConnection": true,
152-
"blockTimeMS": 120
152+
"blockTimeMS": 60
153153
}
154154
}
155155
}
@@ -159,7 +159,7 @@
159159
"object": "db",
160160
"arguments": {
161161
"commandName": "find",
162-
"timeoutMS": 200,
162+
"timeoutMS": 100,
163163
"command": {
164164
"find": "collection",
165165
"batchSize": 2
@@ -580,4 +580,4 @@
580580
]
581581
}
582582
]
583-
}
583+
}

test/tools/unified-spec-runner/operations.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,19 @@ import { pipeline } from 'node:stream/promises';
66
import { AssertionError, expect } from 'chai';
77

88
import {
9+
_log,
910
type ChangeStream,
1011
Collection,
1112
CommandStartedEvent,
1213
Db,
14+
disable,
1315
type Document,
16+
enable,
1417
GridFSBucket,
18+
log,
1519
type MongoClient,
1620
MongoError,
21+
now,
1722
ReadConcern,
1823
ReadPreference,
1924
SERVER_DESCRIPTION_CHANGED,
@@ -821,7 +826,16 @@ operations.set('runCursorCommand', async ({ entities, operation }: OperationFunc
821826
if (!Number.isNaN(+opts.maxTimeMS)) cursor.setMaxTimeMS(+opts.maxTimeMS);
822827
if (opts.comment !== undefined) cursor.setComment(opts.comment);
823828

824-
return cursor.toArray();
829+
enable();
830+
log('starting iteration');
831+
log(now());
832+
const result = await cursor.toArray().catch(e => {
833+
log('finished', now());
834+
disable();
835+
836+
throw e;
837+
});
838+
return result;
825839
});
826840

827841
operations.set('createCommandCursor', async ({ entities, operation }: OperationFunctionParams) => {

test/tools/unified-spec-runner/runner.ts

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -319,23 +319,28 @@ export function runUnifiedSuite(
319319
for (const unifiedSuite of specTests) {
320320
context(String(unifiedSuite.description), function () {
321321
for (const [index, test] of unifiedSuite.tests.entries()) {
322-
it(String(test.description === '' ? `Test ${index}` : test.description), async function () {
323-
if (expectRuntimeError) {
324-
const error = await runUnifiedTest(this, unifiedSuite, test, skipFilter).catch(
325-
error => error
326-
);
327-
expect(error).to.satisfy(value => {
328-
return (
329-
value instanceof AssertionError ||
330-
value instanceof MongoServerError ||
331-
value instanceof TypeError ||
332-
value instanceof MongoParseError
333-
);
334-
});
335-
} else {
336-
await runUnifiedTest(this, unifiedSuite, test, skipFilter);
337-
}
338-
});
322+
for (let i = 0; i < 1000; ++i) {
323+
it(
324+
String(test.description === '' ? `Test ${index}` : test.description) + i,
325+
async function () {
326+
if (expectRuntimeError) {
327+
const error = await runUnifiedTest(this, unifiedSuite, test, skipFilter).catch(
328+
error => error
329+
);
330+
expect(error).to.satisfy(value => {
331+
return (
332+
value instanceof AssertionError ||
333+
value instanceof MongoServerError ||
334+
value instanceof TypeError ||
335+
value instanceof MongoParseError
336+
);
337+
});
338+
} else {
339+
await runUnifiedTest(this, unifiedSuite, test, skipFilter);
340+
}
341+
}
342+
);
343+
}
339344
}
340345
});
341346
}

0 commit comments

Comments
 (0)