This is an automated email from the ASF dual-hosted git repository. spmallette pushed a commit to branch travis-fix in repository https://gitbox.apache.org/repos/asf/tinkerpop.git
commit 4dadccb0e5dae5bee0f8117dd15452b1bd5560c5 Author: stephen <[email protected]> AuthorDate: Mon Nov 11 08:23:31 2019 -0500 A body of commits to debug/fix a failing travis test Prevent a null pointer when session kill futuer is not present CTR Cleanup travis logs a bit by increasing compilation time. Noticed the logs were filled with WARN messages about init scripts taking longer than the default time of 5 seconds to compile. Must just be slower on Travis as we don't see this elsewhere. Make the first request in a synchronous fashion test if waiting helps close connections try-catch-finally to better handle Cluster.close() in tests Remove sleep() from test to see if that makes a difference Increase time willing to wait for a connection --- .../gremlin-server-integration-secure.yaml | 1 + .../gremlin-server/gremlin-server-integration.yaml | 1 + .../gremlin/server/op/session/Session.java | 8 +++- .../server/op/session/SessionOpProcessor.java | 1 - .../server/GremlinServerSessionIntegrateTest.java | 50 ++++++++++++++-------- .../gremlin/server/gremlin-server-integration.yaml | 1 + 6 files changed, 41 insertions(+), 21 deletions(-) diff --git a/docker/gremlin-server/gremlin-server-integration-secure.yaml b/docker/gremlin-server/gremlin-server-integration-secure.yaml index 2274852..c489e07 100644 --- a/docker/gremlin-server/gremlin-server-integration-secure.yaml +++ b/docker/gremlin-server/gremlin-server-integration-secure.yaml @@ -29,6 +29,7 @@ scriptEngines: { gremlin-groovy: { plugins: { org.apache.tinkerpop.gremlin.server.jsr223.GremlinServerGremlinPlugin: {}, org.apache.tinkerpop.gremlin.tinkergraph.jsr223.TinkerGraphGremlinPlugin: {}, + org.apache.tinkerpop.gremlin.groovy.jsr223.GroovyCompilerGremlinPlugin: {expectedCompilationTime: 30000}, org.apache.tinkerpop.gremlin.jsr223.ImportGremlinPlugin: {classImports: [java.lang.Math], methodImports: [java.lang.Math#*]}, org.apache.tinkerpop.gremlin.jsr223.ScriptFileGremlinPlugin: {files: [scripts/generate-all.groovy]}}}, gremlin-jython: {}, diff --git a/docker/gremlin-server/gremlin-server-integration.yaml b/docker/gremlin-server/gremlin-server-integration.yaml index 4ccaf32..7c5445a 100644 --- a/docker/gremlin-server/gremlin-server-integration.yaml +++ b/docker/gremlin-server/gremlin-server-integration.yaml @@ -29,6 +29,7 @@ scriptEngines: { gremlin-groovy: { plugins: { org.apache.tinkerpop.gremlin.server.jsr223.GremlinServerGremlinPlugin: {}, org.apache.tinkerpop.gremlin.tinkergraph.jsr223.TinkerGraphGremlinPlugin: {}, + org.apache.tinkerpop.gremlin.groovy.jsr223.GroovyCompilerGremlinPlugin: {expectedCompilationTime: 30000}, org.apache.tinkerpop.gremlin.jsr223.ImportGremlinPlugin: {classImports: [java.lang.Math], methodImports: [java.lang.Math#*]}, org.apache.tinkerpop.gremlin.jsr223.ScriptFileGremlinPlugin: {files: [scripts/generate-all.groovy]}}}, gremlin-jython: {}, diff --git a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/op/session/Session.java b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/op/session/Session.java index f41a0fb..7191d04 100644 --- a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/op/session/Session.java +++ b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/op/session/Session.java @@ -34,6 +34,7 @@ import javax.script.Bindings; import javax.script.SimpleBindings; import java.util.HashMap; import java.util.Map; +import java.util.Optional; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; @@ -155,7 +156,12 @@ public class Session { * session kill will mean. */ public void manualKill(final boolean force) { - kill.get().cancel(true); + // seems there is a situation where kill can get nulled. seems to only happen in travis as a result of test + // runs and i'm guessing it has something to do with a combination of shutdown and session close though i'm + // not sure why. perhaps this "fix" just masks up a deeper problem but as i reason on it now, it seems mostly + // bound to shutdown situations which basically means the forced end of the session anyway, so perhaps the + // root cause isn't something that needs immediate chasing (at least until it can be shown otherwise anyway) + Optional.ofNullable(kill.get()).ifPresent(f -> f.cancel(true)); kill(force); } diff --git a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/op/session/SessionOpProcessor.java b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/op/session/SessionOpProcessor.java index 54a409b..545ae7e 100644 --- a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/op/session/SessionOpProcessor.java +++ b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/op/session/SessionOpProcessor.java @@ -124,7 +124,6 @@ public class SessionOpProcessor extends AbstractEvalOpProcessor { /** * Session based requests accept a "close" operator in addition to "eval". A close will trigger the session to be * killed and any uncommitted transaction to be rolled-back. - * @return */ @Override public Optional<ThrowingConsumer<Context>> selectOther(final RequestMessage requestMessage) throws OpProcessorException { 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 07944e8..889228c 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 @@ -327,32 +327,44 @@ public class GremlinServerSessionIntegrateTest extends AbstractGremlinServerInt @Test public void shouldEnsureSessionBindingsAreThreadSafe() throws Exception { - final Cluster cluster = TestClientFactory.build().minInProcessPerConnection(16).maxInProcessPerConnection(64).create(); + final Cluster cluster = TestClientFactory.build().maxWaitForConnection(90000). + minInProcessPerConnection(16).maxInProcessPerConnection(64).create(); final Client client = cluster.connect(name.getMethodName()); - client.submitAsync("a=100;b=1000;c=10000;null"); - final int requests = 10000; - final List<CompletableFuture<ResultSet>> futures = new ArrayList<>(requests); - IntStream.range(0, requests).forEach(i -> { - try { - futures.add(client.submitAsync("a+b+c")); - } catch (Exception ex) { - throw new RuntimeException(ex); + try { + client.submit("a=100;b=1000;c=10000;null").all().get(); + final int requests = 10000; + final List<CompletableFuture<ResultSet>> futures = new ArrayList<>(requests); + IntStream.range(0, requests).forEach(i -> { + try { + futures.add(client.submitAsync("a+b+c")); + } catch (Exception ex) { + throw new RuntimeException(ex); + } + }); + + System.out.println("shouldEnsureSessionBindingsAreThreadSafe: sent 10000"); + assertEquals(requests, futures.size()); + + System.out.println("shouldEnsureSessionBindingsAreThreadSafe: asserting 10000"); + int counter = 0; + for (CompletableFuture<ResultSet> f : futures) { + final Result r = f.get().all().get(30000, TimeUnit.MILLISECONDS).get(0); + assertEquals(11100, r.getInt()); + counter++; } - }); - assertEquals(requests, futures.size()); + assertEquals(requests, counter); + System.out.println("shouldEnsureSessionBindingsAreThreadSafe: asserted 10000"); - int counter = 0; - for(CompletableFuture<ResultSet> f : futures) { - final Result r = f.get().all().get(30000, TimeUnit.MILLISECONDS).get(0); - assertEquals(11100, r.getInt()); - counter++; + } catch (Exception ex) { + fail(ex.getMessage()); + } finally { + System.out.println("shouldEnsureSessionBindingsAreThreadSafe: calling cluster.close"); + cluster.close(); + System.out.println("shouldEnsureSessionBindingsAreThreadSafe: called cluster.close"); } - assertEquals(requests, counter); - - cluster.close(); } @Test diff --git a/gremlin-server/src/test/resources/org/apache/tinkerpop/gremlin/server/gremlin-server-integration.yaml b/gremlin-server/src/test/resources/org/apache/tinkerpop/gremlin/server/gremlin-server-integration.yaml index adf05cd..601e404 100644 --- a/gremlin-server/src/test/resources/org/apache/tinkerpop/gremlin/server/gremlin-server-integration.yaml +++ b/gremlin-server/src/test/resources/org/apache/tinkerpop/gremlin/server/gremlin-server-integration.yaml @@ -42,6 +42,7 @@ scriptEngines: { gremlin-groovy: { plugins: { org.apache.tinkerpop.gremlin.server.jsr223.GremlinServerGremlinPlugin: {}, org.apache.tinkerpop.gremlin.tinkergraph.jsr223.TinkerGraphGremlinPlugin: {}, + org.apache.tinkerpop.gremlin.groovy.jsr223.GroovyCompilerGremlinPlugin: {expectedCompilationTime: 30000}, org.apache.tinkerpop.gremlin.jsr223.ImportGremlinPlugin: {classImports: [java.lang.Math], methodImports: [java.lang.Math#*]}, org.apache.tinkerpop.gremlin.jsr223.ScriptFileGremlinPlugin: {files: [scripts/generate-all.groovy]}}}} serializers:
