Skip to content

Commit

Permalink
chore(NODE-6341): remove node18+ dns resolution order hooks (#4202)
Browse files Browse the repository at this point in the history
  • Loading branch information
baileympearson committed Aug 21, 2024
1 parent 55bdeaa commit 62144ed
Show file tree
Hide file tree
Showing 10 changed files with 0 additions and 53 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import * as path from 'path';
// eslint-disable-next-line @typescript-eslint/no-restricted-imports
import { ClientEncryption } from '../../../src/client-side-encryption/client_encryption';
import { type MongoClient, WriteConcern } from '../../mongodb';
import { installNodeDNSWorkaroundHooks } from '../../tools/runner/hooks/configuration';
import { getEncryptExtraOptions } from '../../tools/utils';

describe('Client Side Encryption Prose Corpus Test', function () {
Expand Down Expand Up @@ -146,8 +145,6 @@ describe('Client Side Encryption Prose Corpus Test', function () {
}
}

installNodeDNSWorkaroundHooks();

let client: MongoClient;

beforeEach(async function () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import * as path from 'path';
// eslint-disable-next-line @typescript-eslint/no-restricted-imports
import { ClientEncryption } from '../../../src/client-side-encryption/client_encryption';
import { type CommandStartedEvent, MongoClient, type MongoClientOptions } from '../../mongodb';
import { installNodeDNSWorkaroundHooks } from '../../tools/runner/hooks/configuration';
import { getEncryptExtraOptions } from '../../tools/utils';
import { dropCollection } from '../shared';

Expand Down Expand Up @@ -104,8 +103,6 @@ const metadata = {
}
};
describe('Connection Pool Deadlock Prevention', function () {
installNodeDNSWorkaroundHooks();

beforeEach(async function () {
const url: string = this.configuration.url();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {
type MongoClient,
MongoNetworkError
} from '../../mongodb';
import { installNodeDNSWorkaroundHooks } from '../../tools/runner/hooks/configuration';
import { getEncryptExtraOptions } from '../../tools/utils';

const metadata: MongoDBMetadataUI = {
Expand All @@ -27,8 +26,6 @@ const LOCAL_KEY = Buffer.from(
);

describe('14. Decryption Events', metadata, function () {
installNodeDNSWorkaroundHooks();

let setupClient: MongoClient;
let clientEncryption;
let keyId: Binary;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { ClientEncryption } from '../../../src/client-side-encryption/client_enc
/* eslint-disable @typescript-eslint/no-restricted-imports */
import { MongoCryptCreateEncryptedCollectionError } from '../../../src/client-side-encryption/errors';
import { BSON, Collection, type Db, MongoServerError } from '../../mongodb';
import { installNodeDNSWorkaroundHooks } from '../../tools/runner/hooks/configuration';

const metadata: MongoDBMetadataUI = {
requires: {
Expand All @@ -19,8 +18,6 @@ const documentValidationFailureCode = 121;
const typeMismatchCode = 14;

describe('21. Automatic Data Encryption Keys', () => {
installNodeDNSWorkaroundHooks();

let db: Db;
let clientEncryption;
let client;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { Decimal128, type Document, Double, Long, type MongoClient } from '../..
import { ClientEncryption } from '../../../src/client-side-encryption/client_encryption';
/* eslint-disable @typescript-eslint/no-restricted-imports */
import { MongoCryptError } from '../../../src/client-side-encryption/errors';
import { installNodeDNSWorkaroundHooks } from '../../tools/runner/hooks/configuration';

const getKmsProviders = () => {
const result = EJSON.parse(process.env.CSFLE_KMS_PROVIDERS || '{}') as unknown as {
Expand Down Expand Up @@ -135,8 +134,6 @@ const readEncryptedFieldsFile = (dataType: string): Promise<string> =>
});

describe('Range Explicit Encryption', function () {
installNodeDNSWorkaroundHooks();

let clientEncryption;
let keyId;
let keyVaultClient;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ const { EJSON } = BSON;
const { LEGACY_HELLO_COMMAND, MongoCryptError } = require('../../mongodb');
const { MongoServerError, MongoServerSelectionError, MongoClient } = require('../../mongodb');
const { getEncryptExtraOptions } = require('../../tools/utils');
const { installNodeDNSWorkaroundHooks } = require('../../tools/runner/hooks/configuration');
const { coerce, gte } = require('semver');

const {
Expand Down Expand Up @@ -79,8 +78,6 @@ describe('Client Side Encryption Prose Tests', metadata, function () {
'base64'
);

installNodeDNSWorkaroundHooks();

describe('Data key and double encryption', function () {
// Data key and double encryption
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import * as path from 'path';

import { loadSpecTests } from '../../spec';
import { ClientSideEncryptionFilter } from '../../tools/runner/filters/client_encryption_filter';
import { installNodeDNSWorkaroundHooks } from '../../tools/runner/hooks/configuration';
import {
gatherTestSuites,
generateTopologyTests,
Expand Down Expand Up @@ -70,8 +69,6 @@ describe('Client Side Encryption (Legacy)', function () {
testContext
);

installNodeDNSWorkaroundHooks();

after(() => testContext.teardown());

before(function () {
Expand Down Expand Up @@ -124,8 +121,6 @@ describe('Client Side Encryption (Legacy)', function () {
});

describe('Client Side Encryption (Unified)', function () {
installNodeDNSWorkaroundHooks();

before(async function () {
await filter.initializeFilter({} as any, {});
});
Expand Down
3 changes: 0 additions & 3 deletions test/integration/client-side-encryption/driver.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import * as crypto from 'crypto';
import { ClientEncryption } from '../../../src/client-side-encryption/client_encryption';
import { type Collection, type CommandStartedEvent, type MongoClient } from '../../mongodb';
import * as BSON from '../../mongodb';
import { installNodeDNSWorkaroundHooks } from '../../tools/runner/hooks/configuration';
import { getEncryptExtraOptions } from '../../tools/utils';

const metadata = {
Expand All @@ -23,8 +22,6 @@ describe('Client Side Encryption Functional', function () {
const keyVaultCollName = 'datakeys';
const keyVaultNamespace = `${keyVaultDbName}.${keyVaultCollName}`;

installNodeDNSWorkaroundHooks();

it('CSFLE_KMS_PROVIDERS should be valid EJSON', function () {
const CSFLE_KMS_PROVIDERS = process.env.CSFLE_KMS_PROVIDERS;
if (typeof CSFLE_KMS_PROVIDERS === 'string') {
Expand Down
3 changes: 0 additions & 3 deletions test/manual/socks5.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { expect } from 'chai';
import ConnectionString from 'mongodb-connection-string-url';

import { LEGACY_HELLO_COMMAND, MongoClient, MongoParseError } from '../mongodb';
import { installNodeDNSWorkaroundHooks } from '../tools/runner/hooks/configuration';

/**
* The SOCKS5_CONFIG environment variable is either a JSON 4-tuple
Expand Down Expand Up @@ -34,8 +33,6 @@ describe('Socks5 Connectivity', function () {
singleConnectionString.searchParams.set('serverSelectionTimeoutMS', '2000');
singleConnectionString.searchParams.set('readPreference', 'primaryPreferred');

installNodeDNSWorkaroundHooks();

context((proxyUsername ? 'with' : 'without') + ' Socks5 auth required', function () {
context('with missing required Socks5 auth configuration', function () {
if (!proxyUsername) {
Expand Down
24 changes: 0 additions & 24 deletions test/tools/runner/hooks/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ import { AstrolabeTestConfiguration, TestConfiguration } from '../config';
import { getEnvironmentalOptions } from '../../utils';
import * as mock from '../../mongodb-mock/index';
import { inspect } from 'util';
import { setDefaultResultOrder } from 'dns';
import { coerce, gte } from 'semver';

import { ApiVersionFilter } from '../filters/api_version_filter';
import { AuthFilter } from '../filters/auth_filter';
Expand Down Expand Up @@ -207,28 +205,6 @@ const beforeAllPluginImports = () => {
require('mocha-sinon');
};

/**
* @remarks TODO(NODE-4884): once happy eyeballs support is added, we no longer need to set
* the default dns resolution order for CI
*/
export function installNodeDNSWorkaroundHooks() {
if (gte(coerce(process.version), coerce('18'))) {
// We set before hooks because some tests connect in before hooks
before(() => {
setDefaultResultOrder('ipv4first');
});

// We set beforeEach hooks to make this resilient to test ordering and
// ensure each affected test has the correct ip address resolution setting
beforeEach(() => {
setDefaultResultOrder('ipv4first');
});
afterEach(() => {
setDefaultResultOrder('verbatim');
});
}
}

export const mochaHooks = {
beforeAll: [beforeAllPluginImports, testConfigBeforeHook],
beforeEach: [testSkipBeforeEachHook],
Expand Down

0 comments on commit 62144ed

Please sign in to comment.