Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ matrix:
- export PATH="$HOME/miniconda/bin:$PATH"
script:
- ./java/test.sh
- pushd java
- ./test_cluster.sh
- popd

- os: linux
dist: trusty
Expand Down
2 changes: 1 addition & 1 deletion java/cli/src/main/java/org/ray/cli/RayCli.java
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ private static void submit(CommandSubmit cmdSubmit, String configPath) throws Ex
RayLog.rapp.debug("registerApp " + appId + " for resouorce " + resourceId + " done");

// Unzip the package file.
String appDir = "/tmp/" + cmdSubmit.className;
String appDir = params.working_directory + "/" + cmdSubmit.className;
String extPath = appDir + "/" + packageName;
if (!FileUtil.createDir(extPath, false)) {
throw new RuntimeException("create dir " + extPath + " failed ");
Expand Down
2 changes: 2 additions & 0 deletions java/ray.config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ onebox_delay_seconds_before_run_app_logic = 0

use_raylet = false

raylet_port = 35567

; java class which main is served as the driver in a java worker
driver_class =

Expand Down
1 change: 1 addition & 0 deletions java/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ scripts_dir=$(cd "$(dirname "${BASH_SOURCE:-$0}")"; pwd)
cd $scripts_dir

export RAY_CONFIG=$scripts_dir/ray/ray.config.ini
echo RAY_CONFIG is $RAY_CONFIG
export LD_LIBRARY_PATH=$scripts_dir/ray/native/lib:$LD_LIBRARY_PATH
java -ea -classpath ray/java/lib/*:ray/java/lib/commons-cli-1.3.1.jar org.ray.cli.RayCli "$@"

54 changes: 54 additions & 0 deletions java/test/src/main/java/org/ray/api/example/HelloExample.java
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.

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

*/
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();
}
}
}
103 changes: 76 additions & 27 deletions java/test_cluster.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

my PR changed the logging path to /tmp/raylogs, you should rebase and change this accordingly.

[[ ${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