FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Misc testing fixes. by kurtisvg · Pull Request #1388 · GoogleCloudPlatform/java-docs-samples · GitHub

Misc testing fixes. by kurtisvg · Pull Request #1388 · GoogleCloudPlatform/java-docs-samples · GitHub
Skip to content

Navigation Menu

2 changes: 1 addition & 1 deletion .kokoro/java11/presubmit.cfg
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@
# Tell the trampoline which build file to use.
env_vars: {
key: "TRAMPOLINE_BUILD_FILE"
value: "github/java-docs-samples/.kokoro/tests/diff_tests.sh"
value: "github/java-docs-samples/.kokoro/tests/run_diff_only.sh"
}
2 changes: 1 addition & 1 deletion .kokoro/java8/presubmit.cfg
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@
# Tell the trampoline which build file to use.
env_vars: {
key: "TRAMPOLINE_BUILD_FILE"
value: "github/java-docs-samples/.kokoro/tests/diff_tests.sh"
value: "github/java-docs-samples/.kokoro/tests/run_diff_only.sh"
}
89 changes: 0 additions & 89 deletions .kokoro/tests/diff_tests.sh

This file was deleted.

16 changes: 16 additions & 0 deletions .kokoro/tests/run_diff_only.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/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.
mydir="${0%/*}"
"$mydir"/run_tests.sh --only-diff
162 changes: 104 additions & 58 deletions .kokoro/tests/run_tests.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -13,72 +13,118 @@
# 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
# We spin up some subprocesses. Don't kill them on hangup
trap '' HUP

# Update gcloud and check version
gcloud components update --quiet
echo "********** GCLOUD INFO ***********"
gcloud -v
echo "********** MAVEN INFO ***********"
mvn -v
echo "********** GRADLE INFO ***********"
gradle -v

# Setup required enviormental variables
export GOOGLE_APPLICATION_CREDENTIALS=${KOKORO_GFILE_DIR}/service-acct.json
export GOOGLE_CLOUD_PROJECT=java-docs-samples-testing
source ${KOKORO_GFILE_DIR}/aws-secrets.sh
source ${KOKORO_GFILE_DIR}/storage-hmac-credentials.sh
source ${KOKORO_GFILE_DIR}/dlp_secrets.txt
# Activate service account
gcloud auth activate-service-account\
--key-file=$GOOGLE_APPLICATION_CREDENTIALS \
--project=$GOOGLE_CLOUD_PROJECT

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

# `--debug` can be added make local testing of this script easier
if [[ $* == *--script-debug* ]]; then
SCRIPT_DEBUG="true"
JAVA_VERSION="1.8"
else
SCRIPT_DEBUG="false"
fi

# `--only-changed` will only run tests on projects container changes from the master branch.
if [[ $* == *--only-diff* ]]; then
ONLY_DIFF="true"
else
ONLY_DIFF="false"
fi

# Verify Java versions have been specified
if [[ -z ${JAVA_VERSION+x} ]]; then
echo -e "'JAVA_VERSION' env var should be a comma delimited list of valid java versions."
exit 1
fi

if [[ "$SCRIPT_DEBUG" != "true" ]]; then
# Update `gcloud` and log versioning for debugging.
gcloud components update --quiet
echo "********** GCLOUD INFO ***********"
gcloud -v
echo "********** MAVEN INFO ***********"
mvn -v
echo "********** GRADLE INFO ***********"
gradle -v

# Setup required env variables
export GOOGLE_CLOUD_PROJECT=java-docs-samples-testing
export GOOGLE_APPLICATION_CREDENTIALS=${KOKORO_GFILE_DIR}/service-acct.json
source "${KOKORO_GFILE_DIR}/aws-secrets.sh"
source "${KOKORO_GFILE_DIR}/storage-hmac-credentials.sh"
source "${KOKORO_GFILE_DIR}/dlp_secrets.txt"
# Activate service account
gcloud auth activate-service-account \
--key-file="$GOOGLE_APPLICATION_CREDENTIALS" \
--project="$GOOGLE_CLOUD_PROJECT"

cd github/java-docs-samples
fi

echo -e "\n******************** TESTING PROJECTS ********************"
# Switch to 'fail at end' to allow all tests to complete before exiting.
set +e
RESULT=0
cd github/java-docs-samples
# For every pom.xml (may break on whitespace)
# Use RTN to return a non-zero value if the test fails.
RTN=0
ROOT=$(pwd)
# Find all POMs in the repository (may break on whitespace).
for file in **/pom.xml; do
# Navigate to project
cd "$ROOT"
# Navigate to the project folder.
file=$(dirname "$file")
pushd "$file" > /dev/null

# Only test leafs to prevent testing twice
PARENT=$(grep "<modules>" pom.xml -c)

# Get the Java version from the pom.xml
VERSION=$(grep -oP '(?<=<maven.compiler.target>).*?(?=</maven.compiler.target>)' pom.xml)

# Check for changes to the current folder
if [ "$PARENT" -eq 0 ] && [[ "$JAVA_VERSION" = *"$VERSION"* ]]; then
echo "------------------------------------------------------------"
echo "- testing $file"
echo "------------------------------------------------------------"

