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)
|
|
|
|
|
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
|
|
|
|
exit $exit_code
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2019-03-22 14:30:05 +08:00
|
|
|
pushd $ROOT_DIR/..
|
|
|
|
echo "Linting Java code with checkstyle."
|
2019-03-23 10:44:11 +08:00
|
|
|
# NOTE(hchen): The `test_tag_filters` option causes bazel to ignore caches.
|
|
|
|
# Thus, we add the `build_tests_only` option to avoid re-building everything.
|
|
|
|
bazel test //java:all --test_tag_filters="checkstyle" --build_tests_only
|
2019-03-07 09:59:13 +08:00
|
|
|
|
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
|
|
|
|
|
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.
|
|
|
|
# bazel test //java:all_tests --action_env=ENABLE_MULTI_LANGUAGE_TESTS=1 --test_output="errors" || cluster_exit_code=$?
|
2019-04-02 17:41:20 +08:00
|
|
|
ENABLE_MULTI_LANGUAGE_TESTS=1 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."
|
2019-03-22 14:30:05 +08:00
|
|
|
# bazel test //java:all_tests --jvmopt="-Dray.run-mode=SINGLE_PROCESS" --test_output="errors" || single_exit_code=$?
|
2019-04-02 17:41:20 +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
|
|
|
|
2018-08-02 08:52:49 +08:00
|
|
|
popd
|
2019-03-22 14:30:05 +08:00
|
|
|
|
|
|
|
pushd $ROOT_DIR
|
|
|
|
echo "Testing maven install."
|
2020-04-17 07:30:37 -07:00
|
|
|
mvn -Dorg.slf4j.simpleLogger.defaultLogLevel=WARN clean install -DskipTests
|
2019-03-22 14:30:05 +08:00
|
|
|
popd
|