Skip to content

Commit

Permalink
draft
Browse files Browse the repository at this point in the history
  • Loading branch information
Valentyn Kahamlyk authored and Valentyn Kahamlyk committed Jan 23, 2024
1 parent c28aa2e commit 213cdfa
Show file tree
Hide file tree
Showing 3 changed files with 111 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ namespace Gremlin.Net.IntegrationTest.Process.Traversal.DriverRemoteConnection
internal class RemoteConnectionFactory : IDisposable
{
private static readonly string TestHost = ConfigProvider.Configuration["TestServerIpAddress"]!;
private static readonly int TestPort = Convert.ToInt32(ConfigProvider.Configuration["TestServerPort"]);
private static readonly int TestPort = 8182; // Convert.ToInt32(ConfigProvider.Configuration["TestServerPort"]);

private readonly IList<IDisposable> _cleanUp = new List<IDisposable>();
private readonly IMessageSerializer _messageSerializer;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
using System;
using System.Collections.Generic;
using Gremlin.Net.Process.Traversal;
using Gremlin.Net.Structure;
using Gremlin.Net.Structure.IO.GraphBinary;
using Gremlin.Net.Structure.IO.GraphSON;
using Xunit;
using Xunit.Abstractions;

namespace Gremlin.Net.IntegrationTest.Process.Traversal.DriverRemoteConnection
{
public class SerializationTests
{
private readonly ITestOutputHelper _output;
private readonly RemoteConnectionFactory _connectionFactory = new();

public static List<object[]> testCases =>
new()
{
//new object[] { DataType.Int, 1 },
//new object[] { DataType.Long, 1L },
//new object[] { DataType.String, "qq" },
//new object[] { DataType.Date, DateTimeOffset.FromUnixTimeSeconds(1705105408) }, // not a DateTime, but who cares?
//new object[] { DataType.Timestamp, DateTimeOffset.FromUnixTimeSeconds(1705105408) },
//new object[] { DataType.Class, GremlinType.FromFqcn("test") }, // hangs
//new object[] { DataType.Double, 1.0 },
//new object[] { DataType.Float, 1.0f },
//new object[] { DataType.List, new List<object>() { 1, 2, "test"} },
//new object[] { DataType.Map, new Dictionary<string, string>() { ["hello"] = "world"} },
//new object[] { DataType.Set, new HashSet<string>() { "test"} },
//new object[] { DataType.Uuid, Guid.NewGuid() },
//new object[] { DataType.Edge, new Edge(1, new Vertex(1), "person", new Vertex(1)) },
//new object[] { DataType.Path, new Path(new List<ISet<string>>(), new List<object?>()) },
//new object[] { DataType.Property, new Property("test", "prop") }

new object[] { DataType.Vertex, 1 },
new object[] { DataType.VertexProperty, 1 },
new object[] { DataType.Barrier, 1 },
new object[] { DataType.Binding, 1 },
new object[] { DataType.Bytecode, 1 },
new object[] { DataType.Cardinality, 1 },
new object[] { DataType.Column, 1 },
new object[] { DataType.Direction, 1 },
new object[] { DataType.Operator, 1 },
new object[] { DataType.Order, 1 },
new object[] { DataType.Pick, 1 },
new object[] { DataType.Pop, 1 },
new object[] { DataType.Lambda, 1 },
new object[] { DataType.P, 1 },
new object[] { DataType.Scope, 1 },
};


private readonly GraphTraversalSource _gGraphSON;
private readonly GraphTraversalSource _gGraphBinary;

public SerializationTests(ITestOutputHelper output)
{
_output = output;

_gGraphSON = AnonymousTraversalSource.Traversal()
.WithRemote(_connectionFactory.CreateRemoteConnection("g", 2, new GraphSON3MessageSerializer()));

_gGraphBinary = AnonymousTraversalSource.Traversal()
.WithRemote(_connectionFactory.CreateRemoteConnection("g", 2, new GraphBinaryMessageSerializer()));
}

[Theory]
[MemberData(nameof(testCases))]
public void RoundTripTest(DataType dataType, object value)
{
try
{
var v = _gGraphSON.AddV().Property("test", value).Next()!;
var serverValue = _gGraphSON.V(v.Id).Values<object>("test").Next();
Assert.Equal(value, serverValue);

_output.WriteLine($"GraphSON support {dataType.TypeCode}");
}
catch
{
_output.WriteLine($"GraphSON not support {dataType.TypeCode}");
}

try
{
var v = _gGraphBinary.AddV().Property("test", value).Next()!;
var serverValue = _gGraphBinary.V(v.Id).Values<object>("test").Next();
Assert.Equal(value, serverValue);

_output.WriteLine($"GraphBinary support {dataType.TypeCode}");
}
catch
{
_output.WriteLine($"GraphBinary not support {dataType.TypeCode}");
}
}



}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,20 @@
from gremlin_python.process.strategies import SubgraphStrategy, ReservedKeysVerificationStrategy, SeedStrategy
from gremlin_python.structure.io.util import HashableDict
from gremlin_python.driver.serializer import GraphSONSerializersV2d0
from gremlin_python.statics import GremlinType

__author__ = 'Marko A. Rodriguez (http://markorodriguez.com)'

gremlin_server_url = os.environ.get('GREMLIN_SERVER_URL', 'ws://localhost:{}/gremlin')
test_no_auth_url = gremlin_server_url.format(45940)
test_no_auth_url = gremlin_server_url.format(8182)

class TestDriverRemoteConnection(object):
def test_QQQ(self, remote_connection):
statics.load_statics(globals())
g = traversal().withRemote(remote_connection)
g.addV("test").property('test', GremlinType('test')).next()


def test_traversals(self, remote_connection):
statics.load_statics(globals())
g = traversal().withRemote(remote_connection)
Expand Down

0 comments on commit 213cdfa

Please sign in to comment.