You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by ok...@apache.org on 2015/05/22 22:15:53 UTC

incubator-tinkerpop git commit: going to town testing HadoopGremlinPlugin -- loving it. So much safety.

Repository: incubator-tinkerpop
Updated Branches:
  refs/heads/master 144f605cb -> 055a7fb1a


going to town testing HadoopGremlinPlugin -- loving it. So much safety.


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

Branch: refs/heads/master
Commit: 055a7fb1a35eca8e785b73959a274450c6f9d41b
Parents: 144f605
Author: Marko A. Rodriguez <ok...@gmail.com>
Authored: Fri May 22 14:16:05 2015 -0600
Committer: Marko A. Rodriguez <ok...@gmail.com>
Committed: Fri May 22 14:16:05 2015 -0600

----------------------------------------------------------------------
 .../process/AbstractGremlinProcessTest.java     |  4 +-
 .../groovy/plugin/HadoopGremlinPluginTest.java  | 54 ++++++++++++++++----
 2 files changed, 46 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/055a7fb1/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/AbstractGremlinProcessTest.java
----------------------------------------------------------------------
diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/AbstractGremlinProcessTest.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/AbstractGremlinProcessTest.java
index 8f453a9..9e64522 100644
--- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/AbstractGremlinProcessTest.java
+++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/AbstractGremlinProcessTest.java
@@ -72,7 +72,7 @@ public abstract class AbstractGremlinProcessTest extends AbstractGremlinTest {
         }
     }
 
