Exemple #1
0
def test_integration(request, tmpdir):
    """Actually start the server, wait for it to be online and do a health check"""
    with tmpdir.as_cwd():
        server = ServerMonitor()
        server.start()
        request.addfinalizer(lambda: server.shutdown())

        resp = requests.get(
            f"{server.fetch_url()}/healthcheck", auth=server.fetch_auth()
        )
        assert "ALL OK!" in resp.json()

        # Use global connection info
        conn_info = connection.get_info()
        requests.get(conn_info["baseurl"] + "/healthcheck", auth=conn_info["auth"])

        # Use local connection info
        conn_info = connection.get_info(str(tmpdir))
        requests.get(conn_info["baseurl"] + "/healthcheck", auth=conn_info["auth"])

        server.shutdown()
        assert not (tmpdir / "storage_server.json").exists()

        # Global connection info no longer valid
        with pytest.raises(RuntimeError):
            connection.get_info()
Exemple #2
0
def _assert_server_info() -> None:
    global _STORAGE_URL, _STORAGE_TOKEN  # pylint: disable=global-statement

    if _STORAGE_URL is None:
        info = get_info()
        _STORAGE_URL = info["baseurl"]
        _STORAGE_TOKEN = info["auth"][1]
Exemple #3
0
def _service_check(args: Any) -> None:
    if args.service_name == "storage":
        for _ in range(args.timeout):
            try:
                info = get_info()
                print(f"Ert storage found: {info['baseurl']}")
                return
            except RuntimeError:
                print("Connecting to ert-storage...")
                time.sleep(1)
                continue
        raise SystemExit("ERROR: Ert storage not found!")

    raise SystemExit(f"{args.service_name} not implemented")
Exemple #4
0
def get_info(project_id=None):
    from ert_shared.storage.connection import get_info

    return get_info(project_id)
Exemple #5
0
def get_auth(project_id=None):
    return get_info(project_id)["auth"]
Exemple #6
0
def get_url(project_id=None):
    return get_info(project_id)["baseurl"]
Exemple #7
0
def get_auth(project_id: str = None) -> str:
    return get_info(project_id)["auth"]
Exemple #8
0
def get_url(project_id: str = None) -> str:
    return get_info(project_id)["baseurl"]
Exemple #9
0
def get_info(project_id: str = None) -> Mapping[str, str]:
    from ert_shared.storage.connection import get_info

    return get_info(project_id)
Exemple #10
0
def get_data_loader(project_id: Optional[str] = None) -> DataLoader:
    return DataLoader(*(get_info(project_id).values()))
Exemple #11
0
def get_info(project_id: str = None) -> Mapping[str, str]:
    from ert_shared.storage.connection import get_info

    info = get_info(project_id)
    info["auth"] = info["auth"][1]
    return info