@@ -24,41 +24,114 @@ import { EventEmitter } from 'events';
2424import assert from 'assert' ;
2525import { handleTLSClientKeyOptions } from './tls-helpers' ;
2626
27+ /**
28+ * Description of a MongoDB user account that will be created in a test cluster.
29+ */
2730export interface MongoDBUserDoc {
31+ /**
32+ * SCRAM-SHA-256 username.
33+ */
2834 username : string ;
35+ /**
36+ * SCRAM-SHA-256 password.
37+ */
2938 password : string ;
39+ /**
40+ * Additional metadata for a given user.
41+ */
3042 customData ?: Document ;
43+ /**
44+ * Roles to assign to the user.
45+ */
3146 roles : ( { role : string ; db ?: string } | string ) [ ] ;
47+ /**
48+ * Additional fields may be included as per the `createUser` command.
49+ */
50+ [ key : string ] : unknown ;
3251}
3352
53+ /** Describe the individual members of a replica set */
3454export interface RSMemberOptions {
55+ /**
56+ * Tags to assign to the member, in the format expected by the Node.js driver.
57+ */
3558 tags ?: TagSet ;
59+ /**
60+ * Priority of the member. If none is specified, one member will be given priority 1
61+ * and all others priority 0. The mongodb-runner package assumes that the highest priority
62+ * member will become primary.
63+ */
3664 priority ?: number ;
65+ /**
66+ * Additional arguments for the member.
67+ */
3768 args ?: string [ ] ;
69+ /**
70+ * Whether the member is an arbiter.
71+ */
3872 arbiterOnly ?: boolean ;
3973}
4074
75+ /**
76+ * Shared options for all cluster topologies.
77+ */
4178export interface CommonOptions {
79+ /**
80+ * Directory where server binaries will be downloaded and stored.
81+ */
4282 downloadDir ?: string ;
83+ /**
84+ * Various options to control the download of MongoDB binaries.
85+ */
4386 downloadOptions ?: DownloadOptions ;
4487
88+ /**
89+ * OIDC mock provider command line (e.g. '--port=0' or full path to binary).
90+ * If provided, an OIDC mock provider will be started alongside the cluster,
91+ * and the necessary parameters to connect to it will be added to the
92+ * cluster's mongod/mongos processes.
93+ */
4594 oidc ?: string ;
4695
96+ /**
97+ * MongoDB server version to download and use (e.g. '6.0.3', '8.x-enterprise', 'latest-alpha', etc.)
98+ */
4799 version ?: string ;
100+ /**
101+ * User accounts to create after starting the cluster.
102+ */
48103 users ?: MongoDBUserDoc [ ] ;
104+
105+ /**
106+ * Whether to automatically add an additional TLS client certificate key file
107+ * to the cluster nodes based on whether TLS configuration was detected.
108+ *
109+ * Adding this is required in order for authentication to work when TLS is enabled.
110+ */
49111 tlsAddClientKey ?: boolean ;
50112
113+ /**
114+ * Topology of the cluster.
115+ */
51116 topology : 'standalone' | 'replset' | 'sharded' ;
52117}
53118
119+ /**
120+ * Options specific to replica set clusters.
121+ */
54122export type RSOptions = {
123+ /** Number of arbiters to create (default: 0) */
55124 arbiters ?: number ;
125+ /** Number of secondary nodes to create (default: 2) */
56126 secondaries ?: number ;
127+ /** Explicitly specify replica set members. If set, `arbiters` and `secondaries` will be ignored. */
57128 rsMembers ?: RSMemberOptions [ ] ;
58129} ;
59130
60131export type ShardedOptions = {
132+ /** Arguments to pass to each mongos instance. */
61133 mongosArgs ?: string [ ] [ ] ;
134+ /** Number of shards to create or explicit shard configurations. */
62135 shards ?: number | Partial < MongoClusterOptions > [ ] ;
63136} ;
64137
0 commit comments