Skip to content

Commit 9a29af9

Browse files
committed
fix(MongoBinaryDownloadUrl): clamp ubuntu-year to highest supported year
fixes #846
1 parent 9042eb2 commit 9a29af9

File tree

3 files changed

+40
-5
lines changed

3 files changed

+40
-5
lines changed

docs/guides/supported-systems.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,15 @@ Depends on the distribution, many common ones should just work right out of the
5353

5454
(uses mongodb's `ubuntu` release)<br/>
5555
Lowest supported Distribution version is `1404`<br/>
56-
Highest version is `2204`<br/>
56+
Highest version is `2204` (higher versions will be clamped to this value)<br/>
5757
Default version is `2204`<br/>
5858
Architectures Supported: `x86_64`, `arm64`(`aarch64`)
5959

6060
:::note
6161
Lower Versions than `2004` may be used if mongodb dosnt provide binaries for an lower version of mongodb for an higher version of ubuntu
6262
:::
6363
:::note
64-
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.
64+
Since Mongodb `6.0.4` there are binaries for `2204`, any version before is mapped to `2004` (or earlier) and will require `libssl1.1` to be installed.
6565
See [this mongodb issue](https://jira.mongodb.org/browse/SERVER-62300).
6666
:::
6767

@@ -71,7 +71,7 @@ See [this mongodb issue](https://jira.mongodb.org/browse/SERVER-62300).
7171

7272
(uses mongodb's `debian` release)<br/>
7373
Lowest supported Distribution version is `71`<br/>
74-
Highest version is `11`<br/>
74+
Highest version is `11` (higher versions will be clamped to this value)<br/>
7575
Default version is `10` (when in `unstable` or `testing`, otherwise none)
7676

7777
### Fedora
@@ -80,7 +80,7 @@ Default version is `10` (when in `unstable` or `testing`, otherwise none)
8080

8181
(uses mongodb's `rhel` release)<br/>
8282
Lowest supported Distribution version is `6`<br/>
83-
Highest version is `36` (see note)<br/>
83+
Highest version is `36` (see note) (higher versions will be clamped to this value)<br/>
8484
Default version is `34` (when above or equal to `34`, otherwise none)
8585

8686
:::note
@@ -94,7 +94,7 @@ There are currently no newer mongodb builds that support the newer provided open
9494

9595
(uses mongodb's `rhel` release)<br/>
9696
Lowest supported Distribution version is `5`<br/>
97-
Highest version is `9`<br/>
97+
Highest version is `9` (higher versions will be clamped to this value)<br/>
9898
Default version is `70`<br/>
9999
Architectures Supported: `x86_64`, `arm64`(`aarch64`)
100100

packages/mongodb-memory-server-core/src/util/MongoBinaryDownloadUrl.ts

+18
Original file line numberDiff line numberDiff line change
@@ -566,6 +566,24 @@ export class MongoBinaryDownloadUrl implements MongoBinaryDownloadUrlOpts {
566566
return 'ubuntu2004';
567567
}
568568

569+
// base case for higher than mongodb supported ubuntu versions
570+
{
571+
// TODO: try to keep this up-to-date to the latest mongodb supported ubuntu version
572+
/**
573+
* Highest ubuntu year supported by mongodb binaries
574+
* @see https://www.mongodb.com/download-center/community/releases/archive
575+
*/
576+
const highestUbuntuYear = 22; // 22 is the highest supported as of mongodb 7.0.4
577+
578+
if (ubuntuYear > highestUbuntuYear) {
579+
log(
580+
`getUbuntuVersionString: ubuntuYear "${ubuntuYear}" is higher than the currently supported mongodb year of "${highestUbuntuYear}", using highest known`
581+
);
582+
583+
return 'ubuntu2204';
584+
}
585+
}
586+
569587
// the "04" version always exists for ubuntu, use that as default
570588
return `ubuntu${ubuntuYear}04`;
571589
}

packages/mongodb-memory-server-core/src/util/__tests__/MongoBinaryDownloadUrl.test.ts

+17
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,23 @@ describe('MongoBinaryDownloadUrl', () => {
327327
}
328328
});
329329

330+
it('should clamp to highest supported ubuntu year', async () => {
331+
// TODO: try to keep this up-to-date to the latest mongodb supported ubuntu version
332+
const du = new MongoBinaryDownloadUrl({
333+
platform: 'linux',
334+
arch: 'x64',
335+
version: '7.0.4', // highest released mongodb version
336+
os: {
337+
os: 'linux',
338+
dist: 'ubuntu',
339+
release: '23.04', // highest released ubuntu version
340+
},
341+
});
342+
expect(await du.getDownloadUrl()).toBe(
343+
'https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-ubuntu2204-7.0.4.tgz'
344+
);
345+
});
346+
330347
describe('arm64', () => {
331348
it('for ubuntu arm64 4.0.25 (below 4.1.10)', async () => {
332349
const du = new MongoBinaryDownloadUrl({

0 commit comments

Comments
 (0)