Skip to content

Commit 3e6873a

Browse files
committed
PYTHON-5808 Fix gevent coverage and auth CI failures
Fix shlex-splitting bug in coverage command that broke multi-word marker expressions (e.g. 'not default_async and default') when GREEN_FRAMEWORK is set, by building subprocess args as a list instead of a shell string. Switch enterprise auth setup to use SASL_HOST_BUILD and PRINCIPAL_BUILD secrets so GSSAPI and SASL tests connect to a MongoDB 4.4+ server instead of the legacy 4.2 LDAP test server.
1 parent 6a1bad4 commit 3e6873a

2 files changed

Lines changed: 10 additions & 9 deletions

File tree

.evergreen/scripts/run_tests.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import logging
55
import os
66
import platform
7-
import shlex
87
import shutil
98
import subprocess
109
import sys
@@ -205,11 +204,12 @@ def run() -> None:
205204
TEST_ARGS.extend(f"-o log_cli_level={logging.DEBUG}".split())
206205

207206
if os.environ.get("COVERAGE"):
208-
binary = sys.executable.replace(os.sep, "/")
209-
cmd = f"{binary} -m coverage run -m pytest {' '.join(TEST_ARGS)} {' '.join(sys.argv[1:])}"
210-
result = subprocess.run(shlex.split(cmd), check=False) # noqa: S603
211-
cmd = f"{binary} -m coverage report"
212-
subprocess.run(shlex.split(cmd), check=False) # noqa: S603
207+
binary = sys.executable
208+
result = subprocess.run( # noqa: S603
209+
[binary, "-m", "coverage", "run", "-m", "pytest", *TEST_ARGS, *sys.argv[1:]],
210+
check=False,
211+
)
212+
subprocess.run([binary, "-m", "coverage", "report"], check=False) # noqa: S603
213213
if result.returncode != 0:
214214
print(result.stderr)
215215
sys.exit(result.returncode)

.evergreen/scripts/setup_tests.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -263,16 +263,17 @@ def handle_test_env() -> None:
263263
keytab_file = ROOT / ".evergreen/drivers.keytab"
264264
with keytab_file.open("wb") as fid:
265265
fid.write(keytab)
266-
principal = config["PRINCIPAL"]
266+
principal = config["PRINCIPAL_BUILD"]
267267
LOGGER.info("Running kinit")
268268
os.environ["KRB5_CONFIG"] = str(krb_conf)
269269
cmd = f"kinit -k -t {keytab_file} -p {principal}"
270270
run_command(cmd)
271271

272272
LOGGER.info("Setting GSSAPI variables")
273-
write_env("GSSAPI_HOST", config["SASL_HOST"])
273+
write_env("GSSAPI_HOST", config["SASL_HOST_BUILD"])
274274
write_env("GSSAPI_PORT", config["SASL_PORT"])
275-
write_env("GSSAPI_PRINCIPAL", config["PRINCIPAL"])
275+
write_env("GSSAPI_PRINCIPAL", config["PRINCIPAL_BUILD"])
276+
write_env("SASL_HOST", config["SASL_HOST_BUILD"])
276277

277278
if test_name == "doctest":
278279
UV_ARGS.append("--extra docs")

0 commit comments

Comments
 (0)