Beispiel #1
0
def test_get_webui(shutdown_only):
    addresses = ray.init(include_dashboard=True, num_cpus=1)
    webui_url = addresses["webui_url"]
    assert ray.get_dashboard_url() == webui_url

    assert re.match(r"^(localhost|\d+\.\d+\.\d+\.\d+):\d+$", webui_url)

    start_time = time.time()
    while True:
        try:
            node_info = requests.get("http://" + webui_url +
                                     "/api/node_info").json()
            break
        except requests.exceptions.ConnectionError:
            if time.time() > start_time + 30:
                error_log = None
                out_log = None
                with open(
                        "{}/logs/dashboard.out".format(
                            addresses["session_dir"]), "r") as f:
                    out_log = f.read()
                with open(
                        "{}/logs/dashboard.err".format(
                            addresses["session_dir"]), "r") as f:
                    error_log = f.read()
                raise Exception(
                    "Timed out while waiting for dashboard to start. "
                    "Dashboard output log: {}\n"
                    "Dashboard error log: {}\n".format(out_log, error_log))
    assert node_info["error"] is None
    assert node_info["result"] is not None
    assert isinstance(node_info["timestamp"], float)
Beispiel #2
0
def test_dashboard(shutdown_only):
    addresses = ray.init(include_dashboard=True, num_cpus=1)
    dashboard_url = addresses["webui_url"]
    assert ray.get_dashboard_url() == dashboard_url

    assert re.match(r"^(localhost|\d+\.\d+\.\d+\.\d+):\d+$", dashboard_url)

    start_time = time.time()
    while True:
        try:
            node_info_url = f"http://{dashboard_url}/nodes"
            resp = requests.get(node_info_url, params={"view": "summary"})
            resp.raise_for_status()
            summaries = resp.json()
            assert summaries["result"] is True
            assert "msg" in summaries
            break
        except (requests.exceptions.ConnectionError, AssertionError):
            if time.time() > start_time + 30:
                out_log = None
                with open(
                        "{}/logs/dashboard.log".format(
                            addresses["session_dir"]), "r") as f:
                    out_log = f.read()
                raise Exception(
                    "Timed out while waiting for dashboard to start. "
                    f"Dashboard output log: {out_log}\n")
Beispiel #3
0
def test_port_auto_increment(shutdown_only):
    ray.init()
    url = ray.get_dashboard_url()

    def dashboard_available():
        try:
            requests.get("http://" + url).status_code == 200
            return True
        except Exception:
            return False

    wait_for_condition(dashboard_available)

    run_string_as_driver(f"""
import ray
from ray.test_utils import wait_for_condition
import requests
ray.init()
url = ray.get_dashboard_url()
assert url != "{url}"
def dashboard_available():
    try:
        requests.get("http://"+url).status_code == 200
        return True
    except:
        return False
wait_for_condition(dashboard_available)
ray.shutdown()
        """)
Beispiel #4
0
def test_ray_start_default_port_conflict(call_ray_stop_only, shutdown_only):
    subprocess.check_call(["ray", "start", "--head"])
    ray.init(address="auto")
    assert str(ray_constants.DEFAULT_DASHBOARD_PORT) in ray.get_dashboard_url()

    try:
        subprocess.check_output(
            [
                "ray",
                "start",
                "--head",
                "--port",
                "9999",  # use a different gcs port
            ],
            stderr=subprocess.PIPE)
    except subprocess.CalledProcessError as e:
        assert b"already in use" in e.stderr
Beispiel #5
0
def test_ray_start_default_port_conflict(call_ray_stop_only, shutdown_only):
    subprocess.check_call(["ray", "start", "--head"])
    ray.init(address="auto")
    assert str(ray_constants.DEFAULT_DASHBOARD_PORT) in ray.get_dashboard_url()

    error_raised = False
    try:
        subprocess.check_output(
            [
                "ray",
                "start",
                "--head",
                "--port",
                "9999",  # use a different gcs port
                "--include-dashboard=True"
            ],
            stderr=subprocess.PIPE)
    except subprocess.CalledProcessError as e:
        assert b"already occupied" in e.stderr
        error_raised = True

    assert error_raised, "ray start should cause a conflict error"