From 20dab94e2427771f0d84d58237ba7af083b11d19 Mon Sep 17 00:00:00 2001 From: Tim Seckinger Date: Mon, 3 Apr 2023 10:57:08 +0200 Subject: [PATCH 1/4] fix(MongoBinaryDownloadUrl): update mapping for arch to "ubuntu2204" --- .../src/util/MongoBinaryDownloadUrl.ts | 4 ++-- .../__tests__/MongoBinaryDownloadUrl.test.ts | 22 +++++++++++++++++-- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/packages/mongodb-memory-server-core/src/util/MongoBinaryDownloadUrl.ts b/packages/mongodb-memory-server-core/src/util/MongoBinaryDownloadUrl.ts index bf6c8325f..3394cd1d2 100644 --- a/packages/mongodb-memory-server-core/src/util/MongoBinaryDownloadUrl.ts +++ b/packages/mongodb-memory-server-core/src/util/MongoBinaryDownloadUrl.ts @@ -203,13 +203,13 @@ export class MongoBinaryDownloadUrl implements MongoBinaryDownloadUrlOpts { // Match "arch", "archlinux", "manjaro", "manjarolinux", "arco", "arcolinux" } else if (regexHelper(/(arch|manjaro|arco)(?:linux)?$/i, os)) { console.warn( - `There is no official build of MongoDB for ArchLinux (${os.dist}). Falling back to Ubuntu 20.04 release.` + `There is no official build of MongoDB for ArchLinux (${os.dist}). Falling back to Ubuntu 22.04 release.` ); return this.getUbuntuVersionString({ os: 'linux', dist: 'Ubuntu Linux', - release: '20.04', + release: '22.04', }); } else if (regexHelper(/gentoo/i, os)) { // it seems like debian binaries work for gentoo too (at least most), see https://github.com/nodkz/mongodb-memory-server/issues/639 diff --git a/packages/mongodb-memory-server-core/src/util/__tests__/MongoBinaryDownloadUrl.test.ts b/packages/mongodb-memory-server-core/src/util/__tests__/MongoBinaryDownloadUrl.test.ts index bbf651028..46641e01e 100644 --- a/packages/mongodb-memory-server-core/src/util/__tests__/MongoBinaryDownloadUrl.test.ts +++ b/packages/mongodb-memory-server-core/src/util/__tests__/MongoBinaryDownloadUrl.test.ts @@ -1684,7 +1684,7 @@ describe('MongoBinaryDownloadUrl', () => { }); describe('getLinuxOSVersionString()', () => { - it('should give an warning about "alpine"', () => { + it('should give a warning about "alpine"', () => { jest.spyOn(console, 'warn').mockImplementation(() => void 0); const du = new MongoBinaryDownloadUrl({ platform: 'linux', @@ -1704,7 +1704,7 @@ describe('MongoBinaryDownloadUrl', () => { expect(ret).toBe(''); }); - it('should give an warning about "unknown"', () => { + it('should give a warning about "unknown"', () => { jest.spyOn(console, 'warn').mockImplementation(() => void 0); const du = new MongoBinaryDownloadUrl({ platform: 'linux', @@ -1723,6 +1723,24 @@ describe('MongoBinaryDownloadUrl', () => { expect(du.getLegacyVersionString).toHaveBeenCalledTimes(1); expect(ret).toBe(''); }); + + it('should give a warning about "arch"', () => { + jest.spyOn(console, 'warn').mockImplementation(() => void 0); + const du = new MongoBinaryDownloadUrl({ + platform: 'linux', + arch: 'x64', + version: '3.6.3', + os: { + os: 'linux', + dist: 'archlinux', + release: '0', + codename: 'archlinux', + }, + }); + const ret = du.getLinuxOSVersionString(du.os as LinuxOS); + expect(console.warn).toHaveBeenCalledTimes(1); + expect(ret).toBe('ubuntu1604'); + }); }); describe('translateArch()', () => { From 660e5066d3d6eb4ba742346fad2cf909487d39df Mon Sep 17 00:00:00 2001 From: hasezoey Date: Mon, 3 Apr 2023 20:23:41 +0200 Subject: [PATCH 2/4] docs(supported-systems): update arch "current mapping" --- docs/guides/supported-systems.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/guides/supported-systems.md b/docs/guides/supported-systems.md index d55414949..17fae36fb 100644 --- a/docs/guides/supported-systems.md +++ b/docs/guides/supported-systems.md @@ -144,7 +144,7 @@ Default version is none Unsupported Working There are no official mongodb builds for Arch Distributions, but the `ubuntu` binaries work on most Arch systems, so they are used.
-Currently Mapping to: `ubuntu2004` +Currently Mapping to: `ubuntu2204` :::note Because Arch* dosnt base on ubuntu, there is no specific ubuntu version associated with an arch version, so it defaults to highest supported `ubuntu` version From 409d5fbf559de86270fba6c9bfa88b7f1731179e Mon Sep 17 00:00:00 2001 From: hasezoey Date: Mon, 3 Apr 2023 20:26:22 +0200 Subject: [PATCH 3/4] test(MongoBinaryDownloadUrl): move arch tests to their own block --- .../__tests__/MongoBinaryDownloadUrl.test.ts | 141 ++++++++---------- 1 file changed, 63 insertions(+), 78 deletions(-) diff --git a/packages/mongodb-memory-server-core/src/util/__tests__/MongoBinaryDownloadUrl.test.ts b/packages/mongodb-memory-server-core/src/util/__tests__/MongoBinaryDownloadUrl.test.ts index 46641e01e..8659a7905 100644 --- a/packages/mongodb-memory-server-core/src/util/__tests__/MongoBinaryDownloadUrl.test.ts +++ b/packages/mongodb-memory-server-core/src/util/__tests__/MongoBinaryDownloadUrl.test.ts @@ -637,6 +637,69 @@ describe('MongoBinaryDownloadUrl', () => { }); }); + // for arch and arch based systems (no specific extra mapping) + describe('for arch', () => { + it('for arch for 4.4.2', async () => { + jest.spyOn(console, 'warn').mockImplementation(() => void 0); + + const du = new MongoBinaryDownloadUrl({ + platform: 'linux', + arch: 'x64', + version: '4.4.2', + os: { + os: 'linux', + dist: 'Arch', + release: 'rolling', + id_like: ['arch'], + }, + }); + expect(await du.getDownloadUrl()).toBe( + 'https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-ubuntu2004-4.4.2.tgz' + ); + expect(console.warn).toHaveBeenCalledTimes(1); + }); + + it('for manjaro for 4.4.2', async () => { + jest.spyOn(console, 'warn').mockImplementation(() => void 0); + + const du = new MongoBinaryDownloadUrl({ + platform: 'linux', + arch: 'x64', + version: '4.4.2', + os: { + os: 'linux', + dist: 'ManjaroLinux', + release: '20.2', + id_like: ['arch'], + }, + }); + expect(await du.getDownloadUrl()).toBe( + 'https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-ubuntu2004-4.4.2.tgz' + ); + expect(console.warn).toHaveBeenCalledTimes(1); + }); + + it('for archstrike for 4.4.2', async () => { + jest.spyOn(console, 'warn').mockImplementation(() => void 0); + + const du = new MongoBinaryDownloadUrl({ + platform: 'linux', + arch: 'x64', + version: '4.4.2', + os: { + os: 'linux', + dist: 'ArchStrike', + release: 'rolling', + id_like: ['arch'], + }, + }); + expect(await du.getDownloadUrl()).toBe( + 'https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-ubuntu2004-4.4.2.tgz' + ); + expect(console.warn).toHaveBeenCalledTimes(1); + }); + }); + it('fallback', async () => { jest.spyOn(console, 'warn').mockImplementation(() => void 0); @@ -677,46 +740,6 @@ describe('MongoBinaryDownloadUrl', () => { expect(console.warn).toHaveBeenCalledTimes(2); }); - it('for manjaro', async () => { - jest.spyOn(console, 'warn').mockImplementation(() => void 0); - - const du = new MongoBinaryDownloadUrl({ - platform: 'linux', - arch: 'x64', - version: '4.4.2', - os: { - os: 'linux', - dist: 'ManjaroLinux', - release: '20.2', - id_like: ['arch'], - }, - }); - expect(await du.getDownloadUrl()).toBe( - 'https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-ubuntu2004-4.4.2.tgz' - ); - expect(console.warn).toHaveBeenCalledTimes(1); - }); - - it('for arch', async () => { - jest.spyOn(console, 'warn').mockImplementation(() => void 0); - - const du = new MongoBinaryDownloadUrl({ - platform: 'linux', - arch: 'x64', - version: '4.4.2', - os: { - os: 'linux', - dist: 'Arch', - release: 'rolling', - id_like: ['arch'], - }, - }); - expect(await du.getDownloadUrl()).toBe( - 'https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-ubuntu2004-4.4.2.tgz' - ); - expect(console.warn).toHaveBeenCalledTimes(1); - }); - describe('for gentoo', () => { it('for gentoo 5.0.8', async () => { jest.spyOn(console, 'warn').mockImplementation(() => void 0); @@ -757,26 +780,6 @@ describe('MongoBinaryDownloadUrl', () => { }); }); - it('for unpopular arch', async () => { - jest.spyOn(console, 'warn').mockImplementation(() => void 0); - - const du = new MongoBinaryDownloadUrl({ - platform: 'linux', - arch: 'x64', - version: '4.4.2', - os: { - os: 'linux', - dist: 'ArchStrike', - release: 'rolling', - id_like: ['arch'], - }, - }); - expect(await du.getDownloadUrl()).toBe( - 'https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-ubuntu2004-4.4.2.tgz' - ); - expect(console.warn).toHaveBeenCalledTimes(1); - }); - describe('for elementary', () => { it('should return a archive name for elementary 0.3', async () => { const du = new MongoBinaryDownloadUrl({ @@ -1723,24 +1726,6 @@ describe('MongoBinaryDownloadUrl', () => { expect(du.getLegacyVersionString).toHaveBeenCalledTimes(1); expect(ret).toBe(''); }); - - it('should give a warning about "arch"', () => { - jest.spyOn(console, 'warn').mockImplementation(() => void 0); - const du = new MongoBinaryDownloadUrl({ - platform: 'linux', - arch: 'x64', - version: '3.6.3', - os: { - os: 'linux', - dist: 'archlinux', - release: '0', - codename: 'archlinux', - }, - }); - const ret = du.getLinuxOSVersionString(du.os as LinuxOS); - expect(console.warn).toHaveBeenCalledTimes(1); - expect(ret).toBe('ubuntu1604'); - }); }); describe('translateArch()', () => { From 51cca3e2c89cd9c3ff5feb92637b438406a93fb5 Mon Sep 17 00:00:00 2001 From: hasezoey Date: Mon, 3 Apr 2023 20:29:33 +0200 Subject: [PATCH 4/4] test(MongoBinaryDownloadUrl): add more tests for arch binary selection re #762 --- .../__tests__/MongoBinaryDownloadUrl.test.ts | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/packages/mongodb-memory-server-core/src/util/__tests__/MongoBinaryDownloadUrl.test.ts b/packages/mongodb-memory-server-core/src/util/__tests__/MongoBinaryDownloadUrl.test.ts index 8659a7905..4d45fb7dd 100644 --- a/packages/mongodb-memory-server-core/src/util/__tests__/MongoBinaryDownloadUrl.test.ts +++ b/packages/mongodb-memory-server-core/src/util/__tests__/MongoBinaryDownloadUrl.test.ts @@ -659,6 +659,46 @@ describe('MongoBinaryDownloadUrl', () => { expect(console.warn).toHaveBeenCalledTimes(1); }); + it('for arch for 5.0.0', async () => { + jest.spyOn(console, 'warn').mockImplementation(() => void 0); + + const du = new MongoBinaryDownloadUrl({ + platform: 'linux', + arch: 'x64', + version: '5.0.0', + os: { + os: 'linux', + dist: 'Arch', + release: 'rolling', + id_like: ['arch'], + }, + }); + expect(await du.getDownloadUrl()).toBe( + 'https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-ubuntu2004-5.0.0.tgz' + ); + expect(console.warn).toHaveBeenCalledTimes(1); + }); + + it('for arch for 6.0.4', async () => { + jest.spyOn(console, 'warn').mockImplementation(() => void 0); + + const du = new MongoBinaryDownloadUrl({ + platform: 'linux', + arch: 'x64', + version: '6.0.4', + os: { + os: 'linux', + dist: 'Arch', + release: 'rolling', + id_like: ['arch'], + }, + }); + expect(await du.getDownloadUrl()).toBe( + 'https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-ubuntu2204-6.0.4.tgz' + ); + expect(console.warn).toHaveBeenCalledTimes(1); + }); + it('for manjaro for 4.4.2', async () => { jest.spyOn(console, 'warn').mockImplementation(() => void 0);