Skip to content

Commit 0b0b55e

Browse files
author
Jon Wayne Parrott
committed
Refactor the testing setup a little
Change-Id: I6466bcad2bd4b72d93aad3ba289dcfd68b30aaa8
1 parent 4c639cc commit 0b0b55e

12 files changed

+51
-23
lines changed

.travis.yml

+1-5
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,7 @@ cache:
1212
- $HOME/.cache
1313
env:
1414
global:
15-
- PATH=${PATH}:${HOME}/gcloud/google-cloud-sdk/bin
16-
- GOOGLE_APPLICATION_CREDENTIALS=${TRAVIS_BUILD_DIR}/testing/resources/service-account.json
17-
- GOOGLE_CLIENT_SECRETS=${TRAVIS_BUILD_DIR}/testing/resources/client-secrets.json
18-
- GAE_ROOT=${HOME}/.cache/
19-
- secure: f3aU0nf8ZBV2QfZ03oeqvR0f/JM69P/7IH3IGoBcRUWVIXXhQ6Esh9SmCUILPtis1ZKu11I9c+NDebZio7PFgTqfvLbKzAkrg0ucx+Bsyx6379/S1trbLeKunERSGA3GqK6+OCoR5q/9sKxNvlm/c/e9h7xZmPfP5W0qwVR/K0M=
15+
secure: V8kTaIK8NYMEUVzaekLoVgJzz5/9yA/KKL8CVgOmiPEjt1o1wAXy+ojyXCgjGmB16OOcTYKtXKvOBndDg99MxUzMc9uLrHF4ub2fJZy3ZoCfPaxHNOpIOTTAhB8J/nog/JpW5NnJOBGE8fAQ/TUy8nSvOwe27n4qKO5eWqTy5kA=
2016
addons:
2117
apt:
2218
sources:

TESTING.md

+10-11
Original file line numberDiff line numberDiff line change
@@ -46,27 +46,26 @@ The script will also instruct you to follow a URL to enable APIs. You will need
4646

4747
### Getting a service account key
4848

49-
From the Cloud Console, create a new Service Account and download its json key. Place this file in `testing/resources/service-account.json`.
49+
From the Cloud Console, create a new Service Account and download its json key. Place this file in `testing/service-account.json`.
5050

51-
Create a new OAuth client ID. Create a file `testing/resources/client-secrets.json` and write the `client_id` and `client_secret` to the file in the [Client Secrets JSON format](https://developers.google.com/api-client-library/python/guide/aaa_client_secrets).
51+
Create a new OAuth client ID. Create a file `testing/client-secrets.json` and write the `client_id` and `client_secret` to the file in the [Client Secrets JSON format](https://developers.google.com/api-client-library/python/guide/aaa_client_secrets).
5252

5353
## Environment variables
5454

55-
* Copy `testing/resources/test-env.tmpl.sh` to `testing/resources/test-env.sh`, and updated it with your configuration.
56-
* Run `source testing/resources/test-env.sh`.
57-
* Run `export GOOGLE_APPLICATION_CREDENTIALS=testing/resources/service-account.json`.
58-
* Run `export GOOGLE_CLIENT_SECRETS=testing/resources/client-secrets.json`.
55+
* Copy `testing/test-env.tmpl.sh` to `testing/test-env.sh`, and update it with your configuration.
56+
* Run `source testing/test-env.sh`.
57+
* Run `export GOOGLE_APPLICATION_CREDENTIALS=testing/service-account.json`.
58+
* Run `export GOOGLE_CLIENT_SECRETS=testing/client-secrets.json`.
5959

6060
### Test environments
6161

6262
We use [nox](https://nox.readthedocs.org/en/latest/) to configure
6363
multiple python sessions:
6464

65-
* ``tests`` contains tests for samples that run in a normal Python 2.7 or 3.4
66-
environment. This is everything outside of the ``appengine`` directory. It's
67-
parameterized to run all the tests using the 2.7 and 3.4 interpreters.
65+
* ``tests`` Run all the tests for every sample. It's parameterized to run all
66+
the tests using the 2.7 and 3.5 interpreters.
6867
* ``gae`` contains tests for samples that run only in Google App Engine. This is
69-
(mostly) everything in the ``appengine`` directory.
68+
everything in the ``appengine`` directory.
7069
* ``lint`` just runs the linter.
7170

7271
To see a list of the available sessions:
@@ -81,7 +80,7 @@ with the ``-s`` flag:
8180
To run one particular session or provide additional parameters to ``py.test``,
8281
invoke nox like this:
8382

84-
nox -s tests -- storage/api
83+
nox -s tests -- storage/cloud-client
8584

8685
### Adding new tests
8786
When adding a new top-level directory, be sure to edit ``.coveragerc`` to

scripts/README.md

100644100755
File mode changed.

scripts/decrypt-secrets.sh

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/bash
2+
3+
# Copyright 2015 Google Inc. All rights reserved.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
18+
ROOT=$( dirname "$DIR" )
19+
20+
# Work from the project root.
21+
cd $ROOT
22+
23+
openssl aes-256-cbc -k "$1" -in testing/secrets.tar.enc -out secrets.tar -d
24+
tar xvf secrets.tar
25+
rm secrets.tar

scripts/encrypt-secrets.sh

+10-4
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,17 @@
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
1616

17-
read -s -p "Enter password for encryption: " password
17+
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
18+
ROOT=$( dirname "$DIR" )
19+
20+
# Work from the project root.
21+
cd $ROOT
22+
23+
read -s -p "Enter password for encryption: " PASSWORD
1824
echo
1925

20-
tar cvf secrets.tar testing/resources/{service-account.json,client-secrets.json,test-env.sh}
21-
openssl aes-256-cbc -k "$password" -in secrets.tar -out secrets.tar.enc
26+
tar cvf secrets.tar testing/{service-account.json,client-secrets.json,test-env.sh}
27+
openssl aes-256-cbc -k "$PASSWORD" -in secrets.tar -out testing/secrets.tar.enc
2228
rm secrets.tar
2329

24-
travis encrypt "secrets_password=$password" --add
30+
travis encrypt "SECRETS_PASSWORD=$PASSWORD" --add --override

scripts/travis.sh

+2-3
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@
22

33
# Decrypt secrets if not on an external PR.
44
if [[ $TRAVIS_SECURE_ENV_VARS == "true" ]]; then
5-
openssl aes-256-cbc -k "$secrets_password" -in secrets.tar.enc -out secrets.tar -d;
6-
tar xvf secrets.tar;
5+
scripts/decrypt-secrets.sh "$SECRETS_PASSWORD"
76
fi
87

98
if [[ $TRAVIS_SECURE_ENV_VARS == "true" ]]; then
10-
source ${TRAVIS_BUILD_DIR}/testing/resources/test-env.sh;
9+
source ${TRAVIS_BUILD_DIR}/testing/test-env.sh;
1110
nox --stop-on-first-error -s lint travis;
1211
else
1312
# only run lint on external PRs

secrets.tar.enc

-9.53 KB
Binary file not shown.

testing/.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
test-env.sh
2+
service-account.json
3+
client-secrets.json
File renamed without changes.
File renamed without changes.

testing/secrets.tar.enc

9.53 KB
Binary file not shown.
File renamed without changes.

0 commit comments

Comments
 (0)