Skip to content

Commit

Permalink
chore(data-service): enable debug logging for connectivity tests (#6154)
Browse files Browse the repository at this point in the history
  • Loading branch information
addaleax authored Aug 26, 2024
1 parent d29d513 commit d73838c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
2 changes: 2 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/data-service/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
"eslint": "^7.25.0",
"kerberos": "^2.1.1",
"mocha": "^10.2.0",
"mongodb-log-writer": "^1.4.2",
"nyc": "^15.1.0",
"prettier": "^2.7.1",
"sinon": "^9.2.3",
Expand Down
11 changes: 10 additions & 1 deletion packages/data-service/src/connect.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,18 @@ import ConnectionStringUrl from 'mongodb-connection-string-url';
import path from 'path';
import os from 'os';
import type { MongoClientOptions } from 'mongodb';
import { UUID } from 'mongodb';

import connect from './connect';
import type { ConnectionOptions } from './connection-options';
import type DataService from './data-service';
import { redactConnectionOptions } from './redact';
import { runCommand } from './run-command';
import { MongoLogWriter } from 'mongodb-log-writer';

const IS_CI = process.env.EVERGREEN_BUILD_VARIANT || process.env.CI === 'true';
const SHOULD_DEBUG =
IS_CI || process.env.DEBUG?.includes('data-service-connect');

const SHOULD_RUN_DOCKER_TESTS = process.env.COMPASS_RUN_DOCKER_TESTS === 'true';

Expand Down Expand Up @@ -637,7 +641,12 @@ async function connectAndGetAuthInfo(connectionOptions: ConnectionOptions) {
let dataService: DataService | undefined;

try {
dataService = await connect({ connectionOptions });
dataService = await connect({
connectionOptions,
logger: SHOULD_DEBUG
? new MongoLogWriter(new UUID().toHexString(), null, process.stderr)
: undefined,
});
const connectionStatus = await runCommand(
dataService['_database']('admin', 'META'),
{ connectionStatus: 1 }
Expand Down

0 comments on commit d73838c

Please sign in to comment.