Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit be34f45

Browse files
author
Douglas Greiman
authored
Test cleanups and fixes (GoogleCloudPlatform#179)
* Separate Google Cloud Client Library tests from other tests. Use the --client_test flag to build.sh to run them. * Fix test failure with google-cloud-dlp. See googleapis/google-cloud-python#4924 Also add better logging of exactly which files experience failures. * Remove system test which is redundant with the integration test. * Fix punctuation.
1 parent 1a69141 commit be34f45

File tree

8 files changed

+41
-104
lines changed

8 files changed

+41
-104
lines changed

build.sh

Lines changed: 15 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ set -euo pipefail
1919
# Actions
2020
benchmark=0 # Should run benchmarks?
2121
build=0 # Should build images?
22-
system_test=0 # Should run system tests?
22+
client_test=0 # Should run Google Cloud Client Library tests
2323
test=0 # Should run standard test suite?
2424

2525
local=0 # Should run using local Docker daemon instead of GCR?
@@ -42,8 +42,8 @@ Options:
4242
--[no]benchmark: Run benchmarking suite (default false)
4343
--[no]build: Build all images (default true if no options set)
4444
--[no]test: Run basic tests (default true if no options set)
45+
--[no]client_test: Run Google Cloud Client Library tests (default false)
4546
--[no]local: Build images using local Docker daemon (default false)
46-
--[no]system_test: Run system tests (default false)
4747
"
4848
}
4949

@@ -90,20 +90,20 @@ while [ $# -gt 0 ]; do
9090
build=0
9191
shift
9292
;;
93-
--local)
94-
local=1
93+
--client_test)
94+
client_test=1
9595
shift
9696
;;
97-
--nolocal)
98-
local=0
97+
--noclient_test)
98+
client_test=0
9999
shift
100100
;;
101-
--system_test)
102-
system_test=1
101+
--local)
102+
local=1
103103
shift
104104
;;
105-
--nosystem_test)
106-
system_test=0
105+
--nolocal)
106+
local=0
107107
shift
108108
;;
109109
--test)
@@ -123,7 +123,7 @@ done
123123
# If no actions chosen, then tell the user
124124
if [ "${benchmark}" -eq 0 -a \
125125
"${build}" -eq 0 -a \
126-
"${system_test}" -eq 0 -a \
126+
"${client_test}" -eq 0 -a \
127127
"${test}" -eq 0 \
128128
]; then
129129
echo 'No actions specified, defaulting to --build --test'
@@ -136,17 +136,6 @@ if [ "${local}" -eq 1 ]; then
136136
gcloud_cmd="${local_gcloud_cmd}"
137137
fi
138138

139-
# Read action-specific environment variables
140-
if [ "${system_test}" -eq 1 ]; then
141-
if [ -z "${GOOGLE_APPLICATION_CREDENTIALS_FOR_TESTS+set}" ] ; then
142-
fatal 'Error: $GOOGLE_APPLICATION_CREDENTIALS_FOR_TESTS is not set; invoke with something like GOOGLE_APPLICATION_CREDENTIALS_FOR_TESTS=/path/to/service/account/creds.json'
143-
fi
144-
145-
if [ -z "${GOOGLE_CLOUD_PROJECT_FOR_TESTS+set}" ] ; then
146-
fatal 'Error: $GOOGLE_CLOUD_PROJECT_FOR_TESTS is not set; invoke with something like GOOGLE_CLOUD_PROJECT_FOR_TESTS=YOUR-PROJECT-NAME'
147-
fi
148-
fi
149-
150139
# Use latest released Debian as our base image
151140
export DEBIAN_BASE_IMAGE="gcr.io/google-appengine/debian8:latest"
152141
export STAGING_IMAGE="${DOCKER_NAMESPACE}/python:${TAG}"
@@ -160,7 +149,6 @@ for outfile in \
160149
tests/benchmark/Dockerfile \
161150
tests/eventlet/Dockerfile \
162151
tests/google-cloud-python/Dockerfile \
163-
tests/google-cloud-python-system/Dockerfile \
164152
tests/integration/Dockerfile \
165153
; do
166154
envsubst <"${outfile}".in >"${outfile}" \
@@ -192,14 +180,10 @@ if [ "${test}" -eq 1 ]; then
192180
${gcloud_cmd} --config cloudbuild_test.yaml --substitutions "${substitutions}"
193181
fi
194182

