forked from ray-project/ray
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move serve and asyncio tests to bazel (ray-project#6979)
- Loading branch information
Showing
6 changed files
with
164 additions
and
92 deletions.
There are no files selected for viewing
This file contains 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 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,28 @@ | ||
# This is a dummy test dependency that causes the above tests to be | ||
# re-run if any of these files changes. | ||
py_library( | ||
name = "serve_lib", | ||
srcs = glob(["**/*.py"], exclude=["tests/*.py"]), | ||
) | ||
|
||
# This test aggregates all serve tests and run them in a single session | ||
# similar to `pytest .` | ||
# Serve tests need to run in a single session because starting and stopping | ||
# serve cluster take a large chunk of time. All serve tests use a shared | ||
# cluster. | ||
py_test( | ||
name = "test_serve", | ||
size = "medium", | ||
srcs = glob(["tests/*.py"]), | ||
tags = ["exclusive"], | ||
deps = [":serve_lib"], | ||
) | ||
|
||
# Make sure the example showing in doc is tested | ||
py_test( | ||
name = "echo_full", | ||
size = "small", | ||
srcs = glob(["examples/*.py"]), | ||
tags = ["exclusive"], | ||
deps = [":serve_lib"] | ||
) |
This file contains 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,15 @@ | ||
import pytest | ||
from pathlib import Path | ||
import sys | ||
|
||
if __name__ == "__main__": | ||
curr_dir = Path(__file__).parent | ||
test_paths = curr_dir.rglob("test_*.py") | ||
sorted_path = sorted(map(lambda path: str(path.absolute()), test_paths)) | ||
serve_tests_files = list(sorted_path) | ||
|
||
print("Testing the following files") | ||
for test_file in serve_tests_files: | ||
print("->", test_file.split("/")[-1]) | ||
|
||
sys.exit(pytest.main(["-v", "-s"] + serve_tests_files)) |
This file contains 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 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,98 @@ | ||
# coding: utf-8 | ||
import pytest | ||
|
||
import ray | ||
import ray.cluster_utils | ||
import ray.test_utils | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"ray_start_regular", [{ | ||
"local_mode": True | ||
}, { | ||
"local_mode": False | ||
}], | ||
indirect=True) | ||
def test_args_force_positional(ray_start_regular): | ||
def force_positional(*, a="hello", b="helxo", **kwargs): | ||
return a, b, kwargs | ||
|
||
class TestActor(): | ||
def force_positional(self, a="hello", b="heo", *args, **kwargs): | ||
return a, b, args, kwargs | ||
|
||
def test_function(fn, remote_fn): | ||
assert fn(a=1, b=3, c=5) == ray.get(remote_fn.remote(a=1, b=3, c=5)) | ||
assert fn(a=1) == ray.get(remote_fn.remote(a=1)) | ||
assert fn(a=1) == ray.get(remote_fn.remote(a=1)) | ||
|
||
remote_test_function = ray.remote(test_function) | ||
|
||
remote_force_positional = ray.remote(force_positional) | ||
test_function(force_positional, remote_force_positional) | ||
ray.get( | ||
remote_test_function.remote(force_positional, remote_force_positional)) | ||
|
||
remote_actor_class = ray.remote(TestActor) | ||
remote_actor = remote_actor_class.remote() | ||
actor_method = remote_actor.force_positional | ||
local_actor = TestActor() | ||
local_method = local_actor.force_positional | ||
test_function(local_method, actor_method) | ||
ray.get(remote_test_function.remote(local_method, actor_method)) | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"ray_start_regular", [{ | ||
"local_mode": False | ||
}, { | ||
"local_mode": True | ||
}], | ||
indirect=True) | ||
def test_args_intertwined(ray_start_regular): | ||
def args_intertwined(a, *args, x="hello", **kwargs): | ||
return a, args, x, kwargs | ||
|
||
class TestActor(): | ||
def args_intertwined(self, a, *args, x="hello", **kwargs): | ||
return a, args, x, kwargs | ||
|
||
@classmethod | ||
def cls_args_intertwined(cls, a, *args, x="hello", **kwargs): | ||
return a, args, x, kwargs | ||
|
||
def test_function(fn, remote_fn): | ||
assert fn( | ||
1, 2, 3, x="hi", y="hello") == ray.get( | ||
remote_fn.remote(1, 2, 3, x="hi", y="hello")) | ||
assert fn( | ||
1, 2, 3, y="1hello") == ray.get( | ||
remote_fn.remote(1, 2, 3, y="1hello")) | ||
assert fn(1, y="1hello") == ray.get(remote_fn.remote(1, y="1hello")) | ||
|
||
remote_test_function = ray.remote(test_function) | ||
|
||
remote_args_intertwined = ray.remote(args_intertwined) | ||
test_function(args_intertwined, remote_args_intertwined) | ||
ray.get( | ||
remote_test_function.remote(args_intertwined, remote_args_intertwined)) | ||
|
||
remote_actor_class = ray.remote(TestActor) | ||
remote_actor = remote_actor_class.remote() | ||
actor_method = remote_actor.args_intertwined | ||
local_actor = TestActor() | ||
local_method = local_actor.args_intertwined | ||
test_function(local_method, actor_method) | ||
ray.get(remote_test_function.remote(local_method, actor_method)) | ||
|
||
actor_method = remote_actor.cls_args_intertwined | ||
local_actor = TestActor() | ||
local_method = local_actor.cls_args_intertwined | ||
test_function(local_method, actor_method) | ||
ray.get(remote_test_function.remote(local_method, actor_method)) | ||
|
||
|
||
if __name__ == "__main__": | ||
import pytest | ||
import sys | ||
sys.exit(pytest.main(["-v", __file__])) |
This file contains 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