tinkerpop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From spmalle...@apache.org
Subject [1/2] tinkerpop git commit: Re-worked ordering logic for shouldProcessSessionRequestsInOrder()
Date Tue, 11 Apr 2017 17:36:45 GMT
Repository: tinkerpop
Updated Branches:
  refs/heads/master a2caef218 -> 72b518609


Re-worked ordering logic for shouldProcessSessionRequestsInOrder()

This test would fail intermittently - hoping this approach will work better. CTR


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

Branch: refs/heads/master
Commit: 12e08c3667e7cc275fce79eac25ee767bfe79f24
Parents: e4372b2
Author: Stephen Mallette <spmva@genoprime.com>
Authored: Tue Apr 11 13:35:55 2017 -0400
Committer: Stephen Mallette <spmva@genoprime.com>
Committed: Tue Apr 11 13:35:55 2017 -0400

----------------------------------------------------------------------
 .../server/GremlinDriverIntegrateTest.java      | 35 +++++++++++++-------
 1 file changed, 23 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/12e08c36/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinDriverIntegrateTest.java
----------------------------------------------------------------------
diff --git a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinDriverIntegrateTest.java
b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinDriverIntegrateTest.java
index a8164b5..fd11508 100644
--- a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinDriverIntegrateTest.java
+++ b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinDriverIntegrateTest.java
@@ -60,9 +60,10 @@ import java.util.Map;
 import java.util.concurrent.CompletableFuture;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.TimeoutException;
-import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.concurrent.atomic.AtomicReference;
 import java.util.stream.Collectors;
@@ -72,6 +73,7 @@ import static org.hamcrest.CoreMatchers.containsString;
 import static org.hamcrest.CoreMatchers.endsWith;
 import static org.hamcrest.CoreMatchers.instanceOf;
 import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.collection.IsIterableContainingInOrder.contains;
 import static org.hamcrest.core.AllOf.allOf;
 import static org.hamcrest.number.OrderingComparison.greaterThan;
 import static org.hamcrest.number.OrderingComparison.lessThanOrEqualTo;
@@ -406,19 +408,28 @@ public class GremlinDriverIntegrateTest extends AbstractGremlinServerIntegration
         final CompletableFuture<List<Result>> futureFive = rsFive.all();
         final CompletableFuture<List<Result>> futureZero = rsZero.all();
 
-        final AtomicBoolean hit = new AtomicBoolean(false);
-        while (!futureFive.isDone()) {
-            // futureZero can't finish before futureFive - racy business here?
-            assertThat(futureZero.isDone(), is(false));
-            hit.set(true);
-        }
+        final CountDownLatch latch = new CountDownLatch(2);
+        final List<String> order = new ArrayList<>();
+        final ExecutorService executor = Executors.newSingleThreadExecutor();
 
-        // should have entered the loop at least once and thus proven that futureZero didn't
return ahead of
-        // futureFive
-        assertThat(hit.get(), is(true));
+        futureFive.thenAcceptAsync(r -> {
+            order.add(r.get(0).getString());
+            latch.countDown();
+        }, executor);
 
-        assertEquals("zero", futureZero.get().get(0).getString());
-        assertEquals("five", futureFive.get(10, TimeUnit.SECONDS).get(0).getString());
+        futureZero.thenAcceptAsync(r -> {
+            order.add(r.get(0).getString());
+            latch.countDown();
+        }, executor);
+
+        // wait for both results
+        latch.await(30000, TimeUnit.MILLISECONDS);
+
+        // should be two results
+        assertEquals(2, order.size());
+
+        // ensure that "five" is first then "zero"
+        assertThat(order, contains("five", "zero"));
     }
 
     @Test


Mime
View raw message