diff --git a/.evergreen/config.yml b/.evergreen/config.yml index 4c12e8bdb2..2d357c8229 100644 --- a/.evergreen/config.yml +++ b/.evergreen/config.yml @@ -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}"] diff --git a/.evergreen/run-tests.sh b/.evergreen/run-tests.sh index 1c453c1d6d..61d505d45a 100755 --- a/.evergreen/run-tests.sh +++ b/.evergreen/run-tests.sh @@ -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 diff --git a/.evergreen/scripts/run_tests.py b/.evergreen/scripts/run_tests.py index ceae46d343..830f5190e0 100644 --- a/.evergreen/scripts/run_tests.py +++ b/.evergreen/scripts/run_tests.py @@ -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: diff --git a/.evergreen/scripts/setup_tests.py b/.evergreen/scripts/setup_tests.py index 615f07320a..c874263a5d 100644 --- a/.evergreen/scripts/setup_tests.py +++ b/.evergreen/scripts/setup_tests.py @@ -26,7 +26,7 @@ ) # 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 = { diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d22874faf8..ccce0c1ae7 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -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