mongodb-runner 6.8.5 → 6.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -70,6 +70,16 @@ try {
70
70
  }
71
71
  ```
72
72
 
73
+ ## Environment variables
74
+
75
+ Any CLI option can also be set through a `MONGODB_RUNNER_`-prefixed environment
76
+ variable, e.g. `MONGODB_RUNNER_DOWNLOAD_DIR` for `--downloadDir`. Explicitly
77
+ passed options take precedence.
78
+
79
+ `MONGODB_RUNNER_DOWNLOAD_DIR` is additionally honored when using `MongoCluster`
80
+ programmatically, which is useful for caching server binaries in CI without
81
+ having to change each call site.
82
+
73
83
  ## Config file
74
84
 
75
85
  You can specify a config file for the CLI using `--config`:
@@ -99,6 +109,13 @@ You can specify a config file for the CLI using `--config`:
99
109
  $ npx mongodb-runner start --config <path/to/config.json>
100
110
  ```
101
111
 
112
+ ## DSC clusters
113
+
114
+ mongodb-runner can launch clusters that use DSC, backed by an SLS storage
115
+ layer, managing the storage backend's docker compose project alongside the
116
+ mongod processes. See
117
+ [docs/disaggregated-storage.md](./docs/disaggregated-storage.md).
118
+
102
119
  ## License
103
120
 
104
121
  Apache 2.0
@@ -1,10 +1,19 @@
1
1
  import mod from "./index.js";
2
2
 
3
3
  export default mod;
4
+ export const DockerComposeProject = mod.DockerComposeProject;
4
5
  export const MongoCluster = mod.MongoCluster;
5
6
  export const MongoServer = mod.MongoServer;
7
+ export const SLS_CELL1 = mod.SLS_CELL1;
8
+ export const SLS_CELL2 = mod.SLS_CELL2;
9
+ export const SLS_CELL3 = mod.SLS_CELL3;
10
+ export const SLS_HOSTNAME = mod.SLS_HOSTNAME;
11
+ export const createSLSDisaggregatedStorageConfig = mod.createSLSDisaggregatedStorageConfig;
12
+ export const createSLSDisaggregatedStorageOptions = mod.createSLSDisaggregatedStorageOptions;
13
+ export const createSLSMultiCellEnvironment = mod.createSLSMultiCellEnvironment;
6
14
  export const exec = mod.exec;
7
15
  export const instances = mod.instances;
16
+ export const parseSLSComposeServices = mod.parseSLSComposeServices;
8
17
  export const prune = mod.prune;
9
18
  export const start = mod.start;
10
19
  export const stop = mod.stop;
package/dist/cli.js CHANGED
@@ -73,6 +73,10 @@ const mongodb_connection_string_url_1 = require("mongodb-connection-string-url")
73
73
  .option('version', {
74
74
  type: 'string',
75
75
  describe: 'MongoDB server version to use',
76
+ })
77
+ .option('downloadUrl', {
78
+ type: 'string',
79
+ describe: 'Direct URL to a MongoDB tarball to download (takes precedence over --version)',
76
80
  })
