blob: 27578b20caf743053be52eec4a0ad1bbc7e2d0d5 [file] [log] [blame]
#!/usr/bin/env bash
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you 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
BASE_DIR=$(pwd)
SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
SCRIPTDIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
SOURCE="$(readlink "$SOURCE")"
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
done
SCRIPTDIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
if [[ -z "${GRADLE_TASK}" ]]; then
echo "GRADLE_TASK must be set. exiting..."
exit 1
fi
REPODIR=$(cd geode; git rev-parse --show-toplevel)
if [[ ${PARALLEL_GRADLE:-"true"} == "true" ]]; then
PARALLEL_GRADLE="--parallel"
else
PARALLEL_GRADLE="--no-parallel"
fi
DEFAULT_GRADLE_TASK_OPTIONS="${PARALLEL_GRADLE} --console=plain --no-daemon"
GRADLE_SKIP_TASK_OPTIONS="-x javadoc -x spotlessCheck -x rat"
if [[ -n "${PARALLEL_DUNIT}" && "${PARALLEL_DUNIT}" == "true" ]]; then
PARALLEL_DUNIT="-PparallelDunit"
if [[ -n "${DUNIT_PARALLEL_FORKS}" && "${TEST_USING_DOCKER}" == "false" ]] ; then
DUNIT_PARALLEL_FORKS="--max-workers=${DUNIT_PARALLEL_FORKS} -PtestMaxParallelForks=${DUNIT_PARALLEL_FORKS} -PdunitParallelForks=${DUNIT_PARALLEL_FORKS}"
elif [[ -n "${DUNIT_PARALLEL_FORKS}" && "${TEST_USING_DOCKER}" == "true" ]] ; then
DUNIT_PARALLEL_FORKS="-PdunitParallelForks=${DUNIT_PARALLEL_FORKS}"
DOCKER_TESTING_OPTIONS="-PdunitDockerUser=geode -PdunitDockerImage=\$(docker images --format '{{.Repository}}:{{.Tag}}' | grep test-container)"
fi
else
PARALLEL_DUNIT=""
DUNIT_PARALLEL_FORKS=""
DOCKER_TESTING_OPTIONS=""
fi
case $ARTIFACT_SLUG in
windows*)
echo "Making environment adjustments for windows."
JAVA_BUILD_PATH=C:/java${JAVA_BUILD_VERSION}
JAVA_TEST_PATH=C:/java${JAVA_TEST_VERSION}
TEST_JAVA_8_HOME=C:/java8
TEST_JAVA_11_HOME=C:/java11
TEST_JAVA_17_HOME=C:/java17
GRADLE_SKIP_TASK_OPTIONS="${GRADLE_SKIP_TASK_OPTIONS} -x docker"
SEP=";"
OPTIONAL_KILL_ALL_CMD="${SEP} \
exit_code=\$? ${SEP} \
(taskkill //F //IM java.exe //T) ${SEP} \
exit \${exit_code}
"
;;
*)
JAVA_BUILD_PATH=/usr/lib/jvm/java-${JAVA_BUILD_VERSION}-openjdk-amd64
JAVA_TEST_PATH=/usr/lib/jvm/java-${JAVA_TEST_VERSION}-openjdk-amd64
TEST_JAVA_8_HOME=/usr/lib/jvm/java-8-openjdk-amd64
TEST_JAVA_11_HOME=/usr/lib/jvm/java-11-openjdk-amd64/
TEST_JAVA_17_HOME=/usr/lib/jvm/java-17-openjdk-amd64/
SEP="&&"
;;
esac
GRADLE_ARGS=" \
-PcompileJVM=${JAVA_BUILD_PATH} \
-PcompileJVMVer=${JAVA_BUILD_VERSION} \
-PtestJVM=${JAVA_TEST_PATH} \
-PtestJVMVer=${JAVA_TEST_VERSION} \
-PtestJava8Home=${TEST_JAVA_8_HOME} \
-PtestJava11Home=${TEST_JAVA_11_HOME} \
-PtestJava17Home=${TEST_JAVA_17_HOME} \
${PARALLEL_DUNIT} \
${DUNIT_PARALLEL_FORKS} \
${DOCKER_TESTING_OPTIONS} \
${DEFAULT_GRADLE_TASK_OPTIONS} \
${GRADLE_SKIP_TASK_OPTIONS} \
${GRADLE_TASK} \
${GRADLE_TASK_OPTIONS} \
${GRADLE_GLOBAL_ARGS}"
EXEC_COMMAND="bash -c 'echo Building with: $SEP \
${JAVA_BUILD_PATH}/bin/java -version $SEP \
echo Testing with: $SEP \
${JAVA_TEST_PATH}/bin/java -version $SEP \
cd geode $SEP \
cp gradlew gradlewStrict $SEP \
sed -e 's/JAVA_HOME/GRADLE_JVM/g' -i.bak gradlewStrict $SEP \
GRADLE_JVM=${JAVA_BUILD_PATH} JAVA_TEST_PATH=${JAVA_TEST_PATH} ./gradlewStrict ${GRADLE_ARGS}'"
echo "${EXEC_COMMAND}"
eval "${EXEC_COMMAND}"
# Cleanup
# Make sure all test containers are stopped and removed when tests are finished
DOCKER_CONTAINERS=$(sudo docker ps -a -q 2> /dev/null)
if [ -n "${DOCKER_CONTAINERS}" ]; then
docker stop ${DOCKER_CONTAINERS} > /dev/null
echo -e "Removing containers with ID:"
docker rm ${DOCKER_CONTAINERS}
fi