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

Functional test - Add datastore query tests #281

Merged
merged 5 commits into from
Oct 27, 2014
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
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ script:
- tox -e py26
- tox -e py27
- tox -e lint
- tox -e regression
after_success:
- tox -e cover
- coveralls
- scripts/merge.sh
- scripts/update_docs.sh
70 changes: 67 additions & 3 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Contributing

#. **Please sign one of the contributor license agreements below.**
#. Fork the repo, develop and test your code changes, add docs.
#. Make sure that your commit messages clearly describe the changes.
#. Make sure that your commit messages clearly describe the changes.
#. Send a pull request.

Here are some guidelines for hacking on gcloud-python.
Expand All @@ -16,7 +16,7 @@ using a Git checkout:

- While logged into your GitHub account, navigate to the gcloud-python repo on
GitHub.

https://github.com/GoogleCloudPlatform/gcloud-python

- Fork and clone the gcloud-python repository to your GitHub account by
Expand Down Expand Up @@ -130,6 +130,70 @@ Running Tests
$ cd ~/hack-on-gcloud/
$ /usr/bin/tox

Running Regression Tests
------------------------

- To run regression tests you can execute::

$ tox -e regression

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

$ python regression/run_regression.py --package {package}

This alone will not run the tests. You'll need to change some local
auth settings and change some configuration in your project to
run all the tests.

- Regression tests will be run against an actual project and
so you'll need to provide some environment variables to facilitate
authentication to your project:

- ``GCLOUD_TESTS_DATASET_ID``: The name of the dataset your tests connect to.
- ``GCLOUD_TESTS_CLIENT_EMAIL``: The email for the service account you're
authenticating with
- ``GCLOUD_TESTS_KEY_FILE``: The path to an encrypted key file.
See private key
`docs <https://cloud.google.com/storage/docs/authentication#generating-a-private-key>`__
for explanation on how to get a private key.

- Examples of these can be found in ``regression/local_test_setup.sample``. We
recommend copying this to ``regression/local_test_setup``, editing the values
and sourcing them into your environment::

$ source regression/local_test_setup

- The ``GCLOUD_TESTS_KEY_FILE`` value should point to a valid path (relative or
absolute) on your system where the key file for your service account can
be found.

- For datastore tests, you'll need to create composite
`indexes <https://cloud.google.com/datastore/docs/tools/indexconfig>`__
with the ``gcloud`` command line
`tool <https://developers.google.com/cloud/sdk/gcloud/>`__::

# Install the app (App Engine Command Line Interface) component.
$ gcloud components update app

# See https://cloud.google.com/sdk/crypto for details on PyOpenSSL and
# http://stackoverflow.com/a/25067729/1068170 for why we must persist.
$ export CLOUDSDK_PYTHON_SITEPACKAGES=1

# Authenticate the gcloud tool with your account.
$ gcloud auth activate-service-account $GCLOUD_TESTS_CLIENT_EMAIL \
> --key-file=$GCLOUD_TESTS_KEY_FILE

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

# Create the indexes
$ gcloud preview datastore create-indexes regression/data/ \
> --project=$GCLOUD_TESTS_DATASET_ID

# Restore your environment to its previous state.
$ unset CLOUDSDK_PYTHON_SITEPACKAGES

- For datastore query tests, you'll need stored data in your dataset.
To populate this data, run::

$ python regression/populate_datastore.py

This comment was marked as spam.

This comment was marked as spam.


Test Coverage
-------------
Expand Down Expand Up @@ -184,4 +248,4 @@ Before we can accept your pull requests you'll need to sign a Contributor Licens
- **If you are an individual writing original source code** and **you own the intellectual property**, then you'll need to sign an `individual CLA <https://developers.google.com/open-source/cla/individual>`__.
- **If you work for a company that wants to allow you to contribute your work**, then you'll need to sign a `corporate CLA <https://developers.google.com/open-source/cla/corporate>`__.

You can sign these electronically (just scroll to the bottom). After that, we'll be able to accept your pull requests.
You can sign these electronically (just scroll to the bottom). After that, we'll be able to accept your pull requests.
23 changes: 23 additions & 0 deletions regression/data/index.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
indexes:

- kind: Character
ancestor: yes
properties:
- name: appearances

- kind: Character
ancestor: yes
properties:
- name: alive

- kind: Character
ancestor: yes
properties:
- name: family
- name: appearances

- kind: Character
ancestor: yes
properties:
- name: name
- name: family
Loading