Skip to content
Permalink
Browse files
feat: add mTLS support, fix missing routing header issue (#15)
  • Loading branch information
yoshi-automation committed Jun 11, 2020
1 parent 8bbe5b8 commit b98373544181ecc55104230fc1e53b206c2e23ac
Showing with 1,402 additions and 203 deletions.
  1. +2 −0 .flake8
  2. +3 −1 .gitignore
  3. +0 −2 .kokoro/publish-docs.sh
  4. +0 −2 .kokoro/release.sh
  5. +34 −0 .kokoro/samples/lint/common.cfg
  6. +6 −0 .kokoro/samples/lint/continuous.cfg
  7. +6 −0 .kokoro/samples/lint/periodic.cfg
  8. +6 −0 .kokoro/samples/lint/presubmit.cfg
  9. +34 −0 .kokoro/samples/python3.6/common.cfg
  10. +7 −0 .kokoro/samples/python3.6/continuous.cfg
  11. +6 −0 .kokoro/samples/python3.6/periodic.cfg
  12. +6 −0 .kokoro/samples/python3.6/presubmit.cfg
  13. +34 −0 .kokoro/samples/python3.7/common.cfg
  14. +6 −0 .kokoro/samples/python3.7/continuous.cfg
  15. +6 −0 .kokoro/samples/python3.7/periodic.cfg
  16. +6 −0 .kokoro/samples/python3.7/presubmit.cfg
  17. +34 −0 .kokoro/samples/python3.8/common.cfg
  18. +6 −0 .kokoro/samples/python3.8/continuous.cfg
  19. +6 −0 .kokoro/samples/python3.8/periodic.cfg
  20. +6 −0 .kokoro/samples/python3.8/presubmit.cfg
  21. +104 −0 .kokoro/test-samples.sh
  22. +3 −0 MANIFEST.in
  23. +1 −4 docs/conf.py
  24. +2 −0 docs/index.rst
  25. +7 −0 docs/multiprocessing.rst
  26. +6 −3 docs/servicedirectory_v1beta1/services.rst
  27. +2 −2 docs/servicedirectory_v1beta1/types.rst
  28. +0 −1 google/cloud/servicedirectory/__init__.py
  29. +0 −1 google/cloud/servicedirectory_v1beta1/__init__.py
  30. +48 −33 google/cloud/servicedirectory_v1beta1/services/lookup_service/client.py
  31. +5 −1 google/cloud/servicedirectory_v1beta1/services/lookup_service/transports/grpc.py
  32. +136 −49 google/cloud/servicedirectory_v1beta1/services/registration_service/client.py
  33. +5 −1 google/cloud/servicedirectory_v1beta1/services/registration_service/transports/grpc.py
  34. +11 −11 noxfile.py
  35. +33 −0 scripts/decrypt-secrets.sh
  36. +66 −0 scripts/readme-gen/readme_gen.py
  37. +87 −0 scripts/readme-gen/templates/README.tmpl.rst
  38. +9 −0 scripts/readme-gen/templates/auth.tmpl.rst
  39. +14 −0 scripts/readme-gen/templates/auth_api_key.tmpl.rst
  40. +29 −0 scripts/readme-gen/templates/install_deps.tmpl.rst
  41. +35 −0 scripts/readme-gen/templates/install_portaudio.tmpl.rst
  42. +1 −3 setup.py
  43. +12 −5 synth.metadata
  44. +10 −15 synth.py
  45. +3 −0 testing/.gitignore
  46. +124 −24 tests/unit/servicedirectory_v1beta1/test_lookup_service.py
  47. +435 −45 tests/unit/servicedirectory_v1beta1/test_registration_service.py
@@ -21,6 +21,8 @@ exclude =
# Exclude generated code.
**/proto/**
**/gapic/**
**/services/**
**/types/**
*_pb2.py

# Standard linting exemptions.
@@ -10,6 +10,7 @@
dist
build
eggs
.eggs
parts
bin
var
@@ -44,11 +45,12 @@ pip-log.txt

# Built documentation
docs/_build
htmlcov
bigquery/docs/generated

# Virtual environment
env/
coverage.xml
sponge_log.xml

# System test environment variables.
system_tests/local_test_setup
@@ -13,8 +13,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.

#!/bin/bash

set -eo pipefail

# Disable buffering, so that the logs stream through.
@@ -13,8 +13,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.

#!/bin/bash

set -eo pipefail

# Start the releasetool reporter
@@ -0,0 +1,34 @@
# Format: //devtools/kokoro/config/proto/build.proto

# Build logs will be here
action {
define_artifacts {
regex: "**/*sponge_log.xml"
}
}

