Skip to content

Commit

Permalink
Merge pull request googleapis#2304 from dhermes/fix-2300
Browse files Browse the repository at this point in the history
Allow positional arguments tox -e system-tests.
  • Loading branch information
dhermes authored Sep 12, 2016
2 parents 71228f7 + 6229b71 commit 1537d4a
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 8 deletions.
8 changes: 8 additions & 0 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,17 @@ Running System Tests
- To run system tests you can execute::

$ tox -e system-tests
$ tox -e system-tests3

or run only system tests for a particular package via::

$ python system_tests/run_system_test.py --package {package}
$ python3 system_tests/run_system_test.py --package {package}

To run a subset of the system tests::

$ tox -e system-tests -- datastore storage
$ python system_tests/attempt_system_tests.py datastore storage

This alone will not run the tests. You'll need to change some local
auth settings and change some configuration in your project to
Expand Down Expand Up @@ -243,6 +250,7 @@ Running System Tests
- To run the system tests with the ``pubsub`` emulator::

$ tox -e pubsub-emulator
$ GOOGLE_CLOUD_DISABLE_GRPC=true tox -e pubsub-emulator

If you'd like to run them directly (outside of a ``tox`` environment), first
start the emulator and take note of the process ID::
Expand Down
47 changes: 44 additions & 3 deletions system_tests/attempt_system_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
"""


from __future__ import print_function
import argparse
import os
import subprocess
import sys
Expand All @@ -54,6 +56,7 @@
from run_system_test import run_module_tests


BIGTABLE_API = 'bigtable'
MODULES = ( # ordered from most to least stable
'datastore',
'storage',
Expand All @@ -63,15 +66,15 @@
'logging',
'translate',
'monitoring',
BIGTABLE_API,
)
if sys.version_info[:2] == (2, 7):
MODULES += ('bigtable',)

SCRIPTS_DIR = os.path.dirname(__file__)
ROOT_DIR = os.path.abspath(os.path.join(SCRIPTS_DIR, '..'))
ENCRYPTED_KEYFILE = os.path.join(ROOT_DIR, 'system_tests', 'key.json.enc')
ENCRYPTED_KEY_ENV = 'encrypted_c16407eb06cc_key'
ENCRYPTED_INIT_VECTOR_ENV = 'encrypted_c16407eb06cc_iv'
ALL_MODULES = object() # Sentinel for argparser


def check_environment():
Expand Down Expand Up @@ -136,11 +139,49 @@ def prepare_to_run():
decrypt_keyfile()


def get_parser():
"""Get an argument parser to determine a list of packages."""
parser = argparse.ArgumentParser(
description='google-cloud tests runner.')
help_msg = ('List of packages to be tested. '
'If left blank, tests all packages.')
parser.add_argument('packages', nargs='*',
default=ALL_MODULES, help=help_msg)
return parser


def get_modules():
"""Get the list of modules names to run system tests for."""
parser = get_parser()
args = parser.parse_args()
if args.packages is ALL_MODULES:
result = list(MODULES)
if sys.version_info[:2] != (2, 7):
result.remove(BIGTABLE_API)
else:
result = []
invalid = []
for package in args.packages:
if package in MODULES:
result.append(package)
else:
invalid.append(package)

if invalid:
msg = 'No system test for packages: ' + ', '.join(invalid)
print(msg, file=sys.stderr)
sys.exit(1)

return result


def main():
"""Run all the system tests if necessary."""
prepare_to_run()

failed_modules = 0
for module in MODULES:
modules = get_modules()
for module in modules:
try:
run_module_tests(module)
except FailedSystemTestModule:
Expand Down
15 changes: 10 additions & 5 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ passenv = {[testenv:system-tests]passenv}
basepython =
python2.7
commands =
python -c "import shutil; shutil.rmtree('docs/_build/json', ignore_errors=True)"
python -c \
"import shutil; shutil.rmtree('docs/_build/json', ignore_errors=True)"
{toxinidir}/scripts/update_json_docs.sh
deps =
parinx
Expand All @@ -78,7 +79,8 @@ passenv =
basepython =
python2.7
commands =
python -c "import shutil; shutil.rmtree('docs/_build', ignore_errors=True)"
python -c \
"import shutil; shutil.rmtree('docs/_build', ignore_errors=True)"
sphinx-build -W -b html -d docs/_build/doctrees docs docs/_build/html
python {toxinidir}/scripts/verify_included_modules.py --build-root _build
deps =
Expand All @@ -88,7 +90,10 @@ deps =
passenv = {[testenv:system-tests]passenv} SPHINX_RELEASE READTHEDOCS

[pep8]
exclude = docs/conf.py,google/cloud/bigtable/_generated*/*,google/cloud/datastore/_generated/*
exclude =
docs/conf.py,
google/cloud/bigtable/_generated*/*,
google/cloud/datastore/_generated/*
verbose = 1

[testenv:lint]
Expand All @@ -107,14 +112,14 @@ passenv = {[testenv:system-tests]passenv}
basepython =
python2.7
commands =
python {toxinidir}/system_tests/attempt_system_tests.py
python {toxinidir}/system_tests/attempt_system_tests.py {posargs}
passenv = GOOGLE_* GOOGLE_CLOUD_* TRAVIS* encrypted_*

[testenv:system-tests3]
basepython =
python3.4
commands =
python {toxinidir}/system_tests/attempt_system_tests.py
python {toxinidir}/system_tests/attempt_system_tests.py {posargs}
passenv = {[testenv:system-tests]passenv}

[testenv:datastore-emulator]
Expand Down

0 comments on commit 1537d4a

Please sign in to comment.