You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by sp...@apache.org on 2021/12/29 21:05:51 UTC

[tinkerpop] branch ci-fix updated (c34a460 -> e20acbe)

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

spmallette pushed a change to branch ci-fix
in repository https://gitbox.apache.org/repos/asf/tinkerpop.git.


 discard c34a460  focus on gc issues
 discard 22d1605  close
 discard d63bcba  Close Cluster instances after tests
 discard 3440c42  Prevented neo4j configuration if neo4j not enabled in build
     new e20acbe  Reduced resources consumed by gremlin server integration tests

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (c34a460)
            \
             N -- N -- N   refs/heads/ci-fix (e20acbe)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

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.


Summary of changes:

[tinkerpop] 01/01: Reduced resources consumed by gremlin server integration tests

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

spmallette pushed a commit to branch ci-fix
in repository https://gitbox.apache.org/repos/asf/tinkerpop.git

commit e20acbe994202e31685c84f41f4ee05aac382d41
Author: Stephen Mallette <st...@amazon.com>
AuthorDate: Tue Dec 28 18:30:17 2021 -0500

    Reduced resources consumed by gremlin server integration tests
    
    Prevented neo4j configuration if neo4j not enabled in build helping stop errors in the log. Close Cluster instances after tests. Not doing so seems to leak connection pools which not only consumes memory but floods the logs with fake failures. Reduced the memory footprint of neo4j for testing by modifying its default configurations. Added some changes to help try to release resources held by Gremlin Server. Specifically, called close() on GraphTraversalSource instances in the GraphMan [...]
---
 gremlin-server/conf/neo4j-empty.properties         |  6 ++
 .../tinkerpop/gremlin/server/GremlinServer.java    | 35 ++++++++-
 .../driver/remote/AbstractRemoteGraphProvider.java |  6 ++
 .../AbstractGremlinServerIntegrationTest.java      | 26 ++++++-
 .../gremlin/server/GremlinDriverIntegrateTest.java | 89 +++++++++++-----------
 .../server/GremlinServerHttpIntegrateTest.java     |  6 +-
 .../gremlin/server/GremlinServerIntegrateTest.java | 35 +++++++--
 .../server/GremlinServerSessionIntegrateTest.java  | 15 +---
 8 files changed, 146 insertions(+), 72 deletions(-)

diff --git a/gremlin-server/conf/neo4j-empty.properties b/gremlin-server/conf/neo4j-empty.properties
index d1ad61e..f20aa30 100644
--- a/gremlin-server/conf/neo4j-empty.properties
+++ b/gremlin-server/conf/neo4j-empty.properties
@@ -34,6 +34,12 @@ gremlin.neo4j.conf.dbms.auto_index.nodes.enabled=true
 gremlin.neo4j.conf.dbms.auto_index.relationships.enabled=true
 #gremlin.neo4j.conf.dbms.auto_index.relationships.keys=
 
+# these memory settings are likely unsuitable for production cases
+gremlin.neo4j.conf.dbms.memory.heap.initial_size=500m
+gremlin.neo4j.conf.dbms.memory.heap.max_size=500m
+gremlin.neo4j.conf.dbms.memory.pagecache.size=1m
+gremlin.neo4j.conf.dbms.tx_state.memory_allocation=ON_HEAP
+
 # uncomment the following to enable Bolt on the specified port
 # gremlin.neo4j.conf.dbms.connector.0.type=BOLT
 # gremlin.neo4j.conf.dbms.connector.0.enabled=true
diff --git a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/GremlinServer.java b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/GremlinServer.java
index 2a1adf7..1e16ea1 100644
--- a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/GremlinServer.java
+++ b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/GremlinServer.java
@@ -39,12 +39,15 @@ import org.apache.tinkerpop.gremlin.server.util.LifeCycleHook;
 import org.apache.tinkerpop.gremlin.server.util.MetricManager;
 import org.apache.tinkerpop.gremlin.server.util.ServerGremlinExecutor;
 import org.apache.tinkerpop.gremlin.server.util.ThreadFactoryUtil;
+import org.apache.tinkerpop.gremlin.structure.Graph;
+import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph;
 import org.apache.tinkerpop.gremlin.util.Gremlin;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import java.io.IOException;
 import java.lang.reflect.UndeclaredThrowableException;
+import java.util.Set;
 import java.util.concurrent.CompletableFuture;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.ExecutorService;
