Skip to content

Commit

Permalink
tests: speed up retry conformance tests (#655)
Browse files Browse the repository at this point in the history
* tests: speed up retry conf tests running in parallel

* update conftest readme

* update noxfile and comments

* check test session args

* lint
  • Loading branch information
cojenco committed Dec 10, 2021
1 parent b841482 commit ee41b3f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 10 deletions.
26 changes: 16 additions & 10 deletions noxfile.py
Expand Up @@ -154,24 +154,30 @@ def system(session):
@nox.session(python=CONFORMANCE_TEST_PYTHON_VERSIONS)
def conftest_retry(session):
"""Run the retry conformance test suite."""
conformance_test_path = os.path.join("tests", "conformance.py")
conformance_test_folder_path = os.path.join("tests", "conformance")
conformance_test_exists = os.path.exists(conformance_test_path)
conformance_test_folder_exists = os.path.exists(conformance_test_folder_path)
# Environment check: only run tests if found.
if not conformance_test_exists and not conformance_test_folder_exists:
if not conformance_test_folder_exists:
session.skip("Conformance tests were not found")

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

# Run #CPU processes in parallel if no test session arguments are passed in.
if session.posargs:
test_cmd = [
"py.test",
"--quiet",
conformance_test_folder_path,
*session.posargs,
]
else:
test_cmd = ["py.test", "-n", "auto", "--quiet", conformance_test_folder_path]

# Run py.test against the conformance tests.
if conformance_test_exists:
session.run("py.test", "--quiet", conformance_test_path, *session.posargs)
if conformance_test_folder_exists:
session.run(
"py.test", "--quiet", conformance_test_folder_path, *session.posargs
)
session.run(*test_cmd)


@nox.session(python=DEFAULT_PYTHON_VERSION)
Expand Down
Expand Up @@ -27,3 +27,11 @@ To run the test suite locally:
```bash
nox -s conftest_retry-3.8
```

To run a single test locally:

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`

```bash
nox -re conftest_retry-3.8 -- -k <single_test_name>
```

0 comments on commit ee41b3f

Please sign in to comment.