Skip to content

Commit f26dfc5

Browse files
committed
Adding support for queries in regression test.
This is an attempt port the gcloud-node regression tests for queries over to gcloud-python. This surfaced some API differences (i.e. issue #280) and some missing features (projection, offset and group_by). In addition, __eq__ was implemented on datastore.key.Key to allow for easy comparison within tests.
1 parent f74b0cf commit f26dfc5

File tree

3 files changed

+321
-19
lines changed

3 files changed

+321
-19
lines changed

CONTRIBUTING.rst

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,10 @@ Running Regression Tests
141141

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

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+
144148
- Regression tests will be run against an actual project and
145149
so you'll need to provide some environment variables to facilitate
146150
authentication to your project:
@@ -149,6 +153,9 @@ Running Regression Tests
149153
- ``GCLOUD_TESTS_CLIENT_EMAIL``: The email for the service account you're
150154
authenticating with
151155
- ``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.
152159

153160
- Examples of these can be found in ``regression/local_test_setup.sample``. We
154161
recommend copying this to ``regression/local_test_setup``, editing the values
@@ -160,6 +167,29 @@ Running Regression Tests
160167
absolute) on your system where the key file for your service account can
161168
be found.
162169

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+
163193
Test Coverage
164194
-------------
165195

regression/data/index.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
indexes:
2+
3+
- kind: Character
4+
properties:
5+
- name: family
6+
- name: appearances
7+
8+
- kind: Character
9+
properties:
10+
- name: name
11+
- name: family

0 commit comments

Comments
 (0)