diff --git a/.evergreen/ci_matrix_constants.js b/.evergreen/ci_matrix_constants.js index 3a349d5849..2c522d8b55 100644 --- a/.evergreen/ci_matrix_constants.js +++ b/.evergreen/ci_matrix_constants.js @@ -1,4 +1,5 @@ const MONGODB_VERSIONS = ['latest', 'rapid', '8.0', '7.0', '6.0', '5.0', '4.4', '4.2']; +const COMPAT_TEST_DRIVER_VERSIONS = ['6.20.0', '6.21.0', '7.0.0', 'latest']; const versions = [ { codeName: 'iron', versionNumber: '20.19.0' }, { codeName: 'jod', versionNumber: 22 }, @@ -23,6 +24,7 @@ const DEBIAN_OS = 'debian11-small'; module.exports = { MONGODB_VERSIONS, + COMPAT_TEST_DRIVER_VERSIONS, versions, NODE_VERSIONS, LB_VERSIONS, diff --git a/.evergreen/config.in.yml b/.evergreen/config.in.yml index a25f01069d..a6c4145481 100644 --- a/.evergreen/config.in.yml +++ b/.evergreen/config.in.yml @@ -358,6 +358,16 @@ functions: args: - .evergreen/run-atlas-tests.sh + "run explicit version test": + - command: subprocess.exec + type: test + params: + working_dir: "src" + binary: bash + add_expansions_to_env: true + args: + - .evergreen/run-explicit-version-test.sh + "run socks5 tests": - <<: *assume_secrets_manager_role - command: subprocess.exec diff --git a/.evergreen/config.yml b/.evergreen/config.yml index fe48d3b9be..6f44e373d1 100644 --- a/.evergreen/config.yml +++ b/.evergreen/config.yml @@ -312,6 +312,15 @@ functions: add_expansions_to_env: true args: - .evergreen/run-atlas-tests.sh + run explicit version test: + - command: subprocess.exec + type: test + params: + working_dir: src + binary: bash + add_expansions_to_env: true + args: + - .evergreen/run-explicit-version-test.sh run socks5 tests: - command: ec2.assume_role params: @@ -2166,6 +2175,78 @@ tasks: - func: bootstrap mongo-orchestration - func: assume secrets manager role - func: build and test alpine FLE + - name: test-explicit-driver-version-6.20.0 + tags: + - explicit-version + commands: + - command: expansions.update + type: setup + params: + updates: + - {key: DRIVER_VERSION, value: 6.20.0} + - {key: NODE_LTS_VERSION, value: 20.19.0} + - {key: VERSION, value: latest} + - {key: TOPOLOGY, value: server} + - {key: AUTH, value: auth} + - {key: SSL, value: nossl} + - {key: CLIENT_ENCRYPTION, value: 'false'} + - func: install dependencies + - func: bootstrap mongo-orchestration + - func: run explicit version test + - name: test-explicit-driver-version-6.21.0 + tags: + - explicit-version + commands: + - command: expansions.update + type: setup + params: + updates: + - {key: DRIVER_VERSION, value: 6.21.0} + - {key: NODE_LTS_VERSION, value: 20.19.0} + - {key: VERSION, value: latest} + - {key: TOPOLOGY, value: server} + - {key: AUTH, value: auth} + - {key: SSL, value: nossl} + - {key: CLIENT_ENCRYPTION, value: 'false'} + - func: install dependencies + - func: bootstrap mongo-orchestration + - func: run explicit version test + - name: test-explicit-driver-version-7.0.0 + tags: + - explicit-version + commands: + - command: expansions.update + type: setup + params: + updates: + - {key: DRIVER_VERSION, value: 7.0.0} + - {key: NODE_LTS_VERSION, value: 20.19.0} + - {key: VERSION, value: latest} + - {key: TOPOLOGY, value: server} + - {key: AUTH, value: auth} + - {key: SSL, value: nossl} + - {key: CLIENT_ENCRYPTION, value: 'false'} + - func: install dependencies + - func: bootstrap mongo-orchestration + - func: run explicit version test + - name: test-explicit-driver-version-latest + tags: + - explicit-version + commands: + - command: expansions.update + type: setup + params: + updates: + - {key: DRIVER_VERSION, value: latest} + - {key: NODE_LTS_VERSION, value: 20.19.0} + - {key: VERSION, value: latest} + - {key: TOPOLOGY, value: server} + - {key: AUTH, value: auth} + - {key: SSL, value: nossl} + - {key: CLIENT_ENCRYPTION, value: 'false'} + - func: install dependencies + - func: bootstrap mongo-orchestration + - func: run explicit version test - name: test-latest-server-noauth tags: - latest @@ -4022,6 +4103,30 @@ buildvariants: run_on: rhel80-large tasks: - .resource-management + - name: rhel8-explicit-driver-version + display_name: Explicit Driver Version Test (RHEL8) + run_on: rhel80-large + tasks: + - test-explicit-driver-version-6.20.0 + - test-explicit-driver-version-6.21.0 + - test-explicit-driver-version-7.0.0 + - test-explicit-driver-version-latest + - name: windows-explicit-driver-version + display_name: Explicit Driver Version Test (Windows) + run_on: windows-2022-latest-large + tasks: + - test-explicit-driver-version-6.20.0 + - test-explicit-driver-version-6.21.0 + - test-explicit-driver-version-7.0.0 + - test-explicit-driver-version-latest + - name: macos-explicit-driver-version + display_name: Explicit Driver Version Test (macOS 14 ARM) + run_on: macos-14-arm64 + tasks: + - test-explicit-driver-version-6.20.0 + - test-explicit-driver-version-6.21.0 + - test-explicit-driver-version-7.0.0 + - test-explicit-driver-version-latest - name: TLS tests display_name: TLS smoke tests run_on: rhel80-large diff --git a/.evergreen/generate_evergreen_tasks.js b/.evergreen/generate_evergreen_tasks.js index 291f7670f4..f92db742e1 100644 --- a/.evergreen/generate_evergreen_tasks.js +++ b/.evergreen/generate_evergreen_tasks.js @@ -4,6 +4,7 @@ const semver = require('semver'); const { MONGODB_VERSIONS, + COMPAT_TEST_DRIVER_VERSIONS, versions, NODE_VERSIONS, LB_VERSIONS, @@ -805,6 +806,40 @@ BUILD_VARIANTS.push({ tasks: ['.resource-management'] }); +const EXPLICIT_VERSION_TASKS = COMPAT_TEST_DRIVER_VERSIONS.map(driverVersion => ({ + name: `test-explicit-driver-version-${driverVersion}`, + tags: ['explicit-version'], + commands: [ + updateExpansions({ + DRIVER_VERSION: driverVersion, + NODE_LTS_VERSION: LOWEST_LTS, + VERSION: 'latest', + TOPOLOGY: 'server', + AUTH: 'auth', + SSL: 'nossl', + CLIENT_ENCRYPTION: 'false' + }), + { func: 'install dependencies' }, + { func: 'bootstrap mongo-orchestration' }, + { func: 'run explicit version test' } + ] +})); + +SINGLETON_TASKS.push(...EXPLICIT_VERSION_TASKS); + +for (const [osName, runOn, displayName] of [ + ['rhel8', DEFAULT_OS, 'RHEL8'], + ['windows', WINDOWS_OS, 'Windows'], + ['macos', MACOS_OS, 'macOS 14 ARM'] +]) { + BUILD_VARIANTS.push({ + name: `${osName}-explicit-driver-version`, + display_name: `Explicit Driver Version Test (${displayName})`, + run_on: runOn, + tasks: EXPLICIT_VERSION_TASKS.map(t => t.name) + }); +} + BUILD_VARIANTS.push({ name: 'TLS tests', display_name: 'TLS smoke tests', diff --git a/.evergreen/run-explicit-version-test.sh b/.evergreen/run-explicit-version-test.sh new file mode 100755 index 0000000000..5d2b36ba92 --- /dev/null +++ b/.evergreen/run-explicit-version-test.sh @@ -0,0 +1,13 @@ +#!/bin/bash +set -o errexit + +source $DRIVERS_TOOLS/.evergreen/init-node-and-npm-env.sh + +cd "${PROJECT_DIRECTORY}/test/explicit-version-test" +DRIVER_VERSION="${DRIVER_VERSION:-latest}" + +echo "=== Installing mongodb@${DRIVER_VERSION} ===" +npm install --no-save "mongodb@${DRIVER_VERSION}" + +echo "=== Running explicit version test ===" +node index.mjs diff --git a/test/explicit-version-test/index.mjs b/test/explicit-version-test/index.mjs new file mode 100644 index 0000000000..4ef629b8d1 --- /dev/null +++ b/test/explicit-version-test/index.mjs @@ -0,0 +1,38 @@ +import os from 'os'; +import { readFileSync } from 'fs'; +import { MongoClient, ObjectId } from 'mongodb'; + +async function main() { + const testCluster = 'mongodb+srv://...'; + const client = new MongoClient(testCluster); + try { + await client.connect(); + + const buildInfo = await client.db('admin').command({ buildInfo: 1 }); + const { version: driverVersion } = JSON.parse( + readFileSync(new URL('./node_modules/mongodb/package.json', import.meta.url), 'utf8') + ); + + console.log('Node.js version: ', process.version); + console.log('Driver version: ', driverVersion); + console.log('Server version: ', buildInfo.version); + console.log('OS: ', `${os.type()} ${os.release()} (${os.arch()})`); + console.log('---'); + + // Basic read smoke test (cluster user has read-only access) + const doc = await client + .db('sample_mflix') + .collection('movies') + .findOne({ _id: new ObjectId('573a1390f29313caabcd42e8') }); + if (doc?.title !== 'The Great Train Robbery') + throw new Error(`Unexpected title: ${doc?.title}`); + console.log('Read smoke test: PASS'); + } finally { + await client.close(); + } +} + +main().catch(err => { + console.error(err); + process.exit(1); +}); diff --git a/test/explicit-version-test/package.json b/test/explicit-version-test/package.json new file mode 100644 index 0000000000..352e9a3932 --- /dev/null +++ b/test/explicit-version-test/package.json @@ -0,0 +1,6 @@ +{ + "name": "explicit-version-test", + "version": "1.0.0", + "type": "module", + "private": true +}