diff --git a/.kokoro/tests/run_tests.sh b/.kokoro/tests/run_tests.sh index 72d81fdeab3..969b12dd885 100755 --- a/.kokoro/tests/run_tests.sh +++ b/.kokoro/tests/run_tests.sh @@ -45,7 +45,7 @@ export GOOGLE_APPLICATION_CREDENTIALS=${KOKORO_GFILE_DIR}/service-acct.json export GOOGLE_CLOUD_PROJECT=java-docs-samples-testing export PATH=/google-cloud-sdk/bin:$PATH source ${KOKORO_GFILE_DIR}/aws-secrets.sh - +source ${KOKORO_GFILE_DIR}/dlp_secrets.txt echo "******** Environment *********" env echo "******** mvn & Java *********" @@ -71,75 +71,3 @@ mvn -B --fail-at-end clean verify -Dfile.encoding="UTF-16" \ -Dbigtable.instanceID=instance | \ grep -E -v "(^\[INFO\] Download|^\[INFO\].*skipping)" -echo "******** Deploy to prod *******" -cd appengine-java8 - -for app in "bigtable" "cloudsql" "datastore" "spanner" \ - "urlfetch" -do - (cd "${app}" - sed --in-place='.xx' "s/<\/runtime>/<\/runtime>${app}<\/service>/" \ - src/main/webapp/WEB-INF/appengine-web.xml - mvn -B --fail-at-end -q appengine:deploy -Dapp.deploy.version="1" \ - -Dapp.stage.quickstart=true -Dapp.deploy.force=true -Dapp.deploy.promote=true \ - -Dapp.deploy.project="${GOOGLE_CLOUD_PROJECT}" -DskipTests=true - mv src/main/webapp/WEB-INF/appengine-web.xml.xx src/main/webapp/WEB-INF/appengine-web.xml) -done - -echo "******* Test prod Deployed Apps ********" -export URL="dot-${GOOGLE_CLOUD_PROJECT}.appspot.com" - -# TestIt "helloworld" "" "Hello App Engine -- Java 8!" - - -## Run tests using App Engine local devserver. -# test_localhost() { -# git clone https://github.com/GoogleCloudPlatform/java-repo-tools.git -# -# devserver_tests=( -# appengine/helloworld -# appengine/datastore/indexes -# appengine/datastore/indexes-exploding -# appengine/datastore/indexes-perfect -# ) -# for testdir in "${devserver_tests[@]}" ; do -# if [ -z "$common_dir" ] || [[ $testdir = $common_dir* ]]; then -# ./java-repo-tools/scripts/test-localhost.sh appengine "${testdir}" -# fi -# done - - # newplugin_std_tests=( - # appengine/helloworld-new-plugins - # ) - # for testdir in "${newplugin_std_tests[@]}" ; do - # ./java-repo-tools/scripts/test-localhost.sh standard_mvn "${testdir}" - # ./java-repo-tools/scripts/test-localhost.sh standard_gradle "${testdir}" - # done -} -test_localhost - - - -# ( -# # Stop echoing commands, so we don't leak secret env vars -# # -Pselenium | \ # LV3 20170616 turn off selenium for now. -# set +x -# mvn --batch-mode clean verify \ -# -Dbookshelf.clientID="${OAUTH2_CLIENT_ID}" \ -# -Dbookshelf.clientSecret="${OAUTH2_CLIENT_SECRET}" \ -# -Dbookshelf.bucket="${GCS_BUCKET envvar is unset}" \ -# | \ -# grep -E -v "(^\[INFO\] Download|^\[INFO\].*skipping)" -# ) -# -# Test running samples on localhost. -# git clone https://github.com/GoogleCloudPlatform/java-repo-tools.git -# ./java-repo-tools/scripts/test-localhost.sh jetty helloworld-jsp -- -DskipTests=true -# ./java-repo-tools/scripts/test-localhost.sh jetty helloworld-servlet -- -DskipTests=true -# ./java-repo-tools/scripts/test-localhost.sh jetty helloworld-compat -- -DskipTests=true -# ./java-repo-tools/scripts/test-localhost.sh spring-boot helloworld-springboot -- -DskipTests=true - -# Check that all shell scripts in this repo (including this one) pass the -# Shell Check linter. -cd .. -shellcheck ./**/*.sh diff --git a/circle.yml b/circle.yml deleted file mode 100644 index e397f27704d..00000000000 --- a/circle.yml +++ /dev/null @@ -1,17 +0,0 @@ -machine: - java: - version: oraclejdk8 -dependencies: - pre: - - curl -LO https://github.com/mozilla/geckodriver/releases/download/v0.15.0/geckodriver-v0.15.0-linux64.tar.gz - && sudo tar -zxf geckodriver-*.tar.gz -C "${HOME}/bin" - - sudo apt-add-repository "deb http://archive.ubuntu.com/ubuntu trusty-backports main restricted universe" - && sudo apt-get update - && sudo apt-get install -t trusty-backports shellcheck - - sudo apt-get install expect - - openssl aes-256-cbc -d -in "${HOME}/${CIRCLE_PROJECT_REPONAME}/service-account.json.enc" -k "${key}" -iv "${iv}" -out "${HOME}/google-cloud-service-key.json" - - export GOOGLE_APPLICATION_CREDENTIALS="${HOME}/google-cloud-service-key.json" -test: - override: - - bash ./travis.sh && - bash <(curl -s https://codecov.io/bash) # If successful, run code coverage diff --git a/gae-firebase-secrets.json.enc b/gae-firebase-secrets.json.enc deleted file mode 100644 index d45c328a515..00000000000 Binary files a/gae-firebase-secrets.json.enc and /dev/null differ diff --git a/jenkins.sh b/jenkins.sh deleted file mode 100755 index a85d9e8be7b..00000000000 --- a/jenkins.sh +++ /dev/null @@ -1,81 +0,0 @@ -#!/usr/bin/env 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 -xe -shopt -s globstar -# We spin up some subprocesses. Don't kill them on hangup -trap '' HUP - -# Temporary directory to store any output to display on error -export ERROR_OUTPUT_DIR -ERROR_OUTPUT_DIR="$(mktemp -d)" -trap 'rm -r "${ERROR_OUTPUT_DIR}"' EXIT - -delete_app_version() { - yes | gcloud --project="${GOOGLE_PROJECT_ID}" \ - app versions delete "${1}" -} - -handle_error() { - errcode=$? # Remember the error code so we can exit with it after cleanup - - # Clean up remote app version - delete_app_version "${1}" & - - # Display any errors - if [ -n "$(find "${2}" -mindepth 1 -print -quit)" ]; then - cat "${2:?}"/* 1>&2 - fi - - wait - - exit ${errcode} -} - -cleanup() { - delete_app_version "${GOOGLE_VERSION_ID}" & - rm -r "${ERROR_OUTPUT_DIR:?}/"* -} - -# First, style-check the shell scripts -shellcheck ./**/*.sh - -# Find all jenkins.sh's and run them. -export SCRIPT_LIST -SCRIPT_LIST="$(find . -mindepth 2 -maxdepth 5 -name jenkins.sh -type f)" -for path in $SCRIPT_LIST; do - dir="${path%/jenkins.sh}" - # Need different app versions because flex can't deploy over an existing - # version. Use just the first letter of each subdir in version name - export GOOGLE_VERSION_ID - # shellcheck disable=SC2001 - GOOGLE_VERSION_ID="jenkins-$(echo "${dir#./}" | sed 's#\([a-z]\)[^/]*/#\1-#g')" - - trap 'handle_error "${GOOGLE_VERSION_ID}" "${ERROR_OUTPUT_DIR}"' ERR - ( - # If there's an error, clean up - - pushd "${dir}" - /bin/bash ./jenkins.sh - - # Clean up the app version - cleanup - ) - # Clear the trap - trap - ERR -done - -wait diff --git a/kms/src/main/java/com/example/Snippets.java b/kms/src/main/java/com/example/Snippets.java index f90595d49f1..8e93f4c6fb9 100644 --- a/kms/src/main/java/com/example/Snippets.java +++ b/kms/src/main/java/com/example/Snippets.java @@ -522,14 +522,18 @@ public static void listCryptoKeys(String projectId, String locationId, String ke "projects/%s/locations/%s/keyRings/%s", projectId, locationId, keyRingId); - ListCryptoKeysResponse cryptoKeys = kms.projects().locations().keyRings() - .cryptoKeys() - .list(keyRingPath) - .execute(); - - for (CryptoKey key : cryptoKeys.getCryptoKeys()) { - System.out.println(key); - } + ListCryptoKeysResponse cryptoKeys = null; + do { // Print every page of keys + cryptoKeys = kms.projects().locations().keyRings() + .cryptoKeys() + .list(keyRingPath) + .setPageToken(cryptoKeys != null ? cryptoKeys.getNextPageToken() : null) + .execute(); + + for (CryptoKey key : cryptoKeys.getCryptoKeys()) { + System.out.println(key); + } + } while(cryptoKeys.getNextPageToken() != null); } /** @@ -546,6 +550,7 @@ public static void listCryptoKeyVersions( "projects/%s/locations/%s/keyRings/%s/cryptoKeys/%s", projectId, locationId, keyRingId, cryptoKeyId); + ListCryptoKeyVersionsResponse versions = kms.projects().locations().keyRings().cryptoKeys() .cryptoKeyVersions() .list(cryptoKeys) diff --git a/secrets.env.EXAMPLE b/secrets.env.EXAMPLE deleted file mode 100644 index ce6f489c186..00000000000 --- a/secrets.env.EXAMPLE +++ /dev/null @@ -1,3 +0,0 @@ -export AWS_ACCESS_KEY_ID=MY_KEY_ID -export AWS_SECRET_ACCESS_KEY=MY_ACCESS_KEY -export GOOGLE_API_KEY=MY_API_KEY diff --git a/secrets.env.enc b/secrets.env.enc deleted file mode 100644 index f0558306a88..00000000000 --- a/secrets.env.enc +++ /dev/null @@ -1 +0,0 @@ -;[t xoaId;HwZ1640+#vkRxEs/{Tlc ~ۓđHm d!1X]ekĎq :E JkOiY4Rx?2&Eis^= C#ܷ*~U mjo $쥥Œ  \ No newline at end of file diff --git a/service-account.json.enc b/service-account.json.enc deleted file mode 100644 index 198c19b328b..00000000000 Binary files a/service-account.json.enc and /dev/null differ diff --git a/translate/src/test/java/com/example/cloud/translate/samples/TranslateTextTest.java b/translate/src/test/java/com/example/cloud/translate/samples/TranslateTextTest.java index 4d943a59fd8..6e3a6ad412b 100644 --- a/translate/src/test/java/com/example/cloud/translate/samples/TranslateTextTest.java +++ b/translate/src/test/java/com/example/cloud/translate/samples/TranslateTextTest.java @@ -94,7 +94,9 @@ public class TranslateTextTest { // Assert String got = bout.toString(); for (String language : languages) { - assertThat(got).contains(language); + bout.reset(); + out.print(language); + assertThat(got).contains(bout.toString()); } } diff --git a/travis.sh b/travis.sh deleted file mode 100755 index 3f456e7282b..00000000000 --- a/travis.sh +++ /dev/null @@ -1,118 +0,0 @@ -#!/usr/bin/env bash -# Copyright 2016 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 -e - -cd "${HOME}/project" # lv3 8/8/17 - -set -x -# Set pipefail so that `egrep` does not eat the exit code. -set -o pipefail -shopt -s globstar - -echo "GOOGLE_APPLICATION_CREDENTIALS: ${GOOGLE_APPLICATION_CREDENTIALS}" -echo "CI_PULL_REQUEST: ${CI_PULL_REQUEST}" -echo "CIRCLE_BRANCH: ${CIRCLE_BRANCH}" -echo "git rev-parse HEAD: $(git rev-parse HEAD)" -echo "CIRCLE_PR_NUMBER: ${CIRCLE_PR_NUMBER}" -echo "CIRCLE_PR_USERNAME: ${CIRCLE_PR_USERNAME}" - -SKIP_TESTS=false -if [ -z "$GOOGLE_APPLICATION_CREDENTIALS" ] ; then - SKIP_TESTS=true -fi - -# Finds the closest parent dir that encompasses all changed files, and has a -# pom.xml -changed_files_parent() { - # If we're not in a PR, forget it - [ -z "${CI_PULL_REQUEST}" ] && return 0 - - ( - set +e - - - if ! changed=$(git diff --name-only "${CIRCLE_SHA1}" "${CIRCLE_BRANCH}"); then - # Fall back to git head - if ! changed=$(git diff --name-only "$(git rev-parse HEAD)" "${CIRCLE_BRANCH}"); then - return 0 # Give up. Just run everything. - fi - fi - - # Find the common prefix - prefix=$(echo "${changed}" | sed -e 'N;s/^\(.*\).*\n\1.*$/\1\n\1/;D') - # N: Do this for a pair of lines - # s: capture the beginning of a line, that's followed by a new line - # starting with that capture group. IOW - two lines that start with the - # same zero-or-more characters. Replace it with just the capture group - # (ie the common prefix). - # D: Delete the first line of the pair, leaving the second line for the - # next pass. - - while [ ! -z "$prefix" ] && [ ! -r "$prefix/pom.xml" ] && [ "${prefix%/*}" != "$prefix" ]; do - prefix="${prefix%/*}" - done - - [ -r "$prefix/pom.xml" ] || return 0 - - echo "$prefix" - ) -} - -common_dir="$(changed_files_parent)" - -echo "Common Dir: ${common_dir}" - -[ -z "${common_dir}" ] || pushd "${common_dir}" - -# Give Maven a bit more memory -export MAVEN_OPTS='-Xmx800m -Xms400m' -mvn --batch-mode --fail-at-end clean verify -e \ - -DskipTests=$SKIP_TESTS \ - -Dbigtable.projectID="${GOOGLE_CLOUD_PROJECT}" \ - -Dbigtable.instanceID=instance | \ - grep -E -v "(^\[INFO\] Download|^\[INFO\].*skipping)" - -[ -z "$common_dir" ] || popd - -# Check that all shell scripts in this repo (including this one) pass the -# Shell Check linter. -shellcheck ./**/*.sh - -# Run tests using App Engine local devserver. -test_localhost() { - git clone https://github.com/GoogleCloudPlatform/java-repo-tools.git - - devserver_tests=( - appengine/helloworld - appengine/datastore/indexes - appengine/datastore/indexes-exploding - appengine/datastore/indexes-perfect - ) - for testdir in "${devserver_tests[@]}" ; do - if [ -z "$common_dir" ] || [[ $testdir = $common_dir* ]]; then - ./java-repo-tools/scripts/test-localhost.sh appengine "${testdir}" - fi - done - - # newplugin_std_tests=( - # appengine/helloworld-new-plugins - # ) - # for testdir in "${newplugin_std_tests[@]}" ; do - # ./java-repo-tools/scripts/test-localhost.sh standard_mvn "${testdir}" - # ./java-repo-tools/scripts/test-localhost.sh standard_gradle "${testdir}" - # done -} -test_localhost