Skip to content
Draft
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
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,7 @@ replacements:
SYSTEM_TEST_STANDARD_DEPENDENCIES: List[str] = [
"mock",
"pytest",
"pytest-xdist",
"google-cloud-testutils",
]
SYSTEM_TEST_EXTERNAL_DEPENDENCIES: List[str] = [
Expand Down Expand Up @@ -696,6 +697,19 @@ replacements:
test_map[test_type](session)


def _has_xdist_arg(posargs):
return any(
arg == "-n"
or (
arg.startswith("-n")
and (arg[2:].isdigit() or arg[2:] in ("auto", "logical"))
)
or arg == "--numprocesses"
or arg.startswith("--numprocesses=")
for arg in posargs
)


def system_default(session):
"""Run the system test suite."""
constraints_path = str(
Expand Down Expand Up @@ -729,9 +743,18 @@ replacements:
*session.posargs,
)
if system_test_folder_exists:
in_emulator = bool(
session.env.get("BIGTABLE_EMULATOR_HOST")
or os.environ.get("BIGTABLE_EMULATOR_HOST")
)
has_xdist_arg = _has_xdist_arg(session.posargs)
xdist_args = (
[] if (in_emulator or has_xdist_arg) else ["-n", "8", "--dist=loadfile"]
)
session.run(
"py.test",
"--quiet",
*xdist_args,
f"--junitxml=system_{session.python}_sponge_log.xml",
system_test_folder_path,
*session.posargs,
Expand All @@ -752,6 +775,7 @@ replacements:
"mock",
"pytest",
"pytest-asyncio",
"pytest-xdist",
*req_args,
)
# Install the library from this checkout last so the samples exercise the
Expand All @@ -761,9 +785,12 @@ replacements:

has_target = any(not arg.startswith("-") for arg in session.posargs)
target_paths = [] if has_target else [os.path.join("samples")]
has_xdist_arg = _has_xdist_arg(session.posargs)
xdist_args = [] if has_xdist_arg else ["-n", "8", "--dist=loadfile"]
session.run(
"py.test",
"--quiet",
*xdist_args,
f"--junitxml=samples_{session.python}_sponge_log.xml",
"--ignore=samples/legacy_client/beam",
*target_paths,
Expand Down
Loading
Loading