Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow positional arguments tox -e system-tests. #2304

Merged
merged 1 commit into from
Sep 12, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)

This comment was marked as spam.

This comment was marked as spam.

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