@@ -296,16 +299,44 @@ public class GremlinServer {
                 logger.warn("Timeout waiting for boss/worker thread pools to shutdown - continuing with shutdown process.");
             }
 
+            // close TraversalSource and Graph instances - there aren't guarantees that closing Graph will close all
+            // spawned TraversalSource instances so both should be closed directly and independently.
             if (serverGremlinExecutor != null) {
-                serverGremlinExecutor.getGraphManager().getGraphNames().forEach(gName -> {
+                final Set<String> traversalSourceNames = serverGremlinExecutor.getGraphManager().getTraversalSourceNames();
+                traversalSourceNames.forEach(traversalSourceName -> {
+                    logger.debug("Closing GraphTraversalSource instance [{}]", traversalSourceName);
+                    try {
+                        serverGremlinExecutor.getGraphManager().getTraversalSource(traversalSourceName).close();
+                    } catch (Exception ex) {
+                        logger.warn(String.format("Exception while closing GraphTraversalSource instance [%s]", traversalSourceName), ex);
+                    } finally {
+                        logger.info("Closed GraphTraversalSource instance [{}]", traversalSourceName);
+                    }
+
+                    try {
+                        serverGremlinExecutor.getGraphManager().removeTraversalSource(traversalSourceName);
+                    } catch (Exception ex) {
+                        logger.warn(String.format("Exception while removing GraphTraversalSource instance [%s] from GraphManager", traversalSourceName), ex);
+                    }
+                });
+
+                final Set<String> graphNames = serverGremlinExecutor.getGraphManager().getGraphNames();
+                graphNames.forEach(gName -> {
                     logger.debug("Closing Graph instance [{}]", gName);
                     try {
-                        serverGremlinExecutor.getGraphManager().getGraph(gName).close();
+                        final Graph graph = serverGremlinExecutor.getGraphManager().getGraph(gName);
+                        graph.close();
                     } catch (Exception ex) {
                         logger.warn(String.format("Exception while closing Graph instance [%s]", gName), ex);
                     } finally {
                         logger.info("Closed Graph instance [{}]", gName);
                     }
+
+                    try {
+                        serverGremlinExecutor.getGraphManager().removeGraph(gName);
+                    } catch (Exception ex) {
+                        logger.warn(String.format("Exception while removing Graph instance [%s] from GraphManager", gName), ex);
+                    }
                 });
             }
 
diff --git a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/driver/remote/AbstractRemoteGraphProvider.java b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/driver/remote/AbstractRemoteGraphProvider.java
index e86a546..696669f 100644
--- a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/driver/remote/AbstractRemoteGraphProvider.java
+++ b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/driver/remote/AbstractRemoteGraphProvider.java
@@ -237,6 +237,12 @@ public abstract class AbstractRemoteGraphProvider extends AbstractGraphProvider
     @Override
     public void close() throws Exception {
         try {
+            cluster.close();
+        } catch (Exception ex) {
+            throw new RuntimeException(ex);
+        }
+
+        try {
             stopServer();
         } catch (Exception ex) {
             throw new RuntimeException(ex);
diff --git a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/AbstractGremlinServerIntegrationTest.java b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/AbstractGremlinServerIntegrationTest.java
index 634063e..798eb2f 100644
--- a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/AbstractGremlinServerIntegrationTest.java
+++ b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/AbstractGremlinServerIntegrationTest.java
@@ -18,7 +18,9 @@
  */
 package org.apache.tinkerpop.gremlin.server;
 
+import org.apache.tinkerpop.gremlin.neo4j.structure.Neo4jGraph;
 import org.apache.tinkerpop.gremlin.server.op.OpLoader;
+import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Rule;
@@ -130,9 +132,15 @@ public abstract class AbstractGremlinServerIntegrationTest {
     }
 
     public void stopServer() throws Exception {
+        // calling close() on TinkerGraph does not free resources quickly enough. adding a clear() call let's gc
+        // cleanup earlier
+        server.getServerGremlinExecutor().getGraphManager().getAsBindings().values().stream()
+                .filter(g -> g instanceof TinkerGraph).forEach(g -> ((TinkerGraph) g).clear());
+
         if (server != null) {
             server.stop().join();
         }
+
         // reset the OpLoader processors so that they can get reconfigured on startup - Settings may have changed
         // between tests
         OpLoader.reset();
@@ -155,14 +163,24 @@ public abstract class AbstractGremlinServerIntegrationTest {
         return (directory.delete());
     }
 
-    protected static void assumeNeo4jIsPresent() {
-        boolean neo4jIncludedForTesting;
+    protected static void tryIncludeNeo4jGraph(final Settings settings) {
+        if (isNeo4jPresent()) {
+            deleteDirectory(new File("/tmp/neo4j"));
+            settings.graphs.put("graph", "conf/neo4j-empty.properties");
+        }
+    }
+
+    protected static boolean isNeo4jPresent() {
         try {
             Class.forName("org.neo4j.tinkerpop.api.impl.Neo4jGraphAPIImpl");
-            neo4jIncludedForTesting = true;
+            return true;
         } catch (Exception ex) {
-            neo4jIncludedForTesting = false;
+            return false;
         }
+    }
+
+    protected static void assumeNeo4jIsPresent() {
+        boolean neo4jIncludedForTesting = isNeo4jPresent();
         assumeThat("Neo4j implementation was not included for testing - run with -DincludeNeo4j", neo4jIncludedForTesting, is(true));
     }
 }
diff --git a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinDriverIntegrateTest.java b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinDriverIntegrateTest.java
index 2eb6aa7..15b3004 100644
--- a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinDriverIntegrateTest.java
+++ b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinDriverIntegrateTest.java
@@ -185,16 +185,14 @@ public class GremlinDriverIntegrateTest extends AbstractGremlinServerIntegration
             case "shouldExecuteScriptInSessionOnTransactionalWithManualTransactionsGraph":
             case "shouldExecuteInSessionAndSessionlessWithoutOpeningTransaction":
             case "shouldManageTransactionsInSession":
-                deleteDirectory(new File("/tmp/neo4j"));
-                settings.graphs.put("graph", "conf/neo4j-empty.properties");
+                tryIncludeNeo4jGraph(settings);
                 break;
             case "shouldRequireAliasedGraphVariablesInStrictTransactionMode":
                 settings.strictTransactionManagement = true;
                 break;
             case "shouldAliasGraphVariablesInStrictTransactionMode":
                 settings.strictTransactionManagement = true;
-                deleteDirectory(new File("/tmp/neo4j"));
-                settings.graphs.put("graph", "conf/neo4j-empty.properties");
+                tryIncludeNeo4jGraph(settings);
                 break;
             case "shouldProcessSessionRequestsInOrderAfterTimeout":
                 settings.evaluationTimeout = 250;
@@ -671,6 +669,8 @@ public class GremlinDriverIntegrateTest extends AbstractGremlinServerIntegration
             assertThat("Should contain 2 results", results.size() == 2);
             assertThat("The numeric result should be 1", results.contains(1L));
             assertThat("The string result contain label person", results.contains("person"));
+
+            executor.shutdown();
         } finally {
             cluster.close();
         }
@@ -1022,7 +1022,6 @@ public class GremlinDriverIntegrateTest extends AbstractGremlinServerIntegration
         final Client client = cluster.connect();
 
         try {
-
             final List<Result> r = client.submit("TinkerFactory.createModern().traversal().V(1)").all().join();
             assertEquals(1, r.size());
 
@@ -1502,9 +1501,9 @@ public class GremlinDriverIntegrateTest extends AbstractGremlinServerIntegration
             assertThat(root, instanceOf(ResponseException.class));
             final ResponseException re = (ResponseException) root;
             assertEquals(ResponseStatusCode.REQUEST_ERROR_INVALID_REQUEST_ARGUMENTS, re.getResponseStatusCode());
+        } finally {
+            cluster.close();
         }
-
-        cluster.close();
     }
 
     @Test
@@ -1522,13 +1521,13 @@ public class GremlinDriverIntegrateTest extends AbstractGremlinServerIntegration
             assertThat(root, instanceOf(ResponseException.class));
             final ResponseException re = (ResponseException) root;
             assertEquals(ResponseStatusCode.REQUEST_ERROR_INVALID_REQUEST_ARGUMENTS, re.getResponseStatusCode());
-        }
-
-        final Client rebound = cluster.connect().alias("graph");
-        final Vertex v = rebound.submit("g.addVertex('name','jason')").all().get().get(0).getVertex();
-        assertEquals("jason", v.value("name"));
 
-        cluster.close();
+            final Client rebound = cluster.connect().alias("graph");
+            final Vertex v = rebound.submit("g.addVertex('name','jason')").all().get().get(0).getVertex();
+            assertEquals("jason", v.value("name"));
+        } finally {
+            cluster.close();
+        }
     }
 
     @Test
