Skip to content

Commit d094d30

Browse files
committed
Merge pull request #281 from dhermes/functional-test-part2
Functional test - Add datastore query tests
2 parents 560cae1 + 4af407a commit d094d30

11 files changed

Lines changed: 448 additions & 69 deletions

.travis.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ script:
88
- tox -e py26
99
- tox -e py27
1010
- tox -e lint
11+
- tox -e regression
1112
after_success:
1213
- tox -e cover
1314
- coveralls
14-
- scripts/merge.sh
15+
- scripts/update_docs.sh

CONTRIBUTING.rst

Lines changed: 67 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Contributing
33

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

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

1717
- While logged into your GitHub account, navigate to the gcloud-python repo on
1818
GitHub.
19-
19+
2020
https://github.com/GoogleCloudPlatform/gcloud-python
2121

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

133+
Running Regression Tests
134+
------------------------
135+
136+
- To run regression tests you can execute::
137+
138+
$ tox -e regression
139+
140+
or run only regression tests for a particular package via::
141+
142+
$ python regression/run_regression.py --package {package}
143+
144+
This alone will not run the tests. You'll need to change some local
145+
auth settings and change some configuration in your project to
146+
run all the tests.
147+
148+
- Regression tests will be run against an actual project and
149+
so you'll need to provide some environment variables to facilitate
150+
authentication to your project:
151+
152+
- ``GCLOUD_TESTS_DATASET_ID``: The name of the dataset your tests connect to.
153+
- ``GCLOUD_TESTS_CLIENT_EMAIL``: The email for the service account you're
154+
authenticating with
155+
- ``GCLOUD_TESTS_KEY_FILE``: The path to an encrypted key file.
156+
See private key
157+
`docs <https://cloud.google.com/storage/docs/authentication#generating-a-private-key>`__
158+
for explanation on how to get a private key.
159+
160+
- Examples of these can be found in ``regression/local_test_setup.sample``. We
161+
recommend copying this to ``regression/local_test_setup``, editing the values
162+
and sourcing them into your environment::
163+
164+
$ source regression/local_test_setup
165+
166+
- The ``GCLOUD_TESTS_KEY_FILE`` value should point to a valid path (relative or
167+
absolute) on your system where the key file for your service account can
168+
be found.
169+
170+
- For datastore tests, you'll need to create composite
171+
`indexes <https://cloud.google.com/datastore/docs/tools/indexconfig>`__
172+
with the ``gcloud`` command line
173+
`tool <https://developers.google.com/cloud/sdk/gcloud/>`__::
174+
175+
# Install the app (App Engine Command Line Interface) component.
176+
$ gcloud components update app
177+
178+
# See https://cloud.google.com/sdk/crypto for details on PyOpenSSL and
179+
# http://stackoverflow.com/a/25067729/1068170 for why we must persist.
180+
$ export CLOUDSDK_PYTHON_SITEPACKAGES=1
181+
182+
# Authenticate the gcloud tool with your account.
183+
$ gcloud auth activate-service-account $GCLOUD_TESTS_CLIENT_EMAIL \
184+
> --key-file=$GCLOUD_TESTS_KEY_FILE
185+
186+
# Create the indexes
187+
$ gcloud preview datastore create-indexes regression/data/ \
188+
> --project=$GCLOUD_TESTS_DATASET_ID
189+
190+
# Restore your environment to its previous state.
191+
$ unset CLOUDSDK_PYTHON_SITEPACKAGES
192+
193+
- For datastore query tests, you'll need stored data in your dataset.
194+
To populate this data, run::
195+
196+
$ python regression/populate_datastore.py
133197

134198
Test Coverage
135199
-------------
@@ -184,4 +248,4 @@ Before we can accept your pull requests you'll need to sign a Contributor Licens
184248
- **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>`__.
185249
- **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>`__.
186250

187-
You can sign these electronically (just scroll to the bottom). After that, we'll be able to accept your pull requests.
251+
You can sign these electronically (just scroll to the bottom). After that, we'll be able to accept your pull requests.

regression/data/index.yaml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
indexes:
2+
3+
- kind: Character
4+
ancestor: yes
5+
properties:
6+
- name: appearances
7+
8+
- kind: Character
9+
ancestor: yes
10+
properties:
11+
- name: alive
12+
13+
- kind: Character
14+
ancestor: yes
15+
properties:
16+
- name: family
17+
- name: appearances
18+
19+
- kind: Character
20+
ancestor: yes
21+
properties:
22+
- name: name
23+
- name: family

0 commit comments

Comments
 (0)