From 35d2e011333d963c52507295d54167cbd041e2b6 Mon Sep 17 00:00:00 2001 From: gagik Date: Wed, 14 May 2025 11:23:40 +0200 Subject: [PATCH 1/2] feat: align MacOS deployment target This keeps it consistent with glibc-version though I don't think it has caused problems before. --- packages/native-machine-id/binding.gyp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/native-machine-id/binding.gyp b/packages/native-machine-id/binding.gyp index fe47afed..408f0f92 100644 --- a/packages/native-machine-id/binding.gyp +++ b/packages/native-machine-id/binding.gyp @@ -10,7 +10,7 @@ 'xcode_settings': { 'GCC_ENABLE_CPP_EXCEPTIONS': 'YES', 'CLANG_CXX_LIBRARY': 'libc++', - 'MACOSX_DEPLOYMENT_TARGET': '12.0', + 'MACOSX_DEPLOYMENT_TARGET': '10.7', }, 'msvs_settings': { 'VCCLCompilerTool': { 'ExceptionHandling': 1 }, From c97dec590020dcba9622ad3dc83bddcc26035514 Mon Sep 17 00:00:00 2001 From: gagik Date: Tue, 23 Sep 2025 17:29:23 +0200 Subject: [PATCH 2/2] feat(mongodb-runner): add downloadDir option There are cases where the place we want to manage the place to download and store binaries ourselves. For example in mongosh this is useful in making sure each `mongodb-runner` has its own temporary directory for all other files but refers to only 1 download directory for the database binaries. --- packages/mongodb-runner/README.md | 1 + packages/mongodb-runner/src/cli.ts | 5 +++ .../mongodb-runner/src/mongocluster.spec.ts | 35 +++++++++++++++++++ packages/mongodb-runner/src/mongocluster.ts | 13 +++++-- 4 files changed, 52 insertions(+), 2 deletions(-) diff --git a/packages/mongodb-runner/README.md b/packages/mongodb-runner/README.md index 17aef942..03954e19 100644 --- a/packages/mongodb-runner/README.md +++ b/packages/mongodb-runner/README.md @@ -37,6 +37,7 @@ Options: --version MongoDB server version to use [string] --logDir Directory to store server log files in [string] --binDir Directory containing mongod/mongos binaries [string] + --downloadDir Directory to store downloaded MongoDB versions in [string] --tmpDir Directory for temporary files [string] [default: "/tmp"] --runnerDir Directory for storing cluster metadata [string] [default: "/home/addaleax/.mongodb/runner2"] diff --git a/packages/mongodb-runner/src/cli.ts b/packages/mongodb-runner/src/cli.ts index 0e7c23e2..6fdf2c6f 100644 --- a/packages/mongodb-runner/src/cli.ts +++ b/packages/mongodb-runner/src/cli.ts @@ -49,6 +49,11 @@ import * as utilities from './index'; default: os.tmpdir(), describe: 'Directory for temporary files', }) + .option('downloadDir', { + type: 'string', + describe: + 'Directory for downloading and caching MongoDB binaries (uses tmpDir if not specified)', + }) .option('runnerDir', { type: 'string', default: defaultRunnerDir, diff --git a/packages/mongodb-runner/src/mongocluster.spec.ts b/packages/mongodb-runner/src/mongocluster.spec.ts index 841eed06..54385baa 100644 --- a/packages/mongodb-runner/src/mongocluster.spec.ts +++ b/packages/mongodb-runner/src/mongocluster.spec.ts @@ -4,6 +4,7 @@ import { promises as fs } from 'fs'; import path from 'path'; import os from 'os'; import createDebug from 'debug'; +import sinon from 'sinon'; if (process.env.CI) { createDebug.enable('mongodb-runner,mongodb-downloader'); @@ -36,6 +37,40 @@ describe('MongoCluster', function () { afterEach(async function () { await cluster?.close(); + sinon.restore(); + }); + + it('can use custom downloadDir option for binary downloads', async function () { + const customDownloadDir = path.join(tmpDir, 'custom-downloads'); + await fs.mkdir(customDownloadDir, { recursive: true }); + + sinon + .stub(MongoCluster, 'downloadMongoDb' as any) + .resolves(customDownloadDir); + + try { + cluster = await MongoCluster.start({ + version: '6.x', + topology: 'standalone', + tmpDir, + downloadDir: customDownloadDir, + downloadOptions: { + platform: 'linux', + arch: 'x64', + }, + }); + } catch (err) { + // This will error because no actual binary gets downloaded + } + + expect(MongoCluster['downloadMongoDb']).to.have.been.calledWith( + customDownloadDir, + '6.x', + { + platform: 'linux', + arch: 'x64', + }, + ); }); it('can spawn a 6.x standalone mongod', async function () { diff --git a/packages/mongodb-runner/src/mongocluster.ts b/packages/mongodb-runner/src/mongocluster.ts index 406377f0..18f35b8c 100644 --- a/packages/mongodb-runner/src/mongocluster.ts +++ b/packages/mongodb-runner/src/mongocluster.ts @@ -17,6 +17,7 @@ export interface MongoClusterOptions secondaries?: number; shards?: number; version?: string; + downloadDir?: string; downloadOptions?: DownloadOptions; } @@ -30,6 +31,14 @@ export class MongoCluster { /* see .start() */ } + private static downloadMongoDb( + tmpdir: string, + targetVersionSemverSpecifier?: string | undefined, + options?: DownloadOptions | undefined, + ): Promise { + return downloadMongoDb(tmpdir, targetVersionSemverSpecifier, options); + } + serialize(): unknown /* JSON-serializable */ { return { topology: this.topology, @@ -84,8 +93,8 @@ export class MongoCluster { const cluster = new MongoCluster(); cluster.topology = options.topology; if (!options.binDir) { - options.binDir = await downloadMongoDb( - options.tmpDir, + options.binDir = await MongoCluster.downloadMongoDb( + options.downloadDir ?? options.tmpDir, options.version, options.downloadOptions, );