@@ -1544,13 +1543,13 @@ public class GremlinDriverIntegrateTest extends AbstractGremlinServerIntegration
             assertThat(root, instanceOf(ResponseException.class));
             final ResponseException re = (ResponseException) root;
             assertEquals(ResponseStatusCode.SERVER_ERROR_SCRIPT_EVALUATION, re.getResponseStatusCode());
-        }
-
-        final Client rebound = cluster.connect().alias("graph");
-        final Vertex v = rebound.submit("g.addVertex('name','jason')").all().get().get(0).getVertex();
-        assertEquals("jason", v.value("name"));
 
-        cluster.close();
+            final Client rebound = cluster.connect().alias("graph");
+            final Vertex v = rebound.submit("g.addVertex('name','jason')").all().get().get(0).getVertex();
+            assertEquals("jason", v.value("name"));
+        } finally {
+            cluster.close();
+        }
     }
 
     @Test
@@ -1786,6 +1785,7 @@ public class GremlinDriverIntegrateTest extends AbstractGremlinServerIntegration
         final Client client = Mockito.spy(cluster.connect().alias("g"));
         client.submit("", RequestOptions.build().userAgent("test").create()).all().get();
         cluster.close();
+
         final ArgumentCaptor<RequestMessage> requestMessageCaptor = ArgumentCaptor.forClass(RequestMessage.class);
         verify(client).submitAsync(requestMessageCaptor.capture());
         final RequestMessage requestMessage = requestMessageCaptor.getValue();
