Skip to content

Commit 8b5434c

Browse files
committed
feat(MongoBinaryDownloadUrl): support more arm64 (aarch64) versions
fixes #482
1 parent 782049a commit 8b5434c

File tree

2 files changed

+104
-35
lines changed

2 files changed

+104
-35
lines changed

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

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,6 @@ export class MongoBinaryDownloadUrl implements MongoBinaryDownloadUrlOpts {
134134
* (from: https://www.mongodb.org/dl/linux)
135135
*/
136136
async getArchiveNameLinux(): Promise<string> {
137-
let name = `mongodb-linux-${this.arch}`;
138137
let osString: string | undefined;
139138

140139
// the highest version for "i686" seems to be 3.3
@@ -145,6 +144,10 @@ export class MongoBinaryDownloadUrl implements MongoBinaryDownloadUrlOpts {
145144

146145
osString = this.getLinuxOSVersionString(this.os as LinuxOS);
147146
}
147+
148+
// this is below, to allow overwriting the arch (like arm64 to aarch64)
149+
let name = `mongodb-linux-${this.arch}`;
150+
148151
if (!!osString) {
149152
name += `-${osString}`;
150153
}
@@ -301,13 +304,6 @@ export class MongoBinaryDownloadUrl implements MongoBinaryDownloadUrlOpts {
301304
dist: 'ubuntu',
302305
};
303306

304-
// this is, because currently mongodb only really provides arm64 binaries for "ubuntu1604"
305-
if (this.arch === 'arm64') {
306-
log('getUbuntuVersionString: architecture "arm64" detected, using ubuntu1604');
307-
308-
return 'ubuntu1604';
309-
}
310-
311307
// "id_like" processing (version conversion) [this is an block to be collapsible]
312308
{
313309
if (/^linux\s?mint\s*$/i.test(os.dist)) {
@@ -340,6 +336,27 @@ export class MongoBinaryDownloadUrl implements MongoBinaryDownloadUrlOpts {
340336

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

339+
// this is, because currently mongodb only really provides arm64 binaries for "ubuntu1604"
340+
if (this.arch === 'arm64') {
341+
// this is because, before version 4.1.10, everything for "arm64" / "aarch64" were just "arm64" and for "ubuntu1604"
342+
if (semver.satisfies(this.version, '<4.1.10')) {
343+
this.arch = 'arm64';
344+
345+
return 'ubuntu1604';
346+
}
347+
if (semver.satisfies(this.version, '>=4.1.10')) {
348+
// this is because mongodb changed since 4.1.0 to use "aarch64" instead of "arm64"
349+
this.arch = 'aarch64';
350+
351+
// this is because since versions below "4.4.0" did not provide an binary for something like "20.04"
352+
if (semver.satisfies(this.version, '<4.4.0')) {
353+
return 'ubuntu1804';
354+
}
355+
356+
return `ubuntu${ubuntuYear || 18}04`;
357+
}
358+
}
359+
343360
if (ubuntuOS.release === '14.10') {
344361
return 'ubuntu1410-clang';
345362
}

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

Lines changed: 79 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -67,36 +67,88 @@ describe('MongoBinaryDownloadUrl', () => {
6767
});
6868

6969
describe('for linux', () => {
70-
it('for ubuntu x64', async () => {
71-
const du = new MongoBinaryDownloadUrl({
72-
platform: 'linux',
73-
arch: 'x64',
74-
version: '3.6.3',
75-
os: {
76-
os: 'linux',
77-
dist: 'Ubuntu Linux',
78-
release: '14.04',
79-
},
70+
describe('for ubuntu', () => {
71+
it('for ubuntu x64', async () => {
72+
const du = new MongoBinaryDownloadUrl({
73+
platform: 'linux',
74+
arch: 'x64',
75+
version: '3.6.3',
76+
os: {
77+
os: 'linux',
78+
dist: 'Ubuntu Linux',
79+
release: '14.04',
80+
},
81+
});
82+
expect(await du.getDownloadUrl()).toBe(
83+
'https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-ubuntu1404-3.6.3.tgz'
84+
);
8085
});
81-
expect(await du.getDownloadUrl()).toBe(
82-
'https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-ubuntu1404-3.6.3.tgz'
83-
);
84-
});
8586

86-
it('for ubuntu arm64', async () => {
87-
const du = new MongoBinaryDownloadUrl({
88-
platform: 'linux',
89-
arch: 'arm64',
90-
version: '4.0.20',
91-
os: {
92-
os: 'linux',
93-
dist: 'Ubuntu Linux',
94-
release: '20.04',
95-
},
87+
describe('arm64', () => {
88+
it('for ubuntu arm64 4.0.20 (below 4.1.10)', async () => {
89+
const du = new MongoBinaryDownloadUrl({
90+
platform: 'linux',
91+
arch: 'arm64',
92+
version: '4.0.20',
93+
os: {
94+
os: 'linux',
95+
dist: 'Ubuntu Linux',
96+
release: '20.04',
97+
},
98+
});
99+
expect(await du.getDownloadUrl()).toBe(
100+
'https://fastdl.mongodb.org/linux/mongodb-linux-arm64-ubuntu1604-4.0.20.tgz'
101+
);
102+
});
103+
104+
it('for ubuntu arm64 4.2.14 (above 4.1.10, below 4.4.0)', async () => {
105+
const du = new MongoBinaryDownloadUrl({
106+
platform: 'linux',
107+
arch: 'arm64',
108+
version: '4.2.14',
109+
os: {
110+
os: 'linux',
111+
dist: 'Ubuntu Linux',
112+
release: '20.04',
113+
},
114+
});
115+
expect(await du.getDownloadUrl()).toBe(
116+
'https://fastdl.mongodb.org/linux/mongodb-linux-aarch64-ubuntu1804-4.2.14.tgz'
117+
);
118+
});
119+
120+
it('for ubuntu arm64 4.4.6 & ubuntu1804 (above 4.1.10, above 4.4.0)', async () => {
121+
const du = new MongoBinaryDownloadUrl({
122+
platform: 'linux',
123+
arch: 'arm64',
124+
version: '4.4.6',
125+
os: {
126+
os: 'linux',
127+
dist: 'Ubuntu Linux',
128+
release: '18.04',
129+
},
130+
});
131+
expect(await du.getDownloadUrl()).toBe(
132+
'https://fastdl.mongodb.org/linux/mongodb-linux-aarch64-ubuntu1804-4.4.6.tgz'
133+
);
134+
});
135+
136+
it('for ubuntu arm64 4.4.6 & ubuntu2004 (above 4.1.10, above 4.4.0)', async () => {
137+
const du = new MongoBinaryDownloadUrl({
138+
platform: 'linux',
139+
arch: 'arm64',
140+
version: '4.4.6',
141+
os: {
142+
os: 'linux',
143+
dist: 'Ubuntu Linux',
144+
release: '20.04',
145+
},
146+
});
147+
expect(await du.getDownloadUrl()).toBe(
148+
'https://fastdl.mongodb.org/linux/mongodb-linux-aarch64-ubuntu2004-4.4.6.tgz'
149+
);
150+
});
96151
});
97-
expect(await du.getDownloadUrl()).toBe(
98-
'https://fastdl.mongodb.org/linux/mongodb-linux-arm64-ubuntu1604-4.0.20.tgz'
99-
);
100152
});
101153

102154
describe('for debian', () => {

0 commit comments

Comments
 (0)