PYTHON-5181 Make it easier to set debugging logging in an Evergreen patch (#2177)

This commit is contained in:
Steven Silvester 2025-03-04 08:32:39 -06:00 committed by GitHub
parent f1fe49784b
commit 8927cfe79b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 10 additions and 4 deletions

View File

@ -262,7 +262,7 @@ functions:
params:
include_expansions_in_env: [AUTH, SSL, AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY,
AWS_SESSION_TOKEN, COVERAGE, PYTHON_BINARY, LIBMONGOCRYPT_URL, MONGODB_URI,
DISABLE_TEST_COMMANDS, GREEN_FRAMEWORK, NO_EXT, COMPRESSORS, MONGODB_API_VERSION]
DISABLE_TEST_COMMANDS, GREEN_FRAMEWORK, NO_EXT, COMPRESSORS, MONGODB_API_VERSION, DEBUG_LOG]
binary: bash
working_dir: "src"
args: [.evergreen/just.sh, setup-tests, "${TEST_NAME}", "${SUB_TEST_NAME}"]

View File

@ -33,6 +33,6 @@ fi
PIP_QUIET=0 uv run ${UV_ARGS} --with pip pip list
# Start the test runner.
uv run ${UV_ARGS} .evergreen/scripts/run_tests.py
uv run ${UV_ARGS} .evergreen/scripts/run_tests.py "$@"
popd

View File

@ -1,6 +1,7 @@
from __future__ import annotations
import json
import logging
import os
import platform
import shutil
@ -106,8 +107,11 @@ def run() -> None:
test_kms_remote(SUB_TEST_NAME)
return
if os.environ.get("DEBUG_LOG"):
TEST_ARGS.extend(f"-o log_cli_level={logging.DEBUG} -o log_cli=1".split())
# Run local tests.
pytest.main(TEST_ARGS)
pytest.main(TEST_ARGS + sys.argv[1:])
# Handle perf test post actions.
if TEST_PERF:

View File

@ -26,7 +26,7 @@ from utils import (
)
# Passthrough environment variables.
PASS_THROUGH_ENV = ["GREEN_FRAMEWORK", "NO_EXT", "MONGODB_API_VERSION"]
PASS_THROUGH_ENV = ["GREEN_FRAMEWORK", "NO_EXT", "MONGODB_API_VERSION", "DEBUG_LOG"]
# Map the test name to a test suite.
TEST_SUITE_MAP = {

View File

@ -227,6 +227,8 @@ the pages will re-render and the browser will automatically refresh.
## Enable Debug Logs
- Use `-o log_cli_level="DEBUG" -o log_cli=1` with `just test` or `pytest`.
- 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.
- You can also set `DEBUG_LOG=1` and run either `just setup-tests` or `just-test`.
- For evergreen patch builds, you can use `evergreen patch --param DEBUG_LOG=1` to enable debug logs for the patch.
## Re-sync Spec Tests