You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by da...@apache.org on 2018/02/06 02:50:56 UTC

[1/2] tinkerpop git commit: added proper response message serialization, run all remote connection tests with graphson 2 and 3

Repository: tinkerpop
Updated Branches:
  refs/heads/master ebaad41ed -> f5d67e4a4


added proper response message serialization, run all remote connection tests with graphson 2 and 3


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/f0bbe7c9
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/f0bbe7c9
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/f0bbe7c9

Branch: refs/heads/master
Commit: f0bbe7c90f5f66028203f21dcf720bf0948f1950
Parents: e533b79
Author: davebshow <da...@gmail.com>
Authored: Wed Jan 24 13:14:03 2018 -0800
Committer: davebshow <da...@gmail.com>
Committed: Wed Jan 24 13:14:03 2018 -0800

----------------------------------------------------------------------
 .../jython/gremlin_python/driver/protocol.py    | 32 ++++++++------------
 .../src/main/jython/tests/conftest.py           | 12 +++++---
 .../src/main/jython/tests/driver/test_client.py | 11 ++++---
 .../driver/test_driver_remote_connection.py     |  4 +--
 4 files changed, 28 insertions(+), 31 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/f0bbe7c9/gremlin-python/src/main/jython/gremlin_python/driver/protocol.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/gremlin_python/driver/protocol.py b/gremlin-python/src/main/jython/gremlin_python/driver/protocol.py
index 75c99bc..1330483 100644
--- a/gremlin-python/src/main/jython/gremlin_python/driver/protocol.py
+++ b/gremlin-python/src/main/jython/gremlin_python/driver/protocol.py
@@ -65,12 +65,13 @@ class GremlinServerWSProtocol(AbstractBaseProtocol):
             request_id, request_message)
         self._transport.write(message)
 
-    def data_received(self, data, results_dict):
-        data = json.loads(data.decode('utf-8'))
-        request_id = data['requestId']
+    def data_received(self, message, results_dict):
+        message = self._message_serializer.deserialize_message(json.loads(message.decode('utf-8')))
+        request_id = message['requestId']
         result_set = results_dict[request_id]
