Skip to content

Commit ee41b3f

Browse files
authored
tests: speed up retry conformance tests (#655)
* tests: speed up retry conf tests running in parallel * update conftest readme * update noxfile and comments * check test session args * lint
1 parent b841482 commit ee41b3f

File tree

2 files changed

+24
-10
lines changed

2 files changed

+24
-10
lines changed

noxfile.py

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -154,24 +154,30 @@ def system(session):
154154
@nox.session(python=CONFORMANCE_TEST_PYTHON_VERSIONS)
155155
def conftest_retry(session):
156156
"""Run the retry conformance test suite."""
157-
conformance_test_path = os.path.join("tests", "conformance.py")
158157
conformance_test_folder_path = os.path.join("tests", "conformance")
159-
conformance_test_exists = os.path.exists(conformance_test_path)
160158
conformance_test_folder_exists = os.path.exists(conformance_test_folder_path)
161159
# Environment check: only run tests if found.
162-
if not conformance_test_exists and not conformance_test_folder_exists:
160+
if not conformance_test_folder_exists:
163161
session.skip("Conformance tests were not found")
164162

165-
session.install("pytest",)
163+
# Install all test dependencies and pytest plugin to run tests in parallel.
164+
# Then install this package in-place.
165+
session.install("pytest", "pytest-xdist")
166166
session.install("-e", ".")
167167

168+
# Run #CPU processes in parallel if no test session arguments are passed in.
169+
if session.posargs:
170+
test_cmd = [
171+
"py.test",
172+
"--quiet",
173+
conformance_test_folder_path,
174+
*session.posargs,
175+
]
176+
else:
177+
test_cmd = ["py.test", "-n", "auto", "--quiet", conformance_test_folder_path]
178+
168179
# Run py.test against the conformance tests.
169-
if conformance_test_exists:
170-
session.run("py.test", "--quiet", conformance_test_path, *session.posargs)
171-
if conformance_test_folder_exists:
172-
session.run(
173-
"py.test", "--quiet", conformance_test_folder_path, *session.posargs
174-
)
180+
session.run(*test_cmd)
175181

176182

177183
@nox.session(python=DEFAULT_PYTHON_VERSION)

tests/conformance/retry_conformance_testing.md renamed to tests/conformance/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,11 @@ To run the test suite locally:
2727
```bash
2828
nox -s conftest_retry-3.8
2929
```
30+
31+
To run a single test locally:
32+
33+
Single test names are displayed as "test-S{scenario_id}-{method}-{client-library-method-name}-{instructions index}", such as `test-S1-storage.buckets.get-bucket_reload-1`
34+
35+
```bash
36+
nox -re conftest_retry-3.8 -- -k <single_test_name>
37+
```

0 commit comments

Comments
 (0)