From 2436d6300bd863efa3300103a3223d3849d0bda3 Mon Sep 17 00:00:00 2001 From: hasezoey Date: Tue, 4 Jun 2024 14:08:40 +0200 Subject: [PATCH] feat(resolveConfig): update default binary version to 7.x BREAKING CHANGE: Default binary version is now "7.0.9" --- README.md | 4 ++-- docs/api/config-options.md | 2 +- docs/guides/migration/migrate10.md | 12 +++++++++--- docs/guides/mongodb-server-versions.md | 1 + .../src/__tests__/MongoMemoryReplSet.test.ts | 8 ++++++-- .../src/__tests__/MongoMemoryServer.test.ts | 11 ++++++++--- .../src/__tests__/testUtils/globalSetup.ts | 2 +- .../src/util/resolveConfig.ts | 2 +- 8 files changed, 29 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 23264bb83..917ea0148 100644 --- a/README.md +++ b/README.md @@ -86,7 +86,7 @@ On Linux, you will also need `libcurl4` (or `libcurl3` on some older distro vers ### Configuring which mongod binary to use -The default behavior is that version `6.0.14` for your OS will be downloaded. By setting [Environment variables](https://nodkz.github.io/mongodb-memory-server/docs/api/config-options) you are able to specify which version and binary will be downloaded: +The default behavior is that version `7.0.9` for your OS will be downloaded. By setting [Environment variables](https://nodkz.github.io/mongodb-memory-server/docs/api/config-options) you are able to specify which version and binary will be downloaded: ```sh export MONGOMS_DOWNLOAD_URL=https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-ubuntu1804-4.2.8.tgz @@ -128,7 +128,7 @@ const mongod = new MongoMemoryServer({ auth?: boolean, // add "--auth" argument, dont use this directly use top-level "auth" }, binary?: { - version?: string, // by default '6.0.14' + version?: string, // by default '7.0.9' downloadDir?: string, // see the documentation on what is chosen by default https://nodkz.github.io/mongodb-memory-server/docs/api/config-options#download_dir platform?: string, // by default os.platform() arch?: string, // by default os.arch() diff --git a/docs/api/config-options.md b/docs/api/config-options.md index c85e1c3e5..4436cbb21 100644 --- a/docs/api/config-options.md +++ b/docs/api/config-options.md @@ -93,7 +93,7 @@ Example: `ubuntu-18.04` Option `VERSION` is used to set what mongodb version should be downloaded -Default: `6.0.14` (see [Mongodb Server Versions](../guides/mongodb-server-versions.md) for a complete list and policy) +Default: `7.0.9` (see [Mongodb Server Versions](../guides/mongodb-server-versions.md) for a complete list and policy) This Option does not have a effect when [`ARCHIVE_NAME`](#archive_name) or [`DOWNLOAD_URL`](#download_url) is defined. diff --git a/docs/guides/migration/migrate10.md b/docs/guides/migration/migrate10.md index 043aa0d7f..282aea987 100644 --- a/docs/guides/migration/migrate10.md +++ b/docs/guides/migration/migrate10.md @@ -17,11 +17,17 @@ With 10.0.0 the minimal nodejs required is `16.20.1`. -### Default binary version is now 6.x +### Default binary version is now 7.x -The default binary version has been upgraded from `5.0.x` to `6.0.x`. For more specifics see [mongodb-server-versions](../mongodb-server-versions.md). --> +The default binary version has been upgraded from `6.0.x` to `7.0.x`. For more specifics see [mongodb-server-versions](../mongodb-server-versions.md). + +:::note +In mongodb `7.0.0` storage engine `ephemeralForTest` has been removed, mongodb-memory-server will automatically translate any occurrence to `wiredTiger` with a warning. + +It is recommended to run the tests against a tmpfs or equivalent (default `/tmp` on linux / macos). +::: ## Non-Breaking changes / Additions diff --git a/docs/guides/mongodb-server-versions.md b/docs/guides/mongodb-server-versions.md index 54a60e4d4..834e33c81 100644 --- a/docs/guides/mongodb-server-versions.md +++ b/docs/guides/mongodb-server-versions.md @@ -31,6 +31,7 @@ Starting with MongoDB version 5.0, the default versions for `mongodb-memory-serv | `mongodb-memory-server-core` Version | Default MongoDB Version | | :----------------------------------: | :---------------------: | +| 10.0.x - 10.0.x | 7.0.9 | | 9.2.x - 9.2.x | 6.0.14 | | 9.0.x - 9.1.x | 6.0.9 | | 8.14.x - 8.16.x | 5.0.19 | diff --git a/packages/mongodb-memory-server-core/src/__tests__/MongoMemoryReplSet.test.ts b/packages/mongodb-memory-server-core/src/__tests__/MongoMemoryReplSet.test.ts index a595d593c..2ebc7a7ff 100644 --- a/packages/mongodb-memory-server-core/src/__tests__/MongoMemoryReplSet.test.ts +++ b/packages/mongodb-memory-server-core/src/__tests__/MongoMemoryReplSet.test.ts @@ -239,6 +239,10 @@ describe('single server replset', () => { jest.spyOn(console, 'warn').mockImplementationOnce(() => void 0); const replSet = await MongoMemoryReplSet.create({ replSet: { auth: { enable: true }, count: 3, storageEngine: 'ephemeralForTest' }, + binary: { + // 7.0 removed "ephemeralForTest", this test is explicitly for that engine + version: '6.0.14', + }, }); utils.assertion(!utils.isNullOrUndefined(replSet.replSetOpts.auth)); @@ -436,7 +440,7 @@ describe('MongoMemoryReplSet', () => { dbName: replSet.replSetOpts.dbName, // not testing this value, because its generated "randomly" ip: '127.0.0.1', spawn: {}, - storageEngine: 'ephemeralForTest', + storageEngine: 'wiredTiger', configSettings: {}, }); replSet.replSetOpts = { auth: { enable: true } }; @@ -451,7 +455,7 @@ describe('MongoMemoryReplSet', () => { dbName: replSet.replSetOpts.dbName, // not testing this value, because its generated "randomly" ip: '127.0.0.1', spawn: {}, - storageEngine: 'ephemeralForTest', + storageEngine: 'wiredTiger', configSettings: {}, }); }); diff --git a/packages/mongodb-memory-server-core/src/__tests__/MongoMemoryServer.test.ts b/packages/mongodb-memory-server-core/src/__tests__/MongoMemoryServer.test.ts index cee951352..0a95f75ab 100644 --- a/packages/mongodb-memory-server-core/src/__tests__/MongoMemoryServer.test.ts +++ b/packages/mongodb-memory-server-core/src/__tests__/MongoMemoryServer.test.ts @@ -77,6 +77,10 @@ describe('MongoMemoryServer', () => { instance: { storageEngine: 'ephemeralForTest', }, + binary: { + // 7.0 removed "ephemeralForTest", this test is explicitly for that engine + version: '6.0.14', + }, }); utils.assertion(!utils.isNullOrUndefined(mongoServer.instanceInfo)); @@ -259,6 +263,10 @@ describe('MongoMemoryServer', () => { instance: { storageEngine: 'ephemeralForTest', }, + binary: { + // 7.0 removed "ephemeralForTest", this test is explicitly for that engine + version: '6.0.14', + }, }); utils.assertion(!utils.isNullOrUndefined(mongoServer.instanceInfo)); @@ -368,9 +376,6 @@ describe('MongoMemoryServer', () => { auth: { enable: false, }, - instance: { - storageEngine: 'ephemeralForTest', - }, }); utils.assertion(!utils.isNullOrUndefined(mongoServer.instanceInfo)); diff --git a/packages/mongodb-memory-server-core/src/__tests__/testUtils/globalSetup.ts b/packages/mongodb-memory-server-core/src/__tests__/testUtils/globalSetup.ts index 5791dd731..5e450f5f3 100644 --- a/packages/mongodb-memory-server-core/src/__tests__/testUtils/globalSetup.ts +++ b/packages/mongodb-memory-server-core/src/__tests__/testUtils/globalSetup.ts @@ -5,7 +5,7 @@ import { assertion, isNullOrUndefined } from '../../util/utils'; export = async function globalSetup(): Promise { const defaultVersion = resolveConfig(ResolveConfigVariables.VERSION); assertion(!isNullOrUndefined(defaultVersion), new Error('Default version is not defined')); - const versions = [defaultVersion, '4.0.28', '4.2.24', '4.4.28', '5.0.19', '6.0.14', '7.0.7']; + const versions = [defaultVersion, '4.0.28', '4.2.24', '4.4.28', '5.0.19', '6.0.14', '7.0.9']; // Ensure all required versions are downloaded for tests for (const version of versions) { await MongoBinary.getPath({ version }); diff --git a/packages/mongodb-memory-server-core/src/util/resolveConfig.ts b/packages/mongodb-memory-server-core/src/util/resolveConfig.ts index b150f402e..9ee31e62a 100644 --- a/packages/mongodb-memory-server-core/src/util/resolveConfig.ts +++ b/packages/mongodb-memory-server-core/src/util/resolveConfig.ts @@ -34,7 +34,7 @@ export enum ResolveConfigVariables { /** The Prefix for Environmental values */ export const ENV_CONFIG_PREFIX = 'MONGOMS_'; /** This Value exists here, because "defaultValues" can be changed with "setDefaultValue", but this property is constant */ -export const DEFAULT_VERSION = '6.0.14'; +export const DEFAULT_VERSION = '7.0.9'; /** Default values for some config options that require explicit setting, it is constant so that the default values cannot be interfered with */ export const defaultValues = new Map([ // apply app-default values here