Add test for Ray outputs (#9231)

This commit is contained in:
Siyuan (Ryans) Zhuang
2020-06-30 23:54:54 -07:00
committed by GitHub
parent 8a1a2be4ed
commit a1dfcfc893
2 changed files with 38 additions and 0 deletions
+8
View File
@@ -464,3 +464,11 @@ py_test(
tags = ["exclusive", "manual"],
deps = ["//:ray_lib"],
)
py_test(
name = "test_output",
size = "medium",
srcs = SRCS + ["test_output.py"],
tags = ["exclusive"],
deps = ["//:ray_lib"],
)
+30
View File
@@ -0,0 +1,30 @@
import re
import subprocess
import sys
import pytest
import ray
def test_output():
outputs = subprocess.check_output(
[sys.executable, __file__, "_ray_instance"],
stderr=subprocess.STDOUT).decode()
lines = outputs.split("\n")
assert len(lines) == 3
logging_header = r"\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2},\d{3}\sINFO\s"
assert re.match(
logging_header + r"resource_spec.py:\d+ -- Starting Ray with [0-9\.]+ "
r"GiB memory available for workers and up to [0-9\.]+ GiB "
r"for objects. You can adjust these settings with .*?.", lines[0])
assert re.match(
logging_header +
r"services.py:\d+ -- View the Ray dashboard at .*?localhost:\d+?.*",
lines[1])
if __name__ == "__main__":
if len(sys.argv) > 1 and sys.argv[1] == "_ray_instance":
ray.init()
ray.shutdown()
else:
sys.exit(pytest.main(["-v", __file__]))