Skip to content

Commit

Permalink
Merge branch 'beta' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
hasezoey committed Oct 6, 2023
2 parents 3908d79 + 899a710 commit 0a5a21d
Show file tree
Hide file tree
Showing 60 changed files with 5,226 additions and 5,267 deletions.
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Top Level; Everything that is not convered by anything below
* @nodkz @AJRdev @hasezoey
* @nodkz @hasezoey

**/LICENSE.md @nodkz
website/ @hasezoey
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [12.x, 14.x, 16.x, 18.x]
node-version: [14.x, 16.x, 18.x, 20.x]
steps:
- uses: actions/checkout@v4
if: github.event.inputs.git-ref == ''
Expand Down Expand Up @@ -49,7 +49,7 @@ jobs:
env:
CI: true
- name: Send codecov.io stats
if: matrix.node-version == '12.x'
if: matrix.node-version == '14.x'
uses: codecov/codecov-action@v3

publish:
Expand All @@ -58,10 +58,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Use Node.js 12
- name: Use Node.js 18
uses: actions/setup-node@v3
with:
node-version: 12.x
node-version: 18.x
- name: Install node_modules
run: yarn install
- name: Build
Expand Down
8 changes: 7 additions & 1 deletion .releaserc.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ module.exports = {
{type: "perf", release: "patch"},
{type: "test", release: false},
{type: "chore", release: false},
{type: "deps", release: "minor"},
{type: "devdeps", release: false},
// backwards compatability, remove after 9.0 has been published
{type: "dependencies", release: "minor"},
// dont trigger another release on release commit
{type: "release", release: false}
Expand All @@ -37,6 +40,9 @@ module.exports = {
{type: "perf", section: "Performance"},
{type: "test", hidden: true},
{type: "chore", hidden: true},
{type: "deps", section: "Dependencies"},
{type: "devdeps", section: "Dev-Dependencies"},
// backwards compatability, remove after 9.0 has been published
{type: "dependencies", section: "Dependencies"},
{type: "revert", section: "Reverts"},
{type: "release", hidden: true}
Expand All @@ -46,7 +52,7 @@ module.exports = {
],
[
// Update versions in sub-packages dependencies
"@google/semantic-release-replace-plugin",
"semantic-release-replace-plugin",
{
"replacements": [
{
Expand Down
209 changes: 209 additions & 0 deletions CHANGELOG.md

Large diffs are not rendered by default.

11 changes: 5 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ Choose any package, because they are the same. They differ only in the default c

### Requirements

- NodeJS: 12.22+
- Typescript: 4.4+ (if used)
- NodeJS: 14.20.1+
- Typescript: 5.0+ (if used)

And one of those (on Linux):

Expand All @@ -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 `5.0.19` 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 `6.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
Expand Down Expand Up @@ -122,13 +122,12 @@ const mongod = new MongoMemoryServer({
ip?: string, // by default '127.0.0.1', for binding to all IP addresses set it to `::,0.0.0.0`,
dbName?: string, // by default '' (empty string)
dbPath?: string, // by default create in temp directory
storageEngine?: string, // by default `ephemeralForTest`, available engines: [ 'ephemeralForTest', 'wiredTiger' ]
storageEngine?: string, // by default `ephemeralForTest`(unless mongodb 7.0.0, where its `wiredTiger`), available engines: [ 'ephemeralForTest', 'wiredTiger' ]
replSet?: string, // by default no replica set, replica set name
auth?: boolean, // by default `mongod` is started with '--noauth', start `mongod` with '--auth'
args?: string[], // by default no additional arguments, any additional command line arguments for `mongod` `mongod` (ex. ['--notablescan'])
},
binary?: {
version?: string, // by default '5.0.19'
version?: string, // by default '6.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()
Expand Down
3 changes: 2 additions & 1 deletion commitlint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ module.exports = {
'test',
'chore',
'revert',
'dependencies',
'deps',
'devdeps',
'release',
],
],
Expand Down
4 changes: 2 additions & 2 deletions docs/api/config-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Valid Options are `win32`, `darwin`, `linux`, ~~`sunos`~~(never actually support

Option `ARCH` is used to overwrite the Architecture to download for

Valid Options are `x64`, `arm64`, ~~`ia32`~~([will be removed in 9.0](../guides/error-warning-details.md#mms001))
Valid Options are `x64`, `arm64`

[See here for what versions are available for what architectures](https://www.mongodb.com/download-center/community/releases/archive)

Expand Down Expand Up @@ -171,7 +171,7 @@ Default: `true`

Option `MD5_CHECK` is used to enable an md5 check after download

Default: `false`
Default: `true`

### ARCHIVE_NAME

Expand Down
14 changes: 10 additions & 4 deletions docs/api/interfaces/mongo-memory-instance-opts.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ This option will automatically be set with a directory generated by [`mkdtemp`](
### storageEngine

Typings: `storageEngine?: StorageEngine`
Default: `ephemeralForTest`
Default: `ephemeralForTest` (unless mongodb version is `7.0.0`, where its `wiredTiger`)

Set which storage engine to use, uses [`StorageEngine`](#helper-type-storageengine).

Expand All @@ -85,13 +85,19 @@ Only has a effect when started with [`MongoMemoryReplSet`](../classes/mongo-memo

## Helper Type `StorageEngine`

Typings: `StorageEngine = 'devnull' | 'ephemeralForTest' | 'mmapv1' | 'wiredTiger'`
Typings: `StorageEngine = 'ephemeralForTest' | 'wiredTiger'`

Storage Engines supported by mongodb, see [MongoDB Storage Engines](https://www.mongodb.com/docs/manual/core/storage-engines/).

Custom Explanation:

- `devnull` is a storage engine which discards everything and cannot be read from.
- `ephemeralForTest` is a in-memory storage engine, which stores everything in RAM, which is great to use when wanting a simple database testing backend, is not the same as the Enterprise In-Memory Engine
- `mmapv1` is storage engine which stores data on disk, was removed in mongodb 4.2
- `wiredTiger` is a storage engine which stores data on disk.

:::warning
MongoDB has stated that storage-engine `ephemeralForTest` is unstable and has been deprecated, it will be removed with mongodb 7.

In MMS there has been no observation of `ephemeralForTest` being unstable (aside from some missing features) and will continue to be the default until mongodb-memory-server changes to a version where `ephemeralForTest` is not present anymore.

With mongodb-memory-server 9.0.0, if mongodb 7.0.0 or higher is used, `wiredTiger` is the default engine.
:::
7 changes: 3 additions & 4 deletions docs/api/interfaces/mongo-memory-server-automaticauth.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,12 @@ API Documentation of `AutomaticAuth`-Interface

## Values

### disable
### enable

Typings: `disable?: boolean`
Typings: `enable?: boolean`
Default: `false`

Disable Authentication creation.
Normally authentication is enabled when the `auth` field a object, but with this option it can be explicitly disabled.
Enable or disable Authentication creation.

### extraUsers

Expand Down
6 changes: 4 additions & 2 deletions docs/api/interfaces/mongo-memory-server-opts.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ API Documentation of `MongoMemoryServerOpts`-Interface

### instance

Typings: `instance?: MongoMemoryInstanceOpts`
Typings: `instance?: MemoryServerInstanceOpts`

Set custom options for the instance, uses [`MongoMemoryInstanceOpts`](./mongo-memory-instance-opts.md).
Set custom options based on [`MongoMemoryInstanceOpts`](./mongo-memory-instance-opts.md), but ignores some properties:

- `auth` is ignored because it is set via [auth](#auth) property.

### binary

Expand Down
8 changes: 4 additions & 4 deletions docs/api/interfaces/replset-opts.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ API Documentation of `ReplSetOpts`-Interface

### auth

Typings: `auth?: boolean | AutomaticAuth`
Default: `false`
Typings: `auth?: AutomaticAuth`
Default: `{ enable: false }`

Set wheter to enable Authentication, with configuration from [`AutomaticAuth`](./mongo-memory-server-automaticauth.md).
Set whether to enable Authentication, with configuration from [`AutomaticAuth`](./mongo-memory-server-automaticauth.md).

Also see [`MongoMemoryInstanceOpts.auth`](./mongo-memory-instance-opts.md#auth).

Expand Down Expand Up @@ -66,7 +66,7 @@ Also see [`MongoMemoryInstanceOpts.spawn`](./mongo-memory-instance-opts.md#spawn
### storageEngine

Typings: `storageEngine?: StorageEngine`
Default: `"ephemeralForTest"`
Default: `"ephemeralForTest"` (unless mongodb version is `7.0.0`, where its `wiredTiger`)

Set which Storage Engine to use, uses [`StorageEngine`](./mongo-memory-instance-opts.md#helper-type-storageengine).

Expand Down
11 changes: 11 additions & 0 deletions docs/guides/error-warning-details.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ Default Timeout: `1000 * 30` (30 seconds)

## EnsureInstanceError

:::note
Merged into [`InstanceInfoError`](#instanceinfoerror) in 9.0.0
:::

Example:

- `${baseMesasge} state was "running" but "instanceInfo" was undefined!`
Expand Down Expand Up @@ -168,6 +172,13 @@ Example: `ReplSet Count needs to be 1 or higher! (specified count: "${count}")`
Details:
ReplSet count (like `new MongoMemoryReplSet({ replSet: { count: 0 } })`) needs to be `1` or higher

## UnknownLinuxDistro

Example: `Unknown/unsupported linux "${distro}" id_like's: [${id_like?.join(', ')}]`

Details:
The Linux distro in use does not have a mapping for a mongodb version, please report this issue if the distro / idlike is not mentioned in [Supported Systems](./supported-systems.md).

## Deprecation Codes

### MMS001
Expand Down
2 changes: 1 addition & 1 deletion docs/guides/migration/migrate7.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ This Guide is written for migration from version `6.9.6` to `7.0.0`, for version

## Requirement Changes

- Nodejs `10` & `11` are now unsupported, lowest supported version is now `12.22`
- Nodejs `10` & `11` are now unsupported, lowest supported version is now `14.0`

## Breaking Changes

Expand Down
131 changes: 131 additions & 0 deletions docs/guides/migration/migrate9.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
---
id: migrate9
title: 'Migrate to version 9.0.0'
---

Here are the Important changes made for 9.0.0

:::caution Important, Read this first
This Guide is written for migration from version `8.16.0` to `9.0.0`, for versions `>9.0.0 <10.0.0`, please consult the [CHANGELOG](https://github.com/nodkz/mongodb-memory-server/blob/master/CHANGELOG.md)
:::

## Breaking Changes

### Minimal NodeJS version is now `14`

With 9.0.0 the minimal nodejs required is `14.20.1`.

### Mongodb Driver Version upgraded to 5.x

The used MongoDB Driver version is now `5.9.0`.

### Default binary version is now 6.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).

### Removed platform translations

Some platform translations have been removed, because they are either not needed anymore or werent properly supported in the first place:

- `sunos` -> `linux`
- `elementary OS` -> `linux`

### Removed architectures

Some architectures were removed because they were not being build by mongodb anymore and support in mongodb-memory-server has been largely untested:

- `ia32` -> `i686` / `i386`

### MongoMemoryServer `instance.auth` option is now ignored

With 9.0.0 the option `instance.auth` option is going to be ignored, because its set via the (top-level) `auth` option directly.

Example:

`new MongoMemoryServer({ instance: { auth: true } })` is going to be ignored, use `new MongoMemoryServer({ auth: { enable: true } })`

### `AutomaticAuth` changes

`AutomaticAuth` has been changed to **not** be enabled anymore by just having a empty object. Also property `disable` has been removed and `enable` has been added.

Replace `auth: {}` with `auth: { enable: true }`.
Replace `auth: { disable: true }` with `auth: { enable: false }`.
Replace `auth: { disable: false }` with `auth: { enable: true }`.

### MongoMemoryServer and MongoReplSet `.cleanup(boolean)` and `.stop(boolean)` have been removed

Previously `boolean` was the only option for the `.cleanup` and `.stop` function, but they behaved differently between those 2 function and were replaced with `Cleanup` object-options and now have been completely removed.

Replace `.stop(true)` with `.stop({ doCleanup: true })`.
Replace `.cleanup(true)` with `.stop({ doCleanup: true, force: true })`.

Default is still for both `{ doCleanup: true, force: false }`.

### `MD5_CHECK` is now enabled by default

The config option [`MD5_CHECK`](../../api/config-options.md#md5_check) has been enabled by default now, resulting in always comparing the downloaded archive with a md5 after a download.

### Merged Error types

Some error classes have been merged:

- `EnsureInstanceError` & `InstanceInfoError` -> `InstanceInfoError`
- `NoSystemBinaryFoundError` & `BinaryNotFoundError` -> `BinaryNotFoundError`

### Removed Storage engine `devnull` and `mmapv1`

Storage Engines `devnull` and `mmapv1` have been removed because they are not supported in newer versions of mongodb anymore, `wiredTiger` should be used instead.

### Linux fallback binary has been removed

Previously there was a code-path for a fallback linux binary, but this has been removed because mongodb has stopped shipping generic linux binaries since versions after 4.0.

If a fallback is still required, try to use the ubuntu binary via [Config Options `DISTRO`](../../api/config-options.md#distro).

### Ubuntu fallback year has been updated

The ubuntu fallback year has been updated to `22`, instead of the previous `14`, because newer versions of mongodb dont ship for any EOL ubuntu version anymore.

This fallback is only used if the ubuntu year could not be parsed from the os-file.
This can also be overwritten with [Config Option `DISTRO`](../../api/config-options.md#distro).

## Non-Breaking changes / Additions

### Compiler target is now `es2019`

The tsconfig `target` option has been updated to `es2019`, which will result in less polyfills.
This should be a non-breaking change

## Crypto function have been changed to use nodejs internals

Crypto functions like for the md5 check and uuidv4 generation have been moved to use the `node:crypto` support, resulting in dropping 2 dependencies.

Dropped dependencies are `md5-file` and `uuid`.

## Binary childprocess is now also `.unref()`

The Mongodb Binary childprocess is now also `.unref()`, like the killer process has been for some time.

This *should* help with non-closed instances not exiting the nodejs process.

## The port testing package has been replaced

Previously MMS used `get-port`, but it caused some big memory-leakage across big projects, so it has been replaced with one that uses less maps.

It also has been replaced because newer versions were ESM only, but we couldnt switch to ESM yet (and using ESM in CommonJS is not a great experience)

## Mongodb version 7.0.0 is now supported

Mongob version `7.0.0` removed storage engine `ephemeralForTest`, with mongodb-memory-server 9.0.0 storage engine `wiredTiger` is the default for binary versions `7.0.0` and higher.
Older versions (before `7.0.0`) will still continue to use `ephemeralForTest` by default.

:::info
The version used for the decision is the version provided via the resolved [`VERSION`](../../api/config-options.md#version) config option.
This mean it needs to match the version the system binary is (a warning is printed if they are not the same).

If the option is unset, the default version will be used, which is likely not correct for the system binary.

If the decision should not be automatic, the storage engine can be explicitly defined as a instance option.
:::

It is recommended to run those instances with a db path which is equivalent to [`tmpfs`](https://wiki.archlinux.org/title/tmpfs).
1 change: 1 addition & 0 deletions docs/guides/mongodb-server-versions.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
| :----------------------------------: | :---------------------: |
| 9.0.x - 9.0.x | 6.0.9 |
| 8.14.x - 8.13.x | 5.0.19 |
| 8.13.x - 8.13.x | 5.0.18 |
| 8.11.x - 8.12.x | 5.0.13 |
Expand Down

0 comments on commit 0a5a21d

Please sign in to comment.