Skip to content

Commit

Permalink
ci(NODE-4651): add Node.js 18 (mongodb#3427)
Browse files Browse the repository at this point in the history
  • Loading branch information
baileympearson authored and ZLY201 committed Nov 5, 2022
1 parent aadece9 commit 0d7d6fa
Show file tree
Hide file tree
Showing 12 changed files with 166 additions and 33 deletions.
95 changes: 87 additions & 8 deletions .evergreen/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2250,7 +2250,7 @@ buildvariants:
tasks:
- run-spec-benchmark-tests
- name: rhel80-large-erbium
display_name: rhel8 Node Erbium
display_name: rhel8 Node12
run_on: rhel80-large
expansions:
NODE_LTS_NAME: erbium
Expand Down Expand Up @@ -2298,7 +2298,7 @@ buildvariants:
- test-tls-support-4.4
- test-tls-support-4.2
- name: rhel80-large-fermium
display_name: rhel8 Node Fermium
display_name: rhel8 Node14
run_on: rhel80-large
expansions:
NODE_LTS_NAME: fermium
Expand Down Expand Up @@ -2346,7 +2346,7 @@ buildvariants:
- test-tls-support-4.4
- test-tls-support-4.2
- name: rhel80-large-gallium
display_name: rhel8 Node Gallium
display_name: rhel8 Node16
run_on: rhel80-large
expansions:
NODE_LTS_NAME: gallium
Expand Down Expand Up @@ -2391,8 +2391,50 @@ buildvariants:
- test-tls-support-5.0
- test-tls-support-4.4
- test-tls-support-4.2
- name: rhel80-large-hydrogen
display_name: rhel8 Node18
run_on: rhel80-large
expansions:
NODE_LTS_NAME: hydrogen
CLIENT_ENCRYPTION: true
tasks:
- test-latest-server
- test-latest-replica_set
- test-latest-sharded_cluster
- test-rapid-server
- test-rapid-replica_set
- test-rapid-sharded_cluster
- test-6.0-server
- test-6.0-replica_set
- test-6.0-sharded_cluster
- test-5.0-server
- test-5.0-replica_set
- test-5.0-sharded_cluster
- test-4.4-server
- test-4.4-replica_set
- test-4.4-sharded_cluster
- test-4.2-server
- test-4.2-replica_set
- test-4.2-sharded_cluster
- test-4.0-server
- test-4.0-replica_set
- test-4.0-sharded_cluster
- test-3.6-server
- test-3.6-replica_set
- test-3.6-sharded_cluster
- test-latest-server-v1-api
- test-atlas-connectivity
- test-5.0-load-balanced
- test-6.0-load-balanced
- test-latest-load-balanced
- test-auth-ldap
- test-tls-support-latest
- test-tls-support-6.0
- test-tls-support-5.0
- test-tls-support-4.4
- test-tls-support-4.2
- name: windows-64-vs2019-erbium
display_name: Windows (VS2019) Node Erbium
display_name: Windows (VS2019) Node12
run_on: windows-64-vs2019-large
expansions:
NODE_LTS_NAME: erbium
Expand Down Expand Up @@ -2434,7 +2476,7 @@ buildvariants:
- test-tls-support-4.4
- test-tls-support-4.2
- name: windows-64-vs2019-fermium
display_name: Windows (VS2019) Node Fermium
display_name: Windows (VS2019) Node14
run_on: windows-64-vs2019-large
expansions:
NODE_LTS_NAME: fermium
Expand Down Expand Up @@ -2476,7 +2518,7 @@ buildvariants:
- test-tls-support-4.4
- test-tls-support-4.2
- name: windows-64-vs2019-gallium
display_name: Windows (VS2019) Node Gallium
display_name: Windows (VS2019) Node16
run_on: windows-64-vs2019-large
expansions:
NODE_LTS_NAME: gallium
Expand Down Expand Up @@ -2515,11 +2557,48 @@ buildvariants:
- test-tls-support-5.0
- test-tls-support-4.4
- test-tls-support-4.2
- name: windows-64-vs2019-hydrogen
display_name: Windows (VS2019) Node18
run_on: windows-64-vs2019-large
expansions:
NODE_LTS_NAME: hydrogen
MSVS_VERSION: 2019
tasks:
- test-latest-server
- test-latest-replica_set
- test-latest-sharded_cluster
- test-rapid-server
- test-rapid-replica_set
- test-rapid-sharded_cluster
- test-6.0-server
- test-6.0-replica_set
- test-6.0-sharded_cluster
- test-5.0-server
- test-5.0-replica_set
- test-5.0-sharded_cluster
- test-4.4-server
- test-4.4-replica_set
- test-4.4-sharded_cluster
- test-4.2-server
- test-4.2-replica_set
- test-4.2-sharded_cluster
- test-4.0-server
- test-4.0-replica_set
- test-4.0-sharded_cluster
- test-3.6-server
- test-3.6-replica_set
- test-3.6-sharded_cluster
- test-latest-server-v1-api
- test-tls-support-latest
- test-tls-support-6.0
- test-tls-support-5.0
- test-tls-support-4.4
- test-tls-support-4.2
- name: macos-1100
display_name: MacOS 11 Node Gallium
display_name: MacOS 11 Node18
run_on: macos-1100
expansions:
NODE_LTS_NAME: gallium
NODE_LTS_NAME: hydrogen
CLIENT_ENCRYPTION: true
tasks:
- test-rapid-server
Expand Down
29 changes: 26 additions & 3 deletions .evergreen/generate_evergreen_tasks.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@ const fs = require('fs');
const yaml = require('js-yaml');

const MONGODB_VERSIONS = ['latest', 'rapid', '6.0', '5.0', '4.4', '4.2', '4.0', '3.6'];
const NODE_VERSIONS = ['erbium', 'fermium', 'gallium'];
const versions = [
{ codeName: 'erbium', versionNumber: 12 },
{ codeName: 'fermium', versionNumber: 14 },
{ codeName: 'gallium', versionNumber: 16 },
{ codeName: 'hydrogen', versionNumber: 18 }
];
const NODE_VERSIONS = versions.map(({ codeName }) => codeName)
NODE_VERSIONS.sort();
const LOWEST_LTS = NODE_VERSIONS[0];
const LATEST_LTS = NODE_VERSIONS[NODE_VERSIONS.length - 1];
Expand Down Expand Up @@ -357,7 +363,8 @@ for (const
});

