コード例 #1
0
def test_parse_cluster_info(address: str):
    if address.startswith("ray"):
        assert parse_cluster_info(address, False) == ClusterInfo(
            address="http" + address[address.index("://"):],
            cookies=None,
            metadata=None)
    elif address.startswith("http") or address.startswith("https"):
        assert parse_cluster_info(address, False) == ClusterInfo(
            address=address, cookies=None, metadata=None)
    else:
        with pytest.raises(RuntimeError):
            parse_cluster_info(address, False)
コード例 #2
0
def test_parse_cluster_info(scheme: str, host: str, port: Optional[int]):
    address = f"{scheme}://{host}"
    if port is not None:
        address += f":{port}"

    final_port = port if port is not None else DEFAULT_DASHBOARD_PORT
    if scheme in {"http", "ray"}:
        assert parse_cluster_info(address, False) == ClusterInfo(
            address=f"http://{host}:{final_port}",
            cookies=None,
            metadata=None,
            headers=None,
        )
    elif scheme == "https":
        assert parse_cluster_info(address, False) == ClusterInfo(
            address=f"https://{host}:{final_port}",
            cookies=None,
            metadata=None,
            headers=None,
        )
    else:
        with pytest.raises(RuntimeError):
            parse_cluster_info(address, False)