Skip to content

Commit e57a772

Browse files
ci(NODE-4881): adjust tests to pass on Node18 (#3485)
1 parent eb5f651 commit e57a772

13 files changed

+90
-59
lines changed

.evergreen/config.yml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2204,7 +2204,7 @@ tasks:
22042204
- func: bootstrap kms servers
22052205
- func: run custom csfle tests
22062206
vars:
2207-
CSFLE_GIT_REF: 5745f374109346a2597405f2251a178d463a14e1
2207+
CSFLE_GIT_REF: ddb19ae22dc4a5f8b9208096f69fc23e19bae6c9
22082208
- name: run-custom-csfle-tests-5.0-master
22092209
tags:
22102210
- run-custom-dependency-tests
@@ -2234,7 +2234,7 @@ tasks:
22342234
- func: bootstrap kms servers
22352235
- func: run custom csfle tests
22362236
vars:
2237-
CSFLE_GIT_REF: 5745f374109346a2597405f2251a178d463a14e1
2237+
CSFLE_GIT_REF: ddb19ae22dc4a5f8b9208096f69fc23e19bae6c9
22382238
- name: run-custom-csfle-tests-rapid-master
22392239
tags:
22402240
- run-custom-dependency-tests
@@ -2264,7 +2264,7 @@ tasks:
22642264
- func: bootstrap kms servers
22652265
- func: run custom csfle tests
22662266
vars:
2267-
CSFLE_GIT_REF: 5745f374109346a2597405f2251a178d463a14e1
2267+
CSFLE_GIT_REF: ddb19ae22dc4a5f8b9208096f69fc23e19bae6c9
22682268
- name: run-custom-csfle-tests-latest-master
22692269
tags:
22702270
- run-custom-dependency-tests
@@ -2868,10 +2868,13 @@ buildvariants:
28682868
- test-3.6-sharded_cluster
28692869
- test-latest-server-v1-api
28702870
- test-atlas-connectivity
2871+
- test-atlas-data-lake
28712872
- test-5.0-load-balanced
28722873
- test-6.0-load-balanced
28732874
- test-latest-load-balanced
28742875
- test-auth-ldap
2876+
- test-socks5
2877+
- test-socks5-tls
28752878
- test-tls-support-latest
28762879
- test-tls-support-6.0
28772880
- test-tls-support-5.0
@@ -2910,10 +2913,12 @@ buildvariants:
29102913
- test-3.6-sharded_cluster
29112914
- test-latest-server-v1-api
29122915
- test-atlas-connectivity
2916+
- test-atlas-data-lake
29132917
- test-5.0-load-balanced
29142918
- test-6.0-load-balanced
29152919
- test-latest-load-balanced
29162920
- test-auth-ldap
2921+
- test-socks5-tls
29172922
- test-tls-support-latest
29182923
- test-tls-support-6.0
29192924
- test-tls-support-5.0
@@ -3075,6 +3080,9 @@ buildvariants:
30753080
- test-3.6-replica_set
30763081
- test-3.6-sharded_cluster
30773082
- test-latest-server-v1-api
3083+
- test-atlas-data-lake
3084+
- test-socks5
3085+
- test-socks5-tls
30783086
- test-tls-support-latest
30793087
- test-tls-support-6.0
30803088
- test-tls-support-5.0

.evergreen/generate_evergreen_tasks.js

Lines changed: 10 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -623,7 +623,7 @@ const oneOffFuncAsTasks = oneOffFuncs.map(oneOffFunc => ({
623623
}));
624624

625625
for (const version of ['5.0', 'rapid', 'latest']) {
626-
for (const ref of ['5745f374109346a2597405f2251a178d463a14e1', 'master']) {
626+
for (const ref of ['ddb19ae22dc4a5f8b9208096f69fc23e19bae6c9', 'master']) {
627627
oneOffFuncAsTasks.push({
628628
name: `run-custom-csfle-tests-${version}-${ref === 'master' ? ref : 'pinned-commit'}`,
629629
tags: ['run-custom-dependency-tests'],
@@ -704,41 +704,28 @@ BUILD_VARIANTS.push({
704704

705705
// TODO(NODE-4575): unskip zstd and snappy on node 16
706706
for (const variant of BUILD_VARIANTS.filter(
707-
variant => variant.expansions && variant.expansions.NODE_LTS_NAME === 'gallium'
707+
variant => variant.expansions && ['gallium', 'hydrogen', 'latest'].includes(variant.expansions.NODE_LTS_NAME)
708708
)) {
709709
variant.tasks = variant.tasks.filter(
710710
name => !['test-zstd-compression', 'test-snappy-compression'].includes(name)
711711
);
712712
}
713713

714-
// TODO(NODE-4667): debug failing tests on Node18
714+
// TODO(NODE-4894): fix kerberos tests on Node18
715715
for (const variant of BUILD_VARIANTS.filter(
716-
variant => variant.expansions && variant.expansions.NODE_LTS_NAME === 'hydrogen'
716+
variant => variant.expansions && ['hydrogen', 'latest'].includes(variant.expansions.NODE_LTS_NAME)
717717
)) {
718718
variant.tasks = variant.tasks.filter(
719-
name => ![
720-
'test-zstd-compression',
721-
'test-snappy-compression',
722-
'test-atlas-data-lake',
723-
'test-socks5',
724-
'test-socks5-tls',
725-
'test-auth-kerberos'
726-
].includes(name)
719+
name => !['test-auth-kerberos'].includes(name)
727720
);
728721
}
729722

730-
// TODO(NODE-4667): debug failing tests on Node18
731-
// latest is currently Node19, so these tests fail
732-
for (const variant of BUILD_VARIANTS.filter(({ name }) => name.includes('node-latest'))) {
723+
// TODO(NODE-4897): Debug socks5 tests on node latest
724+
for (const variant of BUILD_VARIANTS.filter(
725+
variant => variant.expansions && ['latest'].includes(variant.expansions.NODE_LTS_NAME)
726+
)) {
733727
variant.tasks = variant.tasks.filter(
734-
name => ![
735-
'test-zstd-compression',
736-
'test-snappy-compression',
737-
'test-atlas-data-lake',
738-
'test-socks5',
739-
'test-socks5-tls',
740-
'test-auth-kerberos'
741-
].includes(name)
728+
name => !['test-socks5'].includes(name)
742729
);
743730
}
744731

.evergreen/run-kms-servers.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ cd ${DRIVERS_TOOLS}/.evergreen/csfle
22
. ./activate-kmstlsvenv.sh
33
# by default it always runs on port 5698
44
./kmstlsvenv/bin/python3 -u kms_kmip_server.py &
5-
./kmstlsvenv/bin/python3 -u kms_http_server.py --ca_file ../x509gen/ca.pem --cert_file ../x509gen/expired.pem --port 8000 &
6-
./kmstlsvenv/bin/python3 -u kms_http_server.py --ca_file ../x509gen/ca.pem --cert_file ../x509gen/wrong-host.pem --port 8001 &
5+
./kmstlsvenv/bin/python3 -u kms_http_server.py --ca_file ../x509gen/ca.pem --cert_file ../x509gen/expired.pem --port 8000 &
6+
./kmstlsvenv/bin/python3 -u kms_http_server.py --ca_file ../x509gen/ca.pem --cert_file ../x509gen/wrong-host.pem --port 8001 &
77
./kmstlsvenv/bin/python3 -u kms_http_server.py --ca_file ../x509gen/ca.pem --cert_file ../x509gen/server.pem --port 8002 --require_client_cert &

test/integration/client-side-encryption/client_side_encryption.prose.corpus.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const BSON = require('bson');
88
const { EJSON } = require('bson');
99
const { expect } = require('chai');
1010
const { getEncryptExtraOptions } = require('../../tools/utils');
11-
const { installNode18DNSHooks } = require('../../tools/runner/hooks/configuration');
11+
const { installNodeDNSWorkaroundHooks } = require('../../tools/runner/hooks/configuration');
1212

1313
describe('Client Side Encryption Prose Corpus Test', function () {
1414
const metadata = {
@@ -148,7 +148,7 @@ describe('Client Side Encryption Prose Corpus Test', function () {
148148
}
149149
}
150150

151-
installNode18DNSHooks();
151+
installNodeDNSWorkaroundHooks();
152152

153153
before(function () {
154154
// 1. Create a MongoClient without encryption enabled (referred to as ``client``).

test/integration/client-side-encryption/client_side_encryption.prose.deadlock.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const util = require('util');
77
const fs = require('fs');
88
const path = require('path');
99
const { getEncryptExtraOptions } = require('../../tools/utils');
10-
const { installNode18DNSHooks } = require('../../tools/runner/hooks/configuration');
10+
const { installNodeDNSWorkaroundHooks } = require('../../tools/runner/hooks/configuration');
1111

1212
/* REFERENCE: (note commit hash) */
1313
/* https://github.com/mongodb/specifications/blob/b3beada72ae1c992294ae6a8eea572003a274c35/source/client-side-encryption/tests/README.rst#deadlock-tests */
@@ -93,8 +93,7 @@ function deadlockTests(_metadata) {
9393
const metadata = { ..._metadata, requires: { ..._metadata.requires, auth: 'disabled' } };
9494
metadata.skipReason = 'TODO: NODE-3891 - fix tests broken when AUTH enabled';
9595
describe('Connection Pool Deadlock Prevention', function () {
96-
installNode18DNSHooks();
97-
96+
installNodeDNSWorkaroundHooks();
9897
beforeEach(function () {
9998
try {
10099
const mongodbClientEncryption = this.configuration.mongodbClientEncryption;

test/integration/client-side-encryption/client_side_encryption.prose.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const { EJSON, Binary } = BSON;
1111
const { LEGACY_HELLO_COMMAND } = require('../../../src/constants');
1212
const { MongoNetworkError, MongoServerError } = require('../../../src/error');
1313
const { getEncryptExtraOptions } = require('../../tools/utils');
14-
const { installNode18DNSHooks } = require('../../tools/runner/hooks/configuration');
14+
const { installNodeDNSWorkaroundHooks } = require('../../tools/runner/hooks/configuration');
1515

1616
const getKmsProviders = (localKey, kmipEndpoint, azureEndpoint, gcpEndpoint) => {
1717
const result = BSON.EJSON.parse(process.env.CSFLE_KMS_PROVIDERS || '{}');
@@ -70,7 +70,7 @@ describe('Client Side Encryption Prose Tests', metadata, function () {
7070
'base64'
7171
);
7272

73-
installNode18DNSHooks();
73+
installNodeDNSWorkaroundHooks();
7474

7575
describe('Data key and double encryption', function () {
7676
// Data key and double encryption

test/integration/client-side-encryption/client_side_encryption.spec.test.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as path from 'path';
22

33
import { loadSpecTests } from '../../spec';
4-
import { installNode18DNSHooks } from '../../tools/runner/hooks/configuration';
4+
import { installNodeDNSWorkaroundHooks } from '../../tools/runner/hooks/configuration';
55
import {
66
gatherTestSuites,
77
generateTopologyTests,
@@ -73,8 +73,7 @@ describe('Client Side Encryption (Legacy)', function () {
7373
testContext
7474
);
7575

76-
installNode18DNSHooks();
77-
76+
installNodeDNSWorkaroundHooks();
7877
after(() => testContext.teardown());
7978
before(function () {
8079
return testContext.setup(this.configuration);
@@ -98,7 +97,7 @@ describe('Client Side Encryption (Legacy)', function () {
9897
});
9998

10099
describe('Client Side Encryption (Unified)', function () {
101-
installNode18DNSHooks();
100+
installNodeDNSWorkaroundHooks();
102101
runUnifiedSuite(loadSpecTests(path.join('client-side-encryption', 'tests', 'unified')), () =>
103102
isServerless ? 'Unified CSFLE tests to not run on serverless' : false
104103
);

test/integration/client-side-encryption/driver.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import * as crypto from 'crypto';
44

55
import { Collection, CommandStartedEvent, MongoClient } from '../../../src';
66
import * as BSON from '../../../src/bson';
7-
import { installNode18DNSHooks } from '../../tools/runner/hooks/configuration';
7+
import { installNodeDNSWorkaroundHooks } from '../../tools/runner/hooks/configuration';
88
import { ClientEncryption } from '../../tools/unified-spec-runner/schema';
99
import { getEncryptExtraOptions } from '../../tools/utils';
1010

@@ -22,7 +22,7 @@ describe('Client Side Encryption Functional', function () {
2222
const keyVaultCollName = 'datakeys';
2323
const keyVaultNamespace = `${keyVaultDbName}.${keyVaultCollName}`;
2424

25-
installNode18DNSHooks();
25+
installNodeDNSWorkaroundHooks();
2626

2727
it('CSFLE_KMS_PROVIDERS should be valid EJSON', function () {
2828
const CSFLE_KMS_PROVIDERS = process.env.CSFLE_KMS_PROVIDERS;

test/integration/server-selection/server_selection.prose.operation_count.test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { on } from 'events';
44
import { CommandStartedEvent } from '../../../src';
55
import { Collection } from '../../../src/collection';
66
import { MongoClient } from '../../../src/mongo_client';
7-
import { installNode18DNSHooks } from '../../tools/runner/hooks/configuration';
7+
import { HostAddress } from '../../../src/utils';
88
import { sleep } from '../../tools/utils';
99

1010
const failPoint = {
@@ -45,13 +45,13 @@ describe('operationCount-based Selection Within Latency Window - Prose Test', fu
4545
let seeds: Array<string>;
4646
let counts: Record<string, number> = {};
4747
const updateCount = ({ address }: CommandStartedEvent) => {
48-
const mongosPort = address.split(':')[1];
49-
const count = counts[mongosPort] ?? 0;
50-
counts[mongosPort] = count + 1;
48+
const hostAddress = HostAddress.fromString(address);
49+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
50+
const port = hostAddress.port!.toString();
51+
const count = counts[port] ?? 0;
52+
counts[port] = count + 1;
5153
};
5254

53-
installNode18DNSHooks();
54-
5555
beforeEach(async function () {
5656
// Step 3: Create a client with both mongoses' addresses in its seed list, appName="loadBalancingTest", and localThresholdMS=30000.
5757
const uri = this.configuration.url({

test/manual/atlas-data-lake-testing/atlas_data_lake_testing.prose.js

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ const { MongoClient } = require('../../../src');
44
// TODO(NODE-3880): These tests are not fully implemented per the spec
55
describe('Atlas Data Lake - prose', function () {
66
let client;
7+
78
beforeEach(function () {
89
client = null;
910
});
@@ -30,7 +31,8 @@ describe('Atlas Data Lake - prose', function () {
3031
* If a driver constructs and issues killCursors commands in other ways (e.g. public API), this test MUST be adapted to test all such code paths.
3132
*/
3233
it('1. Test that the driver properly constructs and issues a killCursors command to Atlas Data Lake.', async function () {
33-
client = new MongoClient('mongodb://mhuser:pencil@localhost');
34+
// TODO(NODE-4884): once happy eyeballs support is added, we no longer need to set the default dns resolution order for CI
35+
client = new MongoClient('mongodb://mhuser:pencil@localhost', { family: 4 });
3436
const db = client.db('admin');
3537
await db.command({ killCursors: 'kill_cursor_collection' });
3638
});
@@ -39,7 +41,8 @@ describe('Atlas Data Lake - prose', function () {
3941
* For these tests, create a MongoClient using a valid connection string without auth credentials and execute a ping command.
4042
*/
4143
it('2. Test that the driver can establish a connection with Atlas Data Lake without authentication.', async function () {
42-
client = new MongoClient('mongodb://localhost');
44+
// TODO(NODE-4884): once happy eyeballs support is added, we no longer need to set the default dns resolution order for CI
45+
client = new MongoClient('mongodb://localhost', { family: 4 });
4346
const db = client.db('admin');
4447
await db.command({ ping: 1 });
4548
});
@@ -49,7 +52,10 @@ describe('Atlas Data Lake - prose', function () {
4952
* from the drivers-evergreen-tools ADL configuration and execute a ping command.
5053
*/
5154
it('3a. Test that the driver can establish a connection with Atlas Data Lake with authentication. (SCRAM-SHA-1)', async function () {
52-
client = new MongoClient('mongodb://mhuser:pencil@localhost?authMechanism=SCRAM-SHA-1');
55+
// TODO(NODE-4884): once happy eyeballs support is added, we no longer need to set the default dns resolution order for CI
56+
client = new MongoClient('mongodb://mhuser:pencil@localhost?authMechanism=SCRAM-SHA-1', {
57+
family: 4
58+
});
5359
const db = client.db('admin');
5460
await db.command({ ping: 1 });
5561
await db.command({ killCursors: 'kill_cursor_collection' });
@@ -59,7 +65,10 @@ describe('Atlas Data Lake - prose', function () {
5965
* Repeat the authentication test using SCRAM-SHA-256.
6066
*/
6167
it('3b. Test that the driver can establish a connection with Atlas Data Lake with authentication. (SCRAM-SHA-256)', async function () {
62-
client = new MongoClient('mongodb://mhuser:pencil@localhost?authMechanism=SCRAM-SHA-256');
68+
// TODO(NODE-4884): once happy eyeballs support is added, we no longer need to set the default dns resolution order for CI
69+
client = new MongoClient('mongodb://mhuser:pencil@localhost?authMechanism=SCRAM-SHA-256', {
70+
family: 4
71+
});
6372
const db = client.db('admin');
6473
await db.command({ ping: 1 });
6574
await db.command({ killCursors: 'kill_cursor_collection' });

test/manual/atlas-data-lake-testing/atlas_data_lake_testing.spec.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
'use strict';
22
const path = require('path');
3+
const { installNodeDNSWorkaroundHooks } = require('../../tools/runner/hooks/configuration');
34
const {
45
TestRunnerContext,
56
gatherTestSuites,
@@ -19,11 +20,19 @@ describe('Atlas Data Lake - spec', function () {
1920
path.resolve(__dirname, '../../spec/atlas-data-lake-testing')
2021
);
2122

22-
after(() => testContext.teardown());
23+
// These tests timeout connecting to on localhost mongohoused in CI on Node18+.
24+
// Manually setting the ip address resolution is safe for testing purposes
25+
// because in production, mongohoused will never be running on localhost.
26+
installNodeDNSWorkaroundHooks();
27+
2328
before(function () {
2429
return testContext.setup(this.configuration);
2530
});
2631

32+
after(() => {
33+
testContext.teardown();
34+
});
35+
2736
for (const suite of testSuites) suite.runOn = []; // patched in for the spec runner
2837

2938
generateTopologyTests(testSuites, testContext);

test/manual/socks5.test.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import ConnectionString from 'mongodb-connection-string-url';
44
import { MongoClient } from '../../src';
55
import { LEGACY_HELLO_COMMAND } from '../../src/constants';
66
import { MongoParseError } from '../../src/error';
7+
import { installNodeDNSWorkaroundHooks } from '../tools/runner/hooks/configuration';
78

89
/**
910
* The SOCKS5_CONFIG environment variable is either a JSON 4-tuple
@@ -34,6 +35,8 @@ describe('Socks5 Connectivity', function () {
3435
rsConnectionString.searchParams.set('serverSelectionTimeoutMS', '2000');
3536
singleConnectionString.searchParams.set('serverSelectionTimeoutMS', '2000');
3637

38+
installNodeDNSWorkaroundHooks();
39+
3740
context((proxyUsername ? 'with' : 'without') + ' Socks5 auth required', function () {
3841
context('with missing required Socks5 auth configuration', function () {
3942
if (!proxyUsername) {
@@ -302,9 +305,12 @@ async function testConnection(connectionString, clientOptions) {
302305
let topologyType;
303306
client.on('topologyDescriptionChanged', ev => (topologyType = ev.newDescription.type));
304307

305-
await client.connect();
306-
await client.db('admin').command({ hello: 1 });
307-
await client.db('test').collection('test').findOne({});
308-
await client.close();
308+
try {
309+
await client.connect();
310+
await client.db('admin').command({ hello: 1 });
311+
await client.db('test').collection('test').findOne({});
312+
} finally {
313+
await client.close();
314+
}
309315
return topologyType;
310316
}

0 commit comments

Comments
 (0)