diff --git a/.kokoro/common.cfg b/.kokoro/common.cfg new file mode 100644 index 000000000..7dbafc200 --- /dev/null +++ b/.kokoro/common.cfg @@ -0,0 +1,13 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +# Download trampoline resources. These will be in ${KOKORO_GFILE_DIR} +gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline" + +# All builds use the trampoline script to run in docker. +build_file: "google-auth-library-python/.kokoro/trampoline.sh" + +# Use the Python worker docker iamge. +env_vars: { + key: "TRAMPOLINE_IMAGE" + value: "gcr.io/silver-python2/python-worker" +} diff --git a/.kokoro/system_tests.cfg b/.kokoro/system_tests.cfg new file mode 100644 index 000000000..aa3e6c6be --- /dev/null +++ b/.kokoro/system_tests.cfg @@ -0,0 +1,16 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +# Download secrets from Cloud Storage. +gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/google-auth-library-python" + +# Tell the trampoline which build file to use. +env_vars: { + key: "TRAMPOLINE_BUILD_FILE" + value: "github/google-auth-library-python/.kokoro/system_tests.sh" +} + +# Tell the system tests which Google Cloud project to use. +env_vars: { + key: "TEST_PROJECT" + value: "python-docs-samples-tests" +} diff --git a/.kokoro/system_tests.sh b/.kokoro/system_tests.sh new file mode 100755 index 000000000..29d509708 --- /dev/null +++ b/.kokoro/system_tests.sh @@ -0,0 +1,33 @@ +#!/bin/bash + +# Copyright 2017 Google Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -eo pipefail + +export PATH=${PATH}:${HOME}/gcloud/google-cloud-sdk/bin + +cd github/google-auth-library-python + +# Unencrypt and extract secrets +SECRETS_PASSWORD=$(cat "${KOKORO_GFILE_DIR}/secrets-password.txt") +./scripts/decrypt-secrets.sh "${SECRETS_PASSWORD}" + +# Setup gcloud, this is needed for the App Engine system test. +gcloud auth activate-service-account --key-file system_tests/data/service_account.json +gcloud config set project "${TEST_PROJECT}" + +# Run tests +tox -e py27-system +tox -e py36-system diff --git a/.kokoro/trampoline.sh b/.kokoro/trampoline.sh new file mode 100755 index 000000000..6e293e638 --- /dev/null +++ b/.kokoro/trampoline.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +# Copyright 2017 Google Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +python3 "${KOKORO_GFILE_DIR}/trampoline_v1.py" diff --git a/system_tests/test_compute_engine.py b/system_tests/test_compute_engine.py index e828cff17..38733276e 100644 --- a/system_tests/test_compute_engine.py +++ b/system_tests/test_compute_engine.py @@ -17,12 +17,15 @@ import google.auth from google.auth import _helpers from google.auth import compute_engine +from google.auth import exceptions from google.auth.compute_engine import _metadata @pytest.fixture(autouse=True) def check_gce_environment(http_request): - if not _metadata.ping(http_request, timeout=1): + try: + _metadata.get_service_account_info(http_request) + except exceptions.TransportError: pytest.skip('Compute Engine metadata service is not available.')