-        status_code = data['status']['code']
-        aggregate_to = data['result']['meta'].get('aggregateTo', 'list')
+        status_code = message['status']['code']
+        aggregate_to = message['result']['meta'].get('aggregateTo', 'list')
+        data = message['result']['data']
         result_set.aggregate_to = aggregate_to
         if status_code == 407:
             auth = b''.join([b'\x00', self._username.encode('utf-8'),
@@ -79,28 +80,19 @@ class GremlinServerWSProtocol(AbstractBaseProtocol):
                 'traversal', 'authentication',
                 {'sasl': base64.b64encode(auth).decode()})
             self.write(request_id, request_message)
-            data = self._transport.read()
-            self.data_received(data, results_dict)
+            message = self._transport.read()
+            self.data_received(message, results_dict)
         elif status_code == 204:
             result_set.stream.put_nowait([])
             del results_dict[request_id]
         elif status_code in [200, 206]:
-            results = []
-            # this is a bit of a hack for now. basically the protocol.py picks the json apart and doesn't
-            # account for types too well right now.
-            if self._message_serializer.version == b"application/vnd.gremlin-v2.0+json":
-                for msg in data["result"]["data"]:
-                    results.append(
-                        self._message_serializer.deserialize_message(msg))
-            else:
-                results = self._message_serializer.deserialize_message(data["result"]["data"]["@value"])
-            result_set.stream.put_nowait(results)
+            result_set.stream.put_nowait(data)
             if status_code == 206:
-                data = self._transport.read()
-                self.data_received(data, results_dict)
+                message = self._transport.read()
+                self.data_received(message, results_dict)
             else:
                 del results_dict[request_id]
         else:
             del results_dict[request_id]
             raise GremlinServerError(
-                "{0}: {1}".format(status_code, data["status"]["message"]))
+                "{0}: {1}".format(status_code, message["status"]["message"]))

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/f0bbe7c9/gremlin-python/src/main/jython/tests/conftest.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/tests/conftest.py b/gremlin-python/src/main/jython/tests/conftest.py
index 6fcb8db..9b12180 100644
--- a/gremlin-python/src/main/jython/tests/conftest.py
+++ b/gremlin-python/src/main/jython/tests/conftest.py
@@ -1,4 +1,4 @@
-'''
+"""
 Licensed to the Apache Software Foundation (ASF) under one
 or more contributor license agreements.  See the NOTICE file
 distributed with this work for additional information
@@ -15,7 +15,7 @@ software distributed under the License is distributed on an
 KIND, either express or implied.  See the License for the
 specific language governing permissions and limitations
 under the License.
-'''
+"""
 import concurrent.futures
 import pytest
 
@@ -65,10 +65,14 @@ def client(request):
         request.addfinalizer(fin)
         return client
 
-@pytest.fixture
+@pytest.fixture(params=['v2', 'v3'])
 def remote_connection(request):
     try:
-        remote_conn = DriverRemoteConnection('ws://localhost:45940/gremlin', 'g')
+        if request.param == 'v2':
+            remote_conn = DriverRemoteConnection('ws://localhost:45940/gremlin', 'g',
+                                                 message_serializer=serializer.GraphSONSerializersV2d0())
+        else:
+            remote_conn = DriverRemoteConnection('ws://localhost:45940/gremlin', 'g')
     except OSError:
         pytest.skip('Gremlin Server is not running')
     else:

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/f0bbe7c9/gremlin-python/src/main/jython/tests/driver/test_client.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/tests/driver/test_client.py b/gremlin-python/src/main/jython/tests/driver/test_client.py
index 7a6f3b4..c804bd1 100644
--- a/gremlin-python/src/main/jython/tests/driver/test_client.py
+++ b/gremlin-python/src/main/jython/tests/driver/test_client.py
@@ -79,12 +79,13 @@ def test_client_async(client):
 
 def test_connection_share(client):
     # Overwrite fixture with pool_size=1 client
-    client = Client('ws://localhost:45940/gremlin', 'g', pool_size=1, message_serializer=serializer.GraphSONSerializersV2d0())
+    client = Client('ws://localhost:45940/gremlin', 'g', pool_size=1)
     g = Graph().traversal()
     t = g.V()
     message = RequestMessage('traversal', 'bytecode', {'gremlin': t.bytecode})
+    message2 = RequestMessage('traversal', 'bytecode', {'gremlin': t.bytecode})
     future = client.submitAsync(message)
-    future2 = client.submitAsync(message)
+    future2 = client.submitAsync(message2)
 
     result_set2 = future2.result()
     assert len(result_set2.all().result()) == 6
@@ -99,10 +100,10 @@ def test_multi_conn_pool(client):
     g = Graph().traversal()
     t = g.V()
     message = RequestMessage('traversal', 'bytecode', {'gremlin': t.bytecode})
-
-    client = Client('ws://localhost:45940/gremlin', 'g', pool_size=1, message_serializer=serializer.GraphSONSerializersV2d0())
+    message2 = RequestMessage('traversal', 'bytecode', {'gremlin': t.bytecode})
+    client = Client('ws://localhost:45940/gremlin', 'g', pool_size=1)
     future = client.submitAsync(message)
-    future2 = client.submitAsync(message)
+    future2 = client.submitAsync(message2)
 
     result_set2 = future2.result()
     assert len(result_set2.all().result()) == 6

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/f0bbe7c9/gremlin-python/src/main/jython/tests/driver/test_driver_remote_connection.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/tests/driver/test_driver_remote_connection.py b/gremlin-python/src/main/jython/tests/driver/test_driver_remote_connection.py
index 5471637..1071493 100644
--- a/gremlin-python/src/main/jython/tests/driver/test_driver_remote_connection.py
+++ b/gremlin-python/src/main/jython/tests/driver/test_driver_remote_connection.py
@@ -119,10 +119,10 @@ class TestDriverRemoteConnection(object):
         assert 6 == g.V().count().next()
         assert 6 == g.E().count().next()
 
-    def test_side_effects(self, remote_connection_v2):
+    def test_side_effects(self, remote_connection):
         statics.load_statics(globals())
         #
-        g = Graph().traversal().withRemote(remote_connection_v2)
+        g = Graph().traversal().withRemote(remote_connection)
         ###
         t = g.V().hasLabel("project").name.iterate()
         assert 0 == len(t.side_effects.keys())


[2/2] tinkerpop git commit: Merge branch 'TINKERPOP-1875'

Posted by da...@apache.org.
Merge branch 'TINKERPOP-1875'


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/f5d67e4a
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/f5d67e4a
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/f5d67e4a

Branch: refs/heads/master
Commit: f5d67e4a4fc8a2d1a671d9ed76eaba6027654333
Parents: ebaad41 f0bbe7c
Author: davebshow <da...@gmail.com>
Authored: Mon Feb 5 18:49:31 2018 -0800
Committer: davebshow <da...@gmail.com>
Committed: Mon Feb 5 18:49:31 2018 -0800

----------------------------------------------------------------------
 .../jython/gremlin_python/driver/protocol.py    | 32 ++++++++------------
 .../src/main/jython/tests/conftest.py           | 12 +++++---
 .../src/main/jython/tests/driver/test_client.py | 11 ++++---
 .../driver/test_driver_remote_connection.py     |  4 +--
 4 files changed, 28 insertions(+), 31 deletions(-)
----------------------------------------------------------------------