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()
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
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