[ 
https://issues.apache.org/jira/browse/TINKERPOP-2438?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17249282#comment-17249282
 ] 

ASF GitHub Bot commented on TINKERPOP-2438:
-------------------------------------------

divijvaidya commented on a change in pull request #1371:
URL: https://github.com/apache/tinkerpop/pull/1371#discussion_r542752536



##########
File path: 
gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinScriptCheckerTest.java
##########
@@ -0,0 +1,300 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tinkerpop.gremlin.groovy.jsr223;
+
+import org.junit.Test;
+
+import java.util.Optional;
+
+import static 
org.apache.tinkerpop.gremlin.groovy.jsr223.GremlinScriptChecker.EMPTY_RESULT;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertSame;
+
+public class GremlinScriptCheckerTest {
+
+    @Test
+    public void shouldNotFindTimeout() {
+        assertEquals(Optional.empty(), 
GremlinScriptChecker.parse("g.with(true).V().out('knows')").getTimeout());
+    }
+
+    @Test
+    public void shouldReturnEmpty() {
+        assertSame(EMPTY_RESULT, GremlinScriptChecker.parse(""));
+    }
+
+    @Test
+    public void shouldNotFindTimeoutCozWeCommentedItOut() {
+        assertEquals(Optional.empty(), GremlinScriptChecker.parse("g.\n" +
+                "                                                  // 
with('evaluationTimeout', 1000L).\n" +
+                "                                                  
with(true).V().out('knows')").getTimeout());
+    }
+
+    @Test
+    public void shouldIdentifyTimeoutAsStringKeySingleQuoted() {
+        assertEquals(1000, 
GremlinScriptChecker.parse("g.with('evaluationTimeout', 
1000L).with(true).V().out('knows')").
+                getTimeout().get().longValue());
+        assertEquals(1000, 
GremlinScriptChecker.parse("g.with('scriptEvaluationTimeout', 
1000L).with(true).V().out('knows')").
+                getTimeout().get().longValue());
+    }
+
+    @Test
+    public void shouldIdentifyTimeoutAsStringKeyDoubleQuoted() {
+        assertEquals(1000, 
GremlinScriptChecker.parse("g.with(\"evaluationTimeout\", 
1000L).with(true).V().out('knows')").
+                getTimeout().get().longValue());
+        assertEquals(1000, 
GremlinScriptChecker.parse("g.with(\"scriptEvaluationTimeout\", 
1000L).with(true).V().out('knows')").
+                getTimeout().get().longValue());
+    }
+
+    @Test
+    public void shouldIdentifyTimeoutAsTokenKey() {
+        assertEquals(1000, 
GremlinScriptChecker.parse("g.with(Tokens.ARGS_EVAL_TIMEOUT, 
1000L).with(true).V().out('knows')").
+                getTimeout().get().longValue());
+        assertEquals(1000, 
GremlinScriptChecker.parse("g.with(Tokens.ARGS_SCRIPT_EVAL_TIMEOUT, 
1000L).with(true).V().out('knows')").
+                getTimeout().get().longValue());
+    }
+
+    @Test
+    public void shouldIdentifyTimeoutAsTokenKeyWithoutClassName() {
+        assertEquals(1000, 
GremlinScriptChecker.parse("g.with(ARGS_EVAL_TIMEOUT, 
1000L).with(true).V().out('knows')").
+                getTimeout().get().longValue());
+        assertEquals(1000, 
GremlinScriptChecker.parse("g.with(ARGS_SCRIPT_EVAL_TIMEOUT, 
1000L).with(true).V().out('knows')").
+                getTimeout().get().longValue());
+    }
+
+    @Test
+    public void shouldIdentifyMultipleTimeouts() {
+        assertEquals(6000, 
GremlinScriptChecker.parse("g.with('evaluationTimeout', 
1000L).with(true).V().out('knows');" +
+                "g.with('evaluationTimeout', 
1000L).with(true).V().out('knows')\n" +
+                "                                                   
//g.with('evaluationTimeout', 1000L).with(true).V().out('knows')\n" +
+                "                                                   /* 
g.with('evaluationTimeout', 1000L).with(true).V().out('knows')*/\n" +
+                "                                                   /* \n" +
+                "g.with('evaluationTimeout', 
1000L).with(true).V().out('knows') \n" +
+                "*/ \n" +
+                "                                                   
g.with('evaluationTimeout', 1000L).with(true).V().out('knows')\n" +

Review comment:
       This should probably have a `;` at the end?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


> Provide a way for scripts to respect with() specification of timeout
> --------------------------------------------------------------------
>
>                 Key: TINKERPOP-2438
>                 URL: https://issues.apache.org/jira/browse/TINKERPOP-2438
>             Project: TinkerPop
>          Issue Type: Improvement
>          Components: server
>    Affects Versions: 3.4.8
>            Reporter: Stephen Mallette
>            Assignee: Stephen Mallette
>            Priority: Major
>             Fix For: 3.5.0, 3.4.9
>
>
> This issue sorta relates to the Gremlin Console but I think it's generally a 
> server side problem as it could easily occur with HTTP or just scripts sent 
> over web sockets. Folks tend to see all the ways they can set timeouts and 
> then mix/match them. It only remains a problem with sending a script as 
> {{g.with("evalTimeout",100)}} because the server won't know that this value 
> was set until the script is passed to {{eval()}} but by then it's too late 
> because we would have already started the timeout countdown.  While most 
> users wouldn't send that as a bare script submission it's a common mistake in 
> the Gremlin Console and similar environments where it is not clear you are 
> working with a remote graph. 



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to