Exemple #1
0
def server(db_apis, request):
    proc = ServerMonitor(rdb_url=ERT_STORAGE.rdb_url,
                         blob_url=ERT_STORAGE.blob_url,
                         lockfile=False)
    proc.start()
    request.addfinalizer(lambda: proc.shutdown())
    yield proc
Exemple #2
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 #3
0
def server(request, monkeypatch, tmp_path: Path):
    marker = request.node.get_closest_marker("script")
    if marker is None:
        return

    script = (
        dedent(
            """\
    #!/usr/bin/python3
    import os
    import sys
    import time
    fd = os.environ.get("ERT_COMM_FD")
    if fd is not None: fd = int(fd)

    """
        )
        + marker.args[0]
    )
    path = tmp_path / "script"
    path.write_text(script)
    path.chmod(0o755)
    monkeypatch.setattr(ServerMonitor, "EXEC_ARGS", [str(path)])
    monkeypatch.setattr(ServerMonitor, "TIMEOUT", 5)

    proc = ServerMonitor()
    proc.start()
    yield proc
def test_integration_auth(request, tmpdir):
    """Start the server, wait for it to be online and then do a health check with an
    invalid auth"""
    with tmpdir.as_cwd():
        server = ServerMonitor()
        server.start()
        request.addfinalizer(lambda: server.shutdown())

        # No auth
        resp = requests.get(f"{server.fetch_url()}/healthcheck")
        assert resp.status_code == 401

        # Invalid auth
        resp = requests.get(f"{server.fetch_url()}/healthcheck",
                            auth=("__token__", "invalid-token"))
        assert resp.status_code == 403
def server(db_api, request):
    proc = ServerMonitor(rdb_url=ERT_STORAGE.SQLALCHEMY_URL, lockfile=False)
    proc.start()
    request.addfinalizer(lambda: proc.shutdown())
    yield proc