From c5828298382da762e37e69c5d46c781c4b4e591e Mon Sep 17 00:00:00 2001 From: hasezoey Date: Thu, 26 Oct 2023 14:57:14 +0200 Subject: [PATCH] feat(MongoBinaryDownloadUrl): re-work rhel to support 9.0 re #821 --- docs/guides/supported-systems.md | 6 +- .../src/util/MongoBinaryDownloadUrl.ts | 27 +++++-- .../__tests__/MongoBinaryDownloadUrl.test.ts | 80 ++++++++++++++++++- .../MongoBinaryDownloadUrl.test.ts.snap | 6 +- 4 files changed, 104 insertions(+), 15 deletions(-) diff --git a/docs/guides/supported-systems.md b/docs/guides/supported-systems.md index e04062d9c..9f7fee6ff 100644 --- a/docs/guides/supported-systems.md +++ b/docs/guides/supported-systems.md @@ -90,16 +90,16 @@ There are currently no newer mongodb builds that support the newer provided open ### Rhel -Untested Outdated +Untested (uses mongodb's `rhel` release)
Lowest supported Distribution version is `5`
-Highest version is `8`
+Highest version is `9`
Default version is `70`
Architectures Supported: `x86_64`, `arm64`(`aarch64`) :::note -`arm64`/`aarch64` support is only for Rhel 8(.2) +`arm64`/`aarch64` support is only for Rhel 8.2 & mongodb 4.4.2 or Rhel 9 & mongodb 6.0.7 ::: ### Amazon diff --git a/packages/mongodb-memory-server-core/src/util/MongoBinaryDownloadUrl.ts b/packages/mongodb-memory-server-core/src/util/MongoBinaryDownloadUrl.ts index b10afce74..cf984e169 100644 --- a/packages/mongodb-memory-server-core/src/util/MongoBinaryDownloadUrl.ts +++ b/packages/mongodb-memory-server-core/src/util/MongoBinaryDownloadUrl.ts @@ -361,11 +361,13 @@ export class MongoBinaryDownloadUrl implements MongoBinaryDownloadUrlOpts { } if (releaseAsSemver) { + // extra checks for architecture aarch64 (arm64) + // should not assign "name" by itself if (this.arch === 'aarch64') { // there are no versions for aarch64 before rhel 8.2 (or currently after) if (semver.lt(releaseAsSemver, '8.2.0')) { throw new KnownVersionIncompatibilityError( - `Rhel ${release}`, + `Rhel ${release} arm64`, this.version, '>=4.4.2', 'ARM64(aarch64) support for rhel is only for rhel82 or higher' @@ -374,16 +376,29 @@ export class MongoBinaryDownloadUrl implements MongoBinaryDownloadUrlOpts { // there are no versions for aarch64 before mongodb 4.4.2 // Note: version 4.4.2 and 4.4.3 are NOT listed at the list, but are existing; list: https://www.mongodb.com/download-center/community/releases/archive if (semver.lt(coercedVersion, '4.4.2') && !testVersionIsLatest(this.version)) { - throw new KnownVersionIncompatibilityError(`Rhel ${release}`, this.version, '>=4.4.2'); + throw new KnownVersionIncompatibilityError( + `Rhel ${release} arm64`, + this.version, + '>=4.4.2' + ); } - if (!semver.eq(releaseAsSemver, '8.2.0')) { - log(`a different rhel version than 8.2 is used: "${release}", using 82 release`); + // rhel 9 does not provide openssl 1.1 anymore, making it incompatible with previous versions + // lowest rhel9 arm64 is 6.0.7 + if (semver.satisfies(releaseAsSemver, '>=9.0.0') && semver.lt(coercedVersion, '6.0.7')) { + throw new KnownVersionIncompatibilityError( + `Rhel ${release} arm64`, + this.version, + '>=6.0.7' + ); } + } - // rhel aarch64 support is only for rhel 8.2 (and no version after explicitly) + if (semver.satisfies(releaseAsSemver, '>=9.0.0')) { + name += '90'; + } else if (semver.satisfies(releaseAsSemver, '8.2.0') && this.arch == 'aarch64') { name += '82'; - } else if (semver.satisfies(releaseAsSemver, '>=8.0.0')) { + } else if (semver.satisfies(releaseAsSemver, '^8.0.0')) { name += '80'; } else if (semver.satisfies(releaseAsSemver, '^7.0.0')) { name += '70'; 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 040f034d2..befe39504 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 @@ -1122,11 +1122,45 @@ describe('MongoBinaryDownloadUrl', () => { ); }); - it('rhel 9 & 5.0.0 arm64', async () => { + it('rhel 9 & 6.0.4 x86_64', async () => { + // lowest rhel 9 x64 supported version is 6.0.4 + const du = new MongoBinaryDownloadUrl({ + platform: 'linux', + arch: 'x64', + version: '6.0.4', + os: { + os: 'linux', + dist: 'rhel', + release: '9', + }, + }); + expect(await du.getDownloadUrl()).toBe( + 'https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel90-6.0.4.tgz' + ); + }); + + it('rhel 9 & 7.0.0 x86_64', async () => { + const du = new MongoBinaryDownloadUrl({ + platform: 'linux', + arch: 'x64', + version: '7.0.0', + os: { + os: 'linux', + dist: 'rhel', + release: '9', + }, + }); + expect(await du.getDownloadUrl()).toBe( + 'https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel90-7.0.0.tgz' + ); + }); + + it('rhel 9 & 6.0.7 arm64', async () => { + // lowest rhel 9 arm64 supported version is 6.0.7 const du = new MongoBinaryDownloadUrl({ platform: 'linux', arch: 'arm64', - version: '5.0.0', + version: '6.0.7', os: { os: 'linux', dist: 'rhel', @@ -1134,7 +1168,23 @@ describe('MongoBinaryDownloadUrl', () => { }, }); expect(await du.getDownloadUrl()).toBe( - 'https://fastdl.mongodb.org/linux/mongodb-linux-aarch64-rhel82-5.0.0.tgz' + 'https://fastdl.mongodb.org/linux/mongodb-linux-aarch64-rhel90-6.0.7.tgz' + ); + }); + + it('rhel 9 & 7.0.0 arm64', async () => { + const du = new MongoBinaryDownloadUrl({ + platform: 'linux', + arch: 'arm64', + version: '7.0.0', + os: { + os: 'linux', + dist: 'rhel', + release: '9', + }, + }); + expect(await du.getDownloadUrl()).toBe( + 'https://fastdl.mongodb.org/linux/mongodb-linux-aarch64-rhel90-7.0.0.tgz' ); }); @@ -1146,7 +1196,7 @@ describe('MongoBinaryDownloadUrl', () => { os: { os: 'linux', dist: 'rhel', - release: '9', + release: '8', }, }); expect(await du.getDownloadUrl()).toBe( @@ -1176,6 +1226,28 @@ describe('MongoBinaryDownloadUrl', () => { } }); + it('should Error when ARM64 rhel 9 and mongodb before 6.0.7 are requested [KnownVersionIncompatibilityError]', async () => { + const du = new MongoBinaryDownloadUrl({ + platform: 'linux', + arch: 'arm64', + version: '6.0.6', + os: { + os: 'linux', + dist: 'rhel', + release: '9', + }, + }); + + try { + await du.getDownloadUrl(); + fail('Expected to throw a KnownVersionIncompatibilityError'); + } catch (err) { + assertIsError(err); + expect(err).toBeInstanceOf(KnownVersionIncompatibilityError); + expect(err.message).toMatchSnapshot(); + } + }); + it('should Error when ARM64 and version below 4.4.2 is requested [KnownVersionIncompatibilityError]', async () => { const du = new MongoBinaryDownloadUrl({ platform: 'linux', diff --git a/packages/mongodb-memory-server-core/src/util/__tests__/__snapshots__/MongoBinaryDownloadUrl.test.ts.snap b/packages/mongodb-memory-server-core/src/util/__tests__/__snapshots__/MongoBinaryDownloadUrl.test.ts.snap index 06f2701ee..5eca57a25 100644 --- a/packages/mongodb-memory-server-core/src/util/__tests__/__snapshots__/MongoBinaryDownloadUrl.test.ts.snap +++ b/packages/mongodb-memory-server-core/src/util/__tests__/__snapshots__/MongoBinaryDownloadUrl.test.ts.snap @@ -18,15 +18,17 @@ Mongodb does not provide binaries for versions before 4.2.1 for Debian 10+ and a exports[`MongoBinaryDownloadUrl getDownloadUrl() for linux for debian should throw a Error when the provided version could not be coerced [UnknownVersionError] 1`] = `"Could not coerce VERSION to a semver version (version: \\"vvv\\")"`; exports[`MongoBinaryDownloadUrl getDownloadUrl() for linux for rhel should Error when ARM64 and rhel below 8 [KnownVersionIncompatibilityError] 1`] = ` -"Requested Version \\"4.4.2\\" is not available for \\"Rhel 7\\"! Available Versions: \\">=4.4.2\\" +"Requested Version \\"4.4.2\\" is not available for \\"Rhel 7 arm64\\"! Available Versions: \\">=4.4.2\\" ARM64(aarch64) support for rhel is only for rhel82 or higher" `; exports[`MongoBinaryDownloadUrl getDownloadUrl() for linux for rhel should Error when ARM64 and version below 4.4.2 is requested [KnownVersionIncompatibilityError] 1`] = ` -"Requested Version \\"4.4.0\\" is not available for \\"Rhel 8\\"! Available Versions: \\">=4.4.2\\" +"Requested Version \\"4.4.0\\" is not available for \\"Rhel 8 arm64\\"! Available Versions: \\">=4.4.2\\" ARM64(aarch64) support for rhel is only for rhel82 or higher" `; +exports[`MongoBinaryDownloadUrl getDownloadUrl() for linux for rhel should Error when ARM64 rhel 9 and mongodb before 6.0.7 are requested [KnownVersionIncompatibilityError] 1`] = `"Requested Version \\"6.0.6\\" is not available for \\"Rhel 9 arm64\\"! Available Versions: \\">=6.0.7\\""`; + exports[`MongoBinaryDownloadUrl getDownloadUrl() for linux for rhel should throw a Error when the provided version could not be coerced [UnknownVersionError] 1`] = `"Could not coerce VERSION to a semver version (version: \\"vvv\\")"`; exports[`MongoBinaryDownloadUrl getDownloadUrl() for linux for ubuntu should throw a Error when the provided version could not be coerced [UnknownVersionError] 1`] = `"Could not coerce VERSION to a semver version (version: \\"vvv\\")"`;