Skip to content

Commit d84e541

Browse files
authored
chore: serialize fragment tests (googleapis#1164)
Occasionally the fragment test nox target trips over its feet when running concurrently. This change makes the tests serial by default.
1 parent 48c7f6a commit d84e541

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

noxfile.py

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -146,11 +146,16 @@ def fragment(session):
146146
)
147147
session.install("-e", ".")
148148

149-
with ThreadPoolExecutor() as p:
150-
all_outs = p.map(FragTester(session, False), FRAGMENT_FILES)
149+
if os.environ.get("PARALLEL_FRAGMENT_TESTS", "false").lower() == "true":
150+
with ThreadPoolExecutor() as p:
151+
all_outs = p.map(FragTester(session, False), FRAGMENT_FILES)
151152

152-
output = "".join(all_outs)
153-
session.log(output)
153+
output = "".join(all_outs)
154+
session.log(output)
155+
else:
156+
tester = FragTester(session, False)
157+
for frag in FRAGMENT_FILES:
158+
session.log(tester(frag))
154159

155160

156161
@nox.session(python=ALL_PYTHON[1:])
@@ -166,11 +171,16 @@ def fragment_alternative_templates(session):
166171
)
167172
session.install("-e", ".")
168173

169-
with ThreadPoolExecutor() as p:
170-
all_outs = p.map(FragTester(session, True), FRAGMENT_FILES)
174+
if os.environ.get("PARALLEL_FRAGMENT_TESTS", "false").lower() == "true":
175+
with ThreadPoolExecutor() as p:
176+
all_outs = p.map(FragTester(session, True), FRAGMENT_FILES)
171177

172-
output = "".join(all_outs)
173-
session.log(output)
178+
output = "".join(all_outs)
179+
session.log(output)
180+
else:
181+
tester = FragTester(session, True)
182+
for frag in FRAGMENT_FILES:
183+
session.log(tester(frag))
174184

175185

176186
# TODO(yon-mg): -add compute context manager that includes rest transport

0 commit comments

Comments
 (0)