-
Notifications
You must be signed in to change notification settings - Fork 6.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #178 from GoogleCloudPlatform/testing-project
gigantic re-organization of tests.
- Loading branch information
Showing
108 changed files
with
766 additions
and
848 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,27 @@ | ||
sudo: false | ||
#add language, etc. here | ||
language: python | ||
|
||
services: | ||
- memcached | ||
- mysql | ||
branches: | ||
only: | ||
- master | ||
|
||
- master | ||
cache: | ||
directories: | ||
- $HOME/.cache | ||
|
||
env: | ||
global: | ||
- PATH=${PATH}:${HOME}/gcloud/google-cloud-sdk/bin | ||
- GOOGLE_APPLICATION_CREDENTIALS=${TRAVIS_BUILD_DIR}/python-docs-samples.json | ||
- GOOGLE_APPLICATION_CREDENTIALS=${TRAVIS_BUILD_DIR}/testing/resources/service-account.json | ||
- GAE_PYTHONPATH=${HOME}/.cache/google_appengine | ||
- TEST_BUCKET_NAME=bigquery-devrel-samples-bucket | ||
- TEST_PROJECT_ID=bigquery-devrel-samples | ||
|
||
- secure: YIowCOMJ97rTcehKVT6Gi3u0Etm8s9+TBRGsNPJLgSF2zZdsh9IHcIc+tMDUMR3lpOe8y2a060RuODQcRsW1W1LIHej+ZE/gv6vATT6qNA3eKfKmZ9AyrpBO0fTOHlHrGBuU9ktBPR+iqvnq8MLWjnUozPFMJbuNBFITU7JP8jc= | ||
before_install: | ||
- tests/scripts/travis-before-install.sh | ||
|
||
- openssl aes-256-cbc -k "$secrets_password" -in secrets.tar.enc -out secrets.tar -d | ||
- tar xvf secrets.tar | ||
install: | ||
# TODO: unpin tox when the following issue is fixed | ||
# https://bitbucket.org/hpk42/tox/issues/285/tox-220-breaks-some-toxini-config-files | ||
- pip install tox | ||
|
||
- pip install -e git+https://github.com/GoogleCloudPlatform/python-repo-tools#egg=python-repo-tools | ||
- gcp-python-repo-tools download-appengine-sdk `dirname "${GAE_PYTHONPATH}"` | ||
script: | ||
- source ${TRAVIS_BUILD_DIR}/testing/resources/test-env.sh | ||
- tox | ||
|
||
# Coveralls is disabled in travis because travis does not run all of our | ||
# tests. The full suite of tests is run on an internal Jenkins instance. | ||
# after_success: | ||
# - coveralls |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
# Testing | ||
|
||
The tests in this repository are system tests and run against live services, therefore, it takes a bit of configuration to run all of the tests locally. | ||
|
||
Before you can run tests locally you must have: | ||
|
||
* The latest [tox](https://tox.readthedocs.org/en/latest/), | ||
[pip](https://pypi.python.org/pypi/pip), and [gcp-python-repo-tools](https://pypi.python.org/pypi/gcp-python-repo-tools) installed. | ||
|
||
$ sudo pip install --upgrade tox pip gcp-python-repo-tools | ||
|
||
* The [Google Cloud SDK](https://cloud.google.com/sdk/) installed. You | ||
can do so with the following command: | ||
|
||
$ curl https://sdk.cloud.google.com | bash | ||
|
||
## Preparing a project for testing | ||
|
||
Most tests require you to have an active, billing-enabled project on the | ||
[Google Cloud Console](https://console.cloud.google.com). | ||
|
||
### Creating resources | ||
|
||
Some resources need to be created in a project ahead of time before testing. We have a script that can create everything needed: | ||
|
||
gcloud config set project <your-project-id> | ||
scripts/prepare-testing-project.sh | ||
|
||
The script will also instruct you to follow a URL to enable APIs. You will need to do that. | ||
|
||
### Getting a service account key | ||
|
||
From the Cloud Console, create a new Service Account and download its json key. Place this file in `testing/resources/service-account.json`. | ||
|
||
## Environment variables | ||
|
||
* Copy `testing/resources/test-env.tmpl.sh` to `testing/resources/test-env.sh`, and updated it with your configuration. | ||
* Run `source testing/resources/test-env.sh`. | ||
* Run `export GOOGLE_APPLICATION_CREDENTIALS=testing/resources/service-account.json`. | ||
|
||
If you want to run the Google App Engine tests, you will need: | ||
|
||
* The App Engine Python SDK. You can also download it programatically with `gcp-python-repo-tools`: | ||
|
||
$ gcp-python-repo-tools download-appengine-sdk <dest> | ||
|
||
* Set the `GAE_PYTHONPATH` variable: | ||
|
||
$ export GAE_PYTHONPATH=<path your AppeEngine sdk> | ||
|
||
### Test environments | ||
|
||
We use [tox](https://tox.readthedocs.org/en/latest/) to configure | ||
multiple python environments: | ||
|
||
* ``py27`` and ``py34`` contains tests for samples that run in a normal Python 2.7 pr 3.4 environment. This is everything outside of the ``appengine`` directory that isn't slow or flaky. | ||
* ``py27-all`` and ``py34-all`` runs all tests except for App Engine tests. This can time some time and some tests are flaky. | ||
* ``gae`` contains tests for samples that run only in Google App Engine. This is (mostly) everything in the ``appengine`` directory. | ||
* ``pep8`` just runs the linter. | ||
|
||
To run tests for a particular environment, invoke tox with the ``-e`` | ||
flag: | ||
|
||
tox -e py27 | ||
|
||
To run one particular test suite or provide additional parameters to | ||
``nose``, invoke tox like this: | ||
|
||
toxe -e py27 -- storage/tests/test_list_objects.py | ||
|
||
### Adding new tests | ||
|
||
When adding a new top-level directory, be sure to edit ``.coveragerc`` | ||
to include it in coveralls. | ||
|
||
To add new tests that require Google App Engine, please place them in | ||
the ``appengine`` directory if possible. If you place them elsewhere, | ||
you will need to modify ``tox.ini`` to make the environments | ||
appropriately run or ignore your test. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.