Skip to content

Commit 1cabacb

Browse files
authored
test: adds pytest-xdist to speed up processing of CI/CD checks (googleapis#2153)
* experimentation using pytest-xdist * adds pytest-xdist to nox system session for experimentation * adds pytest-xdist install AND -n=auto argument * updates sample noxfiles * updates pytest version in requirements-test.txt files * Update samples/notebooks/requirements-test.txt * Update samples/notebooks/requirements-test.txt
1 parent b162288 commit 1cabacb

File tree

6 files changed

+25
-3
lines changed

6 files changed

+25
-3
lines changed

noxfile.py

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ def default(session, install_extras=True):
9898
"pytest",
9999
"google-cloud-testutils",
100100
"pytest-cov",
101+
"pytest-xdist",
101102
"freezegun",
102103
"-c",
103104
constraints_path,
@@ -129,6 +130,7 @@ def default(session, install_extras=True):
129130
# Run py.test against the unit tests.
130131
session.run(
131132
"py.test",
133+
"-n=auto",
132134
"--quiet",
133135
"-W default::PendingDeprecationWarning",
134136
"--cov=google/cloud/bigquery",
@@ -224,7 +226,12 @@ def system(session):
224226

225227
# Install all test dependencies, then install local packages in place.
226228
session.install(
227-
"pytest", "psutil", "google-cloud-testutils", "-c", constraints_path
229+
"pytest",
230+
"psutil",
231+
"pytest-xdist",
232+
"google-cloud-testutils",
233+
"-c",
234+
constraints_path,
228235
)
229236
if os.environ.get("GOOGLE_API_USE_CLIENT_CERTIFICATE", "") == "true":
230237
# mTLS test requires pyopenssl and latest google-cloud-storage
@@ -257,6 +264,7 @@ def system(session):
257264
# Run py.test against the system tests.
258265
session.run(
259266
"py.test",
267+
"-n=auto",
260268
"--quiet",
261269
"-W default::PendingDeprecationWarning",
262270
os.path.join("tests", "system"),
@@ -310,7 +318,9 @@ def snippets(session):
310318
)
311319

312320
# Install all test dependencies, then install local packages in place.
313-
session.install("pytest", "google-cloud-testutils", "-c", constraints_path)
321+
session.install(
322+
"pytest", "pytest-xdist", "google-cloud-testutils", "-c", constraints_path
323+
)
314324
session.install("google-cloud-storage", "-c", constraints_path)
315325
session.install("grpcio", "-c", constraints_path)
316326

@@ -326,9 +336,12 @@ def snippets(session):
326336
# Run py.test against the snippets tests.
327337
# Skip tests in samples/snippets, as those are run in a different session
328338
# using the nox config from that directory.
329-
session.run("py.test", os.path.join("docs", "snippets.py"), *session.posargs)
339+
session.run(
340+
"py.test", "-n=auto", os.path.join("docs", "snippets.py"), *session.posargs
341+
)
330342
session.run(
331343
"py.test",
344+
"-n=auto",
332345
"samples",
333346
"-W default::PendingDeprecationWarning",
334347
"--ignore=samples/desktopapp",
@@ -393,6 +406,7 @@ def prerelease_deps(session):
393406
"google-cloud-testutils",
394407
"psutil",
395408
"pytest",
409+
"pytest-xdist",
396410
"pytest-cov",
397411
)
398412

@@ -439,18 +453,21 @@ def prerelease_deps(session):
439453
# Run all tests, except a few samples tests which require extra dependencies.
440454
session.run(
441455
"py.test",
456+
"-n=auto",
442457
"tests/unit",
443458
"-W default::PendingDeprecationWarning",
444459
)
445460

446461
session.run(
447462
"py.test",
463+
"-n=auto",
448464
"tests/system",
449465
"-W default::PendingDeprecationWarning",
450466
)
451467

452468
session.run(
453469
"py.test",
470+
"-n=auto",
454471
"samples/tests",
455472
"-W default::PendingDeprecationWarning",
456473
)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
google-cloud-testutils==1.6.0
22
pytest==8.3.5
33
mock==5.2.0
4+
pytest-xdist==3.6.1
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
pytest==8.3.5
22
mock==5.2.0
3+
pytest-xdist==3.6.1

samples/magics/requirements-test.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
google-cloud-testutils==1.6.0
22
pytest==8.3.5
33
mock==5.2.0
4+
pytest-xdist==3.6.1
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
google-cloud-testutils==1.6.0
22
pytest==8.3.5
33
mock==5.2.0
4+
pytest-xdist==3.6.1

samples/snippets/requirements-test.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
google-cloud-testutils==1.6.0
33
pytest==8.3.5
44
mock==5.2.0
5+
pytest-xdist==3.6.1

0 commit comments

Comments
 (0)