You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by fl...@apache.org on 2021/04/15 14:52:55 UTC

[tinkerpop] branch TINKERPOP-2390 created (now fef2839)

This is an automated email from the ASF dual-hosted git repository.

florianhockmann pushed a change to branch TINKERPOP-2390
in repository https://gitbox.apache.org/repos/asf/tinkerpop.git.


      at fef2839  WIP Try to reproduce the described scenario

This branch includes the following new commits:

     new fef2839  WIP Try to reproduce the described scenario

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


[tinkerpop] 01/01: WIP Try to reproduce the described scenario

Posted by fl...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

florianhockmann pushed a commit to branch TINKERPOP-2390
in repository https://gitbox.apache.org/repos/asf/tinkerpop.git

commit fef28398bc4841927a5c7ee47ef0032053607d46
Author: Florian Hockmann <fh...@florian-hockmann.de>
AuthorDate: Thu Apr 15 16:51:59 2021 +0200

    WIP Try to reproduce the described scenario
    
    This is just meant to experiment and find the described problem.
---
 .../Driver/MessagesTests.cs                        | 66 ++++++++++++++++++++++
 .../Gremlin.Net.IntegrationTest/appsettings.json   |  2 +-
 .../gremlin/driver/RequestMessageTest.java         | 50 ++++++++++++++++
 3 files changed, 117 insertions(+), 1 deletion(-)

diff --git a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Driver/MessagesTests.cs b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Driver/MessagesTests.cs
index bbb107b..77728e7 100644
--- a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Driver/MessagesTests.cs
+++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Driver/MessagesTests.cs
@@ -24,11 +24,16 @@
 using System;
 using System.Collections.Generic;
 using System.Diagnostics;
+using System.Linq;
 using System.Threading.Tasks;
 using Gremlin.Net.Driver;
 using Gremlin.Net.Driver.Exceptions;
 using Gremlin.Net.Driver.Messages;
+using Gremlin.Net.Driver.Remote;
 using Gremlin.Net.IntegrationTest.Util;
+using Gremlin.Net.Process.Traversal;
+using Gremlin.Net.Process.Traversal.Strategy.Optimization;
+using Gremlin.Net.Structure;
 using Xunit;
 
 namespace Gremlin.Net.IntegrationTest.Driver
@@ -96,6 +101,67 @@ namespace Gremlin.Net.IntegrationTest.Driver
         }
 
         [Fact]
+        public async Task LoadData()
+        {
+            var gremlinServer = new GremlinServer(TestHost, TestPort);
+            using (var gremlinClient = new GremlinClient(gremlinServer))
+            {
+                var g = AnonymousTraversalSource.Traversal().WithRemote(new DriverRemoteConnection(gremlinClient));
+                await g.V().Drop().Promise(t => t.Iterate());
+
+                const int nrVertices = 100;
+                var vertices = new List<Vertex>(nrVertices);
+                for (var i = 0; i < nrVertices; i++)
+                {
+                    var vertex = await g.AddV().Property("name", i).Promise(t => t.Next());
+                    vertices.Add(vertex);
+                }
+                Assert.Equal(nrVertices, await g.V().Count().Promise(t => t.Next()));
+
+                foreach (var sourceVertex in vertices)
+                {
+                    foreach (var targetVertex in vertices)
+                    {
+                        await g.V(sourceVertex).As("source").V(targetVertex).AddE("knows").From("source").Constant(1)
+                            .Promise(t => t.Iterate());
+                    }
+                }
+                Assert.Equal(nrVertices * nrVertices, await g.E().Count().Promise(t => t.Next()));
+            }
+        }
+        
+        [Fact]
+        public async Task ShouldNotOverloadServer()
+        {
+            var gremlinServer = new GremlinServer(TestHost, TestPort);
+            using (var gremlinClient = new GremlinClient(gremlinServer))
+            {
+                var g = AnonymousTraversalSource.Traversal().WithRemote(new DriverRemoteConnection(gremlinClient));
+
+                const int nrTasks = 10;
+                var tasks = new List<Task>(nrTasks);
+                for (var i = 0; i < nrTasks; i++)
+                {
+                    tasks.Add(LongRunningAsync(g));
+                }
+                await Task.WhenAll(tasks);
+                
+                Assert.Equal(100, await g.V().Count().Promise(t => t.Next()));
+            }
+        }
+
+        private async Task LongRunningAsync(GraphTraversalSource g)
+        {
+            try
+            {
+                await g.V().Repeat(__.Both()).Times(3).Path().Limit<long>(100000000).Count().Promise(t => t.Next());
+            }
+            catch (Exception)
+            {
+            }
+        }
+
+        [Fact]
         public async Task ShouldUseSpecifiedEvaluationTimeout()
         {
             var gremlinServer = new GremlinServer(TestHost, TestPort);
diff --git a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/appsettings.json b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/appsettings.json
index 1adda9a..aa0fbf0 100644
--- a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/appsettings.json
+++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/appsettings.json
@@ -1,5 +1,5 @@
 {
   "TestServerIpAddress": "localhost",
-  "TestServerPort": 45940,
+  "TestServerPort": 8182,
   "TestSecureServerPort": 45941
 }
\ No newline at end of file
diff --git a/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/RequestMessageTest.java b/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/RequestMessageTest.java
index d6b47c9..a15abb4 100644
--- a/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/RequestMessageTest.java
+++ b/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/RequestMessageTest.java
@@ -19,11 +19,22 @@
 package org.apache.tinkerpop.gremlin.driver;
 
 import org.apache.tinkerpop.gremlin.driver.message.RequestMessage;
+import org.apache.tinkerpop.gremlin.driver.remote.DriverRemoteConnection;
+import org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV3d0;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.io.IoRegistry;
+import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONMapper;
+import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerIoRegistryV3d0;
 import org.junit.Assert;
 import org.junit.Test;
 
+import java.util.LinkedList;
+import java.util.List;
 import java.util.UUID;
+import java.util.stream.Collectors;
 
+import static org.apache.tinkerpop.gremlin.process.traversal.AnonymousTraversalSource.traversal;
+import static org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__.both;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
@@ -66,4 +77,43 @@ public class RequestMessageTest {
         final RequestMessage msg = RequestMessage.build("op").add("test", "testing").create();
         assertEquals("testing", msg.optionalArgs("test").get());
     }
+
+    @Test
+    public void test() {
+        int port = Integer.parseInt(System.getProperty("port", "8182"));
+
+        MessageSerializer serializer = new GraphSONMessageSerializerV3d0();
+
+        /**
+         * There typically needs to be only one Cluster instance in an application.
+         */
+        Cluster cluster = Cluster.build().port(port).serializer(serializer).create();
+
+        /**
+         * Construct a remote GraphTraversalSource using the above created Cluster instance that will connect to Gremlin
+         * Server.
+         */
+        GraphTraversalSource g = traversal().withRemote(DriverRemoteConnection.using(cluster));
+
+
+        List<Integer> list = new LinkedList<>();
+        for (int i = 0; i < 1; i++)
+        {
+            list.add(i);
+        }
+        list.parallelStream().map(i -> longRunning(g)).collect(Collectors.toList());
+
+
+        //long count = g.V().count().next();
+        //assertEquals(100, count);
+    }
+
+    private int longRunning(GraphTraversalSource g) {
+        try{
+            g.V().repeat(both()).times(3).path().limit(100000000).count().next();
+        } catch(Exception e){
+
+        }
+        return 1;
+    }
 }