mirror of
https://github.com/wassname/ray.git
synced 2026-07-19 11:27:32 +08:00
Use XRay backend by default. (#3020)
* Use XRay backend by default. * Remove irrelevant valgrind tests. * Fix * Move tests around. * Fix * Fix test * Fix test. * String/unicode fix. * Fix test * Fix unicode issue. * Minor changes * Fix bug in test_global_state.py. * Fix test. * Linting * Try arrow change and other object manager changes. * Use newer plasma client API * Small updates * Revert plasma client api change. * Update * Update arrow and allow SendObjectHeaders to fail. * Update arrow * Update python/ray/experimental/state.py Co-Authored-By: robertnishihara <robertnishihara@gmail.com> * Address comments.
This commit is contained in:
committed by
Philipp Moritz
parent
9d2e864caf
commit
9c1826ed69
@@ -2,57 +2,57 @@ from __future__ import absolute_import
|
||||
from __future__ import division
|
||||
from __future__ import print_function
|
||||
|
||||
import pytest
|
||||
import time
|
||||
|
||||
import ray
|
||||
|
||||
|
||||
def setup_module():
|
||||
if not ray.worker.global_worker.connected:
|
||||
ray.init(num_cpus=1)
|
||||
|
||||
# Finish initializing Ray. Otherwise available_resources() does not
|
||||
# reflect resource use of submitted tasks
|
||||
ray.get(cpu_task.remote(0))
|
||||
@pytest.fixture
|
||||
def ray_start():
|
||||
# Start the Ray processes.
|
||||
ray.init(num_cpus=1)
|
||||
yield None
|
||||
# The code after the yield will run as teardown code.
|
||||
ray.shutdown()
|
||||
|
||||
|
||||
@ray.remote(num_cpus=1)
|
||||
def cpu_task(seconds):
|
||||
time.sleep(seconds)
|
||||
def test_replenish_resources(ray_start):
|
||||
cluster_resources = ray.global_state.cluster_resources()
|
||||
available_resources = ray.global_state.available_resources()
|
||||
assert cluster_resources == available_resources
|
||||
|
||||
@ray.remote
|
||||
def cpu_task():
|
||||
pass
|
||||
|
||||
ray.get(cpu_task.remote())
|
||||
start = time.time()
|
||||
resources_reset = False
|
||||
|
||||
class TestAvailableResources(object):
|
||||
timeout = 10
|
||||
|
||||
def test_no_tasks(self):
|
||||
cluster_resources = ray.global_state.cluster_resources()
|
||||
while not resources_reset and time.time() - start < timeout:
|
||||
available_resources = ray.global_state.available_resources()
|
||||
assert cluster_resources == available_resources
|
||||
resources_reset = (cluster_resources == available_resources)
|
||||
|
||||
def test_replenish_resources(self):
|
||||
cluster_resources = ray.global_state.cluster_resources()
|
||||
assert resources_reset
|
||||
|
||||
ray.get(cpu_task.remote(0))
|
||||
start = time.time()
|
||||
resources_reset = False
|
||||
|
||||
while not resources_reset and time.time() - start < self.timeout:
|
||||
available_resources = ray.global_state.available_resources()
|
||||
resources_reset = (cluster_resources == available_resources)
|
||||
def test_uses_resources(ray_start):
|
||||
cluster_resources = ray.global_state.cluster_resources()
|
||||
|
||||
assert resources_reset
|
||||
@ray.remote
|
||||
def cpu_task():
|
||||
time.sleep(1)
|
||||
|
||||
def test_uses_resources(self):
|
||||
cluster_resources = ray.global_state.cluster_resources()
|
||||
task_id = cpu_task.remote(1)
|
||||
start = time.time()
|
||||
resource_used = False
|
||||
cpu_task.remote()
|
||||
resource_used = False
|
||||
|
||||
while not resource_used and time.time() - start < self.timeout:
|
||||
available_resources = ray.global_state.available_resources()
|
||||
resource_used = available_resources[
|
||||
"CPU"] == cluster_resources["CPU"] - 1
|
||||
start = time.time()
|
||||
timeout = 10
|
||||
while not resource_used and time.time() - start < timeout:
|
||||
available_resources = ray.global_state.available_resources()
|
||||
resource_used = available_resources[
|
||||
"CPU"] == cluster_resources["CPU"] - 1
|
||||
|
||||
assert resource_used
|
||||
|
||||
ray.get(task_id) # clean up to reset resources
|
||||
assert resource_used
|
||||
|
||||
@@ -25,19 +25,11 @@ def shutdown_only():
|
||||
|
||||
|
||||
class TestRedisPassword(object):
|
||||
@pytest.mark.skipif(
|
||||
os.environ.get("RAY_USE_NEW_GCS") != "on"
|
||||
and os.environ.get("RAY_USE_XRAY"),
|
||||
reason="Redis authentication works for raylet and old GCS.")
|
||||
def test_exceptions(self, password, shutdown_only):
|
||||
with pytest.raises(Exception):
|
||||
ray.init(redis_password=password)
|
||||
|
||||
@pytest.mark.skipif(
|
||||
os.environ.get("RAY_USE_NEW_GCS") == "on",
|
||||
reason="New GCS API doesn't support Redis authentication yet.")
|
||||
@pytest.mark.skipif(
|
||||
not os.environ.get("RAY_USE_XRAY"),
|
||||
os.environ.get("RAY_USE_XRAY") == "0",
|
||||
reason="Redis authentication is not supported in legacy Ray.")
|
||||
def test_redis_password(self, password, shutdown_only):
|
||||
# Workaround for https://github.com/ray-project/ray/issues/3045
|
||||
|
||||
Reference in New Issue
Block a user