From 8c20624e08244a98213b75198785b33041f2df57 Mon Sep 17 00:00:00 2001 From: hasezoey Date: Thu, 10 Oct 2024 15:05:36 +0200 Subject: [PATCH] fix(MongoBinaryDownloadUrl): fix rhel8 handling for newer versions fixes #893 https://jira.mongodb.org/browse/SERVER-92375 --- .../src/util/MongoBinaryDownloadUrl.ts | 16 ++- .../__tests__/MongoBinaryDownloadUrl.test.ts | 130 ++++++++++++++++++ 2 files changed, 144 insertions(+), 2 deletions(-) diff --git a/packages/mongodb-memory-server-core/src/util/MongoBinaryDownloadUrl.ts b/packages/mongodb-memory-server-core/src/util/MongoBinaryDownloadUrl.ts index 1e8fdaa9..7ed9afbe 100644 --- a/packages/mongodb-memory-server-core/src/util/MongoBinaryDownloadUrl.ts +++ b/packages/mongodb-memory-server-core/src/util/MongoBinaryDownloadUrl.ts @@ -408,9 +408,21 @@ export class MongoBinaryDownloadUrl implements MongoBinaryDownloadUrlOpts { if (semver.satisfies(releaseAsSemver, '>=9.0.0')) { name += '90'; } else if (semver.satisfies(releaseAsSemver, '8.2.0') && this.arch == 'aarch64') { - name += '82'; + // Mongodb changed its naming for rhel8 only https://jira.mongodb.org/browse/SERVER-92375 + // NOTE: as of 10.10.2024 `(rhel8|rhel80)-7.0.13` is not downloadable but `7.0.14` is + if (semver.satisfies(coercedVersion, '^5.0.29 || ^6.0.17 || ^7.0.13 || ^8.0.0')) { + name += '8'; + } else { + name += '82'; + } } else if (semver.satisfies(releaseAsSemver, '^8.0.0')) { - name += '80'; + // Mongodb changed its naming for rhel8 only https://jira.mongodb.org/browse/SERVER-92375 + // NOTE: as of 10.10.2024 `(rhel8|rhel80)-7.0.13` is not downloadable but `7.0.14` is + if (semver.satisfies(coercedVersion, '^5.0.29 || ^6.0.17 || ^7.0.13 || ^8.0.0')) { + name += '8'; + } else { + name += '80'; + } } else if (semver.satisfies(releaseAsSemver, '^7.0.0')) { name += '70'; } else if (semver.satisfies(releaseAsSemver, '^6.0.0')) { 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 39802577..b8faa619 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 @@ -1348,6 +1348,136 @@ describe('MongoBinaryDownloadUrl', () => { ); }); + describe('rhel 8 download name change (JIRA SERVER-92375)', () => { + it('rhel 8 & 5.0.29 x86_64', async () => { + const du = new MongoBinaryDownloadUrl({ + platform: 'linux', + arch: 'x64', + version: '5.0.29', + os: { + os: 'linux', + dist: 'rhel', + release: '8.2', + }, + }); + expect(await du.getDownloadUrl()).toBe( + 'https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel8-5.0.29.tgz' + ); + }); + + it('rhel 8 & 6.0.17 x86_64', async () => { + const du = new MongoBinaryDownloadUrl({ + platform: 'linux', + arch: 'x64', + version: '6.0.17', + os: { + os: 'linux', + dist: 'rhel', + release: '8.2', + }, + }); + expect(await du.getDownloadUrl()).toBe( + 'https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel8-6.0.17.tgz' + ); + }); + + it('rhel 8 & 7.0.13 x86_64', async () => { + const du = new MongoBinaryDownloadUrl({ + platform: 'linux', + arch: 'x64', + version: '7.0.13', + os: { + os: 'linux', + dist: 'rhel', + release: '8.2', + }, + }); + expect(await du.getDownloadUrl()).toBe( + 'https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel8-7.0.13.tgz' + ); + }); + + it('rhel 8 & 8.0.0 x86_64', async () => { + const du = new MongoBinaryDownloadUrl({ + platform: 'linux', + arch: 'x64', + version: '8.0.0', + os: { + os: 'linux', + dist: 'rhel', + release: '8.2', + }, + }); + expect(await du.getDownloadUrl()).toBe( + 'https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel8-8.0.0.tgz' + ); + }); + + it('rhel 8.2 & 5.0.29 arm64', async () => { + const du = new MongoBinaryDownloadUrl({ + platform: 'linux', + arch: 'arm64', + version: '5.0.29', + os: { + os: 'linux', + dist: 'rhel', + release: '8.2', + }, + }); + expect(await du.getDownloadUrl()).toBe( + 'https://fastdl.mongodb.org/linux/mongodb-linux-aarch64-rhel8-5.0.29.tgz' + ); + }); + + it('rhel 8.2 & 6.0.17 arm64', async () => { + const du = new MongoBinaryDownloadUrl({ + platform: 'linux', + arch: 'arm64', + version: '6.0.17', + os: { + os: 'linux', + dist: 'rhel', + release: '8.2', + }, + }); + expect(await du.getDownloadUrl()).toBe( + 'https://fastdl.mongodb.org/linux/mongodb-linux-aarch64-rhel8-6.0.17.tgz' + ); + }); + + it('rhel 8.2 & 7.0.13 arm64', async () => { + const du = new MongoBinaryDownloadUrl({ + platform: 'linux', + arch: 'arm64', + version: '7.0.13', + os: { + os: 'linux', + dist: 'rhel', + release: '8.2', + }, + }); + expect(await du.getDownloadUrl()).toBe( + 'https://fastdl.mongodb.org/linux/mongodb-linux-aarch64-rhel8-7.0.13.tgz' + ); + }); + + it('rhel 8.2 & 8.0.0 arm64', async () => { + const du = new MongoBinaryDownloadUrl({ + platform: 'linux', + arch: 'arm64', + version: '8.0.0', + os: { + os: 'linux', + dist: 'rhel', + release: '8.2', + }, + }); + expect(await du.getDownloadUrl()).toBe( + 'https://fastdl.mongodb.org/linux/mongodb-linux-aarch64-rhel8-8.0.0.tgz' + ); + }); + }); + it('rhel 8.2 & 4.4.2 arm64', async () => { const du = new MongoBinaryDownloadUrl({ platform: 'linux',