# Specify which tests to run
env_vars: {
key: "RUN_TESTS_SESSION"
value: "lint"
}

env_vars: {
key: "TRAMPOLINE_BUILD_FILE"
value: "github/python-service-directory/.kokoro/test-samples.sh"
}

# Configure the docker image for kokoro-trampoline.
env_vars: {
key: "TRAMPOLINE_IMAGE"
value: "gcr.io/cloud-devrel-kokoro-resources/python-samples-testing-docker"
}

# Download secrets for samples
gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/python-docs-samples"

# Download trampoline resources.
gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline"

# Use the trampoline script to run in docker.
build_file: "python-service-directory/.kokoro/trampoline.sh"
@@ -0,0 +1,6 @@
# Format: //devtools/kokoro/config/proto/build.proto

env_vars: {
key: "INSTALL_LIBRARY_FROM_SOURCE"
value: "True"
}
@@ -0,0 +1,6 @@
# Format: //devtools/kokoro/config/proto/build.proto

env_vars: {
key: "INSTALL_LIBRARY_FROM_SOURCE"
value: "False"
}
@@ -0,0 +1,6 @@
# Format: //devtools/kokoro/config/proto/build.proto

env_vars: {
key: "INSTALL_LIBRARY_FROM_SOURCE"
value: "True"
}
@@ -0,0 +1,34 @@
# Format: //devtools/kokoro/config/proto/build.proto

# Build logs will be here
action {
define_artifacts {
regex: "**/*sponge_log.xml"
}
}

# Specify which tests to run
env_vars: {
key: "RUN_TESTS_SESSION"
value: "py-3.6"
}

env_vars: {
key: "TRAMPOLINE_BUILD_FILE"
value: "github/python-service-directory/.kokoro/test-samples.sh"
}

# Configure the docker image for kokoro-trampoline.
env_vars: {
key: "TRAMPOLINE_IMAGE"
value: "gcr.io/cloud-devrel-kokoro-resources/python-samples-testing-docker"
}

# Download secrets for samples
gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/python-docs-samples"

# Download trampoline resources.
gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline"

# Use the trampoline script to run in docker.
build_file: "python-service-directory/.kokoro/trampoline.sh"
@@ -0,0 +1,7 @@
# Format: //devtools/kokoro/config/proto/build.proto

env_vars: {
key: "INSTALL_LIBRARY_FROM_SOURCE"
value: "True"
}

@@ -0,0 +1,6 @@
# Format: //devtools/kokoro/config/proto/build.proto

env_vars: {
key: "INSTALL_LIBRARY_FROM_SOURCE"
value: "False"
}
@@ -0,0 +1,6 @@
# Format: //devtools/kokoro/config/proto/build.proto

env_vars: {
key: "INSTALL_LIBRARY_FROM_SOURCE"
value: "True"
}
@@ -0,0 +1,34 @@
# Format: //devtools/kokoro/config/proto/build.proto

# Build logs will be here
action {
define_artifacts {
regex: "**/*sponge_log.xml"
}
}

# Specify which tests to run
env_vars: {
key: "RUN_TESTS_SESSION"
value: "py-3.7"
}

env_vars: {
key: "TRAMPOLINE_BUILD_FILE"
value: "github/python-service-directory/.kokoro/test-samples.sh"
}

# Configure the docker image for kokoro-trampoline.
env_vars: {
key: "TRAMPOLINE_IMAGE"
value: "gcr.io/cloud-devrel-kokoro-resources/python-samples-testing-docker"
}

# Download secrets for samples
gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/python-docs-samples"

# Download trampoline resources.
gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline"

# Use the trampoline script to run in docker.
build_file: "python-service-directory/.kokoro/trampoline.sh"
@@ -0,0 +1,6 @@
# Format: //devtools/kokoro/config/proto/build.proto

env_vars: {
key: "INSTALL_LIBRARY_FROM_SOURCE"
value: "True"
}
@@ -0,0 +1,6 @@
# Format: //devtools/kokoro/config/proto/build.proto

env_vars: {
key: "INSTALL_LIBRARY_FROM_SOURCE"
value: "False"
}
@@ -0,0 +1,6 @@
# Format: //devtools/kokoro/config/proto/build.proto

env_vars: {
key: "INSTALL_LIBRARY_FROM_SOURCE"
value: "True"
}
@@ -0,0 +1,34 @@
# Format: //devtools/kokoro/config/proto/build.proto

# Build logs will be here
action {
define_artifacts {
regex: "**/*sponge_log.xml"
}
}

