Skip to content

Commit 920ed09

Browse files
committed
tests: run tests in parallel
1 parent 6d04c1f commit 920ed09

File tree

2 files changed

+65
-0
lines changed

2 files changed

+65
-0
lines changed
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
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+
"mock",
22+
"asyncmock",
23+
"pytest",
24+
"pytest-cov",
25+
"pytest-asyncio",
26+
\]
27+
after: |
28+
"mock",
29+
"asyncmock",
30+
"pytest<9",
31+
"pytest-cov",
32+
"pytest-asyncio",
33+
"pytest-xdist",
34+
]
35+
count: 1
36+
- paths: [
37+
packages/google-cloud-compute/noxfile.py,
38+
]
39+
before: |
40+
session.install\("protobuf<4"\)
41+
\
42+
\ # Run py.test against the unit tests.
43+
after: |
44+
session.install("protobuf<4")\n
45+
import faulthandler; faulthandler.enable()
46+
concurrent_args = ["-n", "4", "--max-worker-restart", "0"]\n
47+
# Run py.test against the unit tests.
48+
count: 1
49+
- paths: [
50+
packages/google-cloud-compute/noxfile.py,
51+
]
52+
before: |
53+
\*session.posargs,
54+
\ env=\{
55+
after: |
56+
*session.posargs,
57+
*concurrent_args,
58+
env={
59+
count: 1
60+

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)