2018-05-27 05:38:50 +08:00
|
|
|
#!/usr/bin/env bash
|
2018-08-09 07:24:37 -07:00
|
|
|
|
|
|
|
# Cause the script to exit if a single command fails.
|
|
|
|
set -e
|
|
|
|
# Show explicitly which commands are currently running.
|
|
|
|
set -x
|
|
|
|
|
2018-05-27 05:38:50 +08:00
|
|
|
ROOT_DIR=$(cd "$(dirname "${BASH_SOURCE:-$0}")"; pwd)
|
2020-09-14 17:44:45 +08:00
|
|
|
java -version
|
2018-05-27 05:38:50 +08:00
|
|
|
|
2020-12-29 10:36:16 +08:00
|
|
|
pushd "$ROOT_DIR"
|
|
|
|
echo "Check java code format."
|
|
|
|
# check google java style
|
|
|
|
mvn -T16 spotless:check
|
|
|
|
# check naming and others
|
|
|
|
mvn -T16 checkstyle:check
|
|
|
|
popd
|
|
|
|
|
2019-03-30 19:32:05 +08:00
|
|
|
run_testng() {
|
2020-04-15 15:28:52 +08:00
|
|
|
local exit_code
|
|
|
|
if "$@"; then
|
|
|
|
exit_code=0
|
|
|
|
else
|
|
|
|
exit_code=$?
|
|
|
|
fi
|
2019-03-30 19:32:05 +08:00
|
|
|
# exit_code == 2 means there are skipped tests.
|
|
|
|
if [ $exit_code -ne 2 ] && [ $exit_code -ne 0 ] ; then
|
2020-09-11 17:33:09 +08:00
|
|
|
if [ $exit_code -gt 128 ] ; then
|
|
|
|
# Test crashed. Print the driver log for diagnosis.
|
|
|
|
cat /tmp/ray/session_latest/logs/java-core-driver-*
|
|
|
|
fi
|
2020-09-02 19:47:52 +08:00
|
|
|
find . -name "hs_err_*log" -exec cat {} +
|
2019-03-30 19:32:05 +08:00
|
|
|
exit $exit_code
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2020-07-21 19:56:41 -07:00
|
|
|
pushd "$ROOT_DIR"/..
|
2020-01-10 11:41:00 +08:00
|
|
|
echo "Build java maven deps."
|
|
|
|
bazel build //java:gen_maven_deps
|
|
|
|
|
|
|
|
echo "Build test jar."
|
|
|
|
bazel build //java:all_tests_deploy.jar
|
|
|
|
|
2021-01-22 17:55:00 +08:00
|
|
|
java/generate_jni_header_files.sh
|
|
|
|
|
|
|
|
if ! git diff --exit-code -- java src/ray/core_worker/lib/java; then
|
|
|
|
echo "Files are changed after build. Common cases are:"
|
|
|
|
echo " * Java native methods doesn't match JNI files. You need to either update Java code or JNI code."
|
|
|
|
echo " * pom_template.xml and pom.xml doesn't match. You need to either update pom_template.xml or pom.xml."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2019-03-07 09:59:13 +08:00
|
|
|
echo "Running tests under cluster mode."
|
2019-03-22 14:30:05 +08:00
|
|
|
# TODO(hchen): Ideally, we should use the following bazel command to run Java tests. However, if there're skipped tests,
|
|
|
|
# TestNG will exit with code 2. And bazel treats it as test failure.
|
2020-12-04 14:33:45 +08:00
|
|
|
# bazel test //java:all_tests --config=ci || cluster_exit_code=$?
|
2021-01-25 18:07:45 +08:00
|
|
|
run_testng java -cp "$ROOT_DIR"/../bazel-bin/java/all_tests_deploy.jar org.testng.TestNG -d /tmp/ray_java_test_output "$ROOT_DIR"/testng.xml
|
2019-03-07 09:59:13 +08:00
|
|
|
|
|
|
|
echo "Running tests under single-process mode."
|
2020-07-30 18:09:31 -07:00
|
|
|
# bazel test //java:all_tests --jvmopt="-Dray.run-mode=SINGLE_PROCESS" --config=ci || single_exit_code=$?
|
2021-01-25 18:07:45 +08:00
|
|
|
run_testng java -Dray.run-mode="SINGLE_PROCESS" -cp "$ROOT_DIR"/../bazel-bin/java/all_tests_deploy.jar org.testng.TestNG -d /tmp/ray_java_test_output "$ROOT_DIR"/testng.xml
|
2019-03-07 09:59:13 +08:00
|
|
|
|
2020-09-11 19:15:52 +08:00
|
|
|
echo "Running connecting existing cluster tests."
|
2020-09-09 00:46:32 +08:00
|
|
|
case "${OSTYPE}" in
|
|
|
|
linux*) ip=$(hostname -I | awk '{print $1}');;
|
|
|
|
darwin*) ip=$(ipconfig getifaddr en0);;
|
|
|
|
*) echo "Can't get ip address for ${OSTYPE}"; exit 1;;
|
|
|
|
esac
|
2020-12-10 19:01:40 +08:00
|
|
|
RAY_BACKEND_LOG_LEVEL=debug ray start --head --port=6379 --redis-password=123456
|
2020-09-15 11:13:19 +08:00
|
|
|
RAY_BACKEND_LOG_LEVEL=debug java -cp bazel-bin/java/all_tests_deploy.jar -Dray.address="$ip:6379"\
|
2020-09-09 00:46:32 +08:00
|
|
|
-Dray.redis.password='123456' -Dray.job.code-search-path="$PWD/bazel-bin/java/all_tests_deploy.jar" io.ray.test.MultiDriverTest
|
|
|
|
ray stop
|
2020-09-11 19:15:52 +08:00
|
|
|
|
|
|
|
echo "Running documentation demo code."
|
|
|
|
docdemo_path="java/test/src/main/java/io/ray/docdemo/"
|
|
|
|
for file in "$docdemo_path"*.java; do
|
|
|
|
file=${file#"$docdemo_path"}
|
|
|
|
class=${file%".java"}
|
|
|
|
echo "Running $class"
|
|
|
|
java -cp bazel-bin/java/all_tests_deploy.jar "io.ray.docdemo.$class"
|
|
|
|
done
|
2018-08-02 08:52:49 +08:00
|
|
|
popd
|
2019-03-22 14:30:05 +08:00
|
|
|
|
2020-07-21 19:56:41 -07:00
|
|
|
pushd "$ROOT_DIR"
|
2019-03-22 14:30:05 +08:00
|
|
|
echo "Testing maven install."
|
2020-12-29 10:36:16 +08:00
|
|
|
mvn -Dorg.slf4j.simpleLogger.defaultLogLevel=WARN clean install -DskipTests -Dcheckstyle.skip
|
2020-07-15 10:47:16 +08:00
|
|
|
# Ensure mvn test works
|
|
|
|
mvn test -pl test -Dtest="io.ray.test.HelloWorldTest"
|
2019-03-22 14:30:05 +08:00
|
|
|
popd
|