Skip to content

Commit

Permalink
Merge branch 'master' into feature/9.0
Browse files Browse the repository at this point in the history
  • Loading branch information
hasezoey committed Aug 15, 2023
2 parents 559328b + 9fffce7 commit 48cfbbf
Show file tree
Hide file tree
Showing 17 changed files with 333 additions and 265 deletions.
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
## [8.14.0](https://github.com/nodkz/mongodb-memory-server/compare/v8.13.0...v8.14.0) (2023-08-04)


### Features

* update default-binary 5.0.19 ([296b2f6](https://github.com/nodkz/mongodb-memory-server/commit/296b2f6a4604d6ab1bfc81130b030df829203dac))
* **MongoBinaryDownload:** add option to configure max amount of redirects ([0d81c81](https://github.com/nodkz/mongodb-memory-server/commit/0d81c816eacf2b149ac01cd6bc18088f8486ccbe))
* **MongoBinaryDownload:** follow redirects ([9ec4aee](https://github.com/nodkz/mongodb-memory-server/commit/9ec4aee40d8ac429599b4b97385db1a4ff860c82)), closes [#785](https://github.com/nodkz/mongodb-memory-server/issues/785)


### Dependencies

* **eslint:** upgrade to version 8.46.0 ([713b1a5](https://github.com/nodkz/mongodb-memory-server/commit/713b1a5f5e2040a5297c1d41cf570f0ef7982316))
* **eslint-config-prettier:** upgrade to version 8.10.0 ([097077f](https://github.com/nodkz/mongodb-memory-server/commit/097077ff170f9907ddc7597179f91babdf0cd41a))
* **semver:** upgrade to version 7.5.4 ([f7c4837](https://github.com/nodkz/mongodb-memory-server/commit/f7c483743fdc90ed1eda0fec901d5673d14827f5))
* **tslib:** upgrade to version 2.6.1 ([db16d8f](https://github.com/nodkz/mongodb-memory-server/commit/db16d8fcc6bd9a6735a3f1414d1d3f4420dd9890))

## [8.13.0](https://github.com/nodkz/mongodb-memory-server/compare/v8.12.2...v8.13.0) (2023-06-09)


Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.18` 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 `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:

```sh
export MONGOMS_DOWNLOAD_URL=https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-ubuntu1804-4.2.8.tgz
Expand Down Expand Up @@ -127,7 +127,7 @@ const mongod = new MongoMemoryServer({
args?: string[], // by default no additional arguments, any additional command line arguments for `mongod` `mongod` (ex. ['--notablescan'])
},
binary: {
version?: string, // by default '5.0.18'
version?: string, // by default '5.0.19'
downloadDir?: string, // by default node_modules/.cache/mongodb-memory-server/mongodb-binaries
platform?: string, // by default os.platform()
arch?: string, // by default os.arch()
Expand Down
12 changes: 11 additions & 1 deletion docs/api/config-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ Example: `ubuntu-18.04`

Option `VERSION` is used to set what mongodb version should be downloaded

Default: `5.0.18`
Default: `5.0.19`

This Option does not have a effect when [`ARCHIVE_NAME`](#archive_name) or [`DOWNLOAD_URL`](#download_url) is defined.

Expand Down Expand Up @@ -207,6 +207,16 @@ Option `USE_HTTP` is used to use `http` over `https`

Default: `false`

### MAX_REDIRECTS

| Environment Variable | PackageJson |
| :------------------: | :---------: |
| `MONGOMS_MAX_REDIRECTS` | `maxRedirects` |

Option `MAX_REDIRECTS` is used to set the maximal amount of redirects to follow

Default: `2`

### USE_ARCHIVE_NAME_FOR_BINARY_NAME

| Environment Variable | PackageJson |
Expand Down
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 |
| :----------------------------------: | :---------------------: |
| 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 |
| 8.6.x - 8.10.x | 5.0.8 |
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
"conventional-changelog-conventionalcommits": "6.1.0",
"cross-env": "7.0.3",
"doctoc": "2.2.1",
"eslint": "8.44.0",
"eslint-config-prettier": "^8.8.0",
"eslint": "8.46.0",
"eslint-config-prettier": "^8.10.0",
"eslint-plugin-prettier": "4.2.1",
"husky": "8.0.3",
"jest": "29.6.1",
Expand Down
11 changes: 6 additions & 5 deletions packages/mongodb-memory-server-core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mongodb-memory-server-core",
"version": "8.13.0",
"version": "8.14.0",
"description": "MongoDB Server for testing (core package, without autodownload). The server will allow you to connect your favourite ODM or client library to the MongoDB Server and run parallel integration tests isolated from each other.",
"main": "lib/index",
"types": "lib/index.d.ts",
Expand Down Expand Up @@ -33,6 +33,7 @@
"devDependencies": {
"@types/debug": "^4.1.8",
"@types/find-cache-dir": "^3.2.1",
"@types/follow-redirects": "^1.14.1",
"@types/semver": "^7.5.0",
"@types/tar-stream": "^2.2.2",
"@types/yauzl": "^2.10.0",
Expand All @@ -48,9 +49,10 @@
"https-proxy-agent": "^7.0.1",
"mongodb": "^5.6.0",
"new-find-package-json": "^2.0.0",
"semver": "^7.5.1",
"semver": "^7.5.4",
"tar-stream": "^3.0.0",
"tslib": "^2.5.3",
"tslib": "^2.6.1",
"follow-redirects": "^1.15.2",
"yauzl": "^2.10.0"
},
"scripts": {
Expand All @@ -64,6 +66,5 @@
"test": "yarn run lint && yarn run coverage",
"test:watch": "yarn run watch",
"tscheck": "tsc --noEmit"
},
"optionalDependencies": {}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { assertion, isNullOrUndefined } from '../../util/utils';
export = async function globalSetup(): Promise<void> {
const defaultVersion = resolveConfig(ResolveConfigVariables.VERSION);
assertion(!isNullOrUndefined(defaultVersion), new Error('Default version is not defined'));
const versions = [defaultVersion, '4.0.28', '4.2.23', '4.4.22', '5.0.18', '6.0.6'];
const versions = [defaultVersion, '4.0.28', '4.2.23', '4.4.22', '5.0.19', '6.0.6'];
// Ensure all required versions are downloaded for tests
for (const version of versions) {
await MongoBinary.getPath({ version });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import os from 'os';
import { URL } from 'url';
import path from 'path';
import { promises as fspromises, createWriteStream, createReadStream, constants } from 'fs';
import https from 'https';
import { https } from 'follow-redirects';
import { createUnzip } from 'zlib';
import tar from 'tar-stream';
import yauzl from 'yauzl';
Expand All @@ -15,6 +15,7 @@ import { DryMongoBinary } from './DryMongoBinary';
import { MongoBinaryOpts } from './MongoBinary';
import { clearLine } from 'readline';
import { DownloadError, GenericMMSError, Md5CheckFailedError } from './errors';
import { RequestOptions } from 'https';

const log = debug('MongoMS:MongoBinaryDownload');

Expand Down Expand Up @@ -188,7 +189,7 @@ export class MongoBinaryDownload {
const urlObject = new URL(downloadUrl);
urlObject.port = urlObject.port || '443';

const requestOptions: https.RequestOptions = {
const requestOptions: RequestOptions = {
method: 'GET',
rejectUnauthorized: strictSsl,
protocol: envToBool(resolveConfig(ResolveConfigVariables.USE_HTTP)) ? 'http:' : 'https:',
Expand Down Expand Up @@ -359,17 +360,23 @@ export class MongoBinaryDownload {
*/
async httpDownload(
url: URL,
httpOptions: https.RequestOptions,
httpOptions: RequestOptions,
downloadLocation: string,
tempDownloadLocation: string
): Promise<string> {
log('httpDownload');
const downloadUrl = this.assignDownloadingURL(url);

const maxRedirects = parseInt(resolveConfig(ResolveConfigVariables.MAX_REDIRECTS) || '');
const useHttpsOptions: Parameters<typeof https.get>[1] = {
maxRedirects: Number.isNaN(maxRedirects) ? 2 : maxRedirects,
...httpOptions,
};

return new Promise((resolve, reject) => {
log(`httpDownload: trying to download "${downloadUrl}"`);
https
.get(url, httpOptions, (response) => {
.get(url, useHttpsOptions, (response) => {
if (response.statusCode != 200) {
if (response.statusCode === 403) {
reject(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ describe('MongodbInstance', () => {
const gotPort = await getFreePort(27445);
const mongod = await MongodbInstance.create({
instance: { port: gotPort, dbPath: tmpDir },
binary: { version: '5.0.18' },
binary: { version: '5.0.19' },
});
expect(mongod.mongodProcess!.pid).toBeGreaterThan(0);
await mongod.stop();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,13 @@ export enum ResolveConfigVariables {
SYSTEM_BINARY_VERSION_CHECK = 'SYSTEM_BINARY_VERSION_CHECK',
USE_ARCHIVE_NAME_FOR_BINARY_NAME = 'USE_ARCHIVE_NAME_FOR_BINARY_NAME',
DISTRO = 'DISTRO',
MAX_REDIRECTS = 'MAX_REDIRECTS',
}

/** 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 = '5.0.18';
export const DEFAULT_VERSION = '5.0.19';
/** 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<ResolveConfigVariables, string>([
// apply app-default values here
Expand All @@ -42,6 +43,7 @@ export const defaultValues = new Map<ResolveConfigVariables, string>([
[ResolveConfigVariables.SYSTEM_BINARY_VERSION_CHECK, 'true'],
[ResolveConfigVariables.USE_ARCHIVE_NAME_FOR_BINARY_NAME, 'false'],
[ResolveConfigVariables.MD5_CHECK, 'true'],
[ResolveConfigVariables.MAX_REDIRECTS, '2'],
]);

/** Interface for storing information about the found package.json from `findPackageJson` */
Expand Down
6 changes: 3 additions & 3 deletions packages/mongodb-memory-server-global-4.0/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mongodb-memory-server-global-4.0",
"version": "8.13.0",
"version": "8.14.0",
"mongodb_version": "4.0.28",
"description": "MongoDB Server for testing (auto-download 4.0 version to ~/.cache/mongodb-binaries).",
"main": "index.js",
Expand All @@ -25,8 +25,8 @@
"mongomem"
],
"dependencies": {
"mongodb-memory-server-core": "8.13.0",
"tslib": "^2.5.3"
"mongodb-memory-server-core": "8.14.0",
"tslib": "^2.6.1"
},
"scripts": {
"postinstall": "node ./postinstall.js"
Expand Down
6 changes: 3 additions & 3 deletions packages/mongodb-memory-server-global-4.2/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mongodb-memory-server-global-4.2",
"version": "8.13.0",
"version": "8.14.0",
"mongodb_version": "4.2.23",
"description": "MongoDB Server for testing (auto-download 4.2 version to ~/.cache/mongodb-binaries).",
"main": "index.js",
Expand All @@ -25,8 +25,8 @@
"mongomem"
],
"dependencies": {
"mongodb-memory-server-core": "8.13.0",
"tslib": "^2.5.3"
"mongodb-memory-server-core": "8.14.0",
"tslib": "^2.6.1"
},
"scripts": {
"postinstall": "node ./postinstall.js"
Expand Down
6 changes: 3 additions & 3 deletions packages/mongodb-memory-server-global-4.4/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mongodb-memory-server-global-4.4",
"version": "8.13.0",
"version": "8.14.0",
"mongodb_version": "4.4.22",
"description": "MongoDB Server for testing (auto-download 4.4 version to ~/.cache/mongodb-binaries).",
"main": "index.js",
Expand All @@ -25,8 +25,8 @@
"mongomem"
],
"dependencies": {
"mongodb-memory-server-core": "8.13.0",
"tslib": "^2.5.3"
"mongodb-memory-server-core": "8.14.0",
"tslib": "^2.6.1"
},
"scripts": {
"postinstall": "node ./postinstall.js"
Expand Down
6 changes: 3 additions & 3 deletions packages/mongodb-memory-server-global/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mongodb-memory-server-global",
"version": "8.13.0",
"version": "8.14.0",
"description": "MongoDB Server for testing (auto-download latest version to ~/.cache/mongodb-binaries).",
"main": "index.js",
"types": "index.d.ts",
Expand All @@ -24,8 +24,8 @@
"mongomem"
],
"dependencies": {
"mongodb-memory-server-core": "8.13.0",
"tslib": "^2.5.3"
"mongodb-memory-server-core": "8.14.0",
"tslib": "^2.6.1"
},
"scripts": {
"postinstall": "node ./postinstall.js"
Expand Down
6 changes: 3 additions & 3 deletions packages/mongodb-memory-server/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mongodb-memory-server",
"version": "8.13.0",
"version": "8.14.0",
"description": "MongoDB Server for testing (auto-download latest version). The server will allow you to connect your favourite ODM or client library to the MongoDB Server and run parallel integration tests isolated from each other.",
"main": "index.js",
"types": "index.d.ts",
Expand All @@ -24,8 +24,8 @@
"mongomem"
],
"dependencies": {
"mongodb-memory-server-core": "8.13.0",
"tslib": "^2.5.3"
"mongodb-memory-server-core": "8.14.0",
"tslib": "^2.6.1"
},
"scripts": {
"postinstall": "node ./postinstall.js"
Expand Down
Loading

0 comments on commit 48cfbbf

Please sign in to comment.