[C++ worker] move xlang test to separate test file (#25756)

This commit is contained in:
Guyang Song 2022-06-17 11:05:24 +08:00 committed by GitHub
parent f6735f90c7
commit 974bbc0f43
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 72 additions and 20 deletions

View file

@ -144,12 +144,17 @@ cc_test(
cc_test(
name = "cluster_mode_test",
srcs = glob([
"src/ray/test/cluster/*.cc",
"src/ray/test/cluster/*.h",
]),
srcs = glob(
[
"src/ray/test/cluster/*.cc",
"src/ray/test/cluster/*.h",
],
exclude = [
"src/ray/test/cluster/cluster_mode_xlang_test.cc",
],
),
args = [
"--ray_code_search_path=$(location plus.so):$(location counter.so):cpp/src/ray/test/cluster:$(location //java:libio_ray_ray_test.jar)",
"--ray_code_search_path=$(location plus.so):$(location counter.so):cpp/src/ray/test/cluster",
"--ray_head_args '--include-dashboard false'",
],
copts = COPTS,
@ -158,6 +163,28 @@ cc_test(
"plus.so",
"ray_cpp_pkg",
"src/ray/test/cluster/test_cross_language_invocation.py",
],
linkstatic = True,
tags = ["team:core"],
deps = [
"ray_api",
"@com_google_googletest//:gtest_main",
],
)
cc_test(
name = "cluster_mode_xlang_test",
srcs = glob([
"src/ray/test/cluster/cluster_mode_xlang_test.cc",
"src/ray/test/cluster/*.h",
]),
args = [
"--ray_code_search_path=$(location //java:libio_ray_ray_test.jar)",
"--ray_head_args '--include-dashboard false'",
],
copts = COPTS,
data = [
"ray_cpp_pkg",
"//java:libio_ray_ray_test.jar",
],
linkstatic = True,

View file

@ -252,21 +252,6 @@ TEST(RayClusterModeTest, PythonInvocationTest) {
EXPECT_EQ(p.name, py_result.name);
}
TEST(RayClusterModeTest, JavaInvocationTest) {
auto java_actor_handle =
ray::Actor(ray::JavaActorClass{"io.ray.test.Counter"}).Remote(1);
EXPECT_TRUE(!java_actor_handle.ID().empty());
auto java_actor_ret =
java_actor_handle.Task(ray::JavaActorMethod<int>{"increase"}).Remote(2);
EXPECT_EQ(3, *java_actor_ret.Get());
auto java_task_ret =
ray::Task(ray::JavaFunction<std::string>{"io.ray.test.CrossLanguageInvocationTest",
"returnInputString"})
.Remote("helloworld");
EXPECT_EQ("helloworld", *java_task_ret.Get());
}
TEST(RayClusterModeTest, MaxConcurrentTest) {
auto actor1 =
ray::Actor(ActorConcurrentCall::FactoryCreate).SetMaxConcurrency(3).Remote();

View file

@ -0,0 +1,40 @@
// Copyright 2022 The Ray Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include <gtest/gtest.h>
#include <ray/api.h>
TEST(RayClusterModeXLangTest, JavaInvocationTest) {
auto java_actor_handle =
ray::Actor(ray::JavaActorClass{"io.ray.test.Counter"}).Remote(1);
EXPECT_TRUE(!java_actor_handle.ID().empty());
auto java_actor_ret =
java_actor_handle.Task(ray::JavaActorMethod<int>{"increase"}).Remote(2);
EXPECT_EQ(3, *java_actor_ret.Get());
auto java_task_ret =
ray::Task(ray::JavaFunction<std::string>{"io.ray.test.CrossLanguageInvocationTest",
"returnInputString"})
.Remote("helloworld");
EXPECT_EQ("helloworld", *java_task_ret.Get());
}
int main(int argc, char **argv) {
ray::RayConfig config;
ray::Init(config, argc, argv);
::testing::InitGoogleTest(&argc, argv);
int ret = RUN_ALL_TESTS();
ray::Shutdown();
return ret;
}