You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by dk...@apache.org on 2018/02/27 17:18:35 UTC

[24/50] tinkerpop git commit: TINKERPOP-1726 Added test to check if server auto-closes channels properly

TINKERPOP-1726 Added test to check if server auto-closes channels properly


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

Branch: refs/heads/TINKERPOP-1777
Commit: da48b74b1e10065978f4905693c3b97dad257a0a
Parents: 00e4235
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Tue Feb 20 09:54:01 2018 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Tue Feb 20 09:54:01 2018 -0500

----------------------------------------------------------------------
 .../server/GremlinServerIntegrateTest.java      | 23 ++++++++++++++++++--
 1 file changed, 21 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/da48b74b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerIntegrateTest.java
----------------------------------------------------------------------
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 033c847..1db7a50 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
@@ -131,7 +131,8 @@ public class GremlinServerIntegrateTest extends AbstractGremlinServerIntegration
         recordingAppender = new Log4jRecordingAppender();
         final Logger rootLogger = Logger.getRootLogger();
 
-        if (name.getMethodName().equals("shouldPingChannelIfClientDies")) {
+        if (name.getMethodName().equals("shouldPingChannelIfClientDies") ||
+                name.getMethodName().equals("shouldCloseChannelIfClientDoesntRespond")) {
             final org.apache.log4j.Logger webSocketClientHandlerLogger = org.apache.log4j.Logger.getLogger(OpSelectorHandler.class);
             previousLogLevel = webSocketClientHandlerLogger.getLevel();
             webSocketClientHandlerLogger.setLevel(Level.INFO);
@@ -144,7 +145,8 @@ public class GremlinServerIntegrateTest extends AbstractGremlinServerIntegration
     public void teardownForEachTest() {
         final Logger rootLogger = Logger.getRootLogger();
 
-        if (name.getMethodName().equals("shouldPingChannelIfClientDies")) {
+        if (name.getMethodName().equals("shouldPingChannelIfClientDies")||
+                name.getMethodName().equals("shouldCloseChannelIfClientDoesntRespond")) {
             final org.apache.log4j.Logger webSocketClientHandlerLogger = org.apache.log4j.Logger.getLogger(OpSelectorHandler.class);
             previousLogLevel = webSocketClientHandlerLogger.getLevel();
             webSocketClientHandlerLogger.setLevel(previousLogLevel);
@@ -253,6 +255,9 @@ public class GremlinServerIntegrateTest extends AbstractGremlinServerIntegration
             case "shouldPingChannelIfClientDies":
                 settings.keepAliveInterval = 1000;
                 break;
+            case "shouldCloseChannelIfClientDoesntRespond":
+                settings.idleConnectionTimeout = 1000;
+                break;
         }
 
         return settings;
@@ -313,6 +318,20 @@ public class GremlinServerIntegrateTest extends AbstractGremlinServerIntegration
     }
 
     @Test
+    public void shouldCloseChannelIfClientDoesntRespond() throws Exception {
+        final SimpleClient client = TestClientFactory.createWebSocketClient();
+        client.submit("1+1");
+
+        // since we do nothing for 2 seconds and the time limit for timeout on the server is 1 second, the server
+        // will autoclose the channel
+        Thread.sleep(2000);
+
+        assertThat(recordingAppender.logContainsAny(".*Closing channel - client is disconnected after idle period of .*$"), is(true));
+
+        client.close();
+    }
+
+    @Test
     public void shouldPingChannelIfClientDies() throws Exception {
         final Client client = TestClientFactory.build().maxConnectionPoolSize(1).minConnectionPoolSize(1).keepAliveInterval(0).create().connect();
         client.submit("1+1").all().get();