@@ -1800,14 +1800,15 @@ public class GremlinDriverIntegrateTest extends AbstractGremlinServerIntegration
         final GraphTraversalSource g = traversal().withRemote(DriverRemoteConnection.using(client));
         g.with(Tokens.ARGS_USER_AGENT, "test").V().iterate();
         cluster.close();
-        ArgumentCaptor<RequestOptions> requestOptionsCaptor = ArgumentCaptor.forClass(RequestOptions.class);
+
+        final ArgumentCaptor<RequestOptions> requestOptionsCaptor = ArgumentCaptor.forClass(RequestOptions.class);
         verify(client).submitAsync(Mockito.any(Bytecode.class), requestOptionsCaptor.capture());
-        RequestOptions requestOptions = requestOptionsCaptor.getValue();
+        final RequestOptions requestOptions = requestOptionsCaptor.getValue();
         assertEquals("test", requestOptions.getUserAgent().get());
 
-        ArgumentCaptor<RequestMessage> requestMessageCaptor = ArgumentCaptor.forClass(RequestMessage.class);
+        final ArgumentCaptor<RequestMessage> requestMessageCaptor = ArgumentCaptor.forClass(RequestMessage.class);
         verify(client).submitAsync(requestMessageCaptor.capture());
-        RequestMessage requestMessage = requestMessageCaptor.getValue();
+        final RequestMessage requestMessage = requestMessageCaptor.getValue();
         assertEquals("test", requestMessage.getArgs().getOrDefault(Tokens.ARGS_USER_AGENT, null));
     }
 
