Skip to content

Commit

Permalink
Support roundtrip test segmentation by proxy.
Browse files Browse the repository at this point in the history
Per comment, remove deprecated aws4auth code.

Signed-off-by: Joshua Hoskins <[email protected]>
  • Loading branch information
friendtocephalopods committed Sep 28, 2020
1 parent c239a1f commit e4a8ddb
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 408 deletions.
303 changes: 0 additions & 303 deletions metadata_service/proxy/aws4authwebsocket/transport.py

This file was deleted.

18 changes: 8 additions & 10 deletions metadata_service/proxy/janus_graph_proxy.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
# Copyright Contributors to the Amundsen project.
# SPDX-License-Identifier: Apache-2.0

from metadata_service.proxy.aws4authwebsocket.transport import WebsocketClientTransport
from .gremlin_proxy import AbstractGremlinProxy
from typing import Any, Mapping, Optional, Type

from amundsen_gremlin.script_translator import ScriptTranslatorTargetJanusgraph
from overrides import overrides

from .gremlin_proxy import AbstractGremlinProxy


class JanusGraphGremlinProxy(AbstractGremlinProxy):
"""
A proxy to a JanusGraph using the Gremlin protocol.
TODO: HTTP proxy support. This does *NOT* support HTTP proxies as-is. Why? The default transport factory in
gremlin_python is tornado.websocket, which is hardcoded to use simple_httpclient (look at
WebSocketClientConnection). But, even if that could be made to use curl_httpclient, curl_httpclient requires pycurl
which requires libcurl and other native libraries which is a pain to install.
"""

def __init__(self, *, host: str, port: Optional[int] = None, user: Optional[str] = None,
password: Optional[str] = None, traversal_source: 'str' = 'g',
driver_remote_connection_options: Mapping[str, Any] = {},
websocket_options: Mapping[str, Any] = {}) -> None:
driver_remote_connection_options: Mapping[str, Any] = {}) -> None:
driver_remote_connection_options = dict(driver_remote_connection_options)

# as others, we repurpose host a url, and url can be an HTTPRequest
Expand All @@ -34,11 +37,6 @@ def __init__(self, *, host: str, port: Optional[int] = None, user: Optional[str]

driver_remote_connection_options.update(traversal_source=traversal_source)

# we could use the default Transport, but then we'd have to take different options, which feels clumsier.
def factory() -> WebsocketClientTransport:
return WebsocketClientTransport(extra_websocket_options=websocket_options or {})
driver_remote_connection_options.update(transport_factory=factory)

# use _key
super().__init__(key_property_name='_key',
driver_remote_connection_options=driver_remote_connection_options)
Expand Down
2 changes: 0 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,5 @@ requests-aws4auth==0.9
statsd==3.2.1
pyatlasclient==1.0.5
beaker>=1.10.0
mocket==3.7.3
overrides==2.5
websocket-client==0.56.0
typed-ast==1.4.1
17 changes: 11 additions & 6 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,25 @@

def pytest_addoption(parser: Parser) -> None:
parser.addoption(
"--roundtrip", action="store_true", default=False, help="Run roundtrip tests. These tests are slow and require \
"--roundtrip-neptune", action="store_true", default=False, help="Run roundtrip tests. These tests are slow and require \
a configured neptune instance."
)
parser.addoption(
"--roundtrip-janusgraph", action="store_true", default=False, help="Run roundtrip tests. These tests are slow and require \
a configured janusgraph instance."
)


def pytest_configure(config: Config) -> None:
config.addinivalue_line("markers", "roundtrip: mark test as roundtrip")


def pytest_collection_modifyitems(config: Config, items: List[Item]) -> None:
if config.getoption("--roundtrip"):
# --roundtrip given in cli: do not skip roundtrip tests
return
skip_roundtrip = pytest.mark.skip(reason="need --roundtrip option to run")
roundtrip_neptune: bool = config.getoption("--roundtrip-neptune")
roundtrip_janusgraph: bool = config.getoption("--roundtrip-janusgraph")
skip_roundtrip = pytest.mark.skip(reason="need the approprirate --roundtrip-[neptune|janus] option to run")
for item in items:
if "roundtrip" in item.keywords:
if "NeptuneGremlinProxyTest" in item.keywords and not roundtrip_neptune:
item.add_marker(skip_roundtrip)
if "JanusGraphGremlinProxyTest" in item.keywords and not roundtrip_janusgraph:
item.add_marker(skip_roundtrip)
Loading

0 comments on commit e4a8ddb

Please sign in to comment.