From 6598792b2fd379a78da97f413fbc4a964f89f785 Mon Sep 17 00:00:00 2001 From: hasezoey Date: Fri, 20 Jan 2023 00:40:20 +0100 Subject: [PATCH] fix(MongoBinaryDownloadUrl): support ubuntu 22.04 ^6.0.4 fixes #732 --- docs/guides/supported-systems.md | 2 +- .../src/util/MongoBinaryDownloadUrl.ts | 5 ++-- .../__tests__/MongoBinaryDownloadUrl.test.ts | 24 +++++++++++++++---- 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/docs/guides/supported-systems.md b/docs/guides/supported-systems.md index 88d9bba64..4d5dae142 100644 --- a/docs/guides/supported-systems.md +++ b/docs/guides/supported-systems.md @@ -62,7 +62,7 @@ Architectures Supported: `x86_64`, `arm64`(`aarch64`) Lower Versions than `2004` may be used if mongodb dosnt provide binaries for an lower version of mongodb for an higher version of ubuntu ::: :::note -There are currently no native binaries for `2204`, so it is mapped to `2004` and will require `libssl1.1` to be installed. +Since Mongodb `6.0.4` there are binaries for `2204`, any version before is mapped to `2204` (or earlier) and will require `libssl1.1` to be installed. See [this mongodb issue](https://jira.mongodb.org/browse/SERVER-62300). ::: diff --git a/packages/mongodb-memory-server-core/src/util/MongoBinaryDownloadUrl.ts b/packages/mongodb-memory-server-core/src/util/MongoBinaryDownloadUrl.ts index 896435752..1dd8b14d6 100644 --- a/packages/mongodb-memory-server-core/src/util/MongoBinaryDownloadUrl.ts +++ b/packages/mongodb-memory-server-core/src/util/MongoBinaryDownloadUrl.ts @@ -513,9 +513,8 @@ export class MongoBinaryDownloadUrl implements MongoBinaryDownloadUrlOpts { return 'ubuntu1804'; } - // there are not binaries for ubuntu 21.04, so defaulting to one version below for now - // see https://github.com/nodkz/mongodb-memory-server/issues/582 - if (ubuntuYear >= 21) { + // there are only binaries for 2204 since 6.0.4 (and not binaries for ubuntu2104) + if (ubuntuYear >= 21 && semver.satisfies(coercedVersion, '<6.0.4')) { return 'ubuntu2004'; } diff --git a/packages/mongodb-memory-server-core/src/util/__tests__/MongoBinaryDownloadUrl.test.ts b/packages/mongodb-memory-server-core/src/util/__tests__/MongoBinaryDownloadUrl.test.ts index 8b04edfa8..f4deb7b43 100644 --- a/packages/mongodb-memory-server-core/src/util/__tests__/MongoBinaryDownloadUrl.test.ts +++ b/packages/mongodb-memory-server-core/src/util/__tests__/MongoBinaryDownloadUrl.test.ts @@ -176,7 +176,7 @@ describe('MongoBinaryDownloadUrl', () => { ); }); - it('for ubuntu 22.04 for 4.0', async () => { + it('for ubuntu 22.04 for 4.0 (using 1804)', async () => { const du = new MongoBinaryDownloadUrl({ platform: 'linux', arch: 'x64', @@ -192,7 +192,7 @@ describe('MongoBinaryDownloadUrl', () => { ); }); - it('for ubuntu 22.04 for 4.4', async () => { + it('for ubuntu 22.04 for 4.4 (using 2004)', async () => { const du = new MongoBinaryDownloadUrl({ platform: 'linux', arch: 'x64', @@ -224,7 +224,7 @@ describe('MongoBinaryDownloadUrl', () => { ); }); - it('for ubuntu 22.04 for 5.0', async () => { + it('for ubuntu 22.04 for 5.0 (using 2004)', async () => { const du = new MongoBinaryDownloadUrl({ platform: 'linux', arch: 'x64', @@ -256,7 +256,7 @@ describe('MongoBinaryDownloadUrl', () => { ); }); - it('for ubuntu 22.04 for 6.0', async () => { + it('for ubuntu 22.04 for 6.0 (using 2004)', async () => { const du = new MongoBinaryDownloadUrl({ platform: 'linux', arch: 'x64', @@ -272,6 +272,22 @@ describe('MongoBinaryDownloadUrl', () => { ); }); + it('for ubuntu 22.04 for 6.0.4', async () => { + const du = new MongoBinaryDownloadUrl({ + platform: 'linux', + arch: 'x64', + version: '6.0.4', + os: { + os: 'linux', + dist: 'ubuntu', + release: '22.04', + }, + }); + expect(await du.getDownloadUrl()).toBe( + 'https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-ubuntu2204-6.0.4.tgz' + ); + }); + it('should allow v5.0-latest', async () => { const du = new MongoBinaryDownloadUrl({ platform: 'linux',