Skip to content

Commit

Permalink
fix(NNODE-3688): fix lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
durran committed Mar 15, 2022
1 parent 0bbe7a6 commit d9a3a5c
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 23 deletions.
9 changes: 8 additions & 1 deletion src/cmap/connect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import { LEGACY_HELLO_COMMAND } from '../constants';
import {
AnyError,
MongoCompatibilityError,
MongoError,
MongoErrorLabel,
MongoInvalidArgumentError,
MongoNetworkError,
MongoNetworkTimeoutError,
Expand Down Expand Up @@ -182,7 +184,12 @@ function performInitialHandshake(
);
}
provider.auth(authContext, err => {
if (err) return callback(err);
if (err) {
if (err instanceof MongoError) {
err.addErrorLabel(MongoErrorLabel.RetryableWriteError);
}
return callback(err);
}
callback(undefined, conn);
});

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import { expect } from 'chai';
import * as semver from 'semver';

const metadata = {
requires: {
mongodb: '>=4.2.0',
topology: ['replicaset', 'sharded', 'load-balanced']
}
};
import { TopologyType } from '../../../src';

describe.only('Retryable Reads (prose)', metadata, function () {
const VALID_TOPOLOGIES = [
TopologyType.ReplicaSetWithPrimary,
TopologyType.Sharded,
TopologyType.LoadBalanced
];

describe('Retryable Reads (prose)', function () {
const dbName = 'retryable-handshake-tests';
const collName = 'coll';
const docs = [
Expand All @@ -20,6 +22,14 @@ describe.only('Retryable Reads (prose)', metadata, function () {
let coll;

beforeEach(function () {
if (
semver.lt(this.configuration.buildInfo.version, '4.2.0') ||
!VALID_TOPOLOGIES.includes(this.configuration.topologyType)
) {
this.currentTest.skipReason =
'Retryable reads tests require MongoDB 4.2 and higher and no standalone';
this.skip();
}
client = this.configuration.newClient({});
db = client.db(dbName);
coll = db.collection(collName);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { expect } from 'chai';
import * as semver from 'semver';

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

const metadata = {
requires: {
mongodb: '>=4.2.0',
topology: ['replicaset', 'sharded', 'load-balanced']
}
};
const VALID_TOPOLOGIES = [
TopologyType.ReplicaSetWithPrimary,
TopologyType.Sharded,
TopologyType.LoadBalanced
];

describe('Retryable Writes Spec Prose', () => {
context('when checking against mmapv1', () => {
Expand Down Expand Up @@ -71,7 +71,7 @@ describe('Retryable Writes Spec Prose', () => {
});
});

context('when errors occur in the handshake', metadata, function () {
context('when errors occur in the handshake', function () {
const dbName = 'retryable-handshake-tests';
const collName = 'coll';
const docs = [{ _id: 1, x: 11 }];
Expand All @@ -80,6 +80,14 @@ describe('Retryable Writes Spec Prose', () => {
let coll;

beforeEach(function () {
if (
semver.lt(this.configuration.buildInfo.version, '4.2.0') ||
!VALID_TOPOLOGIES.includes(this.configuration.topologyType)
) {
this.currentTest.skipReason =
'Retryable writes tests require MongoDB 4.2 and higher and no standalone';
this.skip();
}
client = this.configuration.newClient({});
db = client.db(dbName);
coll = db.collection(collName);
Expand Down
26 changes: 18 additions & 8 deletions test/integration/transactions/transactions.prose.spec.test.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import { expect } from 'chai';
import * as semver from 'semver';

const metadata = {
requires: {
mongodb: '>=4.2.0',
topology: ['replicaset', 'sharded', 'load-balanced']
}
};
import { TopologyType } from '../../../src';

describe('Transactions (prose)', metadata, function () {
const VALID_TOPOLOGIES = [
TopologyType.ReplicaSetWithPrimary,
TopologyType.Sharded,
TopologyType.LoadBalanced
];

describe('Transactions (prose)', function () {
const dbName = 'retryable-handshake-tests';
const collName = 'coll';
const docs = [{ _id: 1, x: 11 }];
Expand All @@ -16,6 +18,14 @@ describe('Transactions (prose)', metadata, function () {
let coll;

beforeEach(function () {
if (
semver.lt(this.configuration.buildInfo.version, '4.2.0') ||
!VALID_TOPOLOGIES.includes(this.configuration.topologyType)
) {
this.currentTest.skipReason =
'Transaction tests require MongoDB 4.2 and higher and no standalone';
this.skip();
}
client = this.configuration.newClient({});
db = client.db(dbName);
coll = db.collection(collName);
Expand All @@ -42,7 +52,7 @@ describe('Transactions (prose)', metadata, function () {
data: {
failCommands: ['saslContinue', 'ping'],
closeConnection: true
},
}
});
await coll.insertOne({ _id: 2, x: 22 }, { session });
await session.abortTransaction();
Expand Down
1 change: 1 addition & 0 deletions test/tools/runner/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ export class TestConfiguration {
this.isServerless = !!process.env.SERVERLESS;
this.topologyType = this.isLoadBalanced ? TopologyType.LoadBalanced : context.topologyType;
this.buildInfo = context.buildInfo;
console.log(this.buildInfo);
this.options = {
hosts,
hostAddresses,
Expand Down

0 comments on commit d9a3a5c

Please sign in to comment.