Skip to content

Commit

Permalink
feat(MongoBinaryDownloadUrl::translateArch): remove ia32 translation …
Browse files Browse the repository at this point in the history
…and support

closes #638

BREAKING CHANGE:
"ia32" ("i386" / "i686") are now unsupported by mongodb-memory-server
  • Loading branch information
hasezoey committed Aug 22, 2022
1 parent ebc62f0 commit a827a28
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 41 deletions.
2 changes: 1 addition & 1 deletion docs/api/config-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Valid Options are `win32`, `darwin`, `linux`, ~~`sunos`~~(never actually support

Option `ARCH` is used to overwrite the Architecture to download for

Valid Options are `x64`, `arm64`, ~~`ia32`~~([will be removed in 9.0](../guides/error-warning-details.md#mms001))
Valid Options are `x64`, `arm64`

### VERSION

Expand Down
1 change: 0 additions & 1 deletion docs/guides/supported-systems.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ Officially Supported Architectures:
<!--Platfrom taken from "MongoBinaryDownloadUrl.translateArch"-->
- `x64` / `x86_64`
- `arm64` / `aarch64` (only some linux distros have binaries)
- ~~`ia32` / `i686` / `i386`~~ (There are only binaries up to ~3.2 and [will be removed with the next MMS version](https://github.com/nodkz/mongodb-memory-server/issues/638))

:::note
On systems that have native arch translation (like ARM MacOS), the architecture will need to be overwritten with `MONGOMS_ARCH=x64`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {
UnknownArchitectureError,
UnknownPlatformError,
} from './errors';
import { deprecate } from 'util';

const log = debug('MongoMS:MongoBinaryDownloadUrl');

Expand All @@ -32,7 +31,7 @@ export class MongoBinaryDownloadUrl implements MongoBinaryDownloadUrlOpts {
constructor(opts: MongoBinaryDownloadUrlOpts) {
this.version = opts.version;
this.platform = this.translatePlatform(opts.platform);
this.arch = MongoBinaryDownloadUrl.translateArch(opts.arch, this.platform);
this.arch = MongoBinaryDownloadUrl.translateArch(opts.arch);
this.os = opts.os;
}

Expand Down Expand Up @@ -145,20 +144,16 @@ export class MongoBinaryDownloadUrl implements MongoBinaryDownloadUrlOpts {
* (from: https://www.mongodb.org/dl/linux)
*/
async getArchiveNameLinux(): Promise<string> {
let osString: string | undefined;

// the highest version for "i686" seems to be 3.3
if (this.arch !== 'i686') {
if (!this.os) {
this.os = await getOS();
}

osString = this.getLinuxOSVersionString(this.os as LinuxOS);
if (!this.os) {
this.os = await getOS();
}

const osString: string = this.getLinuxOSVersionString(this.os as LinuxOS);

// this is below, to allow overwriting the arch (like arm64 to aarch64)
let name = `mongodb-linux-${this.arch}`;

// guard against any falsy values
if (!!osString) {
name += `-${osString}`;
}
Expand Down Expand Up @@ -515,22 +510,8 @@ export class MongoBinaryDownloadUrl implements MongoBinaryDownloadUrlOpts {
* x64 -> x86_64
* @param platform The Platform to translate
*/
static translateArch(arch: string, mongoPlatform: string): string {
static translateArch(arch: string): string {
switch (arch) {
case 'ia32':
deprecate(
() => {},
'mongodb-memory-server will fully drop support for ia32 in 9.0',
'MMS001'
)();

if (mongoPlatform === 'linux') {
return 'i686';
} else if (mongoPlatform === 'win32') {
return 'i386';
}

throw new UnknownArchitectureError(arch, mongoPlatform);
case 'x86_64':
case 'x64':
return 'x86_64';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1305,17 +1305,9 @@ describe('MongoBinaryDownloadUrl', () => {
});

describe('translateArch()', () => {
it('should translate "ia32" and linux to "i686"', () => {
expect(MongoBinaryDownloadUrl.translateArch('ia32', 'linux')).toBe('i686');
});

it('should translate "ia32" and win32 to "i386"', () => {
expect(MongoBinaryDownloadUrl.translateArch('ia32', 'win32')).toBe('i386');
});

it('should throw an error for "ia32" and unsupported platform', () => {
it('should throw error when "ia32" is used', () => {
try {
MongoBinaryDownloadUrl.translateArch('ia32', 'darwin');
MongoBinaryDownloadUrl.translateArch('ia32');
fail('Expected "translateArch" to fail');
} catch (err) {
assertIsError(err);
Expand All @@ -1326,7 +1318,7 @@ describe('MongoBinaryDownloadUrl', () => {

it('should throw an error for an unsupported architecture', () => {
try {
MongoBinaryDownloadUrl.translateArch('risc', 'linux');
MongoBinaryDownloadUrl.translateArch('risc');
fail('Expected "translateArch" to fail');
} catch (err) {
assertIsError(err);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ exports[`MongoBinaryDownloadUrl getDownloadUrl() should throw an error if platfo

exports[`MongoBinaryDownloadUrl getDownloadUrl() should throw an error if platform is unknown (translatePlatform) 1`] = `"Unknown Platform: \\"unknown\\""`;

exports[`MongoBinaryDownloadUrl translateArch() should throw an error for "ia32" and unsupported platform 1`] = `"Unsupported Architecture-Platform combination: arch: \\"ia32\\", platform: \\"darwin\\""`;

exports[`MongoBinaryDownloadUrl translateArch() should throw an error for an unsupported architecture 1`] = `"Unsupported Architecture: \\"risc\\""`;

exports[`MongoBinaryDownloadUrl translateArch() should throw error when "ia32" is used 1`] = `"Unsupported Architecture: \\"ia32\\""`;

0 comments on commit a827a28

Please sign in to comment.