Skip to content

Commit c9d9277

Browse files
committed
test(NODE-3688): sync spec tests
1 parent ade5ec2 commit c9d9277

File tree

109 files changed

+2352
-32
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

109 files changed

+2352
-32
lines changed

src/cmap/connect.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { LEGACY_HELLO_COMMAND } from '../constants';
1010
import {
1111
AnyError,
1212
MongoCompatibilityError,
13+
MongoHandshakeError,
1314
MongoInvalidArgumentError,
1415
MongoNetworkError,
1516
MongoNetworkTimeoutError,
@@ -134,7 +135,7 @@ function performInitialHandshake(
134135
const start = new Date().getTime();
135136
conn.command(ns('admin.$cmd'), handshakeDoc, handshakeOptions, (err, response) => {
136137
if (err) {
137-
callback(err);
138+
callback(new MongoHandshakeError(err.message));
138139
return;
139140
}
140141

src/error.ts

+17-1
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,21 @@ export class MongoDriverError extends MongoError {
197197
}
198198
}
199199

200+
/**
201+
* An error during the handshake.
202+
*
203+
* @public
204+
* @category Error
205+
*/
206+
export class MongoHandshakeError extends MongoError {
207+
constructor(message: string) {
208+
super(message);
209+
}
210+
211+
get name(): string {
212+
return 'MongoHandshakeError';
213+
}
214+
}
200215
/**
201216
* An error generated when the driver API is used incorrectly
202217
*
@@ -738,7 +753,8 @@ export function isRetryableError(error: MongoError): boolean {
738753
(typeof error.code === 'number' && RETRYABLE_ERROR_CODES.has(error.code!)) ||
739754
error instanceof MongoNetworkError ||
740755
!!error.message.match(new RegExp(LEGACY_NOT_WRITABLE_PRIMARY_ERROR_MESSAGE)) ||
741-
!!error.message.match(new RegExp(NODE_IS_RECOVERING_ERROR_MESSAGE))
756+
!!error.message.match(new RegExp(NODE_IS_RECOVERING_ERROR_MESSAGE)) ||
757+
error instanceof MongoHandshakeError
742758
);
743759
}
744760

test/integration/retryable-reads/retryable_reads.spec.test.js

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
'use strict';
22

3+
const path = require('path');
34
const { TestRunnerContext, generateTopologyTests } = require('../../tools/spec-runner');
45
const { loadSpecTests } = require('../../spec');
6+
const { runUnifiedSuite } = require('../../tools/unified-spec-runner/runner');
57

6-
describe('Retryable Reads', function () {
8+
describe('Retryable Reads (legacy)', function () {
79
const testContext = new TestRunnerContext();
8-
const testSuites = loadSpecTests('retryable-reads');
10+
const testSuites = loadSpecTests(path.join('retryable-reads', 'legacy'));
911

1012
after(() => testContext.teardown());
1113
before(function () {
@@ -28,3 +30,7 @@ describe('Retryable Reads', function () {
2830
);
2931
});
3032
});
33+
34+
describe('Retryable Reads (unified)', function () {
35+
runUnifiedSuite(loadSpecTests(path.join('retryable-reads', 'unified')));
36+
});

test/spec/retryable-reads/README.rst

+83-14

0 commit comments

Comments
 (0)