Skip to content

Commit 5733a0f

Browse files
committed
feat(MongoBinaryDownloadUrl): add support for ubuntu-arm64
fixes #443
1 parent e0216a0 commit 5733a0f

File tree

3 files changed

+44
-13
lines changed

3 files changed

+44
-13
lines changed

docs/guides/supported-systems.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Should just work out of the box
2525
## MacOS
2626

2727
On x64 systems, it should work right out of the box<br/>
28-
On Arm64 systems, the architecture needs to be overwritten with `MONGOMS_ARCH=x64`
28+
On Arm64 systems, the architecture needs to be overwritten with `MONGOMS_ARCH=x64`, only exception being (and based on) `ubuntu`
2929

3030
## Linux
3131

@@ -39,6 +39,9 @@ Highest version (default to) is `2004`
3939
:::note
4040
Lower Versions than `2004` may be used if mongodb dosnt provide binaries for an lower version of mongodb for an higher version of ubuntu
4141
:::
42+
:::note
43+
For Arm64 MongoDB only provides binaries for `ubuntu1604`
44+
:::
4245

4346
### Debian
4447

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

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,13 @@ export class MongoBinaryDownloadUrl {
279279
dist: 'ubuntu',
280280
};
281281

282+
// this is, because currently mongodb only really provides arm64 binaries for "ubuntu1604"
283+
if (this.arch === 'arm64') {
284+
log('getUbuntuVersionString: architecture "arm64" detected, using ubuntu1604');
285+
286+
return 'ubuntu1604';
287+
}
288+
282289
// "id_like" processing (version conversion) [this is an block to be collapsible]
283290
{
284291
if (/^linux\s?mint\s*$/i.test(os.dist)) {
@@ -374,18 +381,23 @@ export class MongoBinaryDownloadUrl {
374381
* @param platform The Platform to translate
375382
*/
376383
translateArch(arch: string, mongoPlatform: string): string {
377-
if (arch === 'ia32') {
378-
if (mongoPlatform === 'linux') {
379-
return 'i686';
380-
} else if (mongoPlatform === 'win32') {
381-
return 'i386';
382-
}
384+
switch (arch) {
385+
case 'ia32':
386+
if (mongoPlatform === 'linux') {
387+
return 'i686';
388+
} else if (mongoPlatform === 'win32') {
389+
return 'i386';
390+
}
383391

384-
throw new Error('unsupported architecture');
385-
} else if (arch === 'x64') {
386-
return 'x86_64';
387-
} else {
388-
throw new Error('unsupported architecture, ia32 and x64 are the only valid options');
392+
throw new Error(
393+
`Unsupported Architecture-Platform combination: arch: "${arch}", platform: "${mongoPlatform}"`
394+
);
395+
case 'x64':
396+
return 'x86_64';
397+
case 'arm64':
398+
return 'arm64';
399+
default:
400+
throw new Error(`Unsupported Architecture: arch: "${arch}"`);
389401
}
390402
}
391403
}

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

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ describe('MongoBinaryDownloadUrl', () => {
5555
});
5656

5757
describe('for linux', () => {
58-
it('for ubuntu', async () => {
58+
it('for ubuntu x64', async () => {
5959
const du = new MongoBinaryDownloadUrl({
6060
platform: 'linux',
6161
arch: 'x64',
@@ -71,6 +71,22 @@ describe('MongoBinaryDownloadUrl', () => {
7171
);
7272
});
7373

74+
it('for ubuntu arm64', async () => {
75+
const du = new MongoBinaryDownloadUrl({
76+
platform: 'linux',
77+
arch: 'arm64',
78+
version: '4.0.20',
79+
os: {
80+
os: 'linux',
81+
dist: 'Ubuntu Linux',
82+
release: '20.04',
83+
},
84+
});
85+
expect(await du.getDownloadUrl()).toBe(
86+
'https://fastdl.mongodb.org/linux/mongodb-linux-arm64-ubuntu1604-4.0.20.tgz'
87+
);
88+
});
89+
7490
it('for debian', async () => {
7591
const du = new MongoBinaryDownloadUrl({
7692
platform: 'linux',

0 commit comments

Comments
 (0)