Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions packages/cli-repl/src/mongocryptd-manager.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ describe('MongocryptdManager', () => {
expect(makeManager().close().state).to.equal(null);
});

for (const otherMongocryptd of ['none', 'missing', 'broken', 'weirdlog']) {
for (const version of ['4.2', '4.4']) {
for (const otherMongocryptd of ['none', 'missing', 'broken', 'weirdlog', 'broken-after']) {
for (const version of ['4.2', '4.4']) { // This refers to the log format version
for (const variant of ['withunix', 'nounix']) {
// eslint-disable-next-line no-loop-func
it(`spawns a working mongocryptd (${version}, ${variant}, other mongocryptd: ${otherMongocryptd})`, async() => {
Expand All @@ -71,6 +71,9 @@ describe('MongocryptdManager', () => {
if (otherMongocryptd === 'weirdlog') {
spawnPaths.unshift([ process.execPath, path.resolve(fakeMongocryptdDir, 'weirdlog') ]);
}
if (otherMongocryptd === 'broken-after') {
spawnPaths.push([ process.execPath, path.resolve(fakeMongocryptdDir, 'exit1') ]);
}
expect(await makeManager().start()).to.deep.equal({
mongocryptdURI: variant === 'nounix' ?
'mongodb://localhost:27020' :
Expand All @@ -79,7 +82,8 @@ describe('MongocryptdManager', () => {
});

const tryspawns = events.filter(({ event }) => event === 'mongosh:mongocryptd-tryspawn');
expect(tryspawns).to.have.lengthOf(otherMongocryptd === 'none' ? 1 : 2);
expect(tryspawns).to.have.lengthOf(
otherMongocryptd === 'none' || otherMongocryptd === 'broken-after' ? 1 : 2);
});
}
}
Expand Down
1 change: 1 addition & 0 deletions packages/cli-repl/src/mongocryptd-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ export class MongocryptdManager {

// No UNIX socket means we're on Windows, where we have to use networking.
uri = !socket ? `mongodb://localhost:${port}` : `mongodb://${encodeURIComponent(socket)}`;
break;
}
if (!proc || !uri) {
throw lastError ?? new MongoshInternalError('Could not successfully spawn mongocryptd');
Expand Down