77
81
  .option('logDir', {
78
82
  type: 'string',
@@ -111,6 +115,15 @@ const mongodb_connection_string_url_1 = require("mongodb-connection-string-url")
111
115
  .option('oidc', {
112
116
  type: 'string',
113
117
  describe: 'Configure OIDC authentication on the server',
118
+ })
119
+ .option('slsCompose', {
120
+ type: 'string',
121
+ describe: 'Path to an SLS multi-cell docker-compose.yml; launches the SLS DSC project and configures mongod to use it (requires a DSC-capable mongod via --binDir or --downloadUrl)',
122
+ implies: 'slsImageTag',
123
+ })
124
+ .option('slsImageTag', {
125
+ type: 'string',
126
+ describe: 'SLS docker image tag to use with --slsCompose (e.g. the pinned_sls_commit from the server repo manifest)',
114
127
  })
115
128
  .option('debug', { type: 'boolean', describe: 'Enable debug output' })
116
129
  .option('verbose', { type: 'boolean', describe: 'Enable verbose output' })
@@ -126,10 +139,10 @@ const mongodb_connection_string_url_1 = require("mongodb-connection-string-url")
126
139
  args.push(...argv.args.map(String));
127
140
  }
128
141
  if (argv.debug || argv.verbose) {
129
- debug_1.default.enable('mongodb-runner');
142
+ debug_1.default.enable('mongodb-runner,mongodb-downloader');
130
143
  }
131
144
  if (argv.verbose) {
132
- debug_1.default.enable('mongodb-runner:*');
145
+ debug_1.default.enable('mongodb-runner*,mongodb-downloader*');
133
146
  }
134
147
  if (argv.oidc && process.platform !== 'linux') {
135
148
  console.warn('OIDC authentication is currently only supported on Linux platforms.');
@@ -138,7 +151,19 @@ const mongodb_connection_string_url_1 = require("mongodb-connection-string-url")
138
151
  console.warn('OIDC authentication is currently only supported on Enterprise server versions.');
139
152
  }
140
153
  async function start() {
141
- const { cluster, id } = await utilities.start(argv, args);
154
+ const disaggregatedStorage = argv.slsCompose
155
+ ? await utilities.createSLSDisaggregatedStorageOptions({
156
+ composeFile: argv.slsCompose,
157
+ imageTag: argv.slsImageTag,
158
+ })
159
+ : undefined;
160
+ if (disaggregatedStorage && 'sls' in disaggregatedStorage) {
161
+ console.error('Allocated SLS service ports:');
162
+ for (const [serviceName, { addr }] of Object.entries(disaggregatedStorage.sls.services)) {
163
+ console.error(` ${serviceName}: ${addr}`);
164
+ }
165
+ }
166
+ const { cluster, id } = await utilities.start({ ...argv, disaggregatedStorage }, args);
142
167
  const cs = new mongodb_connection_string_url_1.ConnectionString(cluster.connectionString);
143
168
  console.error(`Server started and running at ${cs.toString()}`);
144
169
  if (cluster.oidcIssuer) {
package/dist/cli.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,kDAA0B;AAC1B,2CAAwC;AACxC,4CAAoB;AACpB,gDAAwB;AACxB,kDAAgC;AAChC,mDAAqC;AACrC,iFAAiE;AAGjE,CAAC,KAAK;IACJ,MAAM,gBAAgB,GAAG,cAAI,CAAC,IAAI,CAAC,YAAE,CAAC,OAAO,EAAE,EAAE,UAAU,EAAE,SAAS,CAAC,CAAC;IACxE,MAAM,IAAI,GAAG,MAAM,IAAA,eAAK,EAAC,IAAA,iBAAO,EAAC,OAAO,CAAC,IAAI,CAAC,CAAC;SAC5C,OAAO,CAAC,KAAK,CAAC;SACd,UAAU,CAAC,gBAAgB,CAAC;SAC5B,GAAG,CAAC,gBAAgB,CAAC;SACrB,MAAM,EAAE;SACR,MAAM,CAAC,UAAU,EAAE;QAClB,KAAK,EAAE,GAAG;QACV,OAAO,EAAE,CAAC,YAAY,EAA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 +1,15 @@
1
+ export interface DockerComposeProjectOptions {
2
+ env?: Record<string, string>;
3
+ projectName?: string;
4
+ }
5
+ export declare class DockerComposeProject {
6
+ private readonly composeFile;
7
+ private readonly projectName;
8
+ private readonly env?;
9
+ private constructor();
10
+ static start(composeFile: string, options?: DockerComposeProjectOptions): Promise<DockerComposeProject>;
11
+ close(): Promise<void>;
12
+ serialize(): unknown;
13
+ static deserialize(serialized: any): DockerComposeProject;
14
+ }
15
+ //# sourceMappingURL=docker-compose.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"docker-compose.d.ts","sourceRoot":"","sources":["../src/docker-compose.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,2BAA2B;IAK1C,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAM7B,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAqCD,qBAAa,oBAAoB;IAE7B,OAAO,CAAC,QAAQ,CAAC,WAAW;IAC5B,OAAO,CAAC,QAAQ,CAAC,WAAW;IAC5B,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC;IAHvB,OAAO;WAMM,KAAK,CAChB,WAAW,EAAE,MAAM,EACnB,OAAO,GAAE,2BAAgC,GACxC,OAAO,CAAC,oBAAoB,CAAC;IAqB1B,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAiB5B,SAAS,IAAI,OAAO;IAQpB,MAAM,CAAC,WAAW,CAAC,UAAU,EAAE,GAAG,GAAG,oBAAoB;CAO1D"}
@@ -0,0 +1,75 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DockerComposeProject = void 0;
4
+ const child_process_1 = require("child_process");
5
+ const events_1 = require("events");
6
+ const util_1 = require("./util");
7
+ async function runDockerCompose(composeFile, projectName, env, args) {
8
+ const proc = (0, child_process_1.spawn)('docker', ['compose', '-f', composeFile, '-p', projectName, ...args], {
9
+ stdio: ['inherit', 'pipe', 'pipe'],
10
+ env: { ...process.env, ...env },
11
+ });
12
+ await (0, events_1.once)(proc, 'spawn');
13
+ (0, util_1.debug)('docker compose: spawned', { pid: proc.pid, args });
14
+ let stderr = '';
15
+ proc.stderr.setEncoding('utf8');
16
+ proc.stderr.on('data', (chunk) => {
17
+ stderr += chunk;
18
+ for (const line of chunk.split('\n')) {
19
+ if (line.trim())
20
+ (0, util_1.debug)('docker compose stderr:', line);
21
+ }
22
+ });
23
+ proc.stdout.setEncoding('utf8');
24
+ proc.stdout.on('data', (chunk) => {
25
+ for (const line of chunk.split('\n')) {
26
+ if (line.trim())
27
+ (0, util_1.debug)('docker compose stdout:', line);
28
+ }
29
+ });
30
+ const [code] = await (0, events_1.once)(proc, 'exit');
31
+ (0, util_1.debug)('docker compose: exited', { code });
32
+ return { code: code, stderr };
33
+ }
34
+ class DockerComposeProject {
35
+ constructor(composeFile, projectName, env) {
36
+ this.composeFile = composeFile;
37
+ this.projectName = projectName;
38
+ this.env = env;
39
+ }
40
+ static async start(composeFile, options = {}) {
41
+ const projectName = options.projectName ??
42
+ options.env?.COMPOSE_PROJECT_NAME ??
43
+ `mongodb-runner-${(0, util_1.uuid)()}`;
44
+ (0, util_1.debug)('starting docker compose project', { composeFile, projectName });
45
+ const { code, stderr } = await runDockerCompose(composeFile, projectName, options.env, ['up', '-d']);
46
+ if (code !== 0) {
47
+ throw new Error(`docker compose up failed with exit code ${String(code)}: ${stderr}`);
48
+ }
49
+ (0, util_1.debug)('docker compose project started');
50
+ return new DockerComposeProject(composeFile, projectName, options.env);
51
+ }
52
+ async close() {
53
+ (0, util_1.debug)('stopping docker compose project', {
54
+ composeFile: this.composeFile,
55
+ projectName: this.projectName,
56
+ });
57
+ const { code, stderr } = await runDockerCompose(this.composeFile, this.projectName, this.env, ['down', '--volumes']);
58
+ if (code !== 0) {
59
+ (0, util_1.debug)('docker compose down failed', { code: String(code), stderr });
60
+ }
61
+ (0, util_1.debug)('docker compose project stopped');
62
+ }
63
+ serialize() {
64
+ return {
65
+ composeFile: this.composeFile,
66
+ projectName: this.projectName,
67
+ env: this.env,
68
+ };
69
+ }
70
+ static deserialize(serialized) {
71
+ return new DockerComposeProject(serialized.composeFile, serialized.projectName, serialized.env);
72
+ }
73
+ }
74
+ exports.DockerComposeProject = DockerComposeProject;
75
+ //# sourceMappingURL=docker-compose.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"docker-compose.js","sourceRoot":"","sources":["../src/docker-compose.ts"],"names":[],"mappings":";;;AAAA,iDAAsC;AACtC,mCAA8B;AAC9B,iCAAqC;AAgBrC,KAAK,UAAU,gBAAgB,CAC7B,WAAmB,EACnB,WAAmB,EACnB,GAAuC,EACvC,IAAc;IAEd,MAAM,IAAI,GAAG,IAAA,qBAAK,EAChB,QAAQ,EACR,CAAC,SAAS,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,WAAW,EAAE,GAAG,IAAI,CAAC,EAC1D;QACE,KAAK,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,CAAC;QAClC,GAAG,EAAE,EAAE,GAAG,OAAO,CAAC,GAAG,EAAE,GAAG,GAAG,EAAE;KAChC,CACF,CAAC;IACF,MAAM,IAAA,aAAI,EAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAC1B,IAAA,YAAK,EAAC,yBAAyB,EAAE,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC;IAC1D,IAAI,MAAM,GAAG,EAAE,CAAC;IAChB,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;IAChC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,KAAa,EAAE,EAAE;QACvC,MAAM,IAAI,KAAK,CAAC;QAChB,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;YACrC,IAAI,IAAI,CAAC,IAAI,EAAE;gBAAE,IAAA,YAAK,EAAC,wBAAw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  export { MongoServer, type MongoServerEvents, MongoServerOptions, } from './mongoserver';
2
- export { MongoCluster, type MongoClusterEvents, MongoClusterOptions, MongoDBUserDoc, RSMemberOptions as MongoClusterRSMemberOptions, RSOptions as MongoClusterRSOptions, CommonOptions as MongoClusterCommonOptions, ShardedOptions as MongoClusterShardedOptions, } from './mongocluster';
2
+ export { MongoCluster, type MongoClusterEvents, MongoClusterOptions, MongoDBUserDoc, RSMemberOptions as MongoClusterRSMemberOptions, RSOptions as MongoClusterRSOptions, CommonOptions as MongoClusterCommonOptions, ShardedOptions as MongoClusterShardedOptions, type ShardDescriptor, type DisaggregatedStorageOptions, } from './mongocluster';
3
+ export { createSLSMultiCellEnvironment, createSLSDisaggregatedStorageConfig, createSLSDisaggregatedStorageOptions, type SLSDisaggregatedStorageConfigOptions, type SLSDisaggregatedStorageSetupOptions, parseSLSComposeServices, SLS_HOSTNAME, SLS_CELL1, SLS_CELL2, SLS_CELL3, type SLSCell, type SLSServiceInfo, type SLSMultiCellEnvironment, type SLSMultiCellEnvironmentOptions, } from './sls';
4
+ export { DockerComposeProject, type DockerComposeProjectOptions, } from './docker-compose';
3
5
  export type { LogEntry } from './mongologreader';
4
6
  export type { ConnectionString } from 'mongodb-connection-string-url';
5
7
  export { prune, start, stop, exec, instances } from './runner-helpers';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,KAAK,iBAAiB,EACtB,kBAAkB,GACnB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,YAAY,EACZ,KAAK,kBAAkB,EACvB,mBAAmB,EACnB,cAAc,EACd,eAAe,IAAI,2BAA2B,EAC9C,SAAS,IAAI,qBAAqB,EAClC,aAAa,IAAI,yBAAyB,EAC1C,cAAc,IAAI,0BAA0B,GAC7C,MAAM,gBAAgB,CAAC;AACxB,YAAY,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACjD,YAAY,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,KAAK,iBAAiB,EACtB,kBAAkB,GACnB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,YAAY,EACZ,KAAK,kBAAkB,EACvB,mBAAmB,EACnB,cAAc,EACd,eAAe,IAAI,2BAA2B,EAC9C,SAAS,IAAI,qBAAqB,EAClC,aAAa,IAAI,yBAAyB,EAC1C,cAAc,IAAI,0BAA0B,EAC5C,KAAK,eAAe,EACpB,KAAK,2BAA2B,GACjC,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,6BAA6B,EAC7B,mCAAmC,EACnC,oCAAoC,EACpC,KAAK,oCAAoC,EACzC,KAAK,mCAAmC,EACxC,uBAAuB,EACvB,YAAY,EACZ,SAAS,EACT,SAAS,EACT,SAAS,EACT,KAAK,OAAO,EACZ,KAAK,cAAc,EACnB,KAAK,uBAAuB,EAC5B,KAAK,8BAA8B,GACpC,MAAM,OAAO,CAAC;AACf,OAAO,EACL,oBAAoB,EACpB,KAAK,2BAA2B,GACjC,MAAM,kBAAkB,CAAC;AAC1B,YAAY,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACjD,YAAY,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC"}
package/dist/index.js CHANGED
@@ -1,10 +1,21 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.instances = exports.exec = exports.start = exports.prune = exports.MongoCluster = exports.MongoServer = void 0;
3
+ exports.instances = exports.exec = exports.start = exports.prune = exports.DockerComposeProject = exports.SLS_CELL3 = exports.SLS_CELL2 = exports.SLS_CELL1 = exports.SLS_HOSTNAME = exports.parseSLSComposeServices = exports.createSLSDisaggregatedStorageOptions = exports.createSLSDisaggregatedStorageConfig = exports.createSLSMultiCellEnvironment = exports.MongoCluster = exports.MongoServer = void 0;
4
4
  var mongoserver_1 = require("./mongoserver");
5
5
  Object.defineProperty(exports, "MongoServer", { enumerable: true, get: function () { return mongoserver_1.MongoServer; } });
6
6
  var mongocluster_1 = require("./mongocluster");
7
7
  Object.defineProperty(exports, "MongoCluster", { enumerable: true, get: function () { return mongocluster_1.MongoCluster; } });
8
+ var sls_1 = require("./sls");
9
+ Object.defineProperty(exports, "createSLSMultiCellEnvironment", { enumerable: true, get: function () { return sls_1.createSLSMultiCellEnvironment; } });
10
+ Object.defineProperty(exports, "createSLSDisaggregatedStorageConfig", { enumerable: true, get: function () { return sls_1.createSLSDisaggregatedStorageConfig; } });
11
+ Object.defineProperty(exports, "createSLSDisaggregatedStorageOptions", { enumerable: true, get: function () { return sls_1.createSLSDisaggregatedStorageOptions; } });
12
+ Object.defineProperty(exports, "parseSLSComposeServices", { enumerable: true, get: function () { return sls_1.parseSLSComposeServices; } });
13
+ Object.defineProperty(exports, "SLS_HOSTNAME", { enumerable: true, get: function () { return sls_1.SLS_HOSTNAME; } });
14
+ Object.defineProperty(exports, "SLS_CELL1", { enumerable: true, get: function () { return sls_1.SLS_CELL1; } });
15
+ Object.defineProperty(exports, "SLS_CELL2", { enumerable: true, get: function () { return sls_1.SLS_CELL2; } });
16
+ Object.defineProperty(exports, "SLS_CELL3", { enumerable: true, get: function () { return sls_1.SLS_CELL3; } });
17
+ var docker_compose_1 = require("./docker-compose");
18
+ Object.defineProperty(exports, "DockerComposeProject", { enumerable: true, get: function () { return docker_compose_1.DockerComposeProject; } });
8
19
  var runner_helpers_1 = require("./runner-helpers");
9
20
  Object.defineProperty(exports, "prune", { enumerable: true, get: function () { return runner_helpers_1.prune; } });
10
21
  Object.defineProperty(exports, "start", { enumerable: true, get: function () { return runner_helpers_1.start; } });
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,6CAIuB;AAHrB,0GAAA,WAAW,OAAA;AAIb,+CASwB;AARtB,4GAAA,YAAY,OAAA;AAWd,mDAAuE;AAA9D,uGAAA,KAAK,OAAA;AAAE,uGAAA,KAAK,OAAA;AAAE,sGAAA,IAAI,OAAA;AAAE,sGAAA,IAAI,OAAA;AAAE,2GAAA,SAAS,OAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,6CAIuB;AAHrB,0GAAA,WAAW,OAAA;AAIb,+CAWwB;AAVtB,4GAAA,YAAY,OAAA;AAWd,6BAee;AAdb,oHAAA,6BAA6B,OAAA;AAC7B,0HAAA,mCAAmC,OAAA;AACnC,2HAAA,oCAAoC,OAAA;AAGpC,8GAAA,uBAAuB,OAAA;AACvB,mGAAA,YAAY,OAAA;AACZ,gGAAA,SAAS,OAAA;AACT,gGAAA,SAAS,OAAA;AACT,gGAAA,SAAS,OAAA;AAMX,mDAG0B;AAFxB,sHAAA,oBAAoB,OAAA;AAKtB,mDAAuE;AAA9D,uGAAA,KAAK,OAAA;AAAE,uGAAA,KAAK,OAAA;AAAE,sGAAA,IAAI,OAAA;AAAE,sGAAA,IAAI,OAAA;AAAE,2GAAA,SAAS,OAAA"}
@@ -25,10 +25,12 @@ export interface CommonOptions {
25
25
  downloadOptions?: DownloadOptions;
26
26
  oidc?: string;
27
27
  version?: string;
28
+ downloadUrl?: string;
28
29
  users?: MongoDBUserDoc[];
29
30
  tlsAddClientKey?: boolean;
30
31
  requireApiVersion?: number;
31
32
  topology: 'standalone' | 'replset' | 'sharded';
33
+ disaggregatedStorage?: DisaggregatedStorageOptions;
32
34
  }
33
35
  export type RSOptions = {
34
36
  arbiters?: number;
@@ -39,6 +41,25 @@ export type ShardedOptions = {
39
41
  mongosArgs?: string[][];
40
42
  shards?: number | Partial<MongoClusterOptions>[];
41
43
  };
44
+ export interface ShardMemberDescriptor {
45
+ host: string;
46
+ port: number;
47
+ priority: number;
48
+ arbiterOnly: boolean;
49
+ }
50
+ export interface ShardDescriptor {
51
+ index: number;
52
+ isConfigServer: boolean;
53
+ replSetName?: string;
54
+ members: ShardMemberDescriptor[];
55
+ }
56
+ export interface DisaggregatedStorageOptions {
57
+ composeFile: string;
58
+ env?: Record<string, string>;
59
+ config: string | Record<string, unknown> | ((shard: ShardDescriptor) => string | Record<string, unknown>);
60
+ waitForReady?: () => Promise<void>;
61
+ setupShard?: (shard: ShardDescriptor) => Promise<void>;
62
+ }
42
63
  export type MongoClusterOptions = Pick<MongoServerOptions, 'logDir' | 'tmpDir' | 'args' | 'binDir' | 'docker' | 'internalClientOptions' | 'host' | 'detached'> & CommonOptions & RSOptions & ShardedOptions;
43
64
  export type MongoClusterEvents = {
44
65
  [k in keyof MongoServerEvents]: [serverUUID: string, ...MongoServerEvents[k]];
@@ -52,6 +73,7 @@ export declare class MongoCluster extends EventEmitter<MongoClusterEvents> {
52
73
  private servers;
53
74
  private shards;
54
75
  private oidcMockProviderProcess?;
76
+ private dockerComposeProject?;
55
77
  private defaultConnectionOptions;
56
78
  private users;
57
79
  private constructor();
@@ -65,7 +87,9 @@ export declare class MongoCluster extends EventEmitter<MongoClusterEvents> {
65
87
  get connectionStringUrl(): ConnectionString;
66
88
  get serverVersion(): string;
67
89
  get serverVariant(): 'enterprise' | 'community';
68
- static start({ ...options }: MongoClusterOptions): Promise<MongoCluster>;
90
+ static start(options: MongoClusterOptions): Promise<MongoCluster>;
91
+ private static _start;
92
+ private static _startServers;
69
93
  private children;
70
94
  private allServers;
71
95
  assertAllServersHaveInsertedLocalMetadata(): Promise<void>;
@@ -1 +1 @@
1
- {"version":3,"file":"mongocluster.d.ts","sourceRoot":"","sources":["../src/mongocluster.ts"],"names":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mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC;IAwBhC,eAAe,IAAI,OAAO,CAAC,IAAI,CAAC;IAwBhC,8BAA8B,CAClC,OAAO,EAAE,OAAO,CAAC,kBAAkB,CAAC,GACnC,OAAO,CAAC,IAAI,CAAC;IAYV,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAWtB,UAAU,CAAC,EAAE,SAAS,CAAC,MAAM,EAAE,WAAW,KAAK,GAAG,EACtD,EAAE,EAAE,EAAE,EACN,aAAa,GAAE,kBAAuB,GACrC,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC;IAa1B,GAAG,IAAI,IAAI;IAIX,KAAK,IAAI,IAAI;IAKb,0BAA0B,IAAI;QAAE,YAAY,CAAC,EAAE,oBAAoB,CAAA;KAAE;CA4BtE"}
@@ -10,6 +10,7 @@ const mongodb_downloader_1 = require("@mongodb-js/mongodb-downloader");
10
10
  const mongodb_1 = require("mongodb");
11
11
  const util_1 = require("./util");
12
12
  const oidc_1 = require("./oidc");
13
+ const docker_compose_1 = require("./docker-compose");
13
14
  const events_1 = require("events");
14
15
  const assert_1 = __importDefault(require("assert"));
15
16
  const tls_helpers_1 = require("./tls-helpers");
@@ -65,6 +66,29 @@ function processRSMembers(options) {
65
66
  replSetName,
66
67
  };
67
68
  }
69
+ function buildDisaggregatedArgs(ds, shard, baseArgs) {
70
+ const raw = typeof ds.config === 'function' ? ds.config(shard) : ds.config;
71
+ const value = typeof raw === 'string' ? raw : JSON.stringify(raw);
72
+ return [
73
+ ...baseArgs,
74
+ '--setParameter',
75
+ `disaggregatedStorageConfig=${value}`,
76
+ '--setParameter',
77
+ 'disaggregatedStorageEnabled=true',
78
+ ];
79
+ }
80
+ function stripPortArg(args) {
81
+ return removePortArg(args).filter((arg) => arg !== '--port');
82
+ }
83
+ function getPortArg(args) {
84
+ if (!args)
85
+ return undefined;
86
+ const splitArgIndex = args.indexOf('--port');
87
+ if (splitArgIndex !== -1)
88
+ return +args[splitArgIndex + 1] || undefined;
89
+ const arg = args.find((a) => a.startsWith('--port='));
90
+ return arg ? +arg.split('=')[1] || undefined : undefined;
91
+ }
68
92
  function processShardOptions(options) {
69
93
  const shards = typeof options.shards === 'number' || !options.shards
70
94
  ? (0, util_1.range)((options.shards ?? 3) + 1).map(() => ({}))
@@ -110,12 +134,13 @@ class MongoCluster extends events_1.EventEmitter {
110
134
  }
111
135
  });
112
136
  }
113
- static downloadMongoDb(tmpdir, targetVersionSemverSpecifier, options) {
137
+ static downloadMongoDb(tmpdir, targetVersionSemverSpecifier, options, downloadUrl) {
114
138
  return (0, mongodb_downloader_1.downloadMongoDb)({
115
139
  directory: tmpdir,
116
140
  version: targetVersionSemverSpecifier,
117
141
  downloadOptions: options,
118
142
  useLockfile: true,
143
+ downloadUrl,
119
144
  });
120
145
  }
121
146
  serialize() {
@@ -125,13 +150,14 @@ class MongoCluster extends events_1.EventEmitter {
125
150
  servers: this.servers.map((srv) => srv.serialize()),
126
151
  shards: this.shards.map((shard) => shard.serialize()),
127
152
  oidcMockProviderProcess: this.oidcMockProviderProcess?.serialize(),
153
+ dockerComposeProject: this.dockerComposeProject?.serialize(),
128
154
  defaultConnectionOptions: (0, util_1.jsonClone)(this.defaultConnectionOptions ?? {}),
129
155
  users: (0, util_1.jsonClone)(this.users),
130
156
  };
131
157
  }
132
158
  isClosed() {
133
159
  for (const _ of this.children())
134
- return true;
160
+ return false;
135
161
  return true;
136
162
  }
137
163
  static async deserialize(serialized) {
@@ -145,6 +171,9 @@ class MongoCluster extends events_1.EventEmitter {
145
171
  cluster.oidcMockProviderProcess = serialized.oidcMockProviderProcess
146
172
  ? oidc_1.OIDCMockProviderProcess.deserialize(serialized.oidcMockProviderProcess)
147
173
  : undefined;
174
+ cluster.dockerComposeProject = serialized.dockerComposeProject
175
+ ? docker_compose_1.DockerComposeProject.deserialize(serialized.dockerComposeProject)
176
+ : undefined;
148
177
  return cluster;
149
178
  }
150
179
  get hostport() {
@@ -165,14 +194,19 @@ class MongoCluster extends events_1.EventEmitter {
165
194
  get serverVariant() {
166
195
  return this.servers[0].serverVariant;
167
196
  }
168
- static async start({ ...options }) {
197
+ static async start(options) {
198
+ return await MongoCluster._start(options, undefined);
199
+ }
200
+ static async _start({ ...options }, parentClusterContext) {
169
201
  options = { ...options, ...(await (0, tls_helpers_1.handleTLSClientKeyOptions)(options)) };
170
202
  const cluster = new MongoCluster();
171
203
  cluster.topology = options.topology;
172
204
  cluster.users = options.users ?? [];
173
205
  cluster.defaultConnectionOptions = { ...options.internalClientOptions };
174
206
  if (!options.binDir) {
175
- options.binDir = await this.downloadMongoDb(options.downloadDir ?? options.tmpDir, options.version, options.downloadOptions);
207
+ options.binDir = await this.downloadMongoDb(options.downloadDir ??
208
+ process.env.MONGODB_RUNNER_DOWNLOAD_DIR ??
209
+ options.tmpDir, options.version, options.downloadOptions, options.downloadUrl);
176
210
  }
177
211
  if (options.oidc !== undefined) {
178
212
  cluster.oidcMockProviderProcess = await oidc_1.OIDCMockProviderProcess.start(options.oidc || '--port=0');
@@ -196,7 +230,62 @@ class MongoCluster extends events_1.EventEmitter {
196
230
  'enableTestCommands=true',
197
231
  ];
198
232
  }
233
+ let disaggregatedStorage = parentClusterContext?.disaggregatedStorage;
234
+ if (!disaggregatedStorage && options.disaggregatedStorage) {
235
+ disaggregatedStorage = options.disaggregatedStorage;
236
+ delete options.disaggregatedStorage;
237
+ cluster.dockerComposeProject = await docker_compose_1.DockerComposeProject.start(disaggregatedStorage.composeFile, { env: disaggregatedStorage.env });
238
+ }
239
+ try {
240
+ if (disaggregatedStorage) {
241
+ if (cluster.dockerComposeProject) {
242
+ await disaggregatedStorage.waitForReady?.();
243
+ }
244
+ if (options.secondaries === undefined)
245
+ options.secondaries = 1;
246
+ }
247
+ return await this._startServers(cluster, options, disaggregatedStorage, parentClusterContext?.shardContext ?? {
248
+ index: 0,
249
+ isConfigServer: false,
250
+ });
251
+ }
252
+ catch (err) {
253
+ if (cluster.dockerComposeProject) {
254
+ try {
255
+ await cluster.dockerComposeProject.close();
256
+ }
257
+ catch {
258
+ }
259
+ }
260
+ throw err;
261
+ }
262
+ }
263
+ static async _startServers(cluster, options, disaggregatedStorage, shardContext) {
199
264
  if (options.topology === 'standalone') {
265
+ if (disaggregatedStorage) {
266
+ let port = getPortArg(options.args);
267
+ if (!port) {
268
+ port = await (0, util_1.allocatePort)();
269
+ options.args = [
270
+ ...stripPortArg(options.args ?? []),
271
+ '--port',
272
+ String(port),
273
+ ];
274
+ }
275
+ const descriptor = {
276
+ ...shardContext,
277
+ members: [
278
+ {
279
+ host: options.host ?? '127.0.0.1',
280
+ port,
281
+ priority: 1,
282
+ arbiterOnly: false,
283
+ },
284
+ ],
285
+ };
286
+ await disaggregatedStorage.setupShard?.(descriptor);
287
+ options.args = buildDisaggregatedArgs(disaggregatedStorage, descriptor, options.args ?? []);
288
+ }
200
289
  cluster.servers.push(await mongoserver_1.MongoServer.start({
201
290
  ...options,
202
291
  binary: 'mongod',
@@ -204,6 +293,35 @@ class MongoCluster extends events_1.EventEmitter {
204
293
  }
205
294
  else if (options.topology === 'replset') {
206
295
  const { rsMembers, replSetName } = processRSMembers(options);
296
+ if (disaggregatedStorage) {
297
+ const members = [];
298
+ for (const member of rsMembers) {
299
+ let port = getPortArg(member.args);
300
+ if (!port) {
301
+ port = await (0, util_1.allocatePort)();
302
+ member.args = [
303
+ ...stripPortArg(member.args ?? []),
304
+ '--port',
305
+ String(port),
306
+ ];
307
+ }
308
+ members.push({
309
+ host: options.host ?? '127.0.0.1',
310
+ port,
311
+ priority: member.priority ?? 0,
312
+ arbiterOnly: member.arbiterOnly ?? false,
313
+ });
314
+ }
315
+ const descriptor = {
316
+ ...shardContext,
317
+ replSetName,
318
+ members,
319
+ };
320
+ await disaggregatedStorage.setupShard?.(descriptor);
321
+ for (const member of rsMembers) {
322
+ member.args = buildDisaggregatedArgs(disaggregatedStorage, descriptor, member.args ?? []);
323
+ }
324
+ }
207
325
  (0, util_1.debug)('Starting replica set nodes', {
208
326
  replSetName,
209
327
  secondaries: rsMembers.filter((m) => !m.arbiterOnly).length - 1,
@@ -225,24 +343,26 @@ class MongoCluster extends events_1.EventEmitter {
225
343
  cluster.servers.push(...nodes.map(([srv]) => srv));
226
344
  const primary = cluster.servers[primaryIndex];
227
345
  await primary.withClient(async (client) => {
228
- (0, util_1.debug)('Running rs.initiate');
229
- const rsConf = {
230
- _id: replSetName,
231
- configsvr: rsMembers.some((m) => m.args?.includes('--configsvr')),
232
- members: nodes.map(([srv, member], i) => {
233
- return {
234
- _id: i,
235
- host: srv.hostport,
236
- arbiterOnly: member.arbiterOnly ?? false,
237
- priority: member.priority ?? (i === primaryIndex ? 1 : 0),
238
- tags: member.tags || {},
239
- };
240
- }),
241
- };
242
- (0, util_1.debugVerbose)('replSetInitiate:', rsConf);
243
- await client.db('admin').command({
244
- replSetInitiate: rsConf,
245
- });
346
+ if (!disaggregatedStorage) {
347
+ (0, util_1.debug)('Running rs.initiate');
348
+ const rsConf = {
349
+ _id: replSetName,
350
+ configsvr: rsMembers.some((m) => m.args?.includes('--configsvr')),
351
+ members: nodes.map(([srv, member], i) => {
352
+ return {
353
+ _id: i,
354
+ host: srv.hostport,
355
+ arbiterOnly: member.arbiterOnly ?? false,
356
+ priority: member.priority ?? (i === primaryIndex ? 1 : 0),
357
+ tags: member.tags || {},
358
+ };
359
+ }),
360
+ };
361
+ (0, util_1.debugVerbose)('replSetInitiate:', rsConf);
362
+ await client.db('admin').command({
363
+ replSetInitiate: rsConf,
364
+ });
365
+ }
246
366
  for (let i = 0; i < 60; i++) {
247
367
  const status = await client.db('admin').command({
248
368
  replSetGetStatus: 1,
@@ -260,16 +380,19 @@ class MongoCluster extends events_1.EventEmitter {
260
380
  else if (options.topology === 'sharded') {
261
381
  const { shards, mongosArgs } = processShardOptions(options);
262
382
  (0, util_1.debug)('starting config server and shard servers', shards);
263
- const allShards = await (0, util_1.safePromiseAll)(shards.map(async (s) => {
264
- const isConfig = s.args?.includes('--configsvr');
265
- const cluster = await MongoCluster.start({
383
+ const allShards = await (0, util_1.safePromiseAll)(shards.map(async (s, i) => {
384
+ const isConfigServer = s.args?.includes('--configsvr') ?? false;
385
+ const shardCluster = await MongoCluster._start({
266
386
  ...options,
267
387
  ...s,
268
388
  topology: 'replset',
269
389
  requireApiVersion: undefined,
270
- users: isConfig ? undefined : options.users,
390
+ users: isConfigServer ? undefined : options.users,
391
+ }, {
392
+ disaggregatedStorage,
393
+ shardContext: { index: i, isConfigServer },
271
394
  });
272
- return [cluster, isConfig];
395
+ return [shardCluster, isConfigServer];
273
396
  }));
274
397
  const configsvr = allShards.find(([, isConfig]) => isConfig)[0];
275
398
  const shardsvrs = allShards
@@ -370,6 +493,7 @@ class MongoCluster extends events_1.EventEmitter {
370
493
  }
371
494
  async close() {
372
495
  await (0, util_1.safePromiseAll)([...this.children(), this.oidcMockProviderProcess].map((closable) => closable?.close()));
496
+ await this.dockerComposeProject?.close();
373
497
  this.servers = [];
374
498
  this.shards = [];
375
499
  }