for (const NODE_LTS_NAME of testedNodeVersions) {
const nodeLtsDisplayName = `Node ${NODE_LTS_NAME[0].toUpperCase()}${NODE_LTS_NAME.slice(1)}`;
const nodeVersionNumber = versions.find(({ codeName }) => codeName === NODE_LTS_NAME).versionNumber;
const nodeLtsDisplayName = `Node${nodeVersionNumber}`;
const name = `${osName}-${NODE_LTS_NAME}`;
const display_name = `${osDisplayName} ${nodeLtsDisplayName}`;
const expansions = { NODE_LTS_NAME };
Expand All @@ -376,7 +383,7 @@ for (const

BUILD_VARIANTS.push({
name: 'macos-1100',
display_name: `MacOS 11 Node ${LATEST_LTS[0].toUpperCase()}${LATEST_LTS.slice(1)}`,
display_name: `MacOS 11 Node${versions[versions.length - 1].versionNumber}`,
run_on: 'macos-1100',
expansions: {
NODE_LTS_NAME: LATEST_LTS,
Expand Down Expand Up @@ -645,6 +652,22 @@ for (const variant of BUILD_VARIANTS.filter(
);
}

// TODO(NODE-4667): debug failing tests on Node18
for (const variant of BUILD_VARIANTS.filter(
variant => variant.expansions && variant.expansions.NODE_LTS_NAME === 'hydrogen'
)) {
variant.tasks = variant.tasks.filter(
name => ![
'test-zstd-compression',
'test-snappy-compression',
'test-atlas-data-lake',
'test-socks5',
'test-socks5-tls',
'test-auth-kerberos'
].includes(name)
);
}

const fileData = yaml.load(fs.readFileSync(`${__dirname}/config.in.yml`, 'utf8'));
fileData.tasks = (fileData.tasks || [])
.concat(BASE_TASKS)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const BSON = require('bson');
const { EJSON } = require('bson');
const { expect } = require('chai');
const { getEncryptExtraOptions } = require('../../tools/utils');
const { installNode18DNSHooks } = require('../../tools/runner/hooks/configuration');

describe('Client Side Encryption Prose Corpus Test', function () {
const metadata = {
Expand Down Expand Up @@ -147,6 +148,8 @@ describe('Client Side Encryption Prose Corpus Test', function () {
}
}

installNode18DNSHooks();

before(function () {
// 1. Create a MongoClient without encryption enabled (referred to as ``client``).
client = this.configuration.newClient();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const util = require('util');
const fs = require('fs');
const path = require('path');
const { getEncryptExtraOptions } = require('../../tools/utils');
const { installNode18DNSHooks } = require('../../tools/runner/hooks/configuration');

/* REFERENCE: (note commit hash) */
/* https://github.com/mongodb/specifications/blob/b3beada72ae1c992294ae6a8eea572003a274c35/source/client-side-encryption/tests/README.rst#deadlock-tests */
Expand Down Expand Up @@ -92,6 +93,8 @@ function deadlockTests(_metadata) {
const metadata = { ..._metadata, requires: { ..._metadata.requires, auth: 'disabled' } };
metadata.skipReason = 'TODO: NODE-3891 - fix tests broken when AUTH enabled';
describe('Connection Pool Deadlock Prevention', function () {
installNode18DNSHooks();

beforeEach(function () {
try {
const mongodbClientEncryption = this.configuration.mongodbClientEncryption;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const { EJSON, Binary } = BSON;
const { LEGACY_HELLO_COMMAND } = require('../../../src/constants');
const { MongoNetworkError, MongoServerError } = require('../../../src/error');
const { getEncryptExtraOptions } = require('../../tools/utils');
const { installNode18DNSHooks } = require('../../tools/runner/hooks/configuration');

const getKmsProviders = (localKey, kmipEndpoint, azureEndpoint, gcpEndpoint) => {
const result = BSON.EJSON.parse(process.env.CSFLE_KMS_PROVIDERS || '{}');
Expand Down Expand Up @@ -69,6 +70,8 @@ describe('Client Side Encryption Prose Tests', metadata, function () {
'base64'
);

installNode18DNSHooks();

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

import { loadSpecTests } from '../../spec';
import { installNode18DNSHooks } from '../../tools/runner/hooks/configuration';
import {
gatherTestSuites,
generateTopologyTests,
Expand Down Expand Up @@ -69,6 +70,9 @@ describe('Client Side Encryption (Legacy)', function () {
path.join(__dirname, '../../spec/client-side-encryption/tests/legacy'),
testContext
);

installNode18DNSHooks();

after(() => testContext.teardown());
before(function () {
return testContext.setup(this.configuration);
Expand All @@ -80,5 +84,6 @@ describe('Client Side Encryption (Legacy)', function () {
});

describe('Client Side Encryption (Unified)', function () {
installNode18DNSHooks();
runUnifiedSuite(loadSpecTests(path.join('client-side-encryption', 'tests', 'unified')));
});
3 changes: 3 additions & 0 deletions test/integration/client-side-encryption/driver.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import * as crypto from 'crypto';

import { Collection, CommandStartedEvent, MongoClient } from '../../../src';
import * as BSON from '../../../src/bson';
import { installNode18DNSHooks } from '../../tools/runner/hooks/configuration';
import { ClientEncryption } from '../../tools/unified-spec-runner/schema';
import { getEncryptExtraOptions } from '../../tools/utils';

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

installNode18DNSHooks();

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
4 changes: 3 additions & 1 deletion test/integration/crud/misc_cursors.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,9 @@ describe('Cursor', function () {
.find({ qty: { $gt: 4 } });
await cursor.count({ readPreference: ReadPreference.SECONDARY });

const selectedServerAddress = bag[0].address.replace('127.0.0.1', 'localhost');
const selectedServerAddress = bag[0].address
.replace('127.0.0.1', 'localhost')
.replace('[::1]', 'localhost');
const selectedServer = client.topology.description.servers.get(selectedServerAddress);
expect(selectedServer).property('type').to.equal(ServerType.RSSecondary);
}
Expand Down
25 changes: 9 additions & 16 deletions test/integration/node-specific/ipv6.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import * as process from 'process';
import * as sinon from 'sinon';

import { ConnectionCreatedEvent, MongoClient, ReadPreference, TopologyType } from '../../../src';
import { byStrings, sorted } from '../../tools/utils';

describe('IPv6 Addresses', () => {
let client: MongoClient;
Expand Down Expand Up @@ -48,17 +47,20 @@ describe('IPv6 Addresses', () => {
});

it('should successfully connect using IPv6 loopback addresses', async function () {
const localhostHosts = this.configuration.options.hostAddresses.map(
const localhostHosts: string[] = this.configuration.options.hostAddresses.map(
({ port }) => `localhost:${port}` // ::1 will be swapped out for localhost
);
await client.db().command({ ping: 1 });
// After running the first command we should receive the hosts back as reported by the mongod in a hello response
// mongodb will report the bound host address, in this case "localhost"
expect(client.topology).to.exist;

// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
expect(sorted(client.topology!.s.description.servers.keys(), byStrings)).to.deep.equal(
localhostHosts
);
const hosts = Array.from(client.topology!.s.description.servers.keys());

for (const key of localhostHosts) {
expect(hosts).to.include(key);
}
});

it('should createConnection with IPv6 addresses initially then switch to mongodb bound addresses', async () => {
Expand All @@ -71,24 +73,15 @@ describe('IPv6 Addresses', () => {

const callArgs = createConnectionSpy.getCalls().map(({ args }) => args[0]);

// This is 7 because we create 3 monitoring connections with ::1, then another 3 with localhost
// and then 1 more in the connection pool for the operation, that is why we are checking for the connectionCreated event
expect(callArgs).to.be.lengthOf(7);
expect(connectionCreatedEvents).to.have.lengthOf(1);
expect(connectionCreatedEvents[0]).to.have.property('address').that.includes('localhost');

for (let index = 0; index < 3; index++) {
for (let index = 0; index < ipv6Hosts.length; index++) {
// The first 3 connections (monitoring) are made using the user provided addresses
expect(callArgs[index]).to.have.property('host', '::1');
}

for (let index = 3; index < 6; index++) {
for (let index = ipv6Hosts.length; index < callArgs.length; index++) {
// MongoDB sends back hellos that have the bound address 'localhost'
// We make new connection using that address instead
expect(callArgs[index]).to.have.property('host', 'localhost');
}

// Operation connection
expect(callArgs[6]).to.have.property('host', 'localhost');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { on } from 'events';
import { CommandStartedEvent } from '../../../src';
import { Collection } from '../../../src/collection';
import { MongoClient } from '../../../src/mongo_client';
import { installNode18DNSHooks } from '../../tools/runner/hooks/configuration';
import { sleep } from '../../tools/utils';

const failPoint = {
Expand Down Expand Up @@ -49,6 +50,8 @@ describe('operationCount-based Selection Within Latency Window - Prose Test', fu
counts[mongosPort] = count + 1;
};

installNode18DNSHooks();

beforeEach(async function () {
// Step 3: Create a client with both mongoses' addresses in its seed list, appName="loadBalancingTest", and localThresholdMS=30000.
const uri = this.configuration.url({
Expand Down

0 comments on commit 0d7d6fa

Please sign in to comment.