Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(data-service): enable debug logging for connectivity tests #6154

Merged
merged 2 commits into from
Aug 26, 2024
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
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
Loading