Skip to content

Commit 8927cfe

Browse files
authored
PYTHON-5181 Make it easier to set debugging logging in an Evergreen patch (#2177)
1 parent f1fe497 commit 8927cfe

File tree

5 files changed

+10
-4
lines changed

5 files changed

+10
-4
lines changed

.evergreen/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ functions:
262262
params:
263263
include_expansions_in_env: [AUTH, SSL, AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY,
264264
AWS_SESSION_TOKEN, COVERAGE, PYTHON_BINARY, LIBMONGOCRYPT_URL, MONGODB_URI,
265-
DISABLE_TEST_COMMANDS, GREEN_FRAMEWORK, NO_EXT, COMPRESSORS, MONGODB_API_VERSION]
265+
DISABLE_TEST_COMMANDS, GREEN_FRAMEWORK, NO_EXT, COMPRESSORS, MONGODB_API_VERSION, DEBUG_LOG]
266266
binary: bash
267267
working_dir: "src"
268268
args: [.evergreen/just.sh, setup-tests, "${TEST_NAME}", "${SUB_TEST_NAME}"]

.evergreen/run-tests.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,6 @@ fi
3333
PIP_QUIET=0 uv run ${UV_ARGS} --with pip pip list
3434

3535
# Start the test runner.
36-
uv run ${UV_ARGS} .evergreen/scripts/run_tests.py
36+
uv run ${UV_ARGS} .evergreen/scripts/run_tests.py "$@"
3737

3838
popd

.evergreen/scripts/run_tests.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from __future__ import annotations
22

33
import json
4+
import logging
45
import os
56
import platform
67
import shutil
@@ -106,8 +107,11 @@ def run() -> None:
106107
test_kms_remote(SUB_TEST_NAME)
107108
return
108109

110+
if os.environ.get("DEBUG_LOG"):
111+
TEST_ARGS.extend(f"-o log_cli_level={logging.DEBUG} -o log_cli=1".split())
112+
109113
# Run local tests.
110-
pytest.main(TEST_ARGS)
114+
pytest.main(TEST_ARGS + sys.argv[1:])
111115

112116
# Handle perf test post actions.
113117
if TEST_PERF:

.evergreen/scripts/setup_tests.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
)
2727

2828
# Passthrough environment variables.
29-
PASS_THROUGH_ENV = ["GREEN_FRAMEWORK", "NO_EXT", "MONGODB_API_VERSION"]
29+
PASS_THROUGH_ENV = ["GREEN_FRAMEWORK", "NO_EXT", "MONGODB_API_VERSION", "DEBUG_LOG"]
3030

3131
# Map the test name to a test suite.
3232
TEST_SUITE_MAP = {

CONTRIBUTING.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,8 @@ the pages will re-render and the browser will automatically refresh.
227227
## Enable Debug Logs
228228
- Use `-o log_cli_level="DEBUG" -o log_cli=1` with `just test` or `pytest`.
229229
- Add `log_cli_level = "DEBUG` and `log_cli = 1` to the `tool.pytest.ini_options` section in `pyproject.toml` for Evergreen patches or to enable debug logs by default on your machine.
230+
- You can also set `DEBUG_LOG=1` and run either `just setup-tests` or `just-test`.
231+
- For evergreen patch builds, you can use `evergreen patch --param DEBUG_LOG=1` to enable debug logs for the patch.
230232

231233
## Re-sync Spec Tests
232234

0 commit comments

Comments
 (0)