Skip to content

Commit

Permalink
feat(MongoBinaryDownloadUrl): re-work rhel to support 9.0
Browse files Browse the repository at this point in the history
re #821
  • Loading branch information
hasezoey committed Oct 26, 2023
1 parent fd85337 commit c582829
Show file tree
Hide file tree
Showing 4 changed files with 104 additions and 15 deletions.
6 changes: 3 additions & 3 deletions docs/guides/supported-systems.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,16 +90,16 @@ There are currently no newer mongodb builds that support the newer provided open

### Rhel

<span class="badge badge--warning">Untested</span> <span class="badge badge--warning">Outdated</span>
<span class="badge badge--warning">Untested</span>

(uses mongodb's `rhel` release)<br/>
Lowest supported Distribution version is `5`<br/>
Highest version is `8`<br/>
Highest version is `9`<br/>
Default version is `70`<br/>
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1122,19 +1122,69 @@ 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',
release: '9',
},
});
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'
);
});

Expand All @@ -1146,7 +1196,7 @@ describe('MongoBinaryDownloadUrl', () => {
os: {
os: 'linux',
dist: 'rhel',
release: '9',
release: '8',
},
});
expect(await du.getDownloadUrl()).toBe(
Expand Down Expand Up @@ -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',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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\\")"`;
Expand Down

0 comments on commit c582829

Please sign in to comment.