Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: skip flaky tests #4468

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/cmap/connect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,19 @@
/** @public */
export type Stream = Socket | TLSSocket;

export const log = (...args) => _log && console.error(...args);

Check failure on line 38 in src/cmap/connect.ts

View workflow job for this annotation

GitHub Actions / build

Rest parameter 'args' implicitly has an 'any[]' type.
export let _log = false;
export const enable = () => (_log = true);
export const disable = () => (_log = false);

export async function connect(options: ConnectionOptions): Promise<Connection> {
const start = performance.now();
let connection: Connection | null = null;
try {
const socket = await makeSocket(options);
connection = makeConnection(options, socket);
await performInitialHandshake(connection, options);
log('established: ', performance.now() - start);
return connection;
} catch (error) {
connection?.destroy();
Expand Down
5 changes: 5 additions & 0 deletions src/sdam/server.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { Document } from '../bson';
import { type AutoEncrypter } from '../client-side-encryption/auto_encrypter';
import { log } from '../cmap/connect';
import { type CommandOptions, Connection } from '../cmap/connection';
import {
ConnectionPool,
Expand Down Expand Up @@ -48,6 +49,7 @@ import {
maxWireVersion,
type MongoDBNamespace,
noop,
now,
squashError,
supportsRetryableWrites
} from '../utils';
Expand Down Expand Up @@ -320,7 +322,10 @@ export class Server extends TypedEventEmitter<ServerEvents> {
this.incrementOperationCount();
if (conn == null) {
try {
log('starting checkout, ', now());
conn = await this.pool.checkOut(options);
log('checked out', now());

if (this.loadBalanced && isPinnableCommand(cmd, session)) {
session?.pin(conn);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,26 @@ const skippedTests = {
'timeoutMS is refreshed for getMore if maxAwaitTimeMS is set': 'TODO(DRIVERS-3018)'
};

describe('CSOT spec tests', function () {
const specs = loadSpecTests('client-side-operations-timeout');
for (const spec of specs) {
for (const test of spec.tests) {
if (skippedSpecs[spec.name] != null) {
test.skipReason = skippedSpecs[spec.name];
}
if (skippedTests[test.description] != null) {
test.skipReason = skippedTests[test.description];
}
const specs = loadSpecTests('client-side-operations-timeout');
for (const spec of specs) {
for (const test of spec.tests) {
if (skippedSpecs[spec.name] != null) {
test.skipReason = skippedSpecs[spec.name];
}
if (skippedTests[test.description] != null) {
test.skipReason = skippedTests[test.description];
}
}
}

describe('CSOT spec tests', function () {
runUnifiedSuite(specs, (test, configuration) => {
if (
test.description !==
'Non-tailable cursor lifetime remaining timeoutMS applied to getMore if timeoutMode is unset'
) {
return 'skipped for now';
}
const sessionCSOTTests = ['timeoutMS applied to withTransaction'];
if (
configuration.topologyType === 'LoadBalanced' &&
Expand Down
15 changes: 15 additions & 0 deletions test/spec/client-side-operations-timeout/runCursorCommand.json
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,16 @@
}
],
"operations": [
{
"name": "find",
"object": "collection",
"arguments": {
"filter": {
"_id": 0
}
},
"expectResult": []
},
{
"name": "failPoint",
"object": "testRunner",
Expand Down Expand Up @@ -174,6 +184,11 @@
{
"client": "client",
"events": [
{
"commandStartedEvent": {
"commandName": "find"
}
},
{
"commandStartedEvent": {
"commandName": "find",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@ tests:
runOnRequirements:
- serverless: forbid
operations:
# pre-populate the pool with a connection
- name: find
object: collection
arguments:
filter: { _id: 0 }
expectResult: []
# Block find/getMore for 60ms.
- name: failPoint
object: testRunner
Expand Down Expand Up @@ -97,6 +103,9 @@ tests:
expectEvents:
- client: *client
events:
# first find is from the initial find to populate the connection poo
- commandStartedEvent:
commandName: find
- commandStartedEvent:
commandName: find
command:
Expand Down
16 changes: 15 additions & 1 deletion test/tools/unified-spec-runner/operations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,19 @@ import { pipeline } from 'node:stream/promises';
import { AssertionError, expect } from 'chai';

import {
_log,
type ChangeStream,
Collection,
CommandStartedEvent,
Db,
disable,
type Document,
enable,
GridFSBucket,
log,
type MongoClient,
MongoError,
now,
ReadConcern,
ReadPreference,
SERVER_DESCRIPTION_CHANGED,
Expand Down Expand Up @@ -821,7 +826,16 @@ operations.set('runCursorCommand', async ({ entities, operation }: OperationFunc
if (!Number.isNaN(+opts.maxTimeMS)) cursor.setMaxTimeMS(+opts.maxTimeMS);
if (opts.comment !== undefined) cursor.setComment(opts.comment);

return cursor.toArray();
enable();
log('starting iteration');
log(now());
const result = await cursor.toArray().catch(e => {
log('finished', now());
disable();

throw e;
});
return result;
});

operations.set('createCommandCursor', async ({ entities, operation }: OperationFunctionParams) => {
Expand Down
39 changes: 22 additions & 17 deletions test/tools/unified-spec-runner/runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -319,23 +319,28 @@ export function runUnifiedSuite(
for (const unifiedSuite of specTests) {
context(String(unifiedSuite.description), function () {
for (const [index, test] of unifiedSuite.tests.entries()) {
it(String(test.description === '' ? `Test ${index}` : test.description), async function () {
if (expectRuntimeError) {
const error = await runUnifiedTest(this, unifiedSuite, test, skipFilter).catch(
error => error
);
expect(error).to.satisfy(value => {
return (
value instanceof AssertionError ||
value instanceof MongoServerError ||
value instanceof TypeError ||
value instanceof MongoParseError
);
});
} else {
await runUnifiedTest(this, unifiedSuite, test, skipFilter);
}
});
for (let i = 0; i < 1000; ++i) {
it(
String(test.description === '' ? `Test ${index}` : test.description) + i,
async function () {
if (expectRuntimeError) {
const error = await runUnifiedTest(this, unifiedSuite, test, skipFilter).catch(
error => error
);
expect(error).to.satisfy(value => {
return (
value instanceof AssertionError ||
value instanceof MongoServerError ||
value instanceof TypeError ||
value instanceof MongoParseError
);
});
} else {
await runUnifiedTest(this, unifiedSuite, test, skipFilter);
}
}
);
}
}
});
}
Expand Down