# Run tests and update RESULT if failed
mvn -q --batch-mode --fail-at-end clean verify \
-Dfile.encoding="UTF-8" \
-Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn \
-Dmaven.test.redirectTestOutputToFile=true \
-Dbigtable.projectID="${GOOGLE_CLOUD_PROJECT}" \
-Dbigtable.instanceID=instance
EXIT=$?

if [ $EXIT -ne 0 ]; then
echo -e "\n Tests failed. \n"
RESULT=1
else
echo -e "\n Tests complete. \n"
cd "$file"

# If $DIFF_ONLY is true, skip projects without changes.
if [[ "$ONLY_DIFF" = "true" ]]; then
git diff --quiet origin/master.. .
CHANGED=$?
if [[ "$CHANGED" -eq 0 ]]; then
# echo -e "\n Skipping $file: no changes in folder.\n"
continue
fi
fi

popd > /dev/null
echo "------------------------------------------------------------"
echo "- testing $file"
echo "------------------------------------------------------------"

# Fail the tests if no Java version was found.
POM_JAVA=$(grep -oP '(?<=<maven.compiler.target>).*?(?=</maven.compiler.target>)' pom.xml)
if [[ "$POM_JAVA" = "" ]]; then
RTN=1
echo -e "\n Testing failed: Unable to determine Java version. Please set in pom:"
echo -e "\n<properties>"
echo -e " <maven.compiler.target>1.8</maven.compiler.target>"
echo -e " <maven.compiler.source>1.8</maven.compiler.source>"
echo -e "</properties>\n"
continue
fi

# Skip tests that don't have the correct Java version.
if ! [[ ",$JAVA_VERSION," =~ ",$POM_JAVA," ]]; then
echo -e "\n Skipping tests: Java version ($POM_JAVA) not required ($JAVA_VERSION)\n"
continue
fi

# Use maven to execute the tests for the project.
mvn -q --batch-mode --fail-at-end clean verify \
-Dfile.encoding="UTF-8" \
-Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn \
-Dmaven.test.redirectTestOutputToFile=true \
-Dbigtable.projectID="${GOOGLE_CLOUD_PROJECT}" \
-Dbigtable.instanceID=instance
EXIT=$?

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

done

exit $RESULT
exit "$RTN"
2 changes: 1 addition & 1 deletion appengine-java8/analytics/pom.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<parent>
<groupId>com.google.cloud.samples</groupId>
<artifactId>shared-configuration</artifactId>
<version>1.0.9</version>
<version>1.0.11</version>
</parent>

<properties>
Expand Down
2 changes: 1 addition & 1 deletion appengine-java8/appidentity/pom.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<parent>
<groupId>com.google.cloud.samples</groupId>
<artifactId>shared-configuration</artifactId>
<version>1.0.9</version>
<version>1.0.11</version>
</parent>

<properties>
Expand Down
2 changes: 1 addition & 1 deletion appengine-java8/bigquery/pom.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<parent>
<groupId>com.google.cloud.samples</groupId>
<artifactId>shared-configuration</artifactId>
<version>1.0.9</version>
<version>1.0.11</version>
</parent>

<properties>
Expand Down
4 changes: 2 additions & 2 deletions appengine-java8/bigtable/pom.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ limitations under the License.
<parent>
<groupId>com.google.cloud.samples</groupId>
<artifactId>shared-configuration</artifactId>
<version>1.0.9</version>
<version>1.0.11</version>
</parent>

<properties>
Expand Down Expand Up @@ -139,7 +139,7 @@ limitations under the License.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.20.1</version>
<version>3.0.0-M3</version>
<configuration>
<systemPropertyVariables>
<BIGTABLE_PROJECT>${bigtable.projectID}</BIGTABLE_PROJECT>
Expand Down
2 changes: 1 addition & 1 deletion appengine-java8/cloudsql-postgres/pom.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<parent>
<groupId>com.google.cloud.samples</groupId>
<artifactId>shared-configuration</artifactId>
<version>1.0.9</version>
<version>1.0.11</version>
</parent>

<!-- [START gae_java8_postgres_properties] -->
Expand Down
2 changes: 1 addition & 1 deletion appengine-java8/cloudsql/pom.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<parent>
<groupId>com.google.cloud.samples</groupId>
<artifactId>shared-configuration</artifactId>
<version>1.0.9</version>
<version>1.0.11</version>
</parent>

<!-- [START gae_java8_mysql_properties] -->
Expand Down
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<parent>
<groupId>com.google.cloud.samples</groupId>
<artifactId>shared-configuration</artifactId>
<version>1.0.9</version>
<version>1.0.11</version>
</parent>

<properties>
Expand Down
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<parent>
<groupId>com.google.cloud.samples</groupId>
<artifactId>shared-configuration</artifactId>
<version>1.0.9</version>
<version>1.0.11</version>
</parent>

<properties>
Expand Down
2 changes: 1 addition & 1 deletion appengine-java8/datastore-indexes/pom.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<parent>
<groupId>com.google.cloud.samples</groupId>
<artifactId>shared-configuration</artifactId>
<version>1.0.9</version>
<version>1.0.11</version>
</parent>

<properties>
Expand Down
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<parent>
<groupId>com.google.cloud.samples</groupId>
<artifactId>shared-configuration</artifactId>
<version>1.0.10</version>
<version>1.0.11</version>
</parent>

<properties>
Expand Down
Loading

Footer

© 2026 GitHub, Inc.

Back | FazBrowse Home | New Git URL