From 1a88c37e7b0a019e152dc493d25256d0b2f3e536 Mon Sep 17 00:00:00 2001 From: hasezoey Date: Wed, 9 Oct 2024 12:56:47 +0200 Subject: [PATCH] feat(MongoBinaryDownloadUrl): support ubuntu 2404 & 8.0.0 instead of using 2204 binaries for 2404 --- .../src/util/MongoBinaryDownloadUrl.ts | 9 ++- .../__tests__/MongoBinaryDownloadUrl.test.ts | 68 ++++++++++++++++++- 2 files changed, 73 insertions(+), 4 deletions(-) diff --git a/packages/mongodb-memory-server-core/src/util/MongoBinaryDownloadUrl.ts b/packages/mongodb-memory-server-core/src/util/MongoBinaryDownloadUrl.ts index 2d2fa177..1e8fdaa9 100644 --- a/packages/mongodb-memory-server-core/src/util/MongoBinaryDownloadUrl.ts +++ b/packages/mongodb-memory-server-core/src/util/MongoBinaryDownloadUrl.ts @@ -581,6 +581,11 @@ export class MongoBinaryDownloadUrl implements MongoBinaryDownloadUrlOpts { return 'ubuntu2004'; } + // there are only binaries for 2404 since 8.0.0, not in 7.x + if (ubuntuYear >= 22 && semver.satisfies(coercedVersion, '<8.0.0')) { + return 'ubuntu2204'; + } + // base case for higher than mongodb supported ubuntu versions { // TODO: try to keep this up-to-date to the latest mongodb supported ubuntu version @@ -588,14 +593,14 @@ export class MongoBinaryDownloadUrl implements MongoBinaryDownloadUrlOpts { * Highest ubuntu year supported by mongodb binaries * @see https://www.mongodb.com/download-center/community/releases/archive */ - const highestUbuntuYear = 22; // 22 is the highest supported as of mongodb 7.0.11 + const highestUbuntuYear = 24; // 24 is the highest supported as of mongodb 8.0.1 if (ubuntuYear > highestUbuntuYear) { log( `getUbuntuVersionString: ubuntuYear "${ubuntuYear}" is higher than the currently supported mongodb year of "${highestUbuntuYear}", using highest known` ); - return 'ubuntu2204'; + return 'ubuntu2404'; } } 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 029de569..0c73d386 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 @@ -309,6 +309,70 @@ describe('MongoBinaryDownloadUrl', () => { ); }); + it('for ubuntu 22.04 for 7.0.11', async () => { + const du = new MongoBinaryDownloadUrl({ + platform: 'linux', + arch: 'x64', + version: '7.0.11', + os: { + os: 'linux', + dist: 'ubuntu', + release: '22.04', + }, + }); + expect(await du.getDownloadUrl()).toBe( + 'https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-ubuntu2204-7.0.11.tgz' + ); + }); + + it('for ubuntu 24.04 for 7.0.11', async () => { + const du = new MongoBinaryDownloadUrl({ + platform: 'linux', + arch: 'x64', + version: '7.0.11', + os: { + os: 'linux', + dist: 'ubuntu', + release: '24.04', + }, + }); + expect(await du.getDownloadUrl()).toBe( + 'https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-ubuntu2204-7.0.11.tgz' + ); + }); + + it('for ubuntu 22.04 for 8.0.1', async () => { + const du = new MongoBinaryDownloadUrl({ + platform: 'linux', + arch: 'x64', + version: '8.0.1', + os: { + os: 'linux', + dist: 'ubuntu', + release: '22.04', + }, + }); + expect(await du.getDownloadUrl()).toBe( + 'https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-ubuntu2204-8.0.1.tgz' + ); + }); + + it('for ubuntu 24.04 for 8.0.1', async () => { + const du = new MongoBinaryDownloadUrl({ + platform: 'linux', + arch: 'x64', + version: '8.0.1', + os: { + os: 'linux', + dist: 'ubuntu', + release: '24.04', + }, + }); + expect(await du.getDownloadUrl()).toBe( + 'https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-ubuntu2404-8.0.1.tgz' + ); + }); + it('should allow v5.0-latest', async () => { const du = new MongoBinaryDownloadUrl({ platform: 'linux', @@ -352,7 +416,7 @@ describe('MongoBinaryDownloadUrl', () => { const du = new MongoBinaryDownloadUrl({ platform: 'linux', arch: 'x64', - version: '7.0.4', // highest released mongodb version + version: '8.0.1', // highest released mongodb version os: { os: 'linux', dist: 'ubuntu', @@ -360,7 +424,7 @@ describe('MongoBinaryDownloadUrl', () => { }, }); expect(await du.getDownloadUrl()).toBe( - 'https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-ubuntu2204-7.0.4.tgz' + 'https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-ubuntu2404-8.0.1.tgz' ); });