-
Notifications
You must be signed in to change notification settings - Fork 6k
/
Copy pathtest.sh
executable file
·116 lines (100 loc) · 3.93 KB
/
test.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#!/usr/bin/env bash
# Cause the script to exit if a single command fails.
set -e
# Show explicitly which commands are currently running.
set -x
ROOT_DIR=$(cd "$(dirname "${BASH_SOURCE:-$0}")"; pwd)
java -version
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
run_testng() {
local pid
local exit_code
"$@" &
pid=$!
if wait $pid; then
exit_code=0
else
exit_code=$?
fi
# exit_code == 2 means there are skipped tests.
if [ $exit_code -ne 2 ] && [ $exit_code -ne 0 ] ; then
# Only print log files if it ran in cluster mode
if [[ ! "$*" =~ SINGLE_PROCESS ]]; then
if [ $exit_code -gt 128 ] ; then
# Test crashed. Print the driver log for diagnosis.
cat /tmp/ray/session_latest/logs/java-core-driver-*$pid*
fi
fi
# Only print the hs_err_pid file of TestNG process
find . -name "hs_err_pid$pid.log" -exec cat {} +
exit $exit_code
fi
}
pushd "$ROOT_DIR"/..
echo "Build java maven deps."
bazel build //java:gen_maven_deps
echo "Build test jar."
bazel build //java:all_tests_deploy.jar
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
# NOTE(kfstrom): Java test troubleshooting only.
# Set MAX_ROUNDS to a big number (e.g. 1000) to run Java tests repeatedly.
# You may also want to modify java/testng.xml to run only a subset of test cases.
MAX_ROUNDS=1
if [ $MAX_ROUNDS -gt 1 ]; then
export RAY_BACKEND_LOG_LEVEL=debug
fi
round=1
while true; do
echo Starting cluster mode test round $round
echo "Running tests under cluster mode."
# 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 --config=ci || cluster_exit_code=$?
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
echo Finished cluster mode test round $round
date
round=$((round+1))
if (( round > MAX_ROUNDS )); then
break
fi
done
echo "Running tests under single-process mode."
# bazel test //java:all_tests --jvmopt="-Dray.run-mode=SINGLE_PROCESS" --config=ci || single_exit_code=$?
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
echo "Running connecting existing cluster tests."
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
RAY_BACKEND_LOG_LEVEL=debug ray start --head --port=6379 --redis-password=123456
RAY_BACKEND_LOG_LEVEL=debug java -cp bazel-bin/java/all_tests_deploy.jar -Dray.address="$ip:6379"\
-Dray.redis.password='123456' -Dray.job.code-search-path="$PWD/bazel-bin/java/all_tests_deploy.jar" io.ray.test.MultiDriverTest
ray stop
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 -Dray.job.num-java-workers-per-process=1 "io.ray.docdemo.$class"
done
popd
pushd "$ROOT_DIR"
echo "Testing maven install."
mvn -Dorg.slf4j.simpleLogger.defaultLogLevel=WARN clean install -DskipTests -Dcheckstyle.skip
# Ensure mvn test works
mvn test -pl test -Dtest="io.ray.test.HelloWorldTest"
popd