# Specify which tests to run
env_vars: {
key: "RUN_TESTS_SESSION"
value: "py-3.8"
}

env_vars: {
key: "TRAMPOLINE_BUILD_FILE"
value: "github/python-service-directory/.kokoro/test-samples.sh"
}

# Configure the docker image for kokoro-trampoline.
env_vars: {
key: "TRAMPOLINE_IMAGE"
value: "gcr.io/cloud-devrel-kokoro-resources/python-samples-testing-docker"
}

# Download secrets for samples
gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/python-docs-samples"

# Download trampoline resources.
gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline"

# Use the trampoline script to run in docker.
build_file: "python-service-directory/.kokoro/trampoline.sh"
@@ -0,0 +1,6 @@
# Format: //devtools/kokoro/config/proto/build.proto

env_vars: {
key: "INSTALL_LIBRARY_FROM_SOURCE"
value: "True"
}
@@ -0,0 +1,6 @@
# Format: //devtools/kokoro/config/proto/build.proto

env_vars: {
key: "INSTALL_LIBRARY_FROM_SOURCE"
value: "False"
}
@@ -0,0 +1,6 @@
# Format: //devtools/kokoro/config/proto/build.proto

env_vars: {
key: "INSTALL_LIBRARY_FROM_SOURCE"
value: "True"
}
@@ -0,0 +1,104 @@
#!/bin/bash
# Copyright 2020 Google LLC
#
# 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
#
# https://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.


# `-e` enables the script to automatically fail when a command fails
# `-o pipefail` sets the exit code to the rightmost comment to exit with a non-zero
set -eo pipefail
# Enables `**` to include files nested inside sub-folders
shopt -s globstar

cd github/python-service-directory

# Run periodic samples tests at latest release
if [[ $KOKORO_BUILD_ARTIFACTS_SUBDIR = *"periodic"* ]]; then
LATEST_RELEASE=$(git describe --abbrev=0 --tags)
git checkout $LATEST_RELEASE
fi

# Disable buffering, so that the logs stream through.
export PYTHONUNBUFFERED=1

# Debug: show build environment
env | grep KOKORO

# Install nox
python3.6 -m pip install --upgrade --quiet nox

# Use secrets acessor service account to get secrets
if [[ -f "${KOKORO_GFILE_DIR}/secrets_viewer_service_account.json" ]]; then
gcloud auth activate-service-account \
--key-file="${KOKORO_GFILE_DIR}/secrets_viewer_service_account.json" \
--project="cloud-devrel-kokoro-resources"
fi

# This script will create 3 files:
# - testing/test-env.sh
# - testing/service-account.json
# - testing/client-secrets.json
./scripts/decrypt-secrets.sh

source ./testing/test-env.sh
export GOOGLE_APPLICATION_CREDENTIALS=$(pwd)/testing/service-account.json

# For cloud-run session, we activate the service account for gcloud sdk.
gcloud auth activate-service-account \
--key-file "${GOOGLE_APPLICATION_CREDENTIALS}"

export GOOGLE_CLIENT_SECRETS=$(pwd)/testing/client-secrets.json

echo -e "\n******************** TESTING PROJECTS ********************"

# Switch to 'fail at end' to allow all tests to complete before exiting.
set +e
# Use RTN to return a non-zero value if the test fails.
RTN=0
ROOT=$(pwd)
# Find all requirements.txt in the samples directory (may break on whitespace).
for file in samples/**/requirements.txt; do
cd "$ROOT"
# Navigate to the project folder.
file=$(dirname "$file")
cd "$file"

echo "------------------------------------------------------------"
echo "- testing $file"
echo "------------------------------------------------------------"

# Use nox to execute the tests for the project.
python3.6 -m nox -s "$RUN_TESTS_SESSION"
EXIT=$?

# If this is a periodic build, send the test log to the Build Cop Bot.
# See https://github.com/googleapis/repo-automation-bots/tree/master/packages/buildcop.
if [[ $KOKORO_BUILD_ARTIFACTS_SUBDIR = *"periodic"* ]]; then
chmod +x $KOKORO_GFILE_DIR/linux_amd64/buildcop
$KOKORO_GFILE_DIR/linux_amd64/buildcop
fi

if [[ $EXIT -ne 0 ]]; then
RTN=1
echo -e "\n Testing failed: Nox returned a non-zero exit code. \n"
else
echo -e "\n Testing completed.\n"
fi

done
cd "$ROOT"

# Workaround for Kokoro permissions issue: delete secrets
rm testing/{test-env.sh,client-secrets.json,service-account.json}

exit "$RTN"
Loading

0 comments on commit b983735

Please sign in to comment.