@@ -1815,32 +1816,29 @@ public class GremlinDriverIntegrateTest extends AbstractGremlinServerIntegration
     public void shouldSendRequestIdBytecode() {
         final UUID overrideRequestId = UUID.randomUUID();
         final Cluster cluster = TestClientFactory.build().serializer(Serializers.GRAPHSON_V3D0).create();
-            final Client client = Mockito.spy(cluster.connect().alias("g"));
-            Mockito.when(client.alias("g")).thenReturn(client);
-            GraphTraversalSource g = traversal().withRemote(DriverRemoteConnection.using(client));
-            g.with(Tokens.REQUEST_ID, overrideRequestId).V().iterate();
-            cluster.close();
-            ArgumentCaptor<RequestOptions> requestOptionsCaptor = ArgumentCaptor.forClass(RequestOptions.class);
-            verify(client).submitAsync(Mockito.any(Bytecode.class), requestOptionsCaptor.capture());
-            RequestOptions requestOptions = requestOptionsCaptor.getValue();
-            assertTrue(requestOptions.getOverrideRequestId().isPresent());
-            assertEquals(overrideRequestId, requestOptions.getOverrideRequestId().get());
+        final Client client = Mockito.spy(cluster.connect().alias("g"));
+        Mockito.when(client.alias("g")).thenReturn(client);
+        final GraphTraversalSource g = traversal().withRemote(DriverRemoteConnection.using(client));
+        g.with(Tokens.REQUEST_ID, overrideRequestId).V().iterate();
+        cluster.close();
 
-            ArgumentCaptor<RequestMessage> requestMessageCaptor = ArgumentCaptor.forClass(RequestMessage.class);
-            verify(client).submitAsync(requestMessageCaptor.capture());
-            RequestMessage requestMessage = requestMessageCaptor.getValue();
-            assertEquals(overrideRequestId, requestMessage.getRequestId());
+        final ArgumentCaptor<RequestOptions> requestOptionsCaptor = ArgumentCaptor.forClass(RequestOptions.class);
+        verify(client).submitAsync(Mockito.any(Bytecode.class), requestOptionsCaptor.capture());
+        final RequestOptions requestOptions = requestOptionsCaptor.getValue();
+        assertTrue(requestOptions.getOverrideRequestId().isPresent());
+        assertEquals(overrideRequestId, requestOptions.getOverrideRequestId().get());
 
+        final ArgumentCaptor<RequestMessage> requestMessageCaptor = ArgumentCaptor.forClass(RequestMessage.class);
+        verify(client).submitAsync(requestMessageCaptor.capture());
+        final RequestMessage requestMessage = requestMessageCaptor.getValue();
+        assertEquals(overrideRequestId, requestMessage.getRequestId());
     }
 
     private void assertFutureTimeout(final CompletableFuture<List<Result>> futureFirst) {
-        try
-        {
+        try {
             futureFirst.get();
             fail("Should have timed out");
-        }
-        catch (Exception ex)
-        {
+        } catch (Exception ex) {
             final Throwable root = ExceptionUtils.getRootCause(ex);
             assertThat(root, instanceOf(ResponseException.class));
             assertThat(root.getMessage(), startsWith("Evaluation exceeded the configured 'evaluationTimeout' threshold of 250 ms"));
@@ -1873,9 +1871,10 @@ public class GremlinDriverIntegrateTest extends AbstractGremlinServerIntegration
             // should get a rejection here
             final Throwable root = ExceptionUtils.getRootCause(ex);
             assertThat(root.getMessage(), startsWith("There is already a request pending with an id of:"));
+            assertEquals(100, result1.get().one().getInt());
+        } finally {
+            cluster.close();
         }
-
-        assertEquals(100, result1.get().one().getInt());
     }
 
     /**
@@ -1895,7 +1894,7 @@ public class GremlinDriverIntegrateTest extends AbstractGremlinServerIntegration
             logger.info("Verifying driver cannot connect to server.");
             client.submit("g").all().get(500, TimeUnit.MILLISECONDS);
             fail("Should throw an exception.");
-        } catch (RuntimeException re) {
+        } catch (Exception re) {
             // Client would have no active connections to the host, hence it would encounter a timeout
             // trying to find an alive connection to the host.
             assertThat(re.getCause(), instanceOf(NoHostAvailableException.class));
diff --git a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerHttpIntegrateTest.java b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerHttpIntegrateTest.java
index 8916ee9..9eefa76 100644
--- a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerHttpIntegrateTest.java
+++ b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerHttpIntegrateTest.java
@@ -73,13 +73,11 @@ public class GremlinServerHttpIntegrateTest extends AbstractGremlinServerIntegra
                 settings.maxContentLength = 31;
                 break;
             case "should200OnPOSTTransactionalGraph":
-                deleteDirectory(new File("/tmp/neo4j"));
-                settings.graphs.put("graph", "conf/neo4j-empty.properties");
+                tryIncludeNeo4jGraph(settings);
                 break;
             case "should200OnPOSTTransactionalGraphInStrictMode":
+                tryIncludeNeo4jGraph(settings);
                 settings.strictTransactionManagement = true;
-                deleteDirectory(new File("/tmp/neo4j"));
-                settings.graphs.put("graph", "conf/neo4j-empty.properties");
                 break;
             case "should200OnPOSTWithGraphSON1d0AcceptHeaderDefaultResultToJson":
                 settings.serializers.clear();
diff --git a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerIntegrateTest.java b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerIntegrateTest.java
index 8a63694..4a95ae3 100644
--- a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerIntegrateTest.java
+++ b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerIntegrateTest.java
@@ -267,6 +267,8 @@ public class GremlinServerIntegrateTest extends AbstractGremlinServerIntegration
             assertThat(t, instanceOf(ResponseException.class));
             assertEquals(ResponseStatusCode.SERVER_ERROR_TIMEOUT, ((ResponseException) t).getResponseStatusCode());
         }
+
+        g.close();
     }
 
     @Test
@@ -285,7 +287,8 @@ public class GremlinServerIntegrateTest extends AbstractGremlinServerIntegration
 
     @Test
     public void shouldPingChannelIfClientDies() throws Exception {
-        final Client client = TestClientFactory.build().maxConnectionPoolSize(1).minConnectionPoolSize(1).keepAliveInterval(0).create().connect();
+        final Cluster cluster = TestClientFactory.build().maxConnectionPoolSize(1).minConnectionPoolSize(1).keepAliveInterval(0).create();
+        final Client client = cluster.connect();
         client.submit("1+1").all().get();
 
         // since we do nothing for 3 seconds and the time limit for ping is 1 second we should get *about* 3 pings -
@@ -293,7 +296,7 @@ public class GremlinServerIntegrateTest extends AbstractGremlinServerIntegration
         // there record
         Thread.sleep(3000);
 
-        client.close();
+        cluster.close();
 
         // stop the server to be sure that logs flush
         stopServer();
@@ -327,6 +330,8 @@ public class GremlinServerIntegrateTest extends AbstractGremlinServerIntegration
             assertThat(t, instanceOf(ResponseException.class));
             assertEquals(ResponseStatusCode.SERVER_ERROR_TIMEOUT, ((ResponseException) t).getResponseStatusCode());
         }
+
+        g.close();
     }
 
     @Test
@@ -355,10 +360,12 @@ public class GremlinServerIntegrateTest extends AbstractGremlinServerIntegration
             assertThat(t, instanceOf(ResponseException.class));
             assertEquals(ResponseStatusCode.SERVER_ERROR_TIMEOUT, ((ResponseException) t).getResponseStatusCode());
         }
+
+        g.close();
     }
 
     @Test
-    public void shouldTimeOutRemoteTraversalWithPerRequestOption() {
+    public void shouldTimeOutRemoteTraversalWithPerRequestOption() throws Exception {
         final GraphTraversalSource g = traversal().withRemote(conf);
 
         try {
@@ -383,6 +390,8 @@ public class GremlinServerIntegrateTest extends AbstractGremlinServerIntegration
             assertThat(t, instanceOf(ResponseException.class));
             assertEquals(ResponseStatusCode.SERVER_ERROR_TIMEOUT, ((ResponseException) t).getResponseStatusCode());
         }
+
+        g.close();
     }
 
     @Test
@@ -980,6 +989,7 @@ public class GremlinServerIntegrateTest extends AbstractGremlinServerIntegration
         g.addV("person").property("age", 20).iterate();
         g.addV("person").property("age", 10).iterate();
         assertEquals(50L, g.V().hasLabel("person").map(Lambda.function("it.get().value('age') + 10")).sum().next());
+        g.close();
     }
 
     @Test
@@ -1018,6 +1028,8 @@ public class GremlinServerIntegrateTest extends AbstractGremlinServerIntegration
         gdotv.toList();
         final DriverRemoteTraversalSideEffects gdotvSe = (DriverRemoteTraversalSideEffects) gdotv.asAdmin().getSideEffects();
         assertThat(gdotvSe.statusAttributes().containsKey(Tokens.ARGS_HOST), is(true));
+
+        g.close();
     }
 
     @Test
@@ -1068,6 +1080,9 @@ public class GremlinServerIntegrateTest extends AbstractGremlinServerIntegration
             error = true;
         }
         assertThat(error, is(true));
+
+        g.close();
+        cluster.close();
     }
 
     @Test
@@ -1083,7 +1098,7 @@ public class GremlinServerIntegrateTest extends AbstractGremlinServerIntegration
         traversal.hasNext();
 
         // start a separate thread to iterate
-        final Thread t = new Thread(traversal::iterate);
+        final Thread t = new Thread(traversal::iterate, name.getMethodName());
         t.start();
 
         // blocks here until traversal iteration is complete
@@ -1110,6 +1125,8 @@ public class GremlinServerIntegrateTest extends AbstractGremlinServerIntegration
 
         final BulkSet localBSideEffects = se.get("b");
         assertThat(localBSideEffects.isEmpty(), is(false));
+
+        g.close();
     }
 
     @Test
@@ -1125,7 +1142,7 @@ public class GremlinServerIntegrateTest extends AbstractGremlinServerIntegration
         traversal.hasNext();
 
         // start a separate thread to iterate
-        final Thread t = new Thread(traversal::iterate);
+        final Thread t = new Thread(traversal::iterate, name.getMethodName());
         t.start();
 
         // blocks here until traversal iteration is complete
@@ -1152,6 +1169,8 @@ public class GremlinServerIntegrateTest extends AbstractGremlinServerIntegration
 
         final BulkSet localBSideEffects = se.get("b");
         assertThat(localBSideEffects.isEmpty(), is(false));
+
+        g.close();
     }
 
     @Test
@@ -1163,7 +1182,7 @@ public class GremlinServerIntegrateTest extends AbstractGremlinServerIntegration
         g.addV("person").property("age", 20).promise(Traversal::iterate).join();
 
         final Traversal<Vertex,Integer> traversal = g.V().hasLabel("person").has("age", 20).values("age");
-        int age = traversal.promise(t -> t.next(1).get(0)).join();
+        final int age = traversal.promise(t -> t.next(1).get(0)).join();
         assertEquals(20, age);
         assertEquals(20, (int)traversal.next());
         assertThat(traversal.hasNext(), is(false));
@@ -1174,6 +1193,8 @@ public class GremlinServerIntegrateTest extends AbstractGremlinServerIntegration
         assertThat(traversalCloned.promise(t -> ((Traversal) t).hasNext()).join(), is(false));
 
         assertEquals(3, g.V().promise(Traversal::toList).join().size());
+
+        g.close();
     }
 
     @Test
@@ -1199,6 +1220,8 @@ public class GremlinServerIntegrateTest extends AbstractGremlinServerIntegration
             fail("Should have tanked out because of number of parameters used and size of the compile script");
         } catch (Exception ex) {
             assertThat(ex.getMessage(), containsString("The Gremlin statement that was submitted exceeds the maximum compilation size allowed by the JVM"));
+        } finally {
+            cluster.close();
         }
     }
 }
diff --git a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerSessionIntegrateTest.java b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerSessionIntegrateTest.java
index ddf39d3..5af4f60 100644
--- a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerSessionIntegrateTest.java
+++ b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerSessionIntegrateTest.java
@@ -103,7 +103,10 @@ public class GremlinServerSessionIntegrateTest extends AbstractGremlinServerInte
                 break;
             case "shouldBlockAdditionalRequestsDuringClose":
             case "shouldBlockAdditionalRequestsDuringForceClose":
-                clearNeo4j(settings);
+            case "shouldExecuteInSessionAndSessionlessWithoutOpeningTransactionWithSingleClient":
+            case "shouldExecuteInSessionWithTransactionManagement":
+            case "shouldRollbackOnEvalExceptionForManagedTransaction":
+                tryIncludeNeo4jGraph(settings);
                 break;
             case "shouldEnsureSessionBindingsAreThreadSafe":
                 settings.threadPoolWorker = 2;
@@ -116,21 +119,11 @@ public class GremlinServerSessionIntegrateTest extends AbstractGremlinServerInte
                 processorSettingsForDisableFunctionCache.config.put(SessionOpProcessor.CONFIG_GLOBAL_FUNCTION_CACHE_ENABLED, false);
                 settings.processors.add(processorSettingsForDisableFunctionCache);
                 break;
-            case "shouldExecuteInSessionAndSessionlessWithoutOpeningTransactionWithSingleClient":
-            case "shouldExecuteInSessionWithTransactionManagement":
-            case "shouldRollbackOnEvalExceptionForManagedTransaction":
-                clearNeo4j(settings);
-                break;
         }
 
         return settings;
     }
 
-    private static void clearNeo4j(Settings settings) {
-        deleteDirectory(new File("/tmp/neo4j"));
-        settings.graphs.put("graph", "conf/neo4j-empty.properties");
-    }
-
     @Test
     public void shouldUseGlobalFunctionCache() throws Exception {
         final Cluster cluster = TestClientFactory.open();