|
19 | 19 | from __future__ import absolute_import |
20 | 20 | import os |
21 | 21 | import pathlib |
| 22 | +import re |
22 | 23 | import shutil |
23 | 24 | import warnings |
24 | 25 |
|
@@ -190,7 +191,9 @@ def unit(session): |
190 | 191 | def install_systemtest_dependencies(session, *constraints): |
191 | 192 |
|
192 | 193 | # Use pre-release gRPC for system tests. |
193 | | - session.install("--pre", "grpcio") |
| 194 | + # Exclude version 1.49.0rc1 which has a known issue. |
| 195 | + # See https://github.com/grpc/grpc/pull/30642 |
| 196 | + session.install("--pre", "grpcio!=1.49.0rc1") |
194 | 197 |
|
195 | 198 | session.install(*SYSTEM_TEST_STANDARD_DEPENDENCIES, *constraints) |
196 | 199 |
|
@@ -326,3 +329,94 @@ def docfx(session): |
326 | 329 | os.path.join("docs", ""), |
327 | 330 | os.path.join("docs", "_build", "html", ""), |
328 | 331 | ) |
| 332 | + |
| 333 | + |
| 334 | +@nox.session(python=SYSTEM_TEST_PYTHON_VERSIONS) |
| 335 | +def prerelease_deps(session): |
| 336 | + """Run all tests with prerelease versions of dependencies installed.""" |
| 337 | + |
| 338 | + # Install all dependencies |
| 339 | + session.install("-e", ".[all, tests, tracing]") |
| 340 | + unit_deps_all = UNIT_TEST_STANDARD_DEPENDENCIES + UNIT_TEST_EXTERNAL_DEPENDENCIES |
| 341 | + session.install(*unit_deps_all) |
| 342 | + system_deps_all = ( |
| 343 | + SYSTEM_TEST_STANDARD_DEPENDENCIES |
| 344 | + + SYSTEM_TEST_EXTERNAL_DEPENDENCIES |
| 345 | + + SYSTEM_TEST_EXTRAS |
| 346 | + ) |
| 347 | + session.install(*system_deps_all) |
| 348 | + |
| 349 | + # Because we test minimum dependency versions on the minimum Python |
| 350 | + # version, the first version we test with in the unit tests sessions has a |
| 351 | + # constraints file containing all dependencies and extras. |
| 352 | + with open( |
| 353 | + CURRENT_DIRECTORY |
| 354 | + / "testing" |
| 355 | + / f"constraints-{UNIT_TEST_PYTHON_VERSIONS[0]}.txt", |
| 356 | + encoding="utf-8", |
| 357 | + ) as constraints_file: |
| 358 | + constraints_text = constraints_file.read() |
| 359 | + |
| 360 | + # Ignore leading whitespace and comment lines. |
| 361 | + constraints_deps = [ |
| 362 | + match.group(1) |
| 363 | + for match in re.finditer( |
| 364 | + r"^\s*(\S+)(?===\S+)", constraints_text, flags=re.MULTILINE |
| 365 | + ) |
| 366 | + ] |
| 367 | + |
| 368 | + session.install(*constraints_deps) |
| 369 | + |
| 370 | + prerel_deps = [ |
| 371 | + "protobuf", |
| 372 | + # dependency of grpc |
| 373 | + "six", |
| 374 | + "googleapis-common-protos", |
| 375 | + # Exclude version 1.49.0rc1 which has a known issue. See https://github.com/grpc/grpc/pull/30642 |
| 376 | + "grpcio!=1.49.0rc1", |
| 377 | + "grpcio-status", |
| 378 | + "google-api-core", |
| 379 | + "proto-plus", |
| 380 | + "google-cloud-testutils", |
| 381 | + # dependencies of google-cloud-testutils" |
| 382 | + "click", |
| 383 | + ] |
| 384 | + |
| 385 | + for dep in prerel_deps: |
| 386 | + session.install("--pre", "--no-deps", "--upgrade", dep) |
| 387 | + |
| 388 | + # Remaining dependencies |
| 389 | + other_deps = [ |
| 390 | + "requests", |
| 391 | + "google-auth", |
| 392 | + ] |
| 393 | + session.install(*other_deps) |
| 394 | + |
| 395 | + # Print out prerelease package versions |
| 396 | + session.run( |
| 397 | + "python", "-c", "import google.protobuf; print(google.protobuf.__version__)" |
| 398 | + ) |
| 399 | + session.run("python", "-c", "import grpc; print(grpc.__version__)") |
| 400 | + |
| 401 | + session.run("py.test", "tests/unit") |
| 402 | + |
| 403 | + system_test_path = os.path.join("tests", "system.py") |
| 404 | + system_test_folder_path = os.path.join("tests", "system") |
| 405 | + |
| 406 | + # Only run system tests if found. |
| 407 | + if os.path.exists(system_test_path): |
| 408 | + session.run( |
| 409 | + "py.test", |
| 410 | + "--verbose", |
| 411 | + f"--junitxml=system_{session.python}_sponge_log.xml", |
| 412 | + system_test_path, |
| 413 | + *session.posargs, |
| 414 | + ) |
| 415 | + if os.path.exists(system_test_folder_path): |
| 416 | + session.run( |
| 417 | + "py.test", |
| 418 | + "--verbose", |
| 419 | + f"--junitxml=system_{session.python}_sponge_log.xml", |
| 420 | + system_test_folder_path, |
| 421 | + *session.posargs, |
| 422 | + ) |
0 commit comments