Skip to content

Commit 9ee5b32

Browse files
committed
tests: run tests in parallel
1 parent 6d04c1f commit 9ee5b32

File tree

2 files changed

+57
-0
lines changed

2 files changed

+57
-0
lines changed
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Copyright 2025 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
description: Run tests in parallel to debug generation issue
15+
url: https://github.com/googleapis/google-cloud-python/issues/14992
16+
replacements:
17+
- paths: [
18+
packages/google-cloud-compute/noxfile.py,
19+
]
20+
before: |
21+
"pytest-asyncio",
22+
\]
23+
after: |
24+
"pytest-asyncio",
25+
"pytest-xdist",
26+
]
27+
count: 1
28+
- paths: [
29+
packages/google-cloud-compute/noxfile.py,
30+
]
31+
before: |
32+
session.install\("protobuf<4"\)
33+
\
34+
\ # Run py.test against the unit tests.
35+
after: |
36+
session.install("protobuf<4")\n
37+
import faulthandler; faulthandler.enable()
38+
concurrent_args = ["-n", "auto", "--max-worker-restart", "0"]\n
39+
# Run py.test against the unit tests.
40+
count: 1
41+
- paths: [
42+
packages/google-cloud-compute/noxfile.py,
43+
]
44+
before: |
45+
\*session.posargs,
46+
\ env=\{
47+
after: |
48+
*session.posargs,
49+
*concurrent_args,
50+
env={
51+
count: 1
52+

packages/google-cloud-compute/noxfile.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
"pytest",
6161
"pytest-cov",
6262
"pytest-asyncio",
63+
"pytest-xdist",
6364
]
6465
UNIT_TEST_EXTERNAL_DEPENDENCIES: List[str] = []
6566
UNIT_TEST_LOCAL_DEPENDENCIES: List[str] = []
@@ -253,6 +254,9 @@ def unit(session, protobuf_implementation):
253254
if protobuf_implementation == "cpp":
254255
session.install("protobuf<4")
255256

257+
# Limit to 4 CPUs for now
258+
concurrent_args = ["-n", "4"]
259+
256260
# Run py.test against the unit tests.
257261
session.run(
258262
"py.test",
@@ -266,6 +270,7 @@ def unit(session, protobuf_implementation):
266270
"--cov-fail-under=0",
267271
os.path.join("tests", "unit"),
268272
*session.posargs,
273+
*concurrent_args,
269274
env={
270275
"PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": protobuf_implementation,
271276
},

0 commit comments

Comments
 (0)