-    public <T> void checkResults(final List<T> expectedResults, final Traversal<?, T> traversal) {
+    public static <T> void checkResults(final List<T> expectedResults, final Traversal<?, T> traversal) {
         final List<T> results = traversal.toList();
         assertFalse(traversal.hasNext());
         assertEquals("Checking result size", expectedResults.size(), results.size());
@@ -92,7 +92,7 @@ public abstract class AbstractGremlinProcessTest extends AbstractGremlinTest {
         assertFalse(traversal.hasNext());
     }
 
-    public <T> void checkResults(final Map<T, Long> expectedResults, final Traversal<?, T> traversal) {
+    public static <T> void checkResults(final Map<T, Long> expectedResults, final Traversal<?, T> traversal) {
         final List<T> list = new ArrayList<>();
         expectedResults.forEach((k, v) -> {
             for (int i = 0; i < v; i++) {

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/055a7fb1/hadoop-gremlin/src/test/java/org/apache/tinkerpop/gremlin/hadoop/groovy/plugin/HadoopGremlinPluginTest.java
----------------------------------------------------------------------
diff --git a/hadoop-gremlin/src/test/java/org/apache/tinkerpop/gremlin/hadoop/groovy/plugin/HadoopGremlinPluginTest.java b/hadoop-gremlin/src/test/java/org/apache/tinkerpop/gremlin/hadoop/groovy/plugin/HadoopGremlinPluginTest.java
index a660439..8499840 100644
--- a/hadoop-gremlin/src/test/java/org/apache/tinkerpop/gremlin/hadoop/groovy/plugin/HadoopGremlinPluginTest.java
+++ b/hadoop-gremlin/src/test/java/org/apache/tinkerpop/gremlin/hadoop/groovy/plugin/HadoopGremlinPluginTest.java
@@ -23,11 +23,16 @@ package org.apache.tinkerpop.gremlin.hadoop.groovy.plugin;
 
 import org.apache.tinkerpop.gremlin.AbstractGremlinTest;
 import org.apache.tinkerpop.gremlin.LoadGraphWith;
-import org.apache.tinkerpop.gremlin.groovy.plugin.RemoteAcceptor;
 import org.apache.tinkerpop.gremlin.groovy.util.TestableConsolePluginAcceptor;
 import org.apache.tinkerpop.gremlin.hadoop.HadoopGraphProvider;
 import org.apache.tinkerpop.gremlin.process.AbstractGremlinProcessTest;
+import org.apache.tinkerpop.gremlin.process.computer.KeyValue;
+import org.apache.tinkerpop.gremlin.process.computer.MapReduce;
+import org.apache.tinkerpop.gremlin.process.computer.traversal.step.sideEffect.mapreduce.TraverserMapReduce;
 import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
+import org.apache.tinkerpop.gremlin.process.traversal.Traverser;
+import org.apache.tinkerpop.gremlin.process.traversal.step.util.BulkSet;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
 import org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils;
 import org.junit.Before;
 import org.junit.Test;
@@ -60,9 +65,9 @@ public class HadoopGremlinPluginTest extends AbstractGremlinTest {
     private HadoopRemoteAcceptor remote;
     private TestableConsolePluginAcceptor console;
 
-    @Test
+    /*@Test
     @LoadGraphWith(LoadGraphWith.GraphData.MODERN)
-    public void shouldReturnResultIterator() throws Exception {
+    public void shouldSupportRemoteTraversal() throws Exception {
         this.console.addBinding("graph", this.graph);
         this.console.addBinding("g", this.g);
         this.remote.connect(Arrays.asList("graph", "g"));
@@ -75,7 +80,7 @@ public class HadoopGremlinPluginTest extends AbstractGremlinTest {
 
     @Test
     @LoadGraphWith(LoadGraphWith.GraphData.MODERN)
-    public void shouldSupportSugar() throws Exception {
+    public void shouldSupportRemoteSugarTraversal() throws Exception {
         this.console.addBinding("graph", this.graph);
         this.console.addBinding("g", this.g);
         this.remote.connect(Arrays.asList("graph"));
@@ -86,12 +91,12 @@ public class HadoopGremlinPluginTest extends AbstractGremlinTest {
         assertEquals(28.0d, traversal.next());
         assertFalse(traversal.hasNext());
         assertNotNull(this.console.getBindings().get(RemoteAcceptor.RESULT));
-    }
+    }*/
 
     @Test
     @LoadGraphWith(LoadGraphWith.GraphData.MODERN)
     public void shouldSupportHDFSMethods() throws Exception {
-
+        ////////////////
         List<String> ls = (List<String>) this.console.eval("hdfs.ls()");
         for (final String line : ls) {
             assertTrue(line.startsWith("-") || line.startsWith("r") || line.startsWith("w") || line.startsWith("x"));
@@ -102,10 +107,10 @@ public class HadoopGremlinPluginTest extends AbstractGremlinTest {
             assertTrue(line.startsWith("-") || line.startsWith("r") || line.startsWith("w") || line.startsWith("x"));
             assertEquals(" ", line.substring(9, 10));
         }
-        ////
+        ////////////////
         this.console.eval("hdfs.copyFromLocal('" + HadoopGraphProvider.PATHS.get("tinkerpop-classic.txt") + "', 'target/tinkerpop-classic.txt')");
         assertTrue((Boolean) this.console.eval("hdfs.exists('target/tinkerpop-classic.txt')"));
-        ////
+        ////////////////
         List<String> head = IteratorUtils.asList(this.console.eval("hdfs.head('target/tinkerpop-classic.txt')"));
         assertEquals(6, head.size());
         for (final String line : head) {
@@ -118,10 +123,39 @@ public class HadoopGremlinPluginTest extends AbstractGremlinTest {
             assertEquals(":", line.substring(1, 2));
             assertTrue(Integer.valueOf(line.substring(0, 1)) <= 3);
         }
-        ////
+        ////////////////
         this.console.eval("hdfs.rm('target/tinkerpop-classic.txt')");
         assertFalse((Boolean) this.console.eval("hdfs.exists('target/tinkerpop-classic.txt')"));
-
+        ////////////////
+        this.console.addBinding("graph", this.graph);
+        this.console.addBinding("g", this.g);
+        this.remote.connect(Arrays.asList("graph", "g"));
+        Traversal<Vertex, String> traversal = (Traversal<Vertex, String>) this.remote.submit(Arrays.asList("g.V().hasLabel('person').group('m').by('age').by('name').out('knows').out('created').values('name')"));
+        AbstractGremlinProcessTest.checkResults(Arrays.asList("ripple", "lop"), traversal);
+        assertTrue((Boolean) this.console.eval("hdfs.exists('hadoop-gremlin/target/test-output/m')"));
+        assertTrue((Boolean) this.console.eval("hdfs.exists('hadoop-gremlin/target/test-output/" + TraverserMapReduce.TRAVERSERS + "')"));
+        final List<KeyValue<Integer, BulkSet<String>>> mList = IteratorUtils.asList(this.console.eval("hdfs.head('hadoop-gremlin/target/test-output/m',ObjectWritable)"));
+        assertEquals(4, mList.size());
+        mList.forEach(keyValue -> {
+            if (keyValue.getKey().equals(29))
+                assertEquals(1l, keyValue.getValue().get("marko"));
+            else if (keyValue.getKey().equals(35))
+                assertEquals(1l, keyValue.getValue().get("peter"));
+            else if (keyValue.getKey().equals(32))
+                assertEquals(1l, keyValue.getValue().get("josh"));
+            else if (keyValue.getKey().equals(27))
+                assertEquals(1l, keyValue.getValue().get("vadas"));
+            else
+                throw new IllegalStateException("The provided key/value is unknown: " + keyValue);
+        });
+        final List<KeyValue<MapReduce.NullObject, Traverser<String>>> traversersList = IteratorUtils.asList(this.console.eval("hdfs.head('hadoop-gremlin/target/test-output/" + TraverserMapReduce.TRAVERSERS + "',ObjectWritable)"));
+        assertEquals(2, traversersList.size());
+        traversersList.forEach(keyValue -> {
+            assertEquals(MapReduce.NullObject.instance(), keyValue.getKey());
+            final String name = keyValue.getValue().get();
+            assertTrue(name.equals("ripple") || name.equals("lop"));
+        });
+        ////////////////
     }
 
 }