forked from ray-project/ray
-
Notifications
You must be signed in to change notification settings - Fork 25
Enable java cluster test in CI. #68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
cc7ba07
Fix test_cluster.sh.
jovany-wang b1acc10
Enable test_cluster.sh in ci.
jovany-wang 0d38bf7
test
jovany-wang 12d59bd
test
jovany-wang e022b73
test
jovany-wang 8826341
test
jovany-wang b76d5b8
fix comments.
jovany-wang df4d581
Add an example for test_cluster.sh
jovany-wang 0561c8d
Fix.
jovany-wang d1f1340
Fix in ubuntu.
jovany-wang db481b3
Move test_cluster work space to /tmp.
jovany-wang 81984a7
Revert a error.
jovany-wang File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
java/test/src/main/java/org/ray/api/example/HelloExample.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| package org.ray.api.example; | ||
|
|
||
| import org.ray.api.Ray; | ||
| import org.ray.api.RayObject; | ||
| import org.ray.api.RayRemote; | ||
| import org.ray.core.RayRuntime; | ||
|
|
||
| /** | ||
| * HelloWorld example for tests, like test cluster. | ||
| */ | ||
| public class HelloExample { | ||
|
|
||
| @RayRemote | ||
| public static String sayHello() { | ||
| String ret = "hello"; | ||
| System.out.println(ret); | ||
| return ret; | ||
| } | ||
|
|
||
| @RayRemote | ||
| public static String sayWorld() { | ||
| String ret = "world!"; | ||
| System.out.println(ret); | ||
| return ret; | ||
| } | ||
|
|
||
| /** | ||
| * A remote function with dependency. | ||
| */ | ||
| @RayRemote | ||
| public static String merge(String hello, String world) { | ||
| return hello + "," + world; | ||
| } | ||
|
|
||
| public static String sayHelloWorld() { | ||
| RayObject<String> hello = Ray.call(HelloExample::sayHello); | ||
| RayObject<String> world = Ray.call(HelloExample::sayWorld); | ||
| // Pass unfinished results as the parameters to another remote function. | ||
| return Ray.call(HelloExample::merge, hello, world).get(); | ||
| } | ||
|
|
||
| public static void main(String[] args) throws Exception { | ||
| try { | ||
| Ray.init(); | ||
| String helloWorld = HelloExample.sayHelloWorld(); | ||
| System.out.println(helloWorld); | ||
| assert "hello,world!".equals(helloWorld); | ||
| } catch (Throwable t) { | ||
| t.printStackTrace(); | ||
| } finally { | ||
| RayRuntime.getInstance().cleanUp(); | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,30 +2,79 @@ | |
|
|
||
| ############################# | ||
| # build deploy file and deploy cluster | ||
| sh cleanup.sh | ||
| rm -rf local_deploy | ||
| ./prepare.sh -t local_deploy | ||
| pushd local_deploy | ||
| local_ip=`ifconfig -a|grep inet|grep -v 127.0.0.1|grep -v inet6|awk '{print $2}'|tr -d "addr:"` | ||
| #echo "use local_ip" $local_ip | ||
| OVERWRITE="ray.java.start.redis_port=34222;ray.java.start.node_ip_address=$local_ip;ray.java.start.deploy=true;ray.java.start.run_mode=CLUSTER" | ||
| echo OVERWRITE is $OVERWRITE | ||
| ./run.sh start --head --overwrite=$OVERWRITE > cli.log 2>&1 & | ||
| popd | ||
| sleep 10 | ||
|
|
||
| # auto-pack zip for app example | ||
| pushd example | ||
| if [ ! -d "app1/" ];then | ||
| mkdir app1 | ||
| fi | ||
| cp -rf target/ray-tutorial-1.0.jar app1/ | ||
| zip -r app1.zip app1 | ||
| popd | ||
|
|
||
| # run with cluster mode | ||
| pushd local_deploy | ||
| export RAY_CONFIG=ray/ray.config.ini | ||
| ARGS=" --package ../example/app1.zip --class org.ray.example.HelloWorld --args=test1,test2 --redis-address=$local_ip:34222" | ||
| ../local_deploy/run.sh submit $ARGS | ||
| popd | ||
|
|
||
| function run_test() { | ||
| sh cleanup.sh | ||
| rm -rf /tmp/ray_test | ||
|
|
||
| ./prepare.sh -t /tmp/ray_test/local_deploy | ||
|
|
||
| pushd /tmp/ray_test/local_deploy | ||
| local_ips=`ifconfig -a|grep inet|grep -v 127.0.0.1|grep -v inet6|awk '{print $2}'|tr -d "addr:"` | ||
| local_ip=$(echo $local_ips | awk -F " " '{print $NF}') | ||
| echo "use local_ip" $local_ip | ||
|
|
||
| # Rewrite the ray.config.ini | ||
| if [ "$1" == "raylet" ]; then | ||
| sed -i 's/^use_raylet.*$/use_raylet = true/g' ./ray/ray.config.ini | ||
| else | ||
| sed -i 's/^use_raylet.*$/use_raylet = false/g' ./ray/ray.config.ini | ||
| fi | ||
|
|
||
| OVERWRITE="ray.java.start.redis_port=34222;ray.java.start.node_ip_address=$local_ip;ray.java.start.deploy=true;ray.java.start.run_mode=CLUSTER;ray.java.start.raylet_port=35567;" | ||
|
|
||
| echo OVERWRITE is $OVERWRITE | ||
| ./run.sh start --head --overwrite=$OVERWRITE > cli.log 2>&1 & | ||
| popd | ||
| sleep 10 | ||
|
|
||
| pushd /tmp/ray_test | ||
| # auto-pack zip for app example | ||
| if [ ! -d "example/" ]; then | ||
| mkdir example | ||
| fi | ||
|
|
||
| pushd example | ||
| if [ ! -d "app1/" ]; then | ||
| mkdir app1 | ||
| fi | ||
| popd | ||
|
|
||
| popd # popd from /tmp/ray_test | ||
|
|
||
| cp -rf test/target/ray-test-1.0.jar /tmp/ray_test/example/app1/ | ||
|
|
||
| pushd /tmp/ray_test | ||
| pushd example | ||
| zip -r app1.zip app1 | ||
| popd | ||
|
|
||
| # run with cluster mode | ||
| pushd local_deploy | ||
| export RAY_CONFIG=ray/ray.config.ini | ||
| ARGS=" --package ../example/app1.zip --class org.ray.api.example.HelloExample --args=test1,test2 --redis-address=$local_ip:34222" | ||
| ../local_deploy/run.sh submit $ARGS | ||
| popd | ||
|
|
||
| sleep 3 | ||
| # Remove raylet socket file. | ||
| if [[ -a /tmp/raylet35567 ]]; then | ||
| rm /tmp/raylet35567 | ||
| fi | ||
|
|
||
| # Check the result | ||
| start_process_log=$(cat "./local_deploy/cli.log") | ||
| [[ ${start_process_log} =~ "Started Ray head node" ]] || exit 1 | ||
| echo "Check[$1]: Ray all processes started." | ||
|
|
||
| execution_log=$(cat "./local_deploy/ray/run/org.ray.api.example.HelloExample/0.out.txt") | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. my PR changed the logging path to |
||
| [[ ${execution_log} =~ "hello,world!" ]] || exit 1 | ||
| echo "Check[$1]: The tests ran successfully." | ||
|
|
||
| popd # popd from /tmp/ray_test | ||
|
|
||
| sudo rm -rf /tmp/ray_test | ||
| } | ||
|
|
||
| run_test non-raylet | ||
| run_test raylet | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
test cluster->test_cluster.sh