You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by sp...@apache.org on 2019/11/13 15:50:54 UTC
[tinkerpop] branch travis-fix updated: try-catch-finally to better
handle Cluster.close() in tests
This is an automated email from the ASF dual-hosted git repository.
spmallette pushed a commit to branch travis-fix
in repository https://gitbox.apache.org/repos/asf/tinkerpop.git
The following commit(s) were added to refs/heads/travis-fix by this push:
new 9269cf6 try-catch-finally to better handle Cluster.close() in tests
9269cf6 is described below
commit 9269cf6ac2efae7bcd46460b7fa4ab8f70857579
Author: stephen <sp...@gmail.com>
AuthorDate: Wed Nov 13 10:49:51 2019 -0500
try-catch-finally to better handle Cluster.close() in tests
---
.../server/GremlinServerSessionIntegrateTest.java | 56 ++++++++++++----------
1 file changed, 32 insertions(+), 24 deletions(-)
diff --git a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerSessionIntegrateTest.java b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerSessionIntegrateTest.java
index 75b4586..8418602 100644
--- a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerSessionIntegrateTest.java
+++ b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerSessionIntegrateTest.java
@@ -330,35 +330,43 @@ public class GremlinServerSessionIntegrateTest extends AbstractGremlinServerInt
final Cluster cluster = TestClientFactory.build().minInProcessPerConnection(16).maxInProcessPerConnection(64).create();
final Client client = cluster.connect(name.getMethodName());
- client.submit("a=100;b=1000;c=10000;null").all().get();
- final int requests = 10000;
- final List<CompletableFuture<ResultSet>> futures = new ArrayList<>(requests);
- IntStream.range(0, requests).forEach(i -> {
- try {
- futures.add(client.submitAsync("a+b+c"));
- } catch (Exception ex) {
- throw new RuntimeException(ex);
+ try {
+ client.submit("a=100;b=1000;c=10000;null").all().get();
+ final int requests = 10000;
+ final List<CompletableFuture<ResultSet>> futures = new ArrayList<>(requests);
+ IntStream.range(0, requests).forEach(i -> {
+ try {
+ futures.add(client.submitAsync("a+b+c"));
+ } catch (Exception ex) {
+ throw new RuntimeException(ex);
+ }
+ });
+
+ System.out.println("shouldEnsureSessionBindingsAreThreadSafe: sent 10000");
+ assertEquals(requests, futures.size());
+
+ System.out.println("shouldEnsureSessionBindingsAreThreadSafe: asserting 10000");
+ int counter = 0;
+ for (CompletableFuture<ResultSet> f : futures) {
+ final Result r = f.get().all().get(30000, TimeUnit.MILLISECONDS).get(0);
+ assertEquals(11100, r.getInt());
+ counter++;
}
- });
- assertEquals(requests, futures.size());
+ assertEquals(requests, counter);
+ System.out.println("shouldEnsureSessionBindingsAreThreadSafe: asserted 10000");
- int counter = 0;
- for(CompletableFuture<ResultSet> f : futures) {
- final Result r = f.get().all().get(30000, TimeUnit.MILLISECONDS).get(0);
- assertEquals(11100, r.getInt());
- counter++;
+ } catch (Exception ex) {
+ fail(ex.getMessage());
+ } finally {
+ System.out.println("shouldEnsureSessionBindingsAreThreadSafe: calling cluster.close");
+ cluster.close();
+ System.out.println("shouldEnsureSessionBindingsAreThreadSafe: called cluster.close");
+ System.out.println("shouldEnsureSessionBindingsAreThreadSafe: waiting");
+ Thread.sleep(120000);
+ System.out.println("shouldEnsureSessionBindingsAreThreadSafe: done waiting, exiting test");
}
- assertEquals(requests, counter);
-
- System.out.println("shouldEnsureSessionBindingsAreThreadSafe: calling cluster.close");
- cluster.close();
- System.out.println("shouldEnsureSessionBindingsAreThreadSafe: called cluster.close");
- System.out.println("shouldEnsureSessionBindingsAreThreadSafe: waiting");
- Thread.sleep(120000);
- System.out.println("shouldEnsureSessionBindingsAreThreadSafe: done waiting, exiting test");
-
}
@Test