195-
# Run system tests
196-
if [ "${system_test}" -eq 1 ]; then
197-
echo "Running system tests using project ${GOOGLE_CLOUD_PROJECT_FOR_TESTS}"
198-
199-
trap "rm -f tests/google-cloud-python-system/credentials.json" EXIT
200-
cp "${GOOGLE_APPLICATION_CREDENTIALS_FOR_TESTS}" tests/google-cloud-python-system/credentials.json
201-
${gcloud_cmd} --config cloudbuild_system_test.yaml --substitutions "${substitutions}"
202-
rm -f tests/google-cloud-python-system/credentials.json
183+
# Run client library tests
184+
if [ "${client_test}" -eq 1 ]; then
185+
echo "Testing compatibility with Google Cloud Client Libraries"
186+
${gcloud_cmd} --config cloudbuild_client_test.yaml --substitutions "${substitutions}"
203187
fi
204188

205189
# Run benchmarks

cloudbuild_client_test.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
timeout: 3600s
2+
steps:
3+
- # Build image to run google client library unit tests
4+
name: gcr.io/cloud-builders/docker:latest
5+
args: ['build', '--tag=${_DOCKER_NAMESPACE}/python/tests/google-cloud-python:${_TAG}',
6+
'--no-cache', '/workspace/tests/google-cloud-python/']
7+
- # Run google client library unit tests
8+
name: ${_DOCKER_NAMESPACE}/python/tests/google-cloud-python:${_TAG}
9+
images: []

cloudbuild_system_test.yaml

Lines changed: 0 additions & 9 deletions
This file was deleted.

cloudbuild_test.yaml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,4 @@ steps:
3737
name: gcr.io/cloud-builders/docker:latest
3838
args: ['build', '--tag=${_DOCKER_NAMESPACE}/python/tests/eventlet:${_TAG}',
3939
'--no-cache', '/workspace/tests/eventlet/']
40-
- # Build image to run google client library unit tests
41-
name: gcr.io/cloud-builders/docker:latest
42-
args: ['build', '--tag=${_DOCKER_NAMESPACE}/python/tests/google-cloud-python:${_TAG}',
43-
'--no-cache', '/workspace/tests/google-cloud-python/']
44-
- # Run google client library unit tests
45-
name: ${_DOCKER_NAMESPACE}/python/tests/google-cloud-python:${_TAG}
4640
images: []

tests/google-cloud-python-system/.gitignore

Lines changed: 0 additions & 2 deletions
This file was deleted.

tests/google-cloud-python-system/Dockerfile.in

Lines changed: 0 additions & 16 deletions
This file was deleted.

tests/google-cloud-python-system/run_system_tests.sh

Lines changed: 0 additions & 39 deletions
This file was deleted.

tests/google-cloud-python/run_unit_tests.sh

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,31 @@ set -eu
44
cd /app/google-cloud-python
55

66
exit_code=0
7+
failed_files=
78
for noxfile in */nox.py; do
9+
if [ "${noxfile}" = "dlp/nox.py" ]; then
10+
echo "**** Skipping ${noxfile} ****"
11+
continue
12+
fi
13+
echo "**** Starting tests in ${noxfile} ****"
814
nox \
915
-f "${noxfile}" \
1016
-e \
1117
"unit(py='2.7')" \
1218
"unit(py='3.4')" \
1319
"unit(py='3.5')" \
1420
"unit(py='3.6')" \
15-
|| exit_code=1
21+
|| {
22+
echo "**** FAILED tests in ${noxfile} ****"
23+
exit_code=1
24+
failed_files="${failed_files} ${noxfile}"
25+
}
26+
echo "**** Finished tests in ${noxfile} ****"
1627
done
1728

29+
if [ "${exit_code}" -eq 0 ]; then
30+
echo "**** All tests passed ****"
31+
else
32+
echo "**** There were test failures:${failed_files} ****"
33+
fi
1834
exit "${exit_code}"

0 commit comments

Comments
 (0)