Skip to content

Commit ddf1991

Browse files
committed
feat(MongoBinaryDownloadUrl): change to use "aarch64" by default and map to "arm64" where needed
also slightly update the ubuntu arm translation also adds more tests for arm64 versions fixes #678
1 parent 347f96e commit ddf1991

File tree

2 files changed

+39
-15
lines changed

2 files changed

+39
-15
lines changed

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

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,8 @@ export class MongoBinaryDownloadUrl implements MongoBinaryDownloadUrlOpts {
130130
name = `mongodb-macos`; // somehow these files are not listed in https://www.mongodb.org/dl/osx
131131
}
132132

133-
if (this.arch === 'arm64') {
134-
log('getArchiveNameOsx: Arch is "arm64", using x64 binary');
133+
if (this.arch === 'aarch64') {
134+
log('getArchiveNameOsx: Arch is "aarch64", using x64 binary');
135135
this.arch = 'x86_64';
136136
}
137137

@@ -422,24 +422,16 @@ export class MongoBinaryDownloadUrl implements MongoBinaryDownloadUrlOpts {
422422

423423
const ubuntuYear: number = parseInt(ubuntuOS.release.split('.')[0], 10);
424424

425-
// this is, because currently mongodb only really provides arm64 binaries for "ubuntu1604"
426-
if (this.arch === 'arm64') {
425+
if (this.arch === 'aarch64') {
427426
// this is because, before version 4.1.10, everything for "arm64" / "aarch64" were just "arm64" and for "ubuntu1604"
428427
if (semver.satisfies(this.version, '<4.1.10')) {
429428
this.arch = 'arm64';
430429

431430
return 'ubuntu1604';
432431
}
433-
if (semver.satisfies(this.version, '>=4.1.10')) {
434-
// this is because mongodb changed since 4.1.0 to use "aarch64" instead of "arm64"
435-
this.arch = 'aarch64';
436-
437-
// this is because since versions below "4.4.0" did not provide an binary for something like "20.04"
438-
if (semver.satisfies(this.version, '<4.4.0')) {
439-
return 'ubuntu1804';
440-
}
441-
442-
return `ubuntu${ubuntuYear || 18}04`;
432+
// this is because versions below "4.4.0" did not provide an binary for anything above 1804
433+
if (semver.satisfies(this.version, '>=4.1.10 <4.4.0')) {
434+
return 'ubuntu1804';
443435
}
444436
}
445437

@@ -538,7 +530,7 @@ export class MongoBinaryDownloadUrl implements MongoBinaryDownloadUrlOpts {
538530
case 'x64':
539531
return 'x86_64';
540532
case 'arm64':
541-
return 'arm64';
533+
return 'aarch64';
542534
case 'aarch64':
543535
return 'aarch64';
544536
default:

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

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,38 @@ describe('MongoBinaryDownloadUrl', () => {
153153
'https://fastdl.mongodb.org/linux/mongodb-linux-aarch64-ubuntu2004-4.4.6.tgz'
154154
);
155155
});
156+
157+
it('for ubuntu arm64 5.0.0 & ubuntu2004 (above 4.4.0)', async () => {
158+
const du = new MongoBinaryDownloadUrl({
159+
platform: 'linux',
160+
arch: 'arm64',
161+
version: '5.0.0',
162+
os: {
163+
os: 'linux',
164+
dist: 'Ubuntu Linux',
165+
release: '20.04',
166+
},
167+
});
168+
expect(await du.getDownloadUrl()).toBe(
169+
'https://fastdl.mongodb.org/linux/mongodb-linux-aarch64-ubuntu2004-5.0.0.tgz'
170+
);
171+
});
172+
173+
it('for ubuntu arm64 5.0.0 & ubuntu2204 (above 4.4.0)', async () => {
174+
const du = new MongoBinaryDownloadUrl({
175+
platform: 'linux',
176+
arch: 'arm64',
177+
version: '5.0.0',
178+
os: {
179+
os: 'linux',
180+
dist: 'Ubuntu Linux',
181+
release: '22.04',
182+
},
183+
});
184+
expect(await du.getDownloadUrl()).toBe(
185+
'https://fastdl.mongodb.org/linux/mongodb-linux-aarch64-ubuntu2004-5.0.0.tgz'
186+
);
187+
});
156188
});
157189
});
158190

0 commit comments

Comments
 (0)