tinkerpop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From spmalle...@apache.org
Subject [tinkerpop] 05/06: TINKERPOP-2076 Fixed failing GraphComputer test after Java 11 upgrade
Date Thu, 03 Oct 2019 16:41:42 GMT
This is an automated email from the ASF dual-hosted git repository.

spmallette pushed a commit to branch TINKERPOP-2076
in repository https://gitbox.apache.org/repos/asf/tinkerpop.git

commit 90203e43bfdffce226355e8bd9c570b6e6f23fcb
Author: Stephen Mallette <spmva@genoprime.com>
AuthorDate: Wed Mar 6 15:26:00 2019 -0500

    TINKERPOP-2076 Fixed failing GraphComputer test after Java 11 upgrade
    
    Needed to explicitly count elements in ConcurrentSkipListSet as size() is not a constant-time
operation. Wasn't failing at all on Java 8 but 11 made it fail every time.
---
 .../process/computer/GraphComputerTest.java        | 27 ++++++++++++++--------
 1 file changed, 18 insertions(+), 9 deletions(-)

diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/computer/GraphComputerTest.java
b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/computer/GraphComputerTest.java
index f092f50..2ba9199 100644
--- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/computer/GraphComputerTest.java
+++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/computer/GraphComputerTest.java
@@ -1168,7 +1168,7 @@ public class GraphComputerTest extends AbstractGremlinProcessTest {
     /////////////////////////////////////////////
 
     /////////////////////////////////////////////
-    @org.junit.Ignore
+
     @Test
     @LoadGraphWith(MODERN)
     public void shouldStartAndEndWorkersForVertexProgramAndMapReduce() throws Exception {
@@ -1176,17 +1176,17 @@ public class GraphComputerTest extends AbstractGremlinProcessTest
{
         MapReduceI.WORKER_END.clear();
         assertEquals(3, graphProvider.getGraphComputer(graph).program(new VertexProgramJ()).mapReduce(new
MapReduceI()).submit().get().memory().<Integer>get("a").intValue());
         if (MapReduceI.WORKER_START.size() == 2) {
-            assertEquals(2, MapReduceI.WORKER_START.size());
+            assertEquals(2, MapReduceI.countTrue(MapReduceI.WORKER_START));
             assertTrue(MapReduceI.WORKER_START.contains(MapReduce.Stage.MAP) && MapReduceI.WORKER_START.contains(MapReduce.Stage.REDUCE));
         } else {
-            assertEquals(3, MapReduceI.WORKER_START.size());
+            assertEquals(3, MapReduceI.countTrue(MapReduceI.WORKER_START));
             assertTrue(MapReduceI.WORKER_START.contains(MapReduce.Stage.MAP) && MapReduceI.WORKER_START.contains(MapReduce.Stage.COMBINE)
&& MapReduceI.WORKER_START.contains(MapReduce.Stage.REDUCE));
         }
         if (MapReduceI.WORKER_END.size() == 2) {
-            assertEquals(2, MapReduceI.WORKER_END.size());
+            assertEquals(2, MapReduceI.countTrue(MapReduceI.WORKER_END));
             assertTrue(MapReduceI.WORKER_END.contains(MapReduce.Stage.MAP) && MapReduceI.WORKER_END.contains(MapReduce.Stage.REDUCE));
         } else {
-            assertEquals(3, MapReduceI.WORKER_END.size());
+            assertEquals(3, MapReduceI.countTrue(MapReduceI.WORKER_END));
             assertTrue(MapReduceI.WORKER_END.contains(MapReduce.Stage.MAP) && MapReduceI.WORKER_END.contains(MapReduce.Stage.COMBINE)
&& MapReduceI.WORKER_END.contains(MapReduce.Stage.REDUCE));
         }
     }
@@ -1273,14 +1273,14 @@ public class GraphComputerTest extends AbstractGremlinProcessTest
{
         @Override
         public void map(final Vertex vertex, final MapEmitter<NullObject, Integer>
emitter) {
             emitter.emit(1);
-            assertEquals(1, WORKER_START.size());
+            assertEquals(1, countTrue(WORKER_START));
             assertTrue(WORKER_START.contains(Stage.MAP));
         }
 
         @Override
         public void combine(final NullObject key, final Iterator<Integer> values, final
ReduceEmitter<NullObject, Integer> emitter) {
             emitter.emit(2);
-            assertEquals(2, WORKER_START.size());
+            assertEquals(2, countTrue(WORKER_START));
             assertTrue(WORKER_START.contains(Stage.MAP) && WORKER_START.contains(Stage.COMBINE));
             assertFalse(WORKER_END.isEmpty());
         }
@@ -1289,10 +1289,10 @@ public class GraphComputerTest extends AbstractGremlinProcessTest
{
         public void reduce(final NullObject key, final Iterator<Integer> values, final
ReduceEmitter<NullObject, Integer> emitter) {
             emitter.emit(3);
             if (WORKER_START.size() == 2) {
-                assertEquals(2, WORKER_START.size());
+                assertEquals(2, countTrue(WORKER_START));
                 assertTrue(WORKER_START.contains(Stage.MAP) && WORKER_START.contains(Stage.REDUCE));
             } else {
-                assertEquals(3, WORKER_START.size());
+                assertEquals(3, countTrue(WORKER_START));
                 assertTrue(WORKER_START.contains(Stage.MAP) && WORKER_START.contains(Stage.COMBINE)
&& WORKER_START.contains(Stage.REDUCE));
             }
             assertFalse(WORKER_END.isEmpty());
@@ -1316,6 +1316,15 @@ public class GraphComputerTest extends AbstractGremlinProcessTest {
         public String getMemoryKey() {
             return "a";
         }
+
+        /**
+         * Javadoc for {@code ConcurrentSkipListSet} includes this little note: "Beware that,
unlike in most
+         * collections, the size method is not a constant-time operation." Doing a traversal
of elements will yield
+         * the correct count. Java 11 upgrade seemed to force this failure consistently.
+         */
+        static int countTrue(final Set<Stage> s) {
+            return Long.valueOf(IteratorUtils.count(s)).intValue();
+        }
     }
 
     /////////////////////////////////////////////


Mime
View raw message