TINKERPOP-1968 Simplified gremlin server test configuration There was a fair bit of duplicated configuration for Gremlin Server testing - streamlined that to a single gremlin-server-integration.yaml file and script initializer. Tests had to become more specific as to the graphs that they were executing against as a result.
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/8e2749e7 Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/8e2749e7 Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/8e2749e7 Branch: refs/heads/TINKERPOP-1968 Commit: 8e2749e755db9b592878c065975f4da69e4a83ae Parents: 68bdaed Author: Stephen Mallette <sp...@genoprime.com> Authored: Fri May 18 14:38:04 2018 -0400 Committer: Stephen Mallette <sp...@genoprime.com> Committed: Thu May 31 16:18:08 2018 -0400 ---------------------------------------------------------------------- gremlin-dotnet/test/pom.xml | 2 +- gremlin-javascript/pom.xml | 2 +- .../test/integration/remote-connection-tests.js | 2 +- .../test/integration/traversal-test.js | 2 +- gremlin-python/pom.xml | 2 +- .../src/main/jython/tests/conftest.py | 6 +- .../src/main/jython/tests/driver/test_client.py | 14 ++--- .../driver/test_driver_remote_connection.py | 4 +- .../test_driver_remote_connection_threaded.py | 4 +- gremlin-server/scripts/generate-all.groovy | 63 -------------------- gremlin-server/src/assembly/standalone.xml | 3 - .../driver/remote/RemoteGraphProvider.java | 2 +- .../server/GremlinResultSetIntegrateTest.java | 34 +++++------ .../server/GremlinServerHttpIntegrateTest.java | 18 ++---- .../gremlin/server/ServerTestHelper.java | 7 ++- .../server/util/DefaultGraphManagerTest.java | 32 +++++++--- .../remote/gremlin-server-integration.yaml | 56 ----------------- .../server/gremlin-server-integration.yaml | 11 +++- .../src/test/scripts/generate-all.groovy | 31 +++++++++- .../src/test/scripts/neo4j-empty.properties | 33 ++++++++++ 20 files changed, 139 insertions(+), 189 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/8e2749e7/gremlin-dotnet/test/pom.xml ---------------------------------------------------------------------- diff --git a/gremlin-dotnet/test/pom.xml b/gremlin-dotnet/test/pom.xml index db1f8ad..f8d3118 100644 --- a/gremlin-dotnet/test/pom.xml +++ b/gremlin-dotnet/test/pom.xml @@ -143,7 +143,7 @@ limitations under the License. </property> <property> <name>settingsFile</name> - <value>${gremlin.server.dir}/src/test/resources/org/apache/tinkerpop/gremlin/driver/remote/gremlin-server-integration.yaml</value> + <value>${gremlin.server.dir}/src/test/resources/org/apache/tinkerpop/gremlin/server/gremlin-server-integration.yaml</value> </property> <property> <name>executionName</name> http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/8e2749e7/gremlin-javascript/pom.xml ---------------------------------------------------------------------- diff --git a/gremlin-javascript/pom.xml b/gremlin-javascript/pom.xml index a820f3b..b01b2b9 100644 --- a/gremlin-javascript/pom.xml +++ b/gremlin-javascript/pom.xml @@ -114,7 +114,7 @@ limitations under the License. </property> <property> <name>settingsFile</name> - <value>${gremlin.server.dir}/src/test/resources/org/apache/tinkerpop/gremlin/driver/remote/gremlin-server-integration.yaml</value> + <value>${gremlin.server.dir}/src/test/resources/org/apache/tinkerpop/gremlin/server/gremlin-server-integration.yaml</value> </property> <property> <name>executionName</name> http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/8e2749e7/gremlin-javascript/src/main/javascript/gremlin-javascript/test/integration/remote-connection-tests.js ---------------------------------------------------------------------- diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/integration/remote-connection-tests.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/integration/remote-connection-tests.js index 9e115be..afc0e58 100644 --- a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/integration/remote-connection-tests.js +++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/integration/remote-connection-tests.js @@ -31,7 +31,7 @@ let connection; describe('DriverRemoteConnection', function () { before(function () { - connection = helper.getConnection(); + connection = helper.getConnection('gmodern'); return connection.open(); }); after(function () { http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/8e2749e7/gremlin-javascript/src/main/javascript/gremlin-javascript/test/integration/traversal-test.js ---------------------------------------------------------------------- diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/integration/traversal-test.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/integration/traversal-test.js index 01dde62..920d998 100644 --- a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/integration/traversal-test.js +++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/integration/traversal-test.js @@ -33,7 +33,7 @@ let connection; describe('Traversal', function () { before(function () { - connection = helper.getConnection(); + connection = helper.getConnection('gmodern'); return connection.open(); }); after(function () { http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/8e2749e7/gremlin-python/pom.xml ---------------------------------------------------------------------- diff --git a/gremlin-python/pom.xml b/gremlin-python/pom.xml index a2ab516..13c3454 100644 --- a/gremlin-python/pom.xml +++ b/gremlin-python/pom.xml @@ -507,7 +507,7 @@ limitations under the License. </property> <property> <name>settingsFile</name> - <value>${gremlin.server.dir}/src/test/resources/org/apache/tinkerpop/gremlin/driver/remote/gremlin-server-integration.yaml</value> + <value>${gremlin.server.dir}/src/test/resources/org/apache/tinkerpop/gremlin/server/gremlin-server-integration.yaml</value> </property> <property> <name>executionName</name> http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/8e2749e7/gremlin-python/src/main/jython/tests/conftest.py ---------------------------------------------------------------------- diff --git a/gremlin-python/src/main/jython/tests/conftest.py b/gremlin-python/src/main/jython/tests/conftest.py index 2cd4282..96ded16 100644 --- a/gremlin-python/src/main/jython/tests/conftest.py +++ b/gremlin-python/src/main/jython/tests/conftest.py @@ -38,7 +38,7 @@ def connection(request): executor = concurrent.futures.ThreadPoolExecutor(5) pool = queue.Queue() try: - conn = Connection('ws://localhost:45940/gremlin', 'g', protocol, + conn = Connection('ws://localhost:45940/gremlin', 'gmodern', protocol, lambda: TornadoTransport(), executor, pool) except OSError: executor.shutdown() @@ -53,7 +53,7 @@ def connection(request): @pytest.fixture def client(request): try: - client = Client('ws://localhost:45940/gremlin', 'g') + client = Client('ws://localhost:45940/gremlin', 'gmodern') except OSError: pytest.skip('Gremlin Server is not running') else: @@ -65,7 +65,7 @@ def client(request): @pytest.fixture def remote_connection(request): try: - remote_conn = DriverRemoteConnection('ws://localhost:45940/gremlin', 'g') + remote_conn = DriverRemoteConnection('ws://localhost:45940/gremlin', 'gmodern') except OSError: pytest.skip('Gremlin Server is not running') else: http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/8e2749e7/gremlin-python/src/main/jython/tests/driver/test_client.py ---------------------------------------------------------------------- diff --git a/gremlin-python/src/main/jython/tests/driver/test_client.py b/gremlin-python/src/main/jython/tests/driver/test_client.py index f7b01ce..595aba0 100644 --- a/gremlin-python/src/main/jython/tests/driver/test_client.py +++ b/gremlin-python/src/main/jython/tests/driver/test_client.py @@ -28,7 +28,7 @@ __author__ = 'David M. Brown (davebs...@gmail.com)' def test_connection(connection): g = Graph().traversal() t = g.V() - message = RequestMessage('traversal', 'bytecode', {'gremlin': t.bytecode}) + message = RequestMessage('traversal', 'bytecode', {'gremlin': t.bytecode, 'aliases': {'g': 'gmodern'}}) results_set = connection.write(message).result() future = results_set.all() results = future.result() @@ -51,7 +51,7 @@ def test_client_eval_traversal(client): def test_client_bytecode(client): g = Graph().traversal() t = g.V() - message = RequestMessage('traversal', 'bytecode', {'gremlin': t.bytecode}) + message = RequestMessage('traversal', 'bytecode', {'gremlin': t.bytecode, 'aliases': {'g': 'gmodern'}}) result_set = client.submit(message) assert len(result_set.all().result()) == 6 @@ -59,7 +59,7 @@ def test_client_bytecode(client): def test_iterate_result_set(client): g = Graph().traversal() t = g.V() - message = RequestMessage('traversal', 'bytecode', {'gremlin': t.bytecode}) + message = RequestMessage('traversal', 'bytecode', {'gremlin': t.bytecode, 'aliases': {'g': 'gmodern'}}) result_set = client.submit(message) results = [] for result in result_set: @@ -70,7 +70,7 @@ def test_iterate_result_set(client): def test_client_async(client): g = Graph().traversal() t = g.V() - message = RequestMessage('traversal', 'bytecode', {'gremlin': t.bytecode}) + message = RequestMessage('traversal', 'bytecode', {'gremlin': t.bytecode, 'aliases': {'g': 'gmodern'}}) future = client.submitAsync(message) result_set = future.result() assert len(result_set.all().result()) == 6 @@ -78,10 +78,10 @@ def test_client_async(client): def test_connection_share(client): # Overwrite fixture with pool_size=1 client - client = Client('ws://localhost:45940/gremlin', 'g', pool_size=1) + client = Client('ws://localhost:45940/gremlin', 'gmodern', pool_size=1) g = Graph().traversal() t = g.V() - message = RequestMessage('traversal', 'bytecode', {'gremlin': t.bytecode}) + message = RequestMessage('traversal', 'bytecode', {'gremlin': t.bytecode, 'aliases': {'g': 'gmodern'}}) future = client.submitAsync(message) future2 = client.submitAsync(message) @@ -97,7 +97,7 @@ def test_connection_share(client): def test_multi_conn_pool(client): g = Graph().traversal() t = g.V() - message = RequestMessage('traversal', 'bytecode', {'gremlin': t.bytecode}) + message = RequestMessage('traversal', 'bytecode', {'gremlin': t.bytecode, 'aliases': {'g': 'gmodern'}}) future = client.submitAsync(message) future2 = client.submitAsync(message) http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/8e2749e7/gremlin-python/src/main/jython/tests/driver/test_driver_remote_connection.py ---------------------------------------------------------------------- diff --git a/gremlin-python/src/main/jython/tests/driver/test_driver_remote_connection.py b/gremlin-python/src/main/jython/tests/driver/test_driver_remote_connection.py index 1071493..cd9101e 100644 --- a/gremlin-python/src/main/jython/tests/driver/test_driver_remote_connection.py +++ b/gremlin-python/src/main/jython/tests/driver/test_driver_remote_connection.py @@ -37,7 +37,7 @@ __author__ = 'Marko A. Rodriguez (http://markorodriguez.com)' class TestDriverRemoteConnection(object): def test_traversals(self, remote_connection): statics.load_statics(globals()) - assert "remoteconnection[ws://localhost:45940/gremlin,g]" == str(remote_connection) + assert "remoteconnection[ws://localhost:45940/gremlin,gmodern]" == str(remote_connection) g = Graph().traversal().withRemote(remote_connection) assert long(6) == g.V().count().toList()[0] @@ -233,7 +233,7 @@ def test_in_tornado_app(remote_connection): @gen.coroutine def go(): conn = DriverRemoteConnection( - 'ws://localhost:45940/gremlin', 'g', pool_size=4) + 'ws://localhost:45940/gremlin', 'gmodern', pool_size=4) g = Graph().traversal().withRemote(conn) yield gen.sleep(0) assert len(g.V().toList()) == 6 http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/8e2749e7/gremlin-python/src/main/jython/tests/driver/test_driver_remote_connection_threaded.py ---------------------------------------------------------------------- diff --git a/gremlin-python/src/main/jython/tests/driver/test_driver_remote_connection_threaded.py b/gremlin-python/src/main/jython/tests/driver/test_driver_remote_connection_threaded.py index dffd442..49db930 100644 --- a/gremlin-python/src/main/jython/tests/driver/test_driver_remote_connection_threaded.py +++ b/gremlin-python/src/main/jython/tests/driver/test_driver_remote_connection_threaded.py @@ -41,6 +41,7 @@ def test_conns_in_threads(remote_connection): child.join() child2.join() + def test_conn_in_threads(remote_connection): q = queue.Queue() child = Thread(target=_executor, args=(q, remote_connection)) @@ -53,13 +54,14 @@ def test_conn_in_threads(remote_connection): child.join() child2.join() + def _executor(q, conn): close = False if not conn: # This isn't a fixture so close manually close = True conn = DriverRemoteConnection( - 'ws://localhost:45940/gremlin', 'g', pool_size=4) + 'ws://localhost:45940/gremlin', 'gmodern', pool_size=4) try: g = Graph().traversal().withRemote(conn) future = g.V().promise() http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/8e2749e7/gremlin-server/scripts/generate-all.groovy ---------------------------------------------------------------------- diff --git a/gremlin-server/scripts/generate-all.groovy b/gremlin-server/scripts/generate-all.groovy deleted file mode 100644 index 66b1cb4..0000000 --- a/gremlin-server/scripts/generate-all.groovy +++ /dev/null @@ -1,63 +0,0 @@ -/* - * 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. - */ - -// an init script that returns a Map allows explicit setting of global bindings. -def globals = [:] - -// Generates the modern graph into an "empty" TinkerGraph via LifeCycleHook. -// Note that the name of the key in the "global" map is unimportant. -globals << [hook : [ - onStartUp: { ctx -> - TinkerFactory.generateClassic(classic) - TinkerFactory.generateModern(modern) - TinkerFactory.generateTheCrew(crew) - grateful.io(gryo()).readGraph('../data/grateful-dead.kryo') - TinkerFactory.generateKitchenSink(sink) - - // a wild bit of trickery here. the process tests use an INTEGER id manager when LoadGraphWith is used. this - // closure provides a way to to manually override the various id managers for TinkerGraph - the graph on which - // all of these remote tests are executed - so that the tests will pass nicely. an alternative might have been - // to have a special test TinkerGraph config for setting up the id manager properly, but based on how we do - // things now, that test config would have been mixed in with release artifacts and there would have been ugly - // exclusions to make packaging work properly. - allowSetOfIdManager = { graph, idManagerFieldName -> - java.lang.reflect.Field idManagerField = graph.class.getDeclaredField(idManagerFieldName) - idManagerField.setAccessible(true) - java.lang.reflect.Field modifiersField = java.lang.reflect.Field.class.getDeclaredField("modifiers") - modifiersField.setAccessible(true) - modifiersField.setInt(idManagerField, modifiersField.getModifiers() & ~java.lang.reflect.Modifier.FINAL) - - idManagerField.set(graph, TinkerGraph.DefaultIdManager.INTEGER) - } - - [classic, modern, crew, sink].each{ - allowSetOfIdManager(it, "vertexIdManager") - allowSetOfIdManager(it, "edgeIdManager") - allowSetOfIdManager(it, "vertexPropertyIdManager") - } - } -] as LifeCycleHook] - -// add default TraversalSource instances for each graph instance -globals << [gclassic : classic.traversal()] -globals << [gmodern : modern.traversal()] -globals << [gcrew : crew.traversal()] -globals << [ggraph : graph.traversal()] -globals << [ggrateful : grateful.traversal()] -globals << [gsink : sink.traversal()] \ No newline at end of file http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/8e2749e7/gremlin-server/src/assembly/standalone.xml ---------------------------------------------------------------------- diff --git a/gremlin-server/src/assembly/standalone.xml b/gremlin-server/src/assembly/standalone.xml index cbb862e..f6a3641 100644 --- a/gremlin-server/src/assembly/standalone.xml +++ b/gremlin-server/src/assembly/standalone.xml @@ -38,9 +38,6 @@ limitations under the License. <fileSet> <directory>scripts</directory> <outputDirectory>/scripts</outputDirectory> - <excludes> - <exclude>generate-all.groovy</exclude> - </excludes> </fileSet> <fileSet> <directory>../target/docs/htmlsingle</directory> http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/8e2749e7/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/driver/remote/RemoteGraphProvider.java ---------------------------------------------------------------------- diff --git a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/driver/remote/RemoteGraphProvider.java b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/driver/remote/RemoteGraphProvider.java index 2c81078..8a1413a 100644 --- a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/driver/remote/RemoteGraphProvider.java +++ b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/driver/remote/RemoteGraphProvider.java @@ -122,7 +122,7 @@ public class RemoteGraphProvider extends AbstractGraphProvider implements AutoCl } public static void startServer() throws Exception { - final InputStream stream = RemoteGraphProvider.class.getResourceAsStream("gremlin-server-integration.yaml"); + final InputStream stream = GremlinServer.class.getResourceAsStream("gremlin-server-integration.yaml"); final Settings settings = Settings.read(stream); ServerTestHelper.rewritePathsInGremlinServerSettings(settings); http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/8e2749e7/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinResultSetIntegrateTest.java ---------------------------------------------------------------------- diff --git a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinResultSetIntegrateTest.java b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinResultSetIntegrateTest.java index d890b85..81d51df 100644 --- a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinResultSetIntegrateTest.java +++ b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinResultSetIntegrateTest.java @@ -69,12 +69,6 @@ public class GremlinResultSetIntegrateTest extends AbstractGremlinServerIntegrat private Cluster cluster; private Client client; - @Override - public Settings overrideSettings(final Settings settings) { - settings.scriptEngines.get("gremlin-groovy").scripts = Collections.singletonList("scripts/generate-modern.groovy"); - return settings; - } - @Before public void beforeTest() { final MessageSerializer serializer = new GryoMessageSerializerV1d0(); @@ -96,7 +90,7 @@ public class GremlinResultSetIntegrateTest extends AbstractGremlinServerIntegrat public void shouldHandleVertexResultFromTraversalBulked() throws Exception { final Graph graph = TinkerGraph.open(); final GraphTraversalSource g = graph.traversal(); - final Client aliased = client.alias("g"); + final Client aliased = client.alias("gmodern"); final ResultSet resultSetUnrolled = aliased.submit(g.V().both().barrier().both().barrier()); final List<Result> results = resultSetUnrolled.all().get(); @@ -106,25 +100,25 @@ public class GremlinResultSetIntegrateTest extends AbstractGremlinServerIntegrat @Test public void shouldHandleNullResult() throws Exception { - final ResultSet results = client.submit("g.V().drop().iterate();null"); + final ResultSet results = client.submit("gmodern.V().drop().iterate();null"); assertNull(results.all().get().get(0).getObject()); } @Test public void shouldHandleVoidResult() throws Exception { - final ResultSet results = client.submit("g.V().drop().iterate()"); + final ResultSet results = client.submit("gmodern.V().drop().iterate()"); assertEquals(0, results.all().get().size()); } @Test public void shouldHandleEmptyResult() throws Exception { - final ResultSet results = client.submit("g.V(100,1000,1000)"); + final ResultSet results = client.submit("gmodern.V(100,1000,1000)"); assertEquals(0, results.all().get().size()); } @Test public void shouldHandleVertexResult() throws Exception { - final ResultSet results = client.submit("g.V(1).next()"); + final ResultSet results = client.submit("gmodern.V(1).next()"); final Vertex v = results.all().get().get(0).getVertex(); assertThat(v, instanceOf(DetachedVertex.class)); @@ -143,46 +137,46 @@ public class GremlinResultSetIntegrateTest extends AbstractGremlinServerIntegrat public void shouldHandleVertexResultWithLiteSerialization() throws Exception { final Cluster cluster = TestClientFactory.build().serializer(Serializers.GRYO_LITE_V1D0).create(); final Client clientLite = cluster.connect(); - final ResultSet results = clientLite.submit("g.V(1).next()"); + final ResultSet results = clientLite.submit("gmodern.V(1).next()"); final Vertex v = results.all().get().get(0).getVertex(); assertThat(v, instanceOf(ReferenceVertex.class)); - assertEquals(1L, v.id()); + assertEquals(1, v.id()); assertEquals("person", v.label()); assertEquals(0, IteratorUtils.count(v.properties())); } @Test public void shouldHandleVertexPropertyResult() throws Exception { - final ResultSet results = client.submit("g.V().properties('name').next()"); + final ResultSet results = client.submit("gmodern.V().properties('name').next()"); final VertexProperty<String> v = results.all().get().get(0).getVertexProperty(); assertThat(v, instanceOf(DetachedVertexProperty.class)); } @Test public void shouldHandleEdgeResult() throws Exception { - final ResultSet results = client.submit("g.E().next()"); + final ResultSet results = client.submit("gmodern.E().next()"); final Edge e = results.all().get().get(0).getEdge(); assertThat(e, instanceOf(DetachedEdge.class)); } @Test public void shouldHandlePropertyResult() throws Exception { - final ResultSet results = client.submit("g.E().properties('weight').next()"); + final ResultSet results = client.submit("gmodern.E().properties('weight').next()"); final Property<Double> p = results.all().get().get(0).getProperty(); assertThat(p, instanceOf(DetachedProperty.class)); } @Test public void shouldHandlePathResult() throws Exception { - final ResultSet results = client.submit("g.V().out().path()"); + final ResultSet results = client.submit("gmodern.V().out().path()"); final Path p = results.all().get().get(0).getPath(); assertThat(p, instanceOf(DetachedPath.class)); } @Test public void shouldHandleTinkerGraphResult() throws Exception { - final ResultSet results = client.submit("graph"); + final ResultSet results = client.submit("modern"); final Graph graph = results.all().get().get(0).get(TinkerGraph.class); // test is "lossy for id" because TinkerGraph is configured by default to use the ANY id manager @@ -193,7 +187,7 @@ public class GremlinResultSetIntegrateTest extends AbstractGremlinServerIntegrat @Test public void shouldHandleMapIteratedResult() throws Exception { - final ResultSet results = client.submit("g.V().groupCount().by(bothE().count())"); + final ResultSet results = client.submit("gmodern.V().groupCount().by(bothE().count())"); final List<Result> resultList = results.all().get(); final Map m = resultList.get(0).get(HashMap.class); assertEquals(2, m.size()); @@ -203,7 +197,7 @@ public class GremlinResultSetIntegrateTest extends AbstractGremlinServerIntegrat @Test public void shouldHandleMapObjectResult() throws Exception { - final ResultSet results = client.submit("g.V().groupCount().by(bothE().count()).next()"); + final ResultSet results = client.submit("gmodern.V().groupCount().by(bothE().count()).next()"); final List<Result> resultList = results.all().get(); assertEquals(2, resultList.size()); final Map.Entry firstEntry = resultList.get(0).get(HashMap.Entry.class); http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/8e2749e7/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerHttpIntegrateTest.java ---------------------------------------------------------------------- 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 df7b734..1375521 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 @@ -70,12 +70,6 @@ public class GremlinServerHttpIntegrateTest extends AbstractGremlinServerIntegra case "should413OnPostWithResultTooLarge": settings.maxContentLength = 31; break; - case "should200OnGETWithGremlinQueryStringArgumentWithIteratorResult": - case "should200OnPOSTWithGremlinJsonEndcodedBodyWithIteratorResult": - case "should200OnPOSTWithGremlinJsonEndcodedBodyWithIteratorResultAndAliases": - case "should200OnGETWithGremlinQueryStringArgumentWithIteratorResultAndAliases": - settings.scriptEngines.get("gremlin-groovy").scripts = Collections.singletonList("scripts/generate-classic.groovy"); - break; case "should200OnPOSTTransactionalGraph": deleteDirectory(new File("/tmp/neo4j")); settings.graphs.put("graph", "conf/neo4j-empty.properties"); @@ -354,7 +348,7 @@ public class GremlinServerHttpIntegrateTest extends AbstractGremlinServerIntegra @Test public void should200OnGETWithGremlinQueryStringArgumentWithIteratorResult() throws Exception { final CloseableHttpClient httpclient = HttpClients.createDefault(); - final HttpGet httpget = new HttpGet(TestClientFactory.createURLString("?gremlin=g.V()")); + final HttpGet httpget = new HttpGet(TestClientFactory.createURLString("?gremlin=gclassic.V()")); try (final CloseableHttpResponse response = httpclient.execute(httpget)) { assertEquals(200, response.getStatusLine().getStatusCode()); @@ -369,7 +363,7 @@ public class GremlinServerHttpIntegrateTest extends AbstractGremlinServerIntegra public void should200OnGETWithGremlinQueryStringArgumentWithIteratorResultAndAliases() throws Exception { // we can remove this first test when rebindings are completely removed final CloseableHttpClient httpclientLegacy = HttpClients.createDefault(); - final HttpGet httpgetLegacy = new HttpGet(TestClientFactory.createURLString("?gremlin=g1.V()&rebindings.g1=g")); + final HttpGet httpgetLegacy = new HttpGet(TestClientFactory.createURLString("?gremlin=g1.V()&rebindings.g1=gclassic")); try (final CloseableHttpResponse response = httpclientLegacy.execute(httpgetLegacy)) { assertEquals(200, response.getStatusLine().getStatusCode()); @@ -380,7 +374,7 @@ public class GremlinServerHttpIntegrateTest extends AbstractGremlinServerIntegra } final CloseableHttpClient httpclient = HttpClients.createDefault(); - final HttpGet httpget = new HttpGet(TestClientFactory.createURLString("?gremlin=g1.V()&aliases.g1=g")); + final HttpGet httpget = new HttpGet(TestClientFactory.createURLString("?gremlin=g1.V()&aliases.g1=gclassic")); try (final CloseableHttpResponse response = httpclient.execute(httpget)) { assertEquals(200, response.getStatusLine().getStatusCode()); @@ -573,7 +567,7 @@ public class GremlinServerHttpIntegrateTest extends AbstractGremlinServerIntegra final CloseableHttpClient httpclient = HttpClients.createDefault(); final HttpPost httppost = new HttpPost(TestClientFactory.createURLString()); httppost.addHeader("Content-Type", "application/json"); - httppost.setEntity(new StringEntity("{\"gremlin\":\"g.V()\"}", Consts.UTF_8)); + httppost.setEntity(new StringEntity("{\"gremlin\":\"gclassic.V()\"}", Consts.UTF_8)); try (final CloseableHttpResponse response = httpclient.execute(httppost)) { assertEquals(200, response.getStatusLine().getStatusCode()); @@ -613,7 +607,7 @@ public class GremlinServerHttpIntegrateTest extends AbstractGremlinServerIntegra final CloseableHttpClient httpclientLegacy = HttpClients.createDefault(); final HttpPost httppostLegacy = new HttpPost(TestClientFactory.createURLString()); httppostLegacy.addHeader("Content-Type", "application/json"); - httppostLegacy.setEntity(new StringEntity("{\"gremlin\":\"g1.V()\",\"rebindings\":{\"g1\":\"g\"}}", Consts.UTF_8)); + httppostLegacy.setEntity(new StringEntity("{\"gremlin\":\"g1.V()\",\"rebindings\":{\"g1\":\"gclassic\"}}", Consts.UTF_8)); try (final CloseableHttpResponse response = httpclientLegacy.execute(httppostLegacy)) { assertEquals(200, response.getStatusLine().getStatusCode()); @@ -626,7 +620,7 @@ public class GremlinServerHttpIntegrateTest extends AbstractGremlinServerIntegra final CloseableHttpClient httpclient = HttpClients.createDefault(); final HttpPost httppost = new HttpPost(TestClientFactory.createURLString()); httppost.addHeader("Content-Type", "application/json"); - httppost.setEntity(new StringEntity("{\"gremlin\":\"g1.V()\",\"aliases\":{\"g1\":\"g\"}}", Consts.UTF_8)); + httppost.setEntity(new StringEntity("{\"gremlin\":\"g1.V()\",\"aliases\":{\"g1\":\"gclassic\"}}", Consts.UTF_8)); try (final CloseableHttpResponse response = httpclient.execute(httppost)) { assertEquals(200, response.getStatusLine().getStatusCode()); http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/8e2749e7/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/ServerTestHelper.java ---------------------------------------------------------------------- diff --git a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/ServerTestHelper.java b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/ServerTestHelper.java index e846673..41352a4 100644 --- a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/ServerTestHelper.java +++ b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/ServerTestHelper.java @@ -33,16 +33,17 @@ public class ServerTestHelper { */ public static void rewritePathsInGremlinServerSettings(final Settings overridenSettings) { final String buildDir = System.getProperty("build.dir"); - final String homeDir = buildDir.substring(0, buildDir.indexOf("gremlin-server") + "gremlin-server".length()); + final String homeDir = buildDir.substring(0, buildDir.indexOf("gremlin-server") + "gremlin-server".length()) + + File.separator + "src" + File.separator + "test" + File.separator +"scripts"; overridenSettings.scriptEngines.get("gremlin-groovy").scripts = overridenSettings.scriptEngines .get("gremlin-groovy").scripts.stream() - .map(s -> new File(s).isAbsolute() ? s : homeDir + File.separator + s) + .map(s -> new File(s).isAbsolute() ? s : homeDir + s.substring(s.lastIndexOf(File.separator))) .collect(Collectors.toList()); overridenSettings.graphs = overridenSettings.graphs.entrySet().stream() .map(kv -> { - kv.setValue(homeDir + File.separator + kv.getValue()); + kv.setValue(homeDir + kv.getValue().substring(kv.getValue().lastIndexOf(File.separator))); return kv; }).collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); } http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/8e2749e7/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/util/DefaultGraphManagerTest.java ---------------------------------------------------------------------- diff --git a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/util/DefaultGraphManagerTest.java b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/util/DefaultGraphManagerTest.java index 0841ffa..6c0e8b0 100644 --- a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/util/DefaultGraphManagerTest.java +++ b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/util/DefaultGraphManagerTest.java @@ -47,9 +47,14 @@ public class DefaultGraphManagerTest { final Set<String> graphNames = graphManager.getGraphNames(); assertNotNull(graphNames); - assertEquals(1, graphNames.size()); - - assertEquals(graphNames.toArray()[0], "graph"); + assertEquals(6, graphNames.size()); + + assertThat(graphNames.contains("graph"), is(true)); + assertThat(graphNames.contains("classic"), is(true)); + assertThat(graphNames.contains("modern"), is(true)); + assertThat(graphNames.contains("crew"), is(true)); + assertThat(graphNames.contains("sink"), is(true)); + assertThat(graphNames.contains("grateful"), is(true)); assertThat(graphManager.getGraph("graph"), instanceOf(TinkerGraph.class)); } @@ -60,9 +65,14 @@ public class DefaultGraphManagerTest { final Bindings bindings = graphManager.getAsBindings(); assertNotNull(bindings); - assertEquals(1, bindings.size()); - assertThat(bindings.get("graph"), instanceOf(TinkerGraph.class)); + assertEquals(6, bindings.size()); assertThat(bindings.containsKey("graph"), is(true)); + assertThat(bindings.containsKey("classic"), is(true)); + assertThat(bindings.containsKey("modern"), is(true)); + assertThat(bindings.containsKey("crew"), is(true)); + assertThat(bindings.containsKey("sink"), is(true)); + assertThat(bindings.containsKey("grateful"), is(true)); + assertThat(bindings.get("graph"), instanceOf(TinkerGraph.class)); } @Test @@ -84,8 +94,14 @@ public class DefaultGraphManagerTest { final Set<String> graphNames = graphManager.getGraphNames(); assertNotNull(graphNames); - assertEquals(2, graphNames.size()); + assertEquals(7, graphNames.size()); assertThat(graphNames.contains("newGraph"), is(true)); + assertThat(graphNames.contains("graph"), is(true)); + assertThat(graphNames.contains("classic"), is(true)); + assertThat(graphNames.contains("modern"), is(true)); + assertThat(graphNames.contains("crew"), is(true)); + assertThat(graphNames.contains("sink"), is(true)); + assertThat(graphNames.contains("grateful"), is(true)); assertThat(graphManager.getGraph("newGraph"), instanceOf(TinkerGraph.class)); } @@ -97,14 +113,14 @@ public class DefaultGraphManagerTest { graphManager.putGraph("newGraph", graph); final Set<String> graphNames = graphManager.getGraphNames(); assertNotNull(graphNames); - assertEquals(2, graphNames.size()); + assertEquals(7, graphNames.size()); assertThat(graphNames.contains("newGraph"), is(true)); assertThat(graphManager.getGraph("newGraph"), instanceOf(TinkerGraph.class)); graphManager.removeGraph("newGraph"); final Set<String> graphNames2 = graphManager.getGraphNames(); - assertEquals(1, graphNames2.size()); + assertEquals(6, graphNames2.size()); assertThat(graphNames2.contains("newGraph"), is(false)); } http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/8e2749e7/gremlin-server/src/test/resources/org/apache/tinkerpop/gremlin/driver/remote/gremlin-server-integration.yaml ---------------------------------------------------------------------- diff --git a/gremlin-server/src/test/resources/org/apache/tinkerpop/gremlin/driver/remote/gremlin-server-integration.yaml b/gremlin-server/src/test/resources/org/apache/tinkerpop/gremlin/driver/remote/gremlin-server-integration.yaml deleted file mode 100644 index 7b388aa..0000000 --- a/gremlin-server/src/test/resources/org/apache/tinkerpop/gremlin/driver/remote/gremlin-server-integration.yaml +++ /dev/null @@ -1,56 +0,0 @@ -# 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. - -host: localhost -port: 45940 -scriptEvaluationTimeout: 30000 -graphs: { - graph: conf/tinkergraph-empty.properties, - classic: conf/tinkergraph-empty.properties, - modern: conf/tinkergraph-empty.properties, - crew: conf/tinkergraph-empty.properties, - grateful: conf/tinkergraph-empty.properties, - sink: conf/tinkergraph-empty.properties} -plugins: - - tinkerpop.tinkergraph -scriptEngines: { - gremlin-groovy: { - imports: [java.lang.Math], - staticImports: [java.lang.Math.PI], - scripts: [scripts/generate-all.groovy]}} -serializers: - - { className: org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV1d0, config: { ioRegistries: [org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerIoRegistryV1d0], custom: [groovy.json.JsonBuilder;org.apache.tinkerpop.gremlin.driver.ser.JsonBuilderGryoSerializer]}} - - { className: org.apache.tinkerpop.gremlin.driver.ser.GryoLiteMessageSerializerV1d0, config: { ioRegistries: [org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerIoRegistryV1d0], custom: [groovy.json.JsonBuilder;org.apache.tinkerpop.gremlin.driver.ser.JsonBuilderGryoSerializer]}} - - { className: org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV1d0, config: { serializeResultToString: true}} - - { className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerGremlinV1d0, config: { ioRegistries: [org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerIoRegistryV1d0] }} - - { className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerGremlinV2d0, config: { ioRegistries: [org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerIoRegistryV2d0] }} - - { className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV1d0, config: { ioRegistries: [org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerIoRegistryV1d0] }} -processors: - - { className: org.apache.tinkerpop.gremlin.server.op.session.SessionOpProcessor, config: { sessionTimeout: 28800000 }} -metrics: { - slf4jReporter: {enabled: true, interval: 180000}} -strictTransactionManagement: false -idleConnectionTimeout: 0 -keepAliveInterval: 0 -maxInitialLineLength: 4096 -maxHeaderSize: 8192 -maxChunkSize: 8192 -maxContentLength: 65536 -maxAccumulationBufferComponents: 1024 -resultIterationBatchSize: 64 -writeBufferHighWaterMark: 32768 -writeBufferHighWaterMark: 65536 http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/8e2749e7/gremlin-server/src/test/resources/org/apache/tinkerpop/gremlin/server/gremlin-server-integration.yaml ---------------------------------------------------------------------- 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 3b28020..dcb5299 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 @@ -19,14 +19,19 @@ host: localhost port: 45940 scriptEvaluationTimeout: 30000 graphs: { - graph: conf/tinkergraph-empty.properties} + graph: conf/tinkergraph-empty.properties, + classic: conf/tinkergraph-empty.properties, + modern: conf/tinkergraph-empty.properties, + crew: conf/tinkergraph-empty.properties, + grateful: conf/tinkergraph-empty.properties, + sink: conf/tinkergraph-empty.properties} plugins: - tinkerpop.tinkergraph scriptEngines: { gremlin-groovy: { imports: [java.lang.Math], staticImports: [java.lang.Math.PI], - scripts: [scripts/empty-sample.groovy]}} + scripts: [scripts/generate-all.groovy]}} serializers: - { className: org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV1d0, config: { ioRegistries: [org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerIoRegistryV1d0], custom: [groovy.json.JsonBuilder;org.apache.tinkerpop.gremlin.driver.ser.JsonBuilderGryoSerializer]}} - { className: org.apache.tinkerpop.gremlin.driver.ser.GryoLiteMessageSerializerV1d0, config: { ioRegistries: [org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerIoRegistryV1d0], custom: [groovy.json.JsonBuilder;org.apache.tinkerpop.gremlin.driver.ser.JsonBuilderGryoSerializer]}} @@ -48,4 +53,4 @@ maxContentLength: 65536 maxAccumulationBufferComponents: 1024 resultIterationBatchSize: 64 writeBufferLowWaterMark: 32768 -writeBufferHighWaterMark: 65536 +writeBufferHighWaterMark: 65536 \ No newline at end of file http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/8e2749e7/gremlin-server/src/test/scripts/generate-all.groovy ---------------------------------------------------------------------- diff --git a/gremlin-server/src/test/scripts/generate-all.groovy b/gremlin-server/src/test/scripts/generate-all.groovy index 108ca5d..ee65bb4 100644 --- a/gremlin-server/src/test/scripts/generate-all.groovy +++ b/gremlin-server/src/test/scripts/generate-all.groovy @@ -17,6 +17,11 @@ * under the License. */ +// An example of an initialization script that can be configured to run in Gremlin Server. +// Functions defined here will go into global cache and will not be removed from there +// unless there is a reset of the ScriptEngine. +def addItUp(x, y) { x + y } + // an init script that returns a Map allows explicit setting of global bindings. def globals = [:] @@ -27,16 +32,38 @@ globals << [hook : [ TinkerFactory.generateClassic(classic) TinkerFactory.generateModern(modern) TinkerFactory.generateTheCrew(crew) + TinkerFactory.generateGratefulDead(grateful) TinkerFactory.generateKitchenSink(sink) - grateful.io(gryo()).readGraph('data/grateful-dead.kryo') + + // a wild bit of trickery here. the process tests use an INTEGER id manager when LoadGraphWith is used. this + // closure provides a way to to manually override the various id managers for TinkerGraph - the graph on which + // all of these remote tests are executed - so that the tests will pass nicely. an alternative might have been + // to have a special test TinkerGraph config for setting up the id manager properly, but based on how we do + // things now, that test config would have been mixed in with release artifacts and there would have been ugly + // exclusions to make packaging work properly. + allowSetOfIdManager = { graph, idManagerFieldName -> + java.lang.reflect.Field idManagerField = graph.class.getDeclaredField(idManagerFieldName) + idManagerField.setAccessible(true) + java.lang.reflect.Field modifiersField = java.lang.reflect.Field.class.getDeclaredField("modifiers") + modifiersField.setAccessible(true) + modifiersField.setInt(idManagerField, modifiersField.getModifiers() & ~java.lang.reflect.Modifier.FINAL) + + idManagerField.set(graph, TinkerGraph.DefaultIdManager.INTEGER) + } + + [classic, modern, crew, sink, grateful].each{ + allowSetOfIdManager(it, "vertexIdManager") + allowSetOfIdManager(it, "edgeIdManager") + allowSetOfIdManager(it, "vertexPropertyIdManager") + } } ] as LifeCycleHook] // add default TraversalSource instances for each graph instance globals << [gclassic : classic.traversal()] globals << [gmodern : modern.traversal()] +globals << [g : graph.traversal()] globals << [gcrew : crew.traversal()] globals << [ggraph : graph.traversal()] -globals << [g : modern.traversal()] globals << [ggrateful : grateful.traversal()] globals << [gsink : sink.traversal()] \ No newline at end of file http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/8e2749e7/gremlin-server/src/test/scripts/neo4j-empty.properties ---------------------------------------------------------------------- diff --git a/gremlin-server/src/test/scripts/neo4j-empty.properties b/gremlin-server/src/test/scripts/neo4j-empty.properties new file mode 100644 index 0000000..0ea551b --- /dev/null +++ b/gremlin-server/src/test/scripts/neo4j-empty.properties @@ -0,0 +1,33 @@ +# 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. + +# This is a sample configuration file for Neo4j. Note that +# TinkerPop does not include Neo4j dependencies in its +# distributions. To use this file, please ensure that Neo4j +# dependencies are installed into Gremlin Server's path +# with: +# +# gremlin-server.sh -i org.apache.tinkerpop neo4j-gremlin 3.y.z +# +# Note that unless under a commercial agreement with Neo Technology, +# Neo4j is licensed AGPL. + + +gremlin.graph=org.apache.tinkerpop.gremlin.neo4j.structure.Neo4jGraph +gremlin.neo4j.directory=/tmp/neo4j +gremlin.neo4j.conf.node_auto_indexing=true +gremlin.neo4j.conf.relationship_auto_indexing=true \ No newline at end of file