Skip to content
This repository has been archived by the owner on Dec 12, 2024. It is now read-only.

Commit

Permalink
Fixup build scripts for new structure
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Sloan committed Aug 10, 2017
1 parent 3d6d093 commit c74f7da
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 39 deletions.
22 changes: 9 additions & 13 deletions cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,15 @@
# https://cloud.google.com/container-builder/docs/overview

steps:
# Build the maven project, omitting the docker build step
- name: 'gcr.io/cloud-builders/java/mvn:3.3.9-jdk-8'
args: ['-P-local-docker-build', '-Ddocker.tag.long=${_DOCKER_TAG}', 'clean', 'install']
id: 'MAVEN'
# Execute the docker build
- name: 'gcr.io/cloud-builders/docker'
args: ['build', '--tag=${_IMAGE}', '--no-cache', 'openjdk8/target/docker']
id: 'DOCKER'

# Runtimes-common structure tests
# See https://github.com/GoogleCloudPlatform/runtimes-common/tree/master/structure_tests
- name: 'gcr.io/gcp-runtimes/structure_test'
args: ['--image', '${_IMAGE}', '-v', '--config', '/workspace/openjdk8/target/test-classes/structure.yaml']
id: 'STRUCTURE_TEST'
args:
- 'clean'
- 'install'
- '--batch-mode'
- '-Ddocker.image.name=${_IMAGE}'
# only build the specified module
- '--projects=${_MODULE}'
- '--also-make'
id: 'MVN_PACKAGE'

images: ['${_IMAGE}']
72 changes: 52 additions & 20 deletions scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,39 +16,71 @@

set -e

dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
projectRoot=$dir/..
usage() {
echo "Usage: ${0} <args>"
echo " where <args> include:"
echo " -d|--docker-namespace <docker_namespace> - a docker repository beginning with gcr.io"
echo " -m|--module <module_to_build> - one of {openjdk8, openjdk9}"
echo " [ -l|--local ] - runs the build locally"
exit 1
}

# Parse arguments to this script
while [[ $# -gt 1 ]]; do
key="$1"
case $key in
-d|--docker-namespace)
DOCKER_NAMESPACE="$2"
shift # past argument
;;
-m|--module)
MODULE="$2"
shift # past argument
;;
-l|--local)
LOCAL_BUILD="true"
;;
*)
# unknown option
usage
;;
esac
shift
done

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
PROJECT_ROOT=$DIR/..
RUNTIME_NAME="openjdk"
TAG_PREFIX="8"
DOCKER_NAMESPACE=$1
TAG=$2
BUILD_TIMESTAMP="$(date -u +%Y-%m-%d_%H_%M)"

if [ -z "${DOCKER_NAMESPACE}" ]; then
echo "Usage: ${0} <docker_namespace> [docker_tag] [--local]"
exit 1
if [ -z "${DOCKER_NAMESPACE}" -o -z "${MODULE}" ]; then
usage
fi

if [ -z "${TAG}" ]; then
export TAG="${TAG_PREFIX}-$(date -u +%Y-%m-%d_%H_%M)"
if [ "${MODULE}" == "openjdk8" ]; then
TAG_PREFIX="8"
elif [ "${MODULE}" == "openjdk9" ]; then
TAG_PREFIX="9"
else
echo "${MODULE} is not a supported module"
usage
fi

if [ "$3" == "--local" ]; then
LOCAL_BUILD=true
fi
# export TAG for use in downstream scripts
export TAG="${TAG_PREFIX}-${BUILD_TIMESTAMP}"

IMAGE="${DOCKER_NAMESPACE}/${RUNTIME_NAME}:${TAG}"
echo "IMAGE: $IMAGE"

# build and test the runtime image
if [ "$LOCAL_BUILD" = "true" ]; then
source $dir/cloudbuild_local.sh \
--config=$projectRoot/cloudbuild.yaml \
--substitutions="_IMAGE=$IMAGE,_DOCKER_TAG=$TAG"
if [ "$LOCAL_BUILD" == "true" ]; then
source $DIR/cloudbuild_local.sh \
--config=$PROJECT_ROOT/cloudbuild.yaml \
--substitutions="_IMAGE=$IMAGE,_MODULE=$MODULE"
else
gcloud container builds submit \
--config=$projectRoot/cloudbuild.yaml \
--substitutions="_IMAGE=$IMAGE,_DOCKER_TAG=$TAG" \
$projectRoot
--config=$PROJECT_ROOT/cloudbuild.yaml \
--substitutions="_IMAGE=$IMAGE,_MODULE=$MODULE" \
$PROJECT_ROOT
fi

14 changes: 8 additions & 6 deletions scripts/local_integration_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,11 @@ if [[ -z "$imageUnderTest" ]]; then
fi

# build the test app
pushd ${testAppDir}
mvn clean install -DskipTests --batch-mode
popd
if [ ! -d $deployDir ]; then
echo "Deploy dir $deployDir does not exist. Please build the test application before running\
this test."
exit 1
fi

# build app container locally
pushd $deployDir
Expand All @@ -51,9 +53,9 @@ docker run --rm --name $CONTAINER -e "SHUTDOWN_LOGGING_THREAD_DUMP=true" -e "SHU

function waitForOutput() {
found_output='false'
for run in {1..10}
for run in {1..20}
do
grep "$1" $OUTPUT_FILE && found_output='true' && break
grep -P "$1" $OUTPUT_FILE && found_output='true' && break
sleep 1
done

Expand All @@ -74,7 +76,7 @@ echo 'verify thread dump'
waitForOutput 'Full thread dump OpenJDK 64-Bit Server VM'

echo 'verify heap info'
waitForOutput 'num.*instances.*bytes.*class name'
waitForOutput '\d+:\s+\d+\s+\d+\s+java.lang.Class'

popd

Expand Down

0 comments on commit c74f7da

Please sign in to comment.