Skip to content

Commit 0295f5f

Browse files
committed
fix(NNODE-3688): fix lint errors
1 parent 0bbe7a6 commit 0295f5f

File tree

5 files changed

+68
-32
lines changed

5 files changed

+68
-32
lines changed

src/cmap/connect.ts

+8-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import { LEGACY_HELLO_COMMAND } from '../constants';
1010
import {
1111
AnyError,
1212
MongoCompatibilityError,
13+
MongoError,
14+
MongoErrorLabel,
1315
MongoInvalidArgumentError,
1416
MongoNetworkError,
1517
MongoNetworkTimeoutError,
@@ -182,7 +184,12 @@ function performInitialHandshake(
182184
);
183185
}
184186
provider.auth(authContext, err => {
185-
if (err) return callback(err);
187+
if (err) {
188+
if (err instanceof MongoError) {
189+
err.addErrorLabel(MongoErrorLabel.RetryableWriteError);
190+
}
191+
return callback(err);
192+
}
186193
callback(undefined, conn);
187194
});
188195

test/integration/retryable-reads/retryable_reads.prose.spec.test.ts

+20-10
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
import { expect } from 'chai';
2+
import * as semver from 'semver';
23

3-
const metadata = {
4-
requires: {
5-
mongodb: '>=4.2.0',
6-
topology: ['replicaset', 'sharded', 'load-balanced']
7-
}
8-
};
4+
import { TopologyType } from '../../../src';
95

10-
describe.only('Retryable Reads (prose)', metadata, function () {
6+
const VALID_TOPOLOGIES = [
7+
TopologyType.ReplicaSetWithPrimary,
8+
TopologyType.Sharded,
9+
TopologyType.LoadBalanced
10+
];
11+
12+
describe('Retryable Reads (prose)', function () {
1113
const dbName = 'retryable-handshake-tests';
1214
const collName = 'coll';
1315
const docs = [
@@ -20,18 +22,26 @@ describe.only('Retryable Reads (prose)', metadata, function () {
2022
let coll;
2123

2224
beforeEach(function () {
25+
if (
26+
semver.lt(this.configuration.buildInfo.version, '4.2.0') ||
27+
!VALID_TOPOLOGIES.includes(this.configuration.topologyType)
28+
) {
29+
this.currentTest.skipReason =
30+
'Retryable reads tests require MongoDB 4.2 and higher and no standalone';
31+
this.skip();
32+
}
2333
client = this.configuration.newClient({});
2434
db = client.db(dbName);
2535
coll = db.collection(collName);
2636
});
2737

2838
afterEach(async function () {
29-
await db.admin().command({
39+
await db?.admin().command({
3040
configureFailPoint: 'failCommand',
3141
mode: 'off'
3242
});
33-
await coll.drop();
34-
await client.close();
43+
await coll?.drop();
44+
await client?.close();
3545
});
3646

3747
context('when the handshake fails with a network error', function () {

test/integration/retryable-writes/retryable_writes.spec.prose.test.ts

+18-10
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import { expect } from 'chai';
2+
import * as semver from 'semver';
23

34
import { MongoError, MongoServerError, TopologyType } from '../../../src';
45

5-
const metadata = {
6-
requires: {
7-
mongodb: '>=4.2.0',
8-
topology: ['replicaset', 'sharded', 'load-balanced']
9-
}
10-
};
6+
const VALID_TOPOLOGIES = [
7+
TopologyType.ReplicaSetWithPrimary,
8+
TopologyType.Sharded,
9+
TopologyType.LoadBalanced
10+
];
1111

1212
describe('Retryable Writes Spec Prose', () => {
1313
context('when checking against mmapv1', () => {
@@ -71,7 +71,7 @@ describe('Retryable Writes Spec Prose', () => {
7171
});
7272
});
7373

74-
context('when errors occur in the handshake', metadata, function () {
74+
context('when errors occur in the handshake', function () {
7575
const dbName = 'retryable-handshake-tests';
7676
const collName = 'coll';
7777
const docs = [{ _id: 1, x: 11 }];
@@ -80,18 +80,26 @@ describe('Retryable Writes Spec Prose', () => {
8080
let coll;
8181

8282
beforeEach(function () {
83+
if (
84+
semver.lt(this.configuration.buildInfo.version, '4.2.0') ||
85+
!VALID_TOPOLOGIES.includes(this.configuration.topologyType)
86+
) {
87+
this.currentTest.skipReason =
88+
'Retryable writes tests require MongoDB 4.2 and higher and no standalone';
89+
this.skip();
90+
}
8391
client = this.configuration.newClient({});
8492
db = client.db(dbName);
8593
coll = db.collection(collName);
8694
});
8795

8896
afterEach(async function () {
89-
await db.admin().command({
97+
await db?.admin().command({
9098
configureFailPoint: 'failCommand',
9199
mode: 'off'
92100
});
93-
await coll.drop();
94-
await client.close();
101+
await coll?.drop();
102+
await client?.close();
95103
});
96104

97105
context('when the handshake fails with a network error', function () {

test/integration/transactions/transactions.prose.spec.test.ts

+21-11
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
import { expect } from 'chai';
2+
import * as semver from 'semver';
23

3-
const metadata = {
4-
requires: {
5-
mongodb: '>=4.2.0',
6-
topology: ['replicaset', 'sharded', 'load-balanced']
7-
}
8-
};
4+
import { TopologyType } from '../../../src';
95

10-
describe('Transactions (prose)', metadata, function () {
6+
const VALID_TOPOLOGIES = [
7+
TopologyType.ReplicaSetWithPrimary,
8+
TopologyType.Sharded,
9+
TopologyType.LoadBalanced
10+
];
11+
12+
describe('Transactions (prose)', function () {
1113
const dbName = 'retryable-handshake-tests';
1214
const collName = 'coll';
1315
const docs = [{ _id: 1, x: 11 }];
@@ -16,18 +18,26 @@ describe('Transactions (prose)', metadata, function () {
1618
let coll;
1719

1820
beforeEach(function () {
21+
if (
22+
semver.lt(this.configuration.buildInfo.version, '4.2.0') ||
23+
!VALID_TOPOLOGIES.includes(this.configuration.topologyType)
24+
) {
25+
this.currentTest.skipReason =
26+
'Transaction tests require MongoDB 4.2 and higher and no standalone';
27+
this.skip();
28+
}
1929
client = this.configuration.newClient({});
2030
db = client.db(dbName);
2131
coll = db.collection(collName);
2232
});
2333

2434
afterEach(async function () {
25-
await db.admin().command({
35+
await db?.admin().command({
2636
configureFailPoint: 'failCommand',
2737
mode: 'off'
2838
});
29-
await coll.drop();
30-
await client.close();
39+
await coll?.drop();
40+
await client?.close();
3141
});
3242

3343
context('when the handshake fails with a network error', function () {
@@ -42,7 +52,7 @@ describe('Transactions (prose)', metadata, function () {
4252
data: {
4353
failCommands: ['saslContinue', 'ping'],
4454
closeConnection: true
45-
},
55+
}
4656
});
4757
await coll.insertOne({ _id: 2, x: 22 }, { session });
4858
await session.abortTransaction();

test/tools/runner/config.ts

+1
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ export class TestConfiguration {
8282
this.isServerless = !!process.env.SERVERLESS;
8383
this.topologyType = this.isLoadBalanced ? TopologyType.LoadBalanced : context.topologyType;
8484
this.buildInfo = context.buildInfo;
85+
console.log(this.buildInfo);
8586
this.options = {
8687
hosts,
8788
hostAddresses,

0 commit comments

Comments
 (0)