mirror of
https://github.com/wassname/ray.git
synced 2026-07-02 03:50:57 +08:00
36 lines
1.1 KiB
Python
36 lines
1.1 KiB
Python
import os
|
|
|
|
import pytest
|
|
|
|
import ray
|
|
from ray import serve
|
|
|
|
if os.environ.get("RAY_SERVE_INTENTIONALLY_CRASH", False) == 1:
|
|
serve.controller._CRASH_AFTER_CHECKPOINT_PROBABILITY = 0.5
|
|
|
|
|
|
@pytest.fixture(scope="session")
|
|
def _shared_serve_instance():
|
|
# Uncomment the line below to turn on debug log for tests.
|
|
# os.environ["SERVE_LOG_DEBUG"] = "1"
|
|
# Overriding task_retry_delay_ms to relaunch actors more quickly
|
|
ray.init(
|
|
num_cpus=36,
|
|
_metrics_export_port=9999,
|
|
_system_config={
|
|
"metrics_report_interval_ms": 1000,
|
|
"task_retry_delay_ms": 50
|
|
})
|
|
yield serve.start(detached=True)
|
|
|
|
|
|
@pytest.fixture
|
|
def serve_instance(_shared_serve_instance):
|
|
yield _shared_serve_instance
|
|
controller = _shared_serve_instance._controller
|
|
# Clear all state between tests to avoid naming collisions.
|
|
for endpoint in ray.get(controller.get_all_endpoints.remote()):
|
|
_shared_serve_instance.delete_endpoint(endpoint)
|
|
for backend in ray.get(controller.get_all_backends.remote()):
|
|
_shared_serve_instance.delete_backend(backend)
|