Skip to content

Commit

Permalink
chore: Adding support for running system tests in parallel
Browse files Browse the repository at this point in the history
  • Loading branch information
ankiaga committed Feb 6, 2024
1 parent 122ab36 commit f0b7b2b
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
7 changes: 4 additions & 3 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
UNIT_TEST_EXTRAS: List[str] = []
UNIT_TEST_EXTRAS_BY_PYTHON: Dict[str, List[str]] = {}

SYSTEM_TEST_PYTHON_VERSIONS: List[str] = ["3.8"]
SYSTEM_TEST_PYTHON_VERSIONS: List[str] = ["3.9"]
SYSTEM_TEST_STANDARD_DEPENDENCIES: List[str] = [
"mock",
"pytest",
Expand Down Expand Up @@ -217,6 +217,7 @@ def install_systemtest_dependencies(session, *constraints):
# Exclude version 1.52.0rc1 which has a known issue.
# See https://github.com/grpc/grpc/issues/32163
session.install("--pre", "grpcio!=1.52.0rc1")
session.install("pytest-xdist")

session.install(*SYSTEM_TEST_STANDARD_DEPENDENCIES, *constraints)

Expand Down Expand Up @@ -282,7 +283,7 @@ def system(session, database_dialect):
if system_test_exists:
session.run(
"py.test",
"--quiet",
"-n=12",
f"--junitxml=system_{session.python}_sponge_log.xml",
system_test_path,
*session.posargs,
Expand All @@ -294,7 +295,7 @@ def system(session, database_dialect):
if system_test_folder_exists:
session.run(
"py.test",
"--quiet",
"-n=12",
f"--junitxml=system_{session.python}_sponge_log.xml",
system_test_folder_path,
*session.posargs,
Expand Down
1 change: 1 addition & 0 deletions samples/samples/noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ def _session_tests(

session.run(
"pytest",
"-n=12",
*(PYTEST_COMMON_ARGS + session.posargs + concurrent_args),
# Pytest will return 5 when no tests are collected. This can happen
# on travis where slow and flaky tests are excluded.
Expand Down
1 change: 1 addition & 0 deletions samples/samples/requirements-test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ pytest==8.0.0
pytest-dependency==0.6.0
mock==5.1.0
google-cloud-testutils==1.4.0
pytest-xdist==3.5.0
3 changes: 2 additions & 1 deletion tests/system/_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import operator
import os
import time
from random import randrange

from google.api_core import exceptions
from google.cloud.spanner_v1 import instance as instance_mod
Expand Down Expand Up @@ -134,4 +135,4 @@ def cleanup_old_instances(spanner_client):


def unique_id(prefix, separator="-"):
return f"{prefix}{system.unique_resource_id(separator)}"
return f"{prefix}{system.unique_resource_id(separator)}{randrange(100)}"

0 comments on commit f0b7b